I have an application where I constantly have to undistort pixel positions to their "right" location.
I tried it in Python first, thw following code yields good results:
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)
When I tried to convert that into C++ it's just returning crap. I'm calling:
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);
But in the maps it returns values which are way to big, when I output m_undistortMapX it contains values of about -2.0e+21 . this->m_undistortMapX
and this->m_undistortMapY
are declared in the class and not initialized before. The other parameters look right, too:
std::cout << this->m_cameraMatrix << std::endl;
std::cout << this->m_distortionCoeffs << std::endl;
std::cout << dimX <<" / "<<dimY<<std::endl;
outputs
[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
So just the same as in Python, I thought. Any ideas what can still go wrong?!