Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV - 3.0 Camera calibration gives an error

I was previously doing camera calibration using OpenCV-2.4.10. Now I have installed OpenCV-3.0.0 and run the same code. This is the link of the code.

With the previous version it was working fine, but in OpenCV-3.0.0 it is giving an error.

TypeError: Required argument 'cameraMatrix' (pos 4) not found

can anyone tell me how to fix this?

Any if I add cameraMatrix (Pos4) ,and distcoeff(Pos5), it gives an error :

TypeError: function takes exactly 2 arguments (3 given)

like image 520
Maham Avatar asked Jan 26 '26 18:01

Maham


2 Answers

I got exactly the same error

TypeError: function takes exactly 2 arguments (3 given) 

But it turned out I was passing the shape of the image as ImageSize before transforming to grayscale, so a tuple of 3 values instead of 2, OpenCV has really confusing errors sometimes.

like image 131
Mehdi Avatar answered Jan 28 '26 06:01

Mehdi


I had the same error, you have to pass camera width and height, in my case I used this code line:

ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(_3d_points, 
                                                   _2d_points, 
                                                   (im.shape[1], im.shape[0]), 
                                                   None,
                                                   None)

Here im.shape[1] is the width and im.shape[0] is the height, basically returning the size of the image, also make sure the images are converted to grayscale.

In my case after converting the images to grayscale and adding the above line of code helped me get the o/p.

like image 32
Shreyasta Samal Avatar answered Jan 28 '26 07:01

Shreyasta Samal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!