opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.31k stars 5.74k forks source link

interpolateCornersCharuco misplaces corners in Opencv 4.6.0 #3367

Open apurvazaveri opened 1 year ago

apurvazaveri commented 1 year ago

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)
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
AndrewMartchenko commented 1 year ago

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

apurvazaveri commented 1 year ago

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