hjbolide
hjbolide

Reputation: 391

Calling cv::calibrateCamera() failed

I'm trying to get the cameraMatrix from the function cv::calibrateCamera(), actually I'm not sure if I did it right or not, my initial idea is that:

  1. Get two input images which come from the same camera.
  2. Extract all the feature points from image_1 and image_2
  3. Use cv::calibrateCamera() to get the cameraMatrix (don't know if it would work or not)

Here is my code of doing it:

calling calibrateCamera()

The compilation went through pretty well, but when I ran it, it throws an exception said:

OpenCV Error: Assertion failed (i < 0) in create, file /home/hjbolide/OpenCV-2.3.1/modules/core/src/matrix.cpp, line 1198 terminate called after throwing an instance of 'cv::Exception'
what(): /home/hjbolide/OpenCV-2.3.1/modules/core/src/matrix.cpp:1198: error: (-215) i < 0 in function create

As I said, I was just trying this method, and try to get the cameraMatrix from it. Don't know where it goes wrong. Any suggestions?

Thanks very much.

Upvotes: 2

Views: 2607

Answers (1)

jbromley
jbromley

Reputation: 71

I had a similar problem. I ported a C calibration example from the Learning OpenCV book to use the C++ interface and was seeing the exact error you saw. I changed rvec and tvec to std::vector<cv::Mat> and then the calibration worked. Note that the 2.3 documentation marks both rvec and tvec as OutputArrayOfArrays.

Upvotes: 5

Related Questions