无法消除失真

时间:2013-05-18 16:24:19

标签: java opencv camera-calibration

我正在制作一个程序来校准相机并使用Java中的OpenCV用棋盘消除失真。我一直在阅读“学习OpenCV”,我的代码非常相似,但即使程序运行没有错误,结果也是错误的。我正在寻找内在矩阵和失真系数。

有人可以帮助我吗?我很绝望!!简而言之,我设置了cheesboard的大小(宽度为4个点,高度为5个)。

我捕获图像,并创建4个矩阵 image_points,object_points,图像大小(作为输入)camera_matrix和distortion_coefficients(作为输出)。然后我为噪声效果应用平滑滤波器(高斯滤波器)和:

cvFindChessboardCorners(image,board_sz,corner,                     corner_count,CV_CALIB_CB_FAST_CHECK);

        cvCvtColor(image, gray_image, CV_BGR2GRAY);
        cvFindCornerSubPix(                         // Get Subpixel accuracy on those corners
                gray_image,
                corners,
                corner_count[0],
                cvSize(11,11),
                cvSize(-1, -1),
                cvTermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30,
                        0.1));

         cvDrawChessboardCorners(image, board_sz, corners,
                corner_count[0], found);

// CALIBRATE THE CAMERA!
cvCalibrateCamera2(object_points2, image_points2, point_counts2,
        cvGetSize(image), intrinsic_matrix, distortion_coeffs, null,
        null, CV_CALIB_RATIONAL_MODEL //0 // CV_CALIB_FIX_ASPECT_RATIO
);


IplImage mapx = cvCreateImage(cvGetSize(image), IPL_DEPTH_32F, 1);
IplImage mapy = cvCreateImage(cvGetSize(image), IPL_DEPTH_32F, 1);

cvInitUndistortMap(intrinsic, distortion, mapx, mapy);

while (image != null) {
                imga = ImageIO.read(u);
                image = IplImage.createFrom(imga);

    IplImage t = cvCloneImage(image);
    rawFrame.showImage(image); // Show raw image
    cvRemap(t, image, mapx, mapy, CV_INTER_LINEAR
            | CV_WARP_FILL_OUTLIERS, cvScalarAll(0));
    cvReleaseImage(t);
                undistortFrame.showImage(image); // Show corrected image
       }

我必须获得的参数应该接近这些参数:
*内在矩阵:

fx 800.161011;
fy = 800.174866;
cx = 648.423279;
cy = 483.997681;
  • 失真系数:

    k1 -4.25992794e-002; k2 = -1.11125395e-001; k3 = 8.78498256e-002; k4 = 3.94474864e-002; k5 = -1.00275539e-001; k6 = 8.33327100e-002; p1 = 6.98052521e-004; p2 = 4.69301594e-004;

我真的很绝望!非常感谢你! :)

0 个答案:

没有答案