opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

interpolateCornersCharuco misplaces corners in Opencv 4.6.0

Open apurvazaveri opened this issue 3 years ago • 5 comments

I use post-4.6.0 version of ChaRuCo printed patterns. I noticed that interpolateCornersCharuco misplace corners. The markers are detected correctly but so of the corners as you can see in the attached image are misplaced.

This did not happen in version 4.4. Did some digging into it and I can confirm that it was working as expected until opencv version 4.5.5.64. After that the behavior changed.

System information (version)
  • OpenCV => 4.6.0
  • Operating System / Platform => Mac 12.6
Detailed description

Output in 4.6:

image

vs output in 4.5.5.64:

image

As, you can see that in this version (opencv 4.5.5.64) the markers are detected correctly.

Steps to reproduce
Issue submission checklist
  • [x] I report the issue, it's not a question
  • [x] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • [x] I updated to the latest OpenCV version and the issue is still there
  • [ ] There is reproducer code and related data files: videos, images, onnx, etc

apurvazaveri avatar Oct 21 '22 00:10 apurvazaveri

I have also encountered this problem with in OpenCV 4.6. In my case additional markers were detected in the scene which were throwing off the corner interpolation. I solved the problem by setting the camera matrix and distortion coefficients to empty matrix (cv::Mat()) in the function interpolateCornerCharuco. This forces the algorithm to use a local homography which in my case is more robust than the alternative approximate pose estimation (see function documentation).

Another problem you may be facing is that in OpenCV 4.6 there has been a change in the way Charuco boards are defined. This breaking change only affects boards that have an even number of rows (issue 3301). I get around this issue by creating a board with one extra row, then I manually change the marker ids so that the first marker on the second row has id=0, with following markers having id=1, id=2, and so on. The markers on the first row are dummy markers, they should be set to some value that does not appear in your printed board.

Here is an example of a board I create to detect my legacy (pre 4.6) boards. The part in red is what my printed board looks like. The first row simply hold dummy markers with id value nor present in your printed board. board_4 6_demo

AndrewMartchenko avatar Oct 27 '22 02:10 AndrewMartchenko

Any update on this? Is this available in the latest OpenCv version?

apurvazaveri avatar Jan 30 '23 23:01 apurvazaveri