4
我正在执行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()不旋转图像。
这里有什么问题?我应该如何正确“平行”图像?
warpPerspective()对于转换没有做任何事情,所以它似乎不是(非)倒置矩阵的问题。 – Elmi 2013-05-06 13:28:46
同样,您不能像使用_Rodrigues_函数调用那样使用'rotMtx'。您需要使用相机的焦距和主要点首先计算3x3 __homography__矩阵。使用此矩阵进行转换。 – Pranjal 2013-05-06 15:04:03
但是... cvCalibrateCamera2()返回了什么样的旋转 - 它可以用于什么? – Elmi 2013-05-06 17:33:59