OpenCV投影点生成错误的Z轴(使用棋盘校准)

OpenCV Projectpoints makes wrong Z axis (calibrated with chessboard)

本文关键字:投影 错误 OpenCV      更新时间:2023-10-16

我想校准我的相机并绘制xyz轴。(如此链接所示:http://docs.opencv.org/3.1.0/d7/d53/tutorial_py_pose.html)

不幸的是,我的校准做了一些奇怪的事情,我似乎无法修复它。我制作了一个cad模型,以最大限度地减少其他可能的错误。。。

所以基本上,我做两个步骤:

  1. 校准每个摄像头
  2. 使用投影点绘制线

我不知道哪里出了问题。。。

来自cameraCalibration的变量。图像点中的点由棋盘找到。

vector< vector<cv::Point2f> > imagePoints;
vector< vector< cv::Point3f> > objectPoints;
vector<cv::Mat> rvecs, tvecs;
cv::Mat intrinsic_Matrix, distortion_coeffs;

查找点的代码

cv::Point2f clsCameraControl::FindSpecific(cv::Point3f o3Dpoint)
{
    cv::Mat  rvec, tvec;
    rvec.create(1, 3, cv::DataType<double>::type);
    tvec.create(1, 3, cv::DataType<double>::type);
    rvec = rvecs[0].clone(); 
    tvec = tvecs[0].clone();
    cv::solvePnP(objectPoints[0], imagePoints[0], intrinsic_Matrix, distortion_coeffs, rvec, tvec);
    vector<cv::Point3f> Input1;
    vector <cv::Point2f> Output1;
    Input1.insert(Input1.end(), o3Dpoint);
    Output1.clear();
    cv::projectPoints(Input1, rvec, tvec, intrinsic_Matrix, distortion_coeffs, Output1);
    return Output1[0];
 }

这张图代表了我得到的四个结果(绘制X(绿色)、Y(红色)和Z(蓝色)轴)

Z轴总是错误的。它应该只是向上(或者至少在同一方向上都错了)

我使用的基本图片在这本相册中,如果你想自己尝试的话(我自己制作的,每个人都可以免费使用!)

有人知道我为什么以及如何解决这个问题吗?

对于有这个问题的人:多拍一些照片。。。