OpenCV  4.7.0
Open Source Computer Vision
Public Member Functions | Protected Attributes | List of all members

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

#include <opencv2/objdetect/aruco_detector.hpp>

Inheritance diagram for cv::aruco::ArucoDetector:
cv::Algorithm

Public Member Functions

 ArucoDetector (const Dictionary &dictionary=getPredefinedDictionary(cv::aruco::DICT_4X4_50), const DetectorParameters &detectorParams=DetectorParameters(), const RefineParameters &refineParams=RefineParameters())
 Basic ArucoDetector constructor. More...
 
void detectMarkers (InputArray image, OutputArrayOfArrays corners, OutputArray ids, OutputArrayOfArrays rejectedImgPoints=noArray()) const
 Basic marker detection. More...
 
const DetectorParametersgetDetectorParameters () const
 
const DictionarygetDictionary () const
 
const RefineParametersgetRefineParameters () const
 
virtual void read (const FileNode &fn) override
 Reads algorithm parameters from a file storage. More...
 
void refineDetectedMarkers (InputArray image, const Board &board, InputOutputArrayOfArrays detectedCorners, InputOutputArray detectedIds, InputOutputArrayOfArrays rejectedCorners, InputArray cameraMatrix=noArray(), InputArray distCoeffs=noArray(), OutputArray recoveredIdxs=noArray()) const
 Refind not detected markers based on the already detected and the board layout. More...
 
void setDetectorParameters (const DetectorParameters &detectorParameters)
 
void setDictionary (const Dictionary &dictionary)
 
void setRefineParameters (const RefineParameters &refineParameters)
 
virtual void write (FileStorage &fs) const override
 Stores algorithm parameters in a file storage. More...
 
void write (FileStorage &fs, const String &name)
 simplified API for language bindings More...
 
- Public Member Functions inherited from cv::Algorithm
 Algorithm ()
 
virtual ~Algorithm ()
 
virtual void clear ()
 Clears the algorithm state. More...
 
virtual bool empty () const
 Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read. More...
 
virtual String getDefaultName () const
 
virtual void save (const String &filename) const
 
void write (FileStorage &fs, const String &name) const
 
void write (const Ptr< FileStorage > &fs, const String &name=String()) const
 

Protected Attributes

Ptr< ArucoDetectorImpl > arucoDetectorImpl
 

Additional Inherited Members

- Static Public Member Functions inherited from cv::Algorithm
template<typename _Tp >
static Ptr< _Tp > load (const String &filename, const String &objname=String())
 Loads algorithm from the file. More...
 
template<typename _Tp >
static Ptr< _Tp > loadFromString (const String &strModel, const String &objname=String())
 Loads algorithm from a String. More...
 
template<typename _Tp >
static Ptr< _Tp > read (const FileNode &fn)
 Reads algorithm from the file node. More...
 
- Protected Member Functions inherited from cv::Algorithm
void writeFormat (FileStorage &fs) const
 

Detailed Description

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 also
DetectorParameters, RefineParameters

Constructor & Destructor Documentation

◆ ArucoDetector()

cv::aruco::ArucoDetector::ArucoDetector ( const Dictionary dictionary = getPredefinedDictionary(cv::aruco::DICT_4X4_50),
const DetectorParameters detectorParams = DetectorParameters(),
const RefineParameters refineParams = RefineParameters() 
)

Basic ArucoDetector constructor.

Parameters
dictionaryindicates the type of markers that will be searched
detectorParamsmarker detection parameters
refineParamsmarker refine detection parameters

Member Function Documentation

◆ detectMarkers()

void cv::aruco::ArucoDetector::detectMarkers ( InputArray  image,
OutputArrayOfArrays  corners,
OutputArray  ids,
OutputArrayOfArrays  rejectedImgPoints = noArray() 
) const
Python:
cv.aruco.ArucoDetector.detectMarkers(image[, corners[, ids[, rejectedImgPoints]]]) -> corners, ids, rejectedImgPoints

Basic marker detection.

Parameters
imageinput image
cornersvector of detected marker corners. For each marker, its four corners are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the dimensions of this array is Nx4. The order of the corners is clockwise.
idsvector 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.
rejectedImgPointscontains 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 specific 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.

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

◆ getDetectorParameters()

const DetectorParameters& cv::aruco::ArucoDetector::getDetectorParameters ( ) const
Python:
cv.aruco.ArucoDetector.getDetectorParameters() -> retval

◆ getDictionary()

const Dictionary& cv::aruco::ArucoDetector::getDictionary ( ) const
Python:
cv.aruco.ArucoDetector.getDictionary() -> retval

◆ getRefineParameters()

const RefineParameters& cv::aruco::ArucoDetector::getRefineParameters ( ) const
Python:
cv.aruco.ArucoDetector.getRefineParameters() -> retval

◆ read()

virtual void cv::aruco::ArucoDetector::read ( const FileNode fn)
overridevirtual
Python:
cv.aruco.ArucoDetector.read(fn) -> None

Reads algorithm parameters from a file storage.

Reimplemented from cv::Algorithm.

◆ refineDetectedMarkers()

void cv::aruco::ArucoDetector::refineDetectedMarkers ( InputArray  image,
const Board board,
InputOutputArrayOfArrays  detectedCorners,
InputOutputArray  detectedIds,
InputOutputArrayOfArrays  rejectedCorners,
InputArray  cameraMatrix = noArray(),
InputArray  distCoeffs = noArray(),
OutputArray  recoveredIdxs = noArray() 
) const
Python:
cv.aruco.ArucoDetector.refineDetectedMarkers(image, board, detectedCorners, detectedIds, rejectedCorners[, cameraMatrix[, distCoeffs[, recoveredIdxs]]]) -> detectedCorners, detectedIds, rejectedCorners, recoveredIdxs

Refind not detected markers based on the already detected and the board layout.

Parameters
imageinput image
boardlayout of markers in the board.
detectedCornersvector of already detected marker corners.
detectedIdsvector of already detected marker identifiers.
rejectedCornersvector of rejected candidates during the marker detection process.
cameraMatrixoptional input 3x3 floating-point camera matrix \(A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\)
distCoeffsoptional 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
recoveredIdxsOptional 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.

◆ setDetectorParameters()

void cv::aruco::ArucoDetector::setDetectorParameters ( const DetectorParameters detectorParameters)
Python:
cv.aruco.ArucoDetector.setDetectorParameters(detectorParameters) -> None

◆ setDictionary()

void cv::aruco::ArucoDetector::setDictionary ( const Dictionary dictionary)
Python:
cv.aruco.ArucoDetector.setDictionary(dictionary) -> None

◆ setRefineParameters()

void cv::aruco::ArucoDetector::setRefineParameters ( const RefineParameters refineParameters)
Python:
cv.aruco.ArucoDetector.setRefineParameters(refineParameters) -> None

◆ write() [1/2]

virtual void cv::aruco::ArucoDetector::write ( FileStorage fs) const
overridevirtual
Python:
cv.aruco.ArucoDetector.write(fs, name) -> None

Stores algorithm parameters in a file storage.

Reimplemented from cv::Algorithm.

◆ write() [2/2]

void cv::aruco::ArucoDetector::write ( FileStorage fs,
const String name 
)
inline
Python:
cv.aruco.ArucoDetector.write(fs, name) -> None

simplified API for language bindings

Member Data Documentation

◆ arucoDetectorImpl

Ptr<ArucoDetectorImpl> cv::aruco::ArucoDetector::arucoDetectorImpl
protected

The documentation for this class was generated from the following file: