StereoVision
StereoVision copied to clipboard
Error while using calibrate_cameras
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:]
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?
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...
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.
in the opencv4.4 hais the same problem, self.image_size in the wrong place.
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.