Ask Your Question
0

C vs C++ API for camera calibration

asked 2013-07-17 23:54:38 -0600

Netsai Chibuku gravatar image

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-07-18 01:35:28 -0600

Daniil Osokin gravatar image

Hi, Netsai!

Try the "Camera calibration With OpenCV" tutorial.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-07-17 23:54:38 -0600

Seen: 603 times

Last updated: Jul 18 '13