Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while using calibrate_cameras #32

Open
sokol07 opened this issue Dec 18, 2018 · 5 comments
Open

Error while using calibrate_cameras #32

sokol07 opened this issue Dec 18, 2018 · 5 comments

Comments

@sokol07
Copy link

sokol07 commented Dec 18, 2018

When using calibrate_cameras I was getting such an error:
cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\calib3d\src\calibration.cpp:1318: error: (-211:One of arguments' values is out of range) image width and height must be positive in function 'cvCalibrateCamera2Internal'

I found that #16 was a fix for similar issue. I reverted that change, placed self.image_size after calib.dist_coefs["right"] and everything is ok now.

So this piece of code look at the moment like that in my project:

calib = StereoCalibration()   
        (calib.cam_mats["left"], calib.dist_coefs["left"],  
         calib.cam_mats["right"], calib.dist_coefs["right"],  
         calib.rot_mat, calib.trans_vec, calib.e_mat,  
         calib.f_mat) = cv2.stereoCalibrate(self.object_points,  
                                            self.image_points["left"],  
                                            self.image_points["right"],  
                                            calib.dist_coefs["left"],  
                                            calib.cam_mats["right"],  
                                            calib.dist_coefs["right"],  
                                            self.image_size,  
                                            calib.rot_mat,  
                                            calib.trans_vec,  
                                            calib.e_mat,  
                                            calib.f_mat,  
                                            criteria=criteria,  
                                            flags=flags)[1:]  
                                          
  
@erget
Copy link
Owner

erget commented Jan 2, 2019

This is cool to know. Does cv2.stereoCalibrate use named argument? If that's the case, would you be willing to name the arguments in the invocation, à la cv2.stereoCalibrate(foo=bar) and send a PR?

@sokol07
Copy link
Author

sokol07 commented Jan 2, 2019

I found the documentation of cv2.stereoCalibrate but I'm confused...
https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#cv2.stereoCalibrate

"imageSize" is definitely in the place where #16 placed it. It was in the place where I placed it in old version ("import cv") but in my project I definitely have "import cv2". I'm not sure if this is really an issue or just some kind of a bug and on which side: SteroVision, OpenCV, Python or PyCharm...

@erget
Copy link
Owner

erget commented Jan 3, 2019

Hmm... Yeah, I don't have a setup where I can test it but the OpenCV API has been a bit volatile in the past, leading to such things. I don't think it's possible that Python or PyCharm could be causing it, and StereoVision has worked for a lot of people so I think what we're looking at is some change in the function header as exposed by OpenCV. I'm glad it's working for you now though.

@hezongfanghuaok
Copy link

in the opencv4.4 hais the same problem, self.image_size in the wrong place.

@Jmack66
Copy link

Jmack66 commented Jul 3, 2021

Had the exact same error code as @sokol07, tried the fix in #16 as well, but it didn't work, when I passed self.image_size as a named argument it told me that it was passed positionally in position 8 and by name, passing everything by name argument seemed to fix the order issues for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants