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

Multi-Dictionary Constructor

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

Methods

detectMarkers

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

bytesList
Mat
Bits for all ArUco markers in dictionary (CV_8UC4 type)
markerSize
int
ArUco marker size in units (number of bits per dimension)
maxCorrectionBits
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.
onlyBits
Mat
Input matrix of bits
idx
int&
Output marker ID in the dictionary (if any)
rotation
int&
Output marker rotation (0-3)
maxCorrectionRate
double
Maximum error correction rate
Returns: true if marker is identified

generateImageMarker

Generates a canonical marker image.
id
int
Marker ID to generate
sidePixels
int
Size of the output image in pixels
img
OutputArray
Output marker image
borderBits
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

board
CharucoBoard
ChArUco board configuration
charucoParams
CharucoParameters
ChArUco detection parameters
detectorParams
DetectorParameters
Marker detection parameters
refineParams
RefineParameters
Marker refine detection parameters

Methods

detectBoard

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

Example Usage

DetectorParameters

Parameters for ArUco marker detection.

Key Parameters

cornerRefinementMethod
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
useAruco3Detection
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