Skip to content

aruco_ArucoDetector

objdetectclassOpenCV 5.0.0
import { aruco_ArucoDetector } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

Native object: release it with using or delete(). Factories can return null; check before calling methods. Inherits Algorithm.

The main functionality of ArucoDetector class is detection of markers in an image with detectMarkers() method.

After detecting some markers in the image, you can try to find undetected markers from this dictionary with refineDetectedMarkers() method.

See: DetectorParameters, RefineParameters

Constructors and members

static new

Basic ArucoDetector constructor

new(dictionary: aruco_Dictionary, detectorParams: aruco_DetectorParameters, refineParams: aruco_RefineParameters): aruco_ArucoDetector;
4 available overloads
new(): aruco_ArucoDetector;
new(dictionary: aruco_Dictionary): aruco_ArucoDetector;
new(dictionary: aruco_Dictionary, detectorParams: aruco_DetectorParameters): aruco_ArucoDetector;
new(dictionary: aruco_Dictionary, detectorParams: aruco_DetectorParameters, refineParams: aruco_RefineParameters): aruco_ArucoDetector;
dictionary

indicates the type of markers that will be searched

detectorParams

marker detection parameters

refineParams

marker refine detection parameters

Returns

The aruco_ArucoDetector result.

static from1

Create an owned aruco_ArucoDetector instance with the supplied configuration.

The main functionality of ArucoDetector class is detection of markers in an image with detectMarkers() method.

from1(_0: aruco__DictionaryVector, _1: aruco_DetectorParameters, _2: aruco_RefineParameters): aruco_ArucoDetector | null;
3 available overloads
from1(_0: aruco__DictionaryVector): aruco_ArucoDetector | null;
from1(_0: aruco__DictionaryVector, _1: aruco_DetectorParameters): aruco_ArucoDetector | null;
from1(_0: aruco__DictionaryVector, _1: aruco_DetectorParameters, _2: aruco_RefineParameters): aruco_ArucoDetector | null;
_0

0 argument (aruco__DictionaryVector).

_1

1 argument (aruco_DetectorParameters).

_2

2 argument (aruco_RefineParameters).

Returns

The aruco_ArucoDetector | null result.

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

detectMarkers

Basic marker detection

Note: The function does not correct lens distortion or takes it into account. It's recommended to undistort input image with corresponding camera model, if camera parameters are known See: undistort, estimatePoseSingleMarkers, estimatePoseBoard

detectMarkers(image: Mat, corners: MatVector, ids: Mat, rejectedImgPoints: MatVector): void;
2 available overloads
detectMarkers(image: Mat, corners: MatVector, ids: Mat): void;
detectMarkers(image: Mat, corners: MatVector, ids: Mat, rejectedImgPoints: MatVector): void;
image

input image

corners

Output destination, filled by the native operation. vector of detected marker corners. For each marker, its four corners are provided, (e.g std::vector<std::vectorcv::Point2f > ). For N detected markers, the dimensions of this array is Nx4. The order of the corners is clockwise.

ids

Output destination, filled by the native operation. vector of identifiers of the detected markers. The identifier is of type int (e.g. std::vector<int>). For N detected markers, the size of ids is also N. The identifiers have the same order than the markers in the imgPoints array.

rejectedImgPoints

Output destination, filled by the native operation. contains the imgPoints of those squares whose inner code has not a correct codification. Useful for debugging purposes.

Performs marker detection in the input image. Only markers included in the first specified dictionary are searched. For each detected marker, it returns the 2D position of its corner in the image and its corresponding identifier. Note that this function does not perform pose estimation.

detectMarkersWithConfidence

Marker detection with confidence computation

Note: The function does not correct lens distortion or takes it into account. It's recommended to undistort input image with corresponding camera model, if camera parameters are known See: undistort, estimatePoseSingleMarkers, estimatePoseBoard

detectMarkersWithConfidence(image: Mat, corners: MatVector, ids: Mat, markersConfidence: Mat, rejectedImgPoints: MatVector): void;
2 available overloads
detectMarkersWithConfidence(image: Mat, corners: MatVector, ids: Mat, markersConfidence: Mat): void;
detectMarkersWithConfidence(image: Mat, corners: MatVector, ids: Mat, markersConfidence: Mat, rejectedImgPoints: MatVector): void;
image

input image

corners

Output destination, filled by the native operation. vector of detected marker corners. For each marker, its four corners are provided, (e.g std::vector<std::vectorcv::Point2f > ). For N detected markers, the dimensions of this array is Nx4. The order of the corners is clockwise.

ids

Output destination, filled by the native operation. vector of identifiers of the detected markers. The identifier is of type int (e.g. std::vector<int>). For N detected markers, the size of ids is also N. The identifiers have the same order than the markers in the imgPoints array.

markersConfidence

Output destination, filled by the native operation. contains the normalized confidence [0;1] of the markers' detection, defined as 1 minus the normalized uncertainty (percentage of incorrect pixel detections), with 1 describing a pixel perfect detection. The confidence values are of type float (e.g. std::vector<float>)

rejectedImgPoints

Output destination, filled by the native operation. contains the imgPoints of those squares whose inner code has not a correct codification. Useful for debugging purposes.

Performs marker detection in the input image. Only markers included in the first specified dictionary are searched. For each detected marker, it returns the 2D position of its corner in the image and its corresponding identifier. Note that this function does not perform pose estimation.

refineDetectedMarkers

Refine not detected markers based on the already detected and the board layout

Note: This function assumes that the board only contains markers from one dictionary, so only the first configured dictionary is used. It has to match the dictionary of the board to work properly.

refineDetectedMarkers(image: Mat, board: aruco_Board, detectedCorners: MatVector, detectedIds: Mat, rejectedCorners: MatVector, cameraMatrix: Mat, distCoeffs: Mat, recoveredIdxs: Mat): void;
4 available overloads
refineDetectedMarkers(image: Mat, board: aruco_Board, detectedCorners: MatVector, detectedIds: Mat, rejectedCorners: MatVector): void;
refineDetectedMarkers(image: Mat, board: aruco_Board, detectedCorners: MatVector, detectedIds: Mat, rejectedCorners: MatVector, cameraMatrix: Mat): void;
refineDetectedMarkers(image: Mat, board: aruco_Board, detectedCorners: MatVector, detectedIds: Mat, rejectedCorners: MatVector, cameraMatrix: Mat, distCoeffs: Mat): void;
refineDetectedMarkers(image: Mat, board: aruco_Board, detectedCorners: MatVector, detectedIds: Mat, rejectedCorners: MatVector, cameraMatrix: Mat, distCoeffs: Mat, recoveredIdxs: Mat): void;
image

input image

board

layout of markers in the board.

detectedCorners

Input/output value, modified by the native operation. vector of already detected marker corners.

detectedIds

Input/output value, modified by the native operation. vector of already detected marker identifiers.

rejectedCorners

Input/output value, modified by the native operation. vector of rejected candidates during the marker detection process.

cameraMatrix

optional input 3x3 floating-point camera matrix A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}

distCoeffs

optional vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]]) of 4, 5, 8 or 12 elements

recoveredIdxs

Output destination, filled by the native operation. Optional array to returns the indexes of the recovered candidates in the original rejectedCorners array.

This function tries to find markers that were not detected in the basic detecMarkers function. First, based on the current detected marker and the board layout, the function interpolates the position of the missing markers. Then it tries to find correspondence between the reprojected markers and the rejected candidates based on the minRepDistance and errorCorrectionRate parameters. If camera parameters and distortion coefficients are provided, missing markers are reprojected using projectPoint function. If not, missing marker projections are interpolated using global homography, and all the marker corners in the board must have the same Z coordinate.

detectMarkersMultiDict

Basic marker detection

Note: The function does not correct lens distortion or takes it into account. It's recommended to undistort input image with corresponding camera model, if camera parameters are known See: undistort, estimatePoseSingleMarkers, estimatePoseBoard

detectMarkersMultiDict(image: Mat, corners: MatVector, ids: Mat, rejectedImgPoints: MatVector, dictIndices: Mat): void;
3 available overloads
detectMarkersMultiDict(image: Mat, corners: MatVector, ids: Mat): void;
detectMarkersMultiDict(image: Mat, corners: MatVector, ids: Mat, rejectedImgPoints: MatVector): void;
detectMarkersMultiDict(image: Mat, corners: MatVector, ids: Mat, rejectedImgPoints: MatVector, dictIndices: Mat): void;
image

input image

corners

Output destination, filled by the native operation. vector of detected marker corners. For each marker, its four corners are provided, (e.g std::vector<std::vectorcv::Point2f > ). For N detected markers, the dimensions of this array is Nx4. The order of the corners is clockwise.

ids

Output destination, filled by the native operation. vector of identifiers of the detected markers. The identifier is of type int (e.g. std::vector<int>). For N detected markers, the size of ids is also N. The identifiers have the same order than the markers in the imgPoints array.

rejectedImgPoints

Output destination, filled by the native operation. contains the imgPoints of those squares whose inner code has not a correct codification. Useful for debugging purposes.

dictIndices

Output destination, filled by the native operation. vector of dictionary indices for each detected marker. Use getDictionaries() to get the list of corresponding dictionaries.

Performs marker detection in the input image. Only markers included in the specific dictionaries are searched. For each detected marker, it returns the 2D position of its corner in the image and its corresponding identifier. Note that this function does not perform pose estimation.

getDictionaries

Returns all dictionaries currently used for marker detection as a vector.

getDictionaries(): aruco__DictionaryVector;
Returns

A std::vector<Dictionary> containing all dictionaries used by the ArucoDetector. Release returned native handles with using or delete(), including handles nested in results.

setDictionaries

Sets the entire collection of dictionaries to be used for marker detection, replacing any existing dictionaries.

Note: Setting an empty vector of dictionaries will throw an error.

setDictionaries(dictionaries: aruco__DictionaryVector): void;
dictionaries

A std::vector<Dictionary> containing the new set of dictionaries to be used.

Configures the ArucoDetector to use the provided vector of dictionaries for marker detection. This method replaces any dictionaries that were previously set.

getDetectorParameters

Return the detector parameters configured on this aruco_ArucoDetector object.

getDetectorParameters(): aruco_DetectorParameters;
Returns

The aruco_DetectorParameters result.

setDetectorParameters

Set the detector parameters used by this aruco_ArucoDetector object.

setDetectorParameters(detectorParameters: aruco_DetectorParameters): void;
detectorParameters

detector parameters argument (aruco_DetectorParameters).

getRefineParameters

Return the refine parameters configured on this aruco_ArucoDetector object.

getRefineParameters(): aruco_RefineParameters;
Returns

The aruco_RefineParameters result.

setRefineParameters

Set the refine parameters used by this aruco_ArucoDetector object.

setRefineParameters(refineParameters: aruco_RefineParameters): void;
refineParameters

refine parameters argument (aruco_RefineParameters).

write

simplified API for language bindings

write(fs: FileStorage, name: EmbindString): void;
fs

fs argument (FileStorage).

name

name argument (EmbindString).

read

Reads algorithm parameters from a file storage

read(fn: FileNode): void;
fn

fn argument (FileNode).

getDictionary

Returns first dictionary from internal list used for marker detection.

getDictionary(): aruco_Dictionary;
Returns

The first dictionary from the configured ArucoDetector.

setDictionary

Sets and replaces the first dictionary in internal list to be used for marker detection.

setDictionary(dictionary: aruco_Dictionary): void;
dictionary

The new dictionary that will replace the first dictionary in the internal list.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.