Python 2.7/OpenCV 3.3: Error in cv2.initUndistortRectifyMap . Not showing undistort rectified images

孤街醉人 提交于 2019-12-06 07:42:59

After trying out many things I found out a solution to this particular problem. After comparing camera rotation matrices and distortion matrices obtained using Python OpenCV and Matlab, I found out that there is much difference between matrices obtained using Python and Matlab. Therefore, I again calibrate my cameras and do stereo calibration using Python and OpenCV. Below figure shows the difference between old matrices (got from Python) and new matrices (got after calibrate again using Python).

In this figure, we can see that there is much difference between distortion coefficient matrix for right and left camera for old case (dist coeff. right old and left old) as compare to distortion coefficient matrix for right and left camera for new case (dist coeff. right new and left new). For right camera, old coefficients were 83.85 and -19.18 against 0.78 and -0.61 respectively. Similarly, for left camera, old coefficients were 123.7 and -1641.4 against -0.38 and 0.73 respectively. Also, first element (1,1) of old left camera matrix was 807.24 which differ much as compare to right camera old matrix. New left camera matrix has this element value as 552.41 which I think is correct. When I used all these new matrices and change my alpha value to 0 (alpha = 0) I got the following result.

For stereoCalbirate I used following inputs

retVal, cm1, dc1, cm2, dc2, r, t, e, f = cv2.stereoCalibrate(objpoints, imgpointsL, imgpointsR, cm1, dc1, cm2, dc2, (640, 480), None, None, cv2.CALIB_FIX_INTRINSIC, criteria)

where criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 100, 0.001)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!