我正在执行一个相机校准,就像OpenCV校准样例中描述的那样(对于镜头校正工作得很好)。此外,我现在想做一个空间校正。也就是说,当相机不与棋盘平行时,我希望获得必要的旋转,使棋盘平行于相机。这就是我正在做的:
// calculate intrinsic matrix and distortion coefficients for lens correction and get
// the rotation "rotation"
cvCalibrateCamera2(object_points,image_points,point_counts,cvGetSize(gray_image),
intrinsic_matrix, distortion_coeffs,
rotation,NULL,
0);
...
// convert the rotation to a 3x3 matrix
cv::Rodrigues(rotation,rotMtx,cv::noArray());
// generate maps for lens correction
cv::initUndistortRectifyMap(intrinsic,distortion,cv::Mat(),
cv::getOptimalNewCameraMatrix(intrinsic,distortion,imageSize,1,imageSize,0),
imageSize, CV_16SC2,*handle->mapx,*handle->mapy);
...
// perform lens correction
cv::remap(cv::Mat(sImage),dImage,*handle->mapx,*handle->mapy,cv::INTER_LINEAR);
...
// apply the rotation to make the mage parallel to the camera
cv::warpPerspective(dImage,dImage2,rotMtx,cv::Size(handle->width,handle->height),cv::INTER_LANCZOS4,cv::BORDER_TRANSPARENT,cv::Scalar());
cvCalibrateCamera2()返回的旋转3x1旋转值不为0,说明有返回值。但是warpPerspective()没有旋转图像。
这里出了什么问题?如何正确“并行化”图像?