Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

C vs C++ API for camera calibration

Hello,

I saw that the C API for OpenCV will be deprecated soon. So I took the opportunity to upgrade my project from the C API to C++. I am having great difficulty with cv::calibrateCamera(). The parameters seem to be completely incompatible to cvCalibrateCamera2().

  1. Is it possible use cv::Mat instead of std::vector for objectPoints and imagePoints parameters to cv::calibrateCamera()? The documentation is not clear. However, after tracing through collectCalibrationData() I think it is not possible.

  2. If it is possible, what is the exact format of matrices needed? Is there an example of giving cv::Mat to cv::calibrateCamera() somewhere? I looked online briefly but I could not find one.

  3. Using std::vector<std::vector<Vec3f>> works as a parameter to cv::calibrateCamera(), however it seems that std::vector<std::vector<Vec3f>> cannot be read/written with cv::FileStorage, which would mean I cannot use it. In the XML file it appears as one long list of floats:
    <calib_object_points> 0. 0. 0. 0. 20. .... 120. 120. 0. 120. 140. 0. </calib_object_points>
    As you can see there is no indication of the number of dimensions of each vector, and it cannot be reloaded without an error. Is there a workaround for this?

This is only very early in my conversion from C to C++ API. The C++ API is meant to give shorter, easier-to-read programs, but if I may say so, my first impression is that it is harder to use.

Thanks for any suggestion

Netsai