You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistent orientation of detected/generated ArUco and AprilTags #1195
ArUco and AprilTag detection both uses a clockwise orientation, however, AprilTag corners start with bottom right while ArUco starts with upper left. See the example below:
Code:
importcv2defdraw_markers_with_corners(img, corners):
fori, marker_cornersinenumerate(corners):
# Get the corners of the markercorner_points=marker_corners.reshape((4, 2))
corner_points=corner_points.astype(int)
# Draw each corner with its ordinal positionforj, cornerinenumerate(corner_points):
# Draw corner pointcv2.circle(img, tuple(corner), 5, (0, 0, 255), -1)
# Label the corner with its ordinal position (0, 1, 2, 3)cv2.putText(
img,
str(j),
(corner[0] +10, corner[1] +10),
cv2.FONT_HERSHEY_SIMPLEX,
0.5,
(255, 0, 0),
2,
)
returnimgimg=cv2.imread("markers.jpeg")
parameters=cv2.aruco.DetectorParameters()
april_dict=cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_APRILTAG_36h11)
april_detector=cv2.aruco.ArucoDetector(april_dict, parameters)
aruco_dict=cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_4X4_250)
aruco_detector=cv2.aruco.ArucoDetector(aruco_dict, parameters)
img_marked=img.copy()
april_corners, _, _=april_detector.detectMarkers(img)
img_marked=draw_markers_with_corners(img_marked, april_corners)
aruco_corners, _, _=aruco_detector.detectMarkers(img)
img_marked=draw_markers_with_corners(img_marked, aruco_corners)
cv2.imwrite("markers_detected.jpeg", img_marked)
The same issue persists (likely due to pre-defined dictionary configurations) for generation:
The generated AprilTag 36h11 - 0 (wrong orientation, see above)
The generated ArUco 4x4_250 - 0 (correct orientation, see above)
#### 36h11
### Tag image generation
Using your Python script and with the following parameters, it gives for:
36h11, id=46
Thanks so much for trying out! This looks great to me. I would personally love to see your branch merged to fix the issue for good. For me personally, I have a workaround to simply re-order the detected corners for AprilTags for now. Up to you how you would like to proceed.
Activity
qian-chu commentedon Jan 28, 2026
Also reported in https://stackoverflow.com/questions/79044142/why-is-the-order-of-the-incoming-corners-different-between-apriltag-and-aruco-ma
s-trinh commentedon Jan 28, 2026
The generated image uses: https://github.com/opencv/opencv/blob/55a8996ffe660444b0a3c268c967f67b133ab332/modules/objdetect/src/aruco/apriltag/predefined_dictionaries_apriltag.hpp#L11961-L11966
33in decimal gives in binary:0010 0001161in decimal gives in binary:1010 0001In my opinion, the following should be tested/verified:
s-trinh commentedon Jan 29, 2026
AprilTag official repository
Using the opencv_demo.cc in the AprilTag repository, it gives the following corners order:
You can use this tool to generate the marker images:
Regeneration of the AprilTag codeword
I have regenerated the AprilTag codeword in order to try to match the ArUco convention:
It seems to work.
25h9
36h11
Tag image generation
Using your Python script and with the following parameters, it gives for:
qian-chu commentedon Feb 13, 2026
Thanks so much for trying out! This looks great to me. I would personally love to see your branch merged to fix the issue for good. For me personally, I have a workaround to simply re-order the detected corners for AprilTags for now. Up to you how you would like to proceed.
Fix the AprilTag markers dictionaries: generating the AprilTag marker…
Merge pull request #28823 from s-trinh:fix_apriltag_corners_order_upd…
Merge pull request opencv#28823 from s-trinh:fix_apriltag_corners_ord…