我正在执行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()不会旋转图像。
这里出了什么问题?我应该如何正确地“并行化”镜像?
发布于 2013-05-06 20:14:25
根据我对这个主题的理解,你用来“并行化”图像的旋转矩阵提供了两个图像平面之间的旋转。你正在寻找的是,一个从图像平面到相机平面的转换。这需要计算平面之间的单应性。你需要弄清楚是什么矩阵把你从图像平面带到了相机平面。使用这个矩阵来并行化你的图像。
此外,calibrateCamera为您提供了正向变换,以返回到您需要求逆矩阵的原始状态。
试着读一下这个- Homography
提示:使用焦距和主点信息在图像和相机平面之间移动。
https://stackoverflow.com/questions/16198923
复制相似问题