我有来自校准相机的内在和失真矩阵。我正在使用 open cv 3.2 c++。我得到对象姿态估计的错误输出。帮我解决这个错误。值和错误图像附在下面。
Mat K = (Mat_<double>(3, 3) << 5489.58773029126, 0, 1167.86282865392, 0, 5481.84660546223, 1047.21450461614, 0, 0, 1);
Mat dist = (Mat_<double>(1, 5) << -0.111931171641671, 0.087488429523756156, 0.000844290429230941, 0.00204127293599477,0);
我已经有了图像和对象点,所以继续使用solvepnp来获取旋转和平移向量。所以,
Mat rvecs, tvecs;
vector<Point3f> end_point3D;
vector<Point2f> end_point2D;
end_point3D.push_back(Point3f(50, 0, 0));
end_point3D.push_back(Point3f(0, 50, 0));
end_point3D.push_back(Point3f(0, 0, 50));
solvePnP(Object_points, Image_points, K, dist, rvecs, tvecs);
projectPoints(end_point3D, rvecs, tvecs, K, dist, end_point2D, noArray(), 0.0);
cv::line(image, Image_points[0], end_point2D[0], cv::Scalar(255, 0, 0), 6);
cv::line(image, Image_points[0], end_point2D[1], cv::Scalar(0, 255, 0), 6);
cv::line(image, Image_points[0], end_point2D[2], cv::Scalar(0, 0, 255), 6);
图片如下所示。估计位姿的误差输出
编辑:对象点和图像点以相同的方式正确排序。我确定订单,我已经完成了主要订单。
Size sq_size(6, 6);
int Sq_length = 30;
vector<Point3f>Object_points;
for (int r = 0; r < sq_size.height; r++)
for (int c = 0; c < sq_size.width; c++)
Object_points.push_back(Point3f(r*Sq_length, c*Sq_length, 0));
vector<Point2f>Image_points;
for (int i = 0; i < 36; i++)
Image_points.push_back((Point2f)op_cent[i]);
//row-major ordered image points
我有两个疑问, 1.虽然它们的顺序正确,但有时姿势结果错误如下所示,可能是什么原因?
2.如果我画了,估计的姿势只在 Image_points[0],结果是正确的,但不是在任何其他点。有人可以解释为什么 Image_points[30] 的姿势错误吗?在任何时候,物体的姿势都应该是一样的,对吧?