opencv_contrib: CharucoBoard_create regression / incompatible patterns (only even row count) with 4.6.0
System information (version)
OpenCV = 4.6.0 / 4.5.5
Detailed description
cv2.aruco.CharucoBoard_create creates a different pattern in 4.6.0 than in 4.5.5 for even row counts. This leads to backwards incompatibility with previous versions, previously manufactured targets, etc.
OpenCV 4.5.5:
OpenCV 4.6.0:
Maybe this regression was introduced when resolving issue https://github.com/opencv/opencv_contrib/issues/2623 ?
Steps to reproduce
import cv2
aruco_dict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_5X5_1000)
charuco_board = cv2.aruco.CharucoBoard_create(
squaresX = 5,
squaresY = 4,
squareLength = 4,
markerLength = 3,
dictionary = aruco_dict
)
img_board = charuco_board.draw((250,200), marginSize=0, borderBits=1)
cv2.imwrite('charuco_OpenCV-' + cv2.__version__ + '.png', img_board)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 17 (7 by maintainers)
I understand the reasoning behind the change, but I believe that backward compatibility (huge) trumps consistency here. I strongly support the opinion that a legacy switch (on by default) is needed. For developers printing patterns ad-hoc the change might not seem dramatic, but ChAruCo patterns are used in mission critical production software pipelines by many customers worldwide. No-one expects an OpenCV version update to break compatibility with older patterns. Considerable investments have been made into stock. Keeping separate pre- and post- 4.6.0 ChAruCo boards is wasteful in terms of time and resources.
Jakob // Calib.io
Now that 4.6.0 is out in the wild it should be worth to consider actively breaking API backward compatibility and not setting a default option, forcing developers to choose (legacy or new). Otherwise unsuspecting individuals might stumble over this issue for quite a while. Maybe someone is producing new targets with 4.6.0 now, which would break if a future version has the legacy flag set to true by default?
Either way it would be really appreciated to have the legacy functionality accessible without applying a patch manually and compiling opencv+contrib from source.
PS: The patch I suggested above does not change the order of IDs for “legacy”, so maybe it would not re-open issues https://github.com/opencv/opencv_contrib/issues/2623 and https://github.com/opencv/opencv_contrib/issues/2604?
Why do you say that? What is this based on?
Production code around the world relies on physical boards with even row counts, produced using pre-4.6.0 code, that cannot and will not be physically replaced to the new pattern. This renders opencv 4.6.0 unusable in many calibration/tracking systems, including ones that I developed and maintain. In #3301 the guy bought a board from calib.io, should he throw it out? Should calib.io discard their stock?
@AleksandrPanov I don’t think you realize that this was a huge breaking change. A legacy flag set to true by default is the least that can be done to avoid breaking existing code when upgrading (speaking from experience here). @alalek what do you think?
I went ahead and created pull request https://github.com/opencv/opencv_contrib/pull/3305 with this patch. Legacy is set to “true” by default. Some small adjustments were necessary to get the unit tests working properly with both board types. All is pass now, and there are no fails regarding bad reprojection errors or similar. Changing or removing the default value of legacy would be simple enough if that would be the final verdict.
@gmedan
Done:
I was calibrating with 4.6.0 and 8x11 board charuco board and always got huge reprojection error.
This bug is not easy to find.
I downgraded the opencv to 4.5.*, hope we can have a fix soon
About the chessboard pattern, this is indeed a
9x6
pattern since only corners from intersection are detected / used.Fixed in main branch by https://github.com/opencv/opencv/pull/23153 for next OpenCV release 4.8.0.
opencv 4.7.0 is now released, with aruco moved to the main repo (not contrib). This problem was not addressed, and the legacy flag was not introduced. @stefan523 I think you should reopen the issue under the main repo and port your PR
Behavior is aligned with chessboard: https://github.com/opencv/opencv/blob/4.x/doc/pattern.png