Skip to content

Fix OpenCV 5 compatibility in camera calibration reprojection error calculation#306

Open
tanmoykalita808 wants to merge 2 commits into
localdevices:302-opencv-5from
tanmoykalita808:fix/opencv5-projectpoints-shape
Open

Fix OpenCV 5 compatibility in camera calibration reprojection error calculation#306
tanmoykalita808 wants to merge 2 commits into
localdevices:302-opencv-5from
tanmoykalita808:fix/opencv5-projectpoints-shape

Conversation

@tanmoykalita808

Copy link
Copy Markdown

Summary

This PR proposes a fix for one of the OpenCV 5 compatibility issues discussed in #302.

Problem

While testing with:

  • Python 3.14.4
  • OpenCV 5.0.0

tests/test_cameraconfig.py::test_camera_calib failed during the reprojection error calculation inside calibrate_camera().

The point arrays returned by cv2.projectPoints() and the detected chessboard corner points had different array layouts, causing cv2.norm() to fail with an input type mismatch.

Solution

Normalize both point arrays to shape (N, 2) before computing the reprojection error.

The same change is applied in both reprojection error calculation paths.

Validation

  • Reproduced the failure locally with Python 3.14.4 and OpenCV 5.0.0.
  • Verified the output shape of cv2.projectPoints() using a minimal example.
  • Confirmed that tests/test_cameraconfig.py::test_camera_calib passes after the change.

Thanks for the guidance on targeting the 302-opencv-5 branch. I'm happy to make any additional changes if needed to maintain backward compatibility.

@tanmoykalita808

Copy link
Copy Markdown
Author

Hi, just checking in to see if there's anything I can help with regarding this PR. I'm happy to make any changes or run additional tests if needed. Thanks!

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

Successfully merging this pull request may close these issues.

1 participant