1. Choosing the Right ArUco Dictionary
OpenCV includes predefined dictionaries ranging from 4×4 to 7×7 bits:
DICT_4X4_50/DICT_4X4_100: Best for high frame-rate tracking and long distances. Fewer internal bits mean larger module blocks that are easier for low-resolution cameras to resolve.DICT_5X5_100/DICT_5X5_250: Balanced general-purpose standard. Offers 100–250 unique IDs with strong inter-marker Hamming distance.DICT_6X6_250/DICT_7X7_1000: Best for large multi-marker environments. Supports hundreds of distinct IDs with minimal collision probability.
2. Python OpenCV Quickstart (cv2.aruco)
import cv2
import cv2.aruco as aruco
# Initialize dictionary & detector parameters
aruco_dict = aruco.getPredefinedDictionary(aruco.DICT_4X4_50)
parameters = aruco.DetectorParameters()
detector = aruco.ArucoDetector(aruco_dict, parameters)
# Capture frame and detect markers
corners, ids, rejected = detector.detectMarkers(gray_frame)
if ids is not None:
aruco.drawDetectedMarkers(frame, corners, ids)
3. ArUco vs. AprilTag: Which Should You Choose?
- Choose ArUco: If you are working directly in pure Python/C++ with OpenCV and want zero third-party C library dependencies.
- Choose AprilTag (Tag36h11): If your priority is maximum detection range, extreme perspective angles, and sub-pixel accuracy in ROS2/Nav2 mobile robots.