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

(-5:Bad argument) in function 'calibrateCamera' #18

Open
Super-Iron-Man opened this issue Jan 25, 2022 · 6 comments
Open

(-5:Bad argument) in function 'calibrateCamera' #18

Super-Iron-Man opened this issue Jan 25, 2022 · 6 comments

Comments

@Super-Iron-Man
Copy link

Super-Iron-Man commented Jan 25, 2022

when I run calibrate.py, it shows:
`points.corners, image_size, None, None, criteria=criteria, flags=flags)
cv2.error: OpenCV(4.5.5) 👎 error: (-5:Bad argument) in function 'calibrateCamera'

Overload resolution failed:

  • Can't parse 'imagePoints'. Sequence item with index 0 has a wrong type
  • Can't parse 'imagePoints'. Sequence item with index 0 has a wrong type`

when I run
print(np.array(points.object_points).shape

it shows:
(12,114,3)

@Super-Iron-Man Super-Iron-Man changed the title (-5:Bad (-5:Bad argument) in function 'calibrateCamera' Jan 25, 2022
@ykk648
Copy link

ykk648 commented May 13, 2022

same problem, I uninstall opencv-python and reinstall opencv-contrib-python , solved this issue.

my final version:

opencv-contrib-python 4.5.5.64

@dkguo
Copy link

dkguo commented Nov 18, 2022

Same problem here. Using opencv-contrib-python 4.5.5.64 doesn’t help. Do you have other ideas for this problem? Thanks.

@Jungduri
Copy link

Jungduri commented Jan 25, 2023

This issue origins from the type checker, of which OpenCV has been updated from a specific version(sorry I am not sure).
"calibrateCamera" needs float32 of nparray. but NumPy turns it to np.float64 as a default.

Quick solution

you may change as below(in camera.py):

            np.array(points.object_points, dtype=np.float32),
            np.array(points.corners, dtype=np.float32),

This is not a good idea, but works for quick turns.
Hope it works.

@jessicalfr
Copy link

I'm going through the same problem trying to calibrate 4 cameras. The problem seems to happen in the top_detection_coverage function call in line 72 of camera.py. After the call points = calibration_points(boards, detections) in line 70 the object points.object_points is a list of numpy arrays. After the top_detection_coverage call the same object turns into a list of lists for one of my cameras and the error occurs. Coincidence or not, this camera has a different resolution from the others, but I've done this before and it worked.

I'm still trying a few solutions and if something works I'll bring it here.

@jessicalfr
Copy link

Commenting the line that calls top_detection_coverage obviously works, but doesn't seem like the best solution!

@helloqxwang
Copy link

adding
for i in range(len(points.object_points)): points.object_points[i] = np.ndarray(points.object_points[i], dtype=np.float32) for i in range(len(points.corners)): points.corners[i] = np.array(points.corners[i], dtype=np.float32)
after the top_detection_coverage function call works well for me. I think the reason is just what @jessicalfr say.

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