Kinect One calibration using OpenCV
I'm working on a project with stereo calibration for Kinect one using OpenCV. The CoordinateMapper in the Kinect SDK does not provide sufficent results (speed & quality). The color camera has a full HD resolution (1920x1080 pixel) and the depth/infrared image is 512x424 pixel. My checkerboard is 10x7 with 36mm on an A3-sheet.
I perform the intrinsic calibration with cv::calibrateCamera
for both cameras separately. The resulting camera and distortion matrix is pretty similar to GML camera calibration. cv::undistort
returns good visual results applying these parameters. The error is 0.941842 (infrared) and 0.583004 (color)
Next is stereo Calibration using previous intrinsics:
cv::Mat rotation, translation, fundamental, essential;
std::cout << "Stereo Error: " << cv::stereoCalibrate(pointsBoard, points1, points2, cameraMatrix1, distortion1, cameraMatrix2, distortion2, imageSize,
rotation, translation, essential, fundamental, cv::TermCriteria(CV_TERMCRIT_ITER+ CV_TERMCRIT_EPS, 100, 1e-5), CV_CALIB_FIX_INTRINSIC|CV_CALIB_ZERO_TANGENT_DIST) << std::endl;
cv::Mat R1, R2, P1, P2, Q;
cv::Rect validRoi[2];
cv::stereoRectify(cameraMatrix1, distortion1,
cameraMatrix2, distortion2,
imageSize, rotation, translation, R1, R2, P1, P2, Q,
cv::CALIB_ZERO_DISPARITY, 1, imageSize, &validRoi[0], &validRoi[1]);
cv::initUndistortRectifyMap(cameraMatrix1, distortion1, R1, P1, imageSize, CV_16SC2, rmap[0][0], rmap[0][7]);
cv::initUndistortRectifyMap(cameraMatrix2, distortion2, R2, P2, imageSize, CV_16SC2, rmap[1][0], rmap[1][8]);
I create the map for undistortion and rectifing only one time during calibration. The translation in pixel is calculated by cv::remap
one calibration image, again searching for checkerboard and calculating the average translation in X since both images should match on height and width?! The stereo is 0.412727 and reprojection error is 0.715183 using only images with checkerboard parallel to camera (growing on different positions/angles). Calibration image remapping and translation looks ok.
In live mode both images are remaped and translated so that they should match:
//overlay images
// recitfy
cv::remap(depth1, depth2, rmap[0][0], rmap[0][13], cv::INTER_LINEAR);
cv::remap(color1, color2, rmap[1][0], rmap[1][14], cv::INTER_LINEAR);
// translation and crop
depth1 = depth2(cv::Rect(750, 380, imagesOutputSize.width, imagesOutputSize.height)).clone();
color1 = color2(cv::Rect(750+translationX, 380, imagesOutputSize.width, imagesOutputSize.height)).clone();
The result is pretty bad :(
上一篇: 查看位于同一平面上的点