Skip to main content

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
Dictionary indicating the type of markers that will be searched
DetectorParameters
Marker detection parameters
RefineParameters
Marker refine detection parameters

Multi-Dictionary Constructor

std::vector<Dictionary>
Multiple dictionaries for marker detection. Cannot be empty.

Methods

detectMarkers

Basic marker detection in an image.
InputArray
Input image where markers will be detected
OutputArrayOfArrays
Vector of detected marker corners. For each marker, its four corners are provided (clockwise order). For N detected markers, dimensions are Nx4.
OutputArray
Vector of identifiers of the detected markers. For N detected markers, the size is N.
OutputArrayOfArrays
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.
OutputArray
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.
InputArray
Input image
Board
Layout of markers in the board
InputOutputArrayOfArrays
Vector of already detected marker corners
InputOutputArray
Vector of already detected marker identifiers
InputOutputArrayOfArrays
Vector of rejected candidates during the marker detection process
InputArray
Optional 3x3 floating-point camera matrix
InputArray
Optional vector of distortion coefficients
OutputArray
Optional array to return the indexes of recovered candidates in the original rejectedCorners array

getDictionary / setDictionary

Gets or sets the first dictionary used for marker detection.

getDetectorParameters / setDetectorParameters

Gets or sets the detector parameters.

getRefineParameters / setRefineParameters

Gets or sets the refine parameters.

Example Usage


Dictionary

A dictionary is a set of unique ArUco markers of the same size.

Constructor

Mat
Bits for all ArUco markers in dictionary (CV_8UC4 type)
int
ArUco marker size in units (number of bits per dimension)
int
default:"0"
Maximum number of bits that can be corrected

Properties

  • bytesList (Mat): Marker code information stored as 2D matrix with 4 channels
  • markerSize (int): Number of bits per dimension
  • maxCorrectionBits (int): Maximum number of bits that can be corrected

Methods

identify

Given a matrix of bits, returns whether the marker is identified.
Mat
Input matrix of bits
int&
Output marker ID in the dictionary (if any)
int&
Output marker rotation (0-3)
double
Maximum error correction rate
Returns: true if marker is identified

generateImageMarker

Generates a canonical marker image.
int
Marker ID to generate
int
Size of the output image in pixels
OutputArray
Output marker image
int
default:"1"
Width of the marker border

Predefined Dictionaries

getPredefinedDictionary

Available predefined dictionaries:
  • DICT_4X4_50 - 4x4 bits, 50 markers, hamming distance 4
  • DICT_4X4_100 - 4x4 bits, 100 markers, hamming distance 3
  • DICT_4X4_250 - 4x4 bits, 250 markers, hamming distance 3
  • DICT_4X4_1000 - 4x4 bits, 1000 markers, hamming distance 2
  • DICT_5X5_50 - 5x5 bits, 50 markers, hamming distance 8
  • DICT_5X5_100 - 5x5 bits, 100 markers, hamming distance 7
  • DICT_5X5_250 - 5x5 bits, 250 markers, hamming distance 6
  • DICT_5X5_1000 - 5x5 bits, 1000 markers, hamming distance 5
  • DICT_6X6_50 - 6x6 bits, 50 markers, hamming distance 13
  • DICT_6X6_100 - 6x6 bits, 100 markers, hamming distance 12
  • DICT_6X6_250 - 6x6 bits, 250 markers, hamming distance 11
  • DICT_6X6_1000 - 6x6 bits, 1000 markers, hamming distance 9
  • DICT_7X7_50 - 7x7 bits, 50 markers, hamming distance 19
  • DICT_7X7_100 - 7x7 bits, 100 markers, hamming distance 18
  • DICT_7X7_250 - 7x7 bits, 250 markers, hamming distance 17
  • DICT_7X7_1000 - 7x7 bits, 1000 markers, hamming distance 14
  • DICT_ARUCO_ORIGINAL - 6x6 bits, 1024 markers (standard ArUco Library)
  • DICT_APRILTAG_16h5 - 4x4 bits, 30 markers, hamming distance 5
  • DICT_APRILTAG_25h9 - 5x5 bits, 35 markers, hamming distance 9
  • DICT_APRILTAG_36h10 - 6x6 bits, 2320 markers, hamming distance 10
  • DICT_APRILTAG_36h11 - 6x6 bits, 587 markers, hamming distance 11
  • DICT_ARUCO_MIP_36h12 - 6x6 bits, 250 markers, hamming distance 12

CharucoDetector

Detector for ChArUco boards (chessboard + ArUco markers).

Constructor

CharucoBoard
ChArUco board configuration
CharucoParameters
ChArUco detection parameters
DetectorParameters
Marker detection parameters
RefineParameters
Marker refine detection parameters

Methods

detectBoard

Detects ArUco markers and interpolates ChArUco board corners.
InputArray
Input image necessary for corner refinement
OutputArray
Interpolated chessboard corners
OutputArray
Interpolated chessboard corner identifiers
InputOutputArrayOfArrays
Vector of already detected marker corners. If empty, the function will detect markers.
InputOutputArray
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.
InputArray
Input image necessary for corner subpixel accuracy
OutputArrayOfArrays
Output list of detected diamond corners (4 corners per diamond) in clockwise order
OutputArray
IDs of the diamonds. Each diamond has 4 IDs corresponding to the ArUco markers composing it.
InputOutputArrayOfArrays
List of detected marker corners. If empty, the function will detect markers.
InputOutputArray
List of marker IDs. If empty, the function will detect markers.

Example Usage

DetectorParameters

Parameters for ArUco marker detection.

Key Parameters

int
Corner refinement method:
  • CORNER_REFINE_NONE - No refinement
  • CORNER_REFINE_SUBPIX - Subpixel corner refinement
  • CORNER_REFINE_CONTOUR - Contour-based refinement
  • CORNER_REFINE_APRILTAG - AprilTag approach
bool
Enable the new and faster ArUco 3 detection strategy (from Romero-Ramirez et al. 2018)

Utility Functions

drawDetectedMarkers

Draws detected markers in an image.

generateImageMarker

Generates a canonical marker image.

See Also