Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV Error: Bad argument (For non-planar calibration rigs the initial intrinsic matrix must be specified) in cvCalibrateCamera2

Hi there! I'm trying to compute the camera matrix using a series of (2D <-> 3D) correspondences not acquired from a planar rig. From the documentation of calibrateCamera() it seems possible to use it also in this way but, when I run my program, I get this error:

OpenCV Error: Bad argument (For non-planar calibration rigs the initial intrinsic matrix must be specified) in cvCalibrateCamera2, file /opt/local/var/macports/build/_opt_mports_dports_graphics_opencv/opencv/work/opencv-2.4.5/modules/calib3d/src/calibration.cpp, line 1592 terminate called throwing an exception

The code is very simple, here is a sketch

vector<vector<Point3f> > objectPoints;
vector<vector<Point2f> > imagePoints;
......
   ...insert 3D and 2D points in objectPoint and imagePoints
......
Mat cameraMatrix= Mat(3, 3, CV_64F);
Mat distCoeffs;
vector<Mat> rvecs; //rotation vector
vector<Mat> tvecs;//translation vector

calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs);

Does anybody know what's wrong? Thanks in advance!