-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Detection of multiple ChArUco boards with different IDs in one image broken in 4.8.0 #23905
Copy link
Copy link
Closed
Labels
bugcategory: objdetectconfirmedThere is stable reproducer / investigation completeThere is stable reproducer / investigation complete
Milestone
Description
System Information
OpenCV 4.8.0
Ubuntu 22.04
Python 3.10.6
Detailed description
In OpenCV 4.7.0 you could separately detect two ChArUco boards visible in a single image:
dict_type = aruco.DICT_6X6_250
squares = (5, 7)
square_length_mm = 20.0
marker_length_mm = 10.0
aruco_dict = aruco.getPredefinedDictionary(dict_type)
board0 = aruco.CharucoBoard(squares, square_length_mm,
marker_length_mm, aruco_dict, np.arange(17)) # There are 17 white squares, provide 17 markers with ids [0..16]
detector = aruco.CharucoDetector(board0)
charuco_corners, charuco_ids, marker_corners, marker_ids = detector.detectBoard(image)
aruco.drawDetectedCornersCharuco(image, charuco_corners, charuco_ids, (255, 0, 0))
board1 = aruco.CharucoBoard(squares, square_length_mm,
marker_length_mm, aruco_dict, np.arange(17) + 17) # 17 markers with ids [17..33]
detector = aruco.CharucoDetector(board1)
charuco_corners, charuco_ids, marker_corners, marker_ids = detector.detectBoard(image)
aruco.drawDetectedCornersCharuco(image, charuco_corners, charuco_ids, (0, 255, 0))In OpenCV 4.8.0, the second detectBoard does not return any ChArUco corners. charuco_cornersand charuco_ids are both None.
The markers are still returned, so it is not a detection issue.
Sample code and sample image (see below) return under 4.7.0:
Running OpenCV 4.7.0
board0
charuco ids 0..23 (24)
marker ids 0..33 (34)
board1
charuco ids 0..23 (24)
marker ids 0..33 (23)
and SAME code under OpenCV 4.8.0:
Running OpenCV 4.8.0
board0
charuco ids 0..23 (24)
marker ids 0..33 (34)
board1
no charuco ids
marker ids 0..33 (23)
Steps to reproduce
import numpy as np
import cv2
import cv2.aruco as aruco
if __name__ == '__main__':
# Load image
image = cv2.imread('image.png')
# Generate Aruco boards
dict_type = aruco.DICT_6X6_250
squares = (5, 7)
square_length_mm = 20.0
marker_length_mm = 10.0
aruco_dict = aruco.getPredefinedDictionary(dict_type)
board0 = aruco.CharucoBoard(squares, square_length_mm,
marker_length_mm, aruco_dict, np.arange(17))
board1 = aruco.CharucoBoard(squares, square_length_mm,
marker_length_mm, aruco_dict, np.arange(17) + 17)
print(f'Running OpenCV {cv2.__version__}')
detector = aruco.CharucoDetector(board0)
charuco_corners, charuco_ids, marker_corners, marker_ids = detector.detectBoard(image)
print('board0')
if charuco_ids is None:
print(' no charuco ids')
else:
print(f' charuco ids {np.min(charuco_ids)}..{np.max(charuco_ids)} ({len(charuco_ids)})')
aruco.drawDetectedCornersCharuco(image, charuco_corners, charuco_ids, (255, 0, 0))
print(f' marker ids {np.min(marker_ids)}..{np.max(marker_ids)} ({len(marker_ids)})')
detector = aruco.CharucoDetector(board1)
charuco_corners, charuco_ids, marker_corners, marker_ids = detector.detectBoard(image)
print('board1')
if charuco_ids is None:
print(' no charuco ids')
else:
print(f' charuco ids {np.min(charuco_ids)}..{np.max(charuco_ids)} ({len(charuco_ids)})')
aruco.drawDetectedCornersCharuco(image, charuco_corners, charuco_ids, (0, 255, 0))
print(f' marker ids {np.min(marker_ids)}..{np.max(marker_ids)} ({len(marker_ids)})')
cv2.imshow(f'charuco ids with OpenCV {cv2.__version__}', image)
cv2.waitKey(0)
cv2.destroyAllWindows()Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- 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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugcategory: objdetectconfirmedThere is stable reproducer / investigation completeThere is stable reproducer / investigation complete

