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

cv2.error: /io/opencv/modules/calib3d/src/calibration.cpp:3083: error: (-215) nimages > 0 && nimages == (int)imagePoints1.total() && (!imgPtMat2 || nimages == (int)imagePoints2.total()) in function collectCalibrationData #4

Open
nearkyh opened this issue Jul 27, 2018 · 5 comments

Comments

@nearkyh
Copy link

nearkyh commented Jul 27, 2018

When I run the code, I get the following error:

OpenCV Error: Assertion failed (nimages > 0 && nimages == (int)imagePoints1.total() && (!imgPtMat2 || nimages == (int)imagePoints2.total())) in collectCalibrationData, file /io/opencv/modules/calib3d/src/calibration.cpp, line 3083 Traceback (most recent call last): File "test.py", line 129, in <module> cal_data = StereoCalibration(args.filepath) File "test.py", line 25, in __init__ self.read_images(self.cal_path) File "test.py", line 71, in read_images self.objpoints, self.imgpoints_l, img_shape, None, None) cv2.error: /io/opencv/modules/calib3d/src/calibration.cpp:3083: error: (-215) nimages > 0 && nimages == (int)imagePoints1.total() && (!imgPtMat2 || nimages == (int)imagePoints2.total()) in function collectCalibrationData

Is there a solution?

@Brandonn-Etheve
Copy link

I've similar issue too. The solution i've found is to manualy add left and right img in the LEFT and RIGHT folder and check if it's working. Some images produces an error, just try others images.

@nosovandrew
Copy link

nosovandrew commented May 6, 2019

Hello! This happens because self.objpoints, imgpoints_l, imgpoints_r have different length. When func findChessboard doesn't find chessboard -> ret_l or ret_r isn't True.
The solve of problem — delete self.imgpoints_l.append(corners_l) and self.imgpoints_r.append(corners_r) from if and after for add

if ret_l is True and ret_r is True:
self.imgpoints_l.append(corners_l)
self.imgpoints_r.append(corners_r)
self.objpoints.append(self.objp)

@willeett
Copy link

Hi,

I am trying to run the code using Visual Studio Code in Anaconda. I am getting an error.

Traceback (most recent call last):
File "c:/Users/William/hello/_runscript.py", line 5, in
cal = StereoCalibration(r'C:\Users\William\hello\images')
File "c:\Users\William\hello\camera_calibration.py", line 25, in init
self.read_images(self.cal_path)
File "c:\Users\William\hello\camera_calibration.py", line 71, in read_images
self.objpoints, self.imgpoints_l, img_shape, None, None)
UnboundLocalError: local variable 'img_shape' referenced before assignment

Anyone know what might be the cause of this error?

Best regards

@danielajisafe
Copy link

@willeett, I think you have an indentation issue. You need to somehow push
img_shape = gray_l.shape[::-1]

backwards a bit.

@hussnainsheikh
Copy link

It is a bit confusing counting the squares correctly but try and count the 'inside' corners. In my case, I was using an 8 by 6 checkerboard (8,6).

source: StackOverflow

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

6 participants