我正在执行 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() 不会旋转图像。
这里有什么问题?我应该如何正确“并行化”图像?