一、一定要先单独标定每个相机的内参,应该如下,flag不能瞎设定。
calibrateCamera(objectPoints
,imagePointsLeft
,imageSize
,intrinsicMatLeft
,distCoeffsLeft
,rvecsMatLeft
,tvecsMatLeft
);
二、双目标定使用上面单目标定的结果,应该如下:
cv::stereoCalibrate(
objectPoints,
imagePointsLeft,
imagePointsRight,
intrinsicMatLeft, distCoeffsLeft,
intrinsicMatRight, distCoeffsRight,
imageSize,
rotation,
translation,
elementalMat, fundamentalMat
,cv::CALIB_FIX_INTRINSIC
);
cv::CALIB_FIX_INTRINSIC保证了单目的内参在双目中也不变,这样来优化其他参数。
三、双目矫正应该如下:
cv::stereoRectify(intrinsicMatLeft, distCoeffsLeft,
intrinsicMatRight, distCoeffsRight,
imageSize,
rotation, translation,
R1, R2,
P1, P2,
Q
//,cv::CALIB_ZERO_DISPARITY 千万不能搞这个!
,0
,-1);
|