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