Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::CalibrateCamera vs. cvCalibateCamera2 difference ?


I am using two different codes for camera calibration (one with the old C interface and one with the C++ interface) I want to unify this using only C++ interface but when I run the functions cv::calibrateCamera and cvCalibrateCamera2 on the exact same data I get different results and the C results are much better.

Here is the core function that I tested :

vector<vector<Point3f>> modele_points;
vector<vector<Point2f>> image_points;

//I skip the code to fill the vectors

double rms_error = calibrateCamera(model_points, image_points,size, intrinsic, disto, rotations, translations,flags);//flags = 0

and :

CvMat* cam_image_points        = cvCreateMat(n_boards*cam_board_n,2, CV_32FC1);
CvMat* cam_object_points       = cvCreateMat(n_boards*cam_board_n,3, CV_32FC1);
CvMat* cam_point_counts        = cvCreateMat(n_boards, 1, CV_32SC1);

CvMat* cam_rotation_vectors    = cvCreateMat(n_boards, 3, CV_32FC1);
CvMat* cam_translation_vectors = cvCreateMat(n_boards, 3, CV_32FC1);
CvMat* camera_matrix           = cvCreateMat(3,3,CV_32F);
CvMat *dist_coeffs         = cvCreateMat(5,1,CV_32FC1);

//Filling the matrices

double rms_error = cvCalibrateCamera2(cam_object_points,cam_image_points, cam_point_counts, image_size, camera_matrix, dist_coeffs,cam_rotation_vectors,cam_translation_vectors);

I wrote the content of model_points and cam_object_points in a file, they are exactly the same. And image_points also contains the same values as cam_image_points. Those values are obtained using chessboard detection and subpixel corner refinement respectively with c++ and c interface. But I get different results cvCalibrateCamera2 returns a rms error of 0.1 on my data and calibrateCamera returns an error of 0.8 with a different camera matrix whose values are not completely out of the expected range but are not as good as those of cvCalibrateCamera2 by far.

Is there a big difference between the two versions that could explain the different results ? Could there be a problem in the way i use these functions.

I can provide more information on request (values or whatever) if needed.

Thanks in advance.