ArUco Marker Detection
API reference for detecting ArUco markers and CharUco boards for robust camera pose estimation.ArucoDetector
Main class for detecting ArUco markers in images.Constructor
Dictionary indicating the type of markers that will be searched
Marker detection parameters
Marker refine detection parameters
Multi-Dictionary Constructor
Multiple dictionaries for marker detection. Cannot be empty.
Methods
detectMarkers
Basic marker detection in an image.Input image where markers will be detected
Vector of detected marker corners. For each marker, its four corners are provided (clockwise order). For N detected markers, dimensions are Nx4.
Vector of identifiers of the detected markers. For N detected markers, the size is N.
Contains the corners of squares whose inner code has incorrect codification. Useful for debugging.
The function does not correct lens distortion. It’s recommended to undistort the input image if camera parameters are known.
detectMarkersWithConfidence
Marker detection with confidence computation.Contains the normalized confidence [0;1] of the markers’ detection, defined as 1 minus the normalized uncertainty (percentage of incorrect pixel detections).
refineDetectedMarkers
Refine undetected markers based on already detected markers and board layout.Input image
Layout of markers in the board
Vector of already detected marker corners
Vector of already detected marker identifiers
Vector of rejected candidates during the marker detection process
Optional 3x3 floating-point camera matrix
Optional vector of distortion coefficients
Optional array to return the indexes of recovered candidates in the original rejectedCorners array
getDictionary / setDictionary
getDetectorParameters / setDetectorParameters
getRefineParameters / setRefineParameters
Example Usage
- C++
- Python
Dictionary
A dictionary is a set of unique ArUco markers of the same size.Constructor
Bits for all ArUco markers in dictionary (CV_8UC4 type)
ArUco marker size in units (number of bits per dimension)
Maximum number of bits that can be corrected
Properties
bytesList(Mat): Marker code information stored as 2D matrix with 4 channelsmarkerSize(int): Number of bits per dimensionmaxCorrectionBits(int): Maximum number of bits that can be corrected
Methods
identify
Given a matrix of bits, returns whether the marker is identified.Input matrix of bits
Output marker ID in the dictionary (if any)
Output marker rotation (0-3)
Maximum error correction rate
true if marker is identified
generateImageMarker
Generates a canonical marker image.Marker ID to generate
Size of the output image in pixels
Output marker image
Width of the marker border
Predefined Dictionaries
getPredefinedDictionary
DICT_4X4_50- 4x4 bits, 50 markers, hamming distance 4DICT_4X4_100- 4x4 bits, 100 markers, hamming distance 3DICT_4X4_250- 4x4 bits, 250 markers, hamming distance 3DICT_4X4_1000- 4x4 bits, 1000 markers, hamming distance 2DICT_5X5_50- 5x5 bits, 50 markers, hamming distance 8DICT_5X5_100- 5x5 bits, 100 markers, hamming distance 7DICT_5X5_250- 5x5 bits, 250 markers, hamming distance 6DICT_5X5_1000- 5x5 bits, 1000 markers, hamming distance 5DICT_6X6_50- 6x6 bits, 50 markers, hamming distance 13DICT_6X6_100- 6x6 bits, 100 markers, hamming distance 12DICT_6X6_250- 6x6 bits, 250 markers, hamming distance 11DICT_6X6_1000- 6x6 bits, 1000 markers, hamming distance 9DICT_7X7_50- 7x7 bits, 50 markers, hamming distance 19DICT_7X7_100- 7x7 bits, 100 markers, hamming distance 18DICT_7X7_250- 7x7 bits, 250 markers, hamming distance 17DICT_7X7_1000- 7x7 bits, 1000 markers, hamming distance 14DICT_ARUCO_ORIGINAL- 6x6 bits, 1024 markers (standard ArUco Library)DICT_APRILTAG_16h5- 4x4 bits, 30 markers, hamming distance 5DICT_APRILTAG_25h9- 5x5 bits, 35 markers, hamming distance 9DICT_APRILTAG_36h10- 6x6 bits, 2320 markers, hamming distance 10DICT_APRILTAG_36h11- 6x6 bits, 587 markers, hamming distance 11DICT_ARUCO_MIP_36h12- 6x6 bits, 250 markers, hamming distance 12
CharucoDetector
Detector for ChArUco boards (chessboard + ArUco markers).Constructor
ChArUco board configuration
ChArUco detection parameters
Marker detection parameters
Marker refine detection parameters
Methods
detectBoard
Detects ArUco markers and interpolates ChArUco board corners.Input image necessary for corner refinement
Interpolated chessboard corners
Interpolated chessboard corner identifiers
Vector of already detected marker corners. If empty, the function will detect markers.
List of identifiers for each marker in corners. If empty, the function will detect markers.
After OpenCV 4.6.0, there was an incompatible change in the ChArUco pattern generation algorithm for even row counts. Use
CharucoBoard::setLegacyPattern() to ensure compatibility with patterns created before 4.6.0.detectDiamonds
Detects ChArUco Diamond markers.Input image necessary for corner subpixel accuracy
Output list of detected diamond corners (4 corners per diamond) in clockwise order
IDs of the diamonds. Each diamond has 4 IDs corresponding to the ArUco markers composing it.
List of detected marker corners. If empty, the function will detect markers.
List of marker IDs. If empty, the function will detect markers.
Example Usage
- C++
- Python
DetectorParameters
Parameters for ArUco marker detection.Key Parameters
Corner refinement method:
CORNER_REFINE_NONE- No refinementCORNER_REFINE_SUBPIX- Subpixel corner refinementCORNER_REFINE_CONTOUR- Contour-based refinementCORNER_REFINE_APRILTAG- AprilTag approach
Enable the new and faster ArUco 3 detection strategy (from Romero-Ramirez et al. 2018)
