python cv2 stereoCalibrate [closed]
Greetings,
When trying to use the python function cv2.stereCalibrate() I am receiving an "Assertion error -215".
I am able to get a successful monocular calibration with cv2.cameraCalibrate().
The traceback is as follows:
cv2.error: OpenCV(3.4.3) /Users/travis/build/skvark/opencv-python/opencv/modules/calib3d/src/calibration.cpp:3136: error: (-215:Assertion failed) nimages > 0 && nimages == (int)imagePoints1.total() && (!imgPtMat2 || nimages == (int)imagePoints2.total()) in function 'collectCalibrationData'
Has anyone found a workaround to this ?
Thanks,
wildwallaby
can you show the relevant piece of code ?
the error mainly says, that it did not find enough chessboard corners in some of the images
Thanks for the rapid response. The lengths of the objpoints, imgpoints_l and imgpoints_r are 52, 39, 23 respetively. I thought that these would indicate that enough corners have been found. Perhaps I am missing something else. I am opting to calculate the camera and distortion matrices just with cv2.stereoCalibrate(). Below is a code snippet.
`
M1, M2 = np.zeros((3,3)), np.zeros((3,3))
d1, d2 = np.zeros((3,1)), np.zeros((3,1))
stereocalib_criteria = (cv2.TERM_CRITERIA_MAX_ITER +
cv2.TERM_CRITERIA_EPS, 30, 1e-5)
ret, M1, d1, M2, d2, R, T, E, F = cv2.stereoCalibrate(
self.objpoints, self.imgpoints_l,
self.imgpoints_r, M1, d1, M2,
d2, dims,
criteria=stereocalib_criteria, flags=flags)
`
Thanks for your help.
look at the shapes for self.objpoints, self.imgpoints_l, self.imgpoints_r. they should have all the same length.
you should have rejected image pairs earlier on, which do not have the full number of expected chessboard corners.
again, ALL chessboard corners need to be detected.