【发布时间】:2017-04-13 13:11:49
【问题描述】:
我有一个应用程序,我经常需要将像素位置不失真到它们的“正确”位置。
我首先在 Python 中尝试过,下面的代码产生了很好的结果:
cam_m=np.array([[2590.2742, 0, 997.78192],[0, 2582.9724, 509.76907],[0, 0, 1]])
dist_c=np.array([0.088253155, 0.96952456, 0.0033740622, -0.00064934365, -6.0030732])
map1,map2=cv2.initUndistortRectifyMap(cam_m, dist_c, None, None, (1920,1024), cv2.CV_32FC1)
当我尝试将其转换为 C++ 时,它只是返回废话。我在打电话:
cv::initUndistortRectifyMap(this->m_cameraMatrix,this->m_distortionCoeffs,
cv::Mat::eye(3, 3, CV_32FC1),cv::Mat::eye(3, 3, CV_32FC1),
cv::Size(dimX,dimY),CV_32FC1,this->m_undistortMapX,this->m_undistortMapY);
但是在地图中它返回的值很大,当我输出 m_undistortMapX 它包含大约 -2.0e+21 的值。 this->m_undistortMapX 和 this->m_undistortMapY 在类中声明,之前没有初始化。其他参数看起来也不错:
std::cout << this->m_cameraMatrix << std::endl;
std::cout << this->m_distortionCoeffs << std::endl;
std::cout << dimX <<" / "<<dimY<<std::endl;
输出
[2590.2742, 0, 997.78192;
0, 2582.9724, 509.76907;
0, 0, 1]
[0.088253155, 0.96952456, 0.0033740622, -0.00064934365, -6.0030732]
1920 / 1024
所以就像在 Python 中一样,我想。有什么想法还会出错吗?!
【问题讨论】:
标签: python c++ opencv computer-vision camera-calibration