Table of Contents

Class CvAruco

Namespace
OpenCvSharp.Aruco
Assembly
OpenCvSharp.dll

aruco module

public static class CvAruco
Inheritance
CvAruco
Inherited Members

Methods

DetectCharucoBoard(InputArray, int, int, float, float, PredefinedDictionaryType, out Point2f[], out int[], out Point2f[][], out int[])

Detect ChArUco Board.

public static void DetectCharucoBoard(InputArray image, int squaresX, int squaresY, float squareLength, float markerLength, PredefinedDictionaryType arucoDictId, out Point2f[] charucoCorners, out int[] charucoIds, out Point2f[][] markerCorners, out int[] markerIds)

Parameters

image InputArray

input image necessary for corner refinement.

squaresX int

number of chessboard squares in x directions.

squaresY int

number of chessboard squares in y directions.

squareLength float

chessboard square side length (normally in meters).

markerLength float

marker side length (same unit than squareLength).

arucoDictId PredefinedDictionaryType

dictionary of markers indicating the type of markers.

charucoCorners Point2f[]

output list of detected charuco corners.

charucoIds int[]

ids of the charucos in charucoCorners.

markerCorners Point2f[][]

output list of detected marker corners.

markerIds int[]

ids of the corners in markerCorners.

DetectCharucoDiamond(InputArray, Point2f[][], IEnumerable<int>, float, out Point2f[][], out Vec4i[], InputArray?, InputArray?)

Detect ChArUco Diamond markers.

public static void DetectCharucoDiamond(InputArray image, Point2f[][] markerCorners, IEnumerable<int> markerIds, float squareMarkerLengthRate, out Point2f[][] diamondCorners, out Vec4i[] diamondIds, InputArray? cameraMatrix = null, InputArray? distCoeffs = null)

Parameters

image InputArray

input image necessary for corner subpixel.

markerCorners Point2f[][]

list of detected marker corners from detectMarkers function.

markerIds IEnumerable<int>

list of marker ids in markerCorners.

squareMarkerLengthRate float

rate between square and marker length: squareMarkerLengthRate = squareLength/markerLength. The real units are not necessary.

diamondCorners Point2f[][]

output list of detected diamond corners (4 corners per diamond). The order is the same than in marker corners: top left, top right, bottom right and bottom left. Similar format than the corners returned by detectMarkers (e.g std::vector<std::vector<cv::Point2f>>).

diamondIds Vec4i[]

ids of the diamonds in diamondCorners. The id of each diamond is in fact of type Vec4i, so each diamond has 4 ids, which are the ids of the aruco markers composing the diamond.

cameraMatrix InputArray

Optional camera calibration matrix.

distCoeffs InputArray

Optional camera distortion coefficients.

DetectMarkers(InputArray, Dictionary, out Point2f[][], out int[], DetectorParameters, out Point2f[][])

Basic marker detection

public static void DetectMarkers(InputArray image, Dictionary dictionary, out Point2f[][] corners, out int[] ids, DetectorParameters parameters, out Point2f[][] rejectedImgPoints)

Parameters

image InputArray

input image

dictionary Dictionary

indicates the type of markers that will be searched

corners Point2f[][]

vector of detected marker corners. For each marker, its four corners are provided. For N detected markers, the dimensions of this array is Nx4.The order of the corners is clockwise.

ids int[]

vector of identifiers of the detected markers. The identifier is of type 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.

parameters DetectorParameters

marker detection parameters

rejectedImgPoints Point2f[][]

contains the imgPoints of those squares whose inner code has not a correct codification.Useful for debugging purposes.

DrawDetectedCornersCharuco(InputArray, Point2f[], IEnumerable<int>?)

Draw a set of detected ChArUco Diamond markers.

public static void DrawDetectedCornersCharuco(InputArray image, Point2f[] charucoCorners, IEnumerable<int>? charucoIds = null)

Parameters

image InputArray

input/output image. It must have 1 or 3 channels. The number of channels is not altered.

charucoCorners Point2f[]

vector of detected charuco corners.

charucoIds IEnumerable<int>

list of identifiers for each corner in charucoCorners.

DrawDetectedCornersCharuco(InputArray, Point2f[], IEnumerable<int>?, Scalar)

Draw a set of detected ChArUco Diamond markers.

public static void DrawDetectedCornersCharuco(InputArray image, Point2f[] charucoCorners, IEnumerable<int>? charucoIds, Scalar cornerColor)

Parameters

image InputArray

input/output image. It must have 1 or 3 channels. The number of channels is not altered.

charucoCorners Point2f[]

vector of detected charuco corners.

charucoIds IEnumerable<int>

list of identifiers for each corner in charucoCorners.

cornerColor Scalar

color of the square surrounding each corner.

DrawDetectedDiamonds(InputArray, Point2f[][], IEnumerable<Vec4i>?)

Draw a set of detected ChArUco Diamond markers.

public static void DrawDetectedDiamonds(InputArray image, Point2f[][] diamondCorners, IEnumerable<Vec4i>? diamondIds = null)

Parameters

image InputArray

input/output image. It must have 1 or 3 channels. The number of channels is not altered.

diamondCorners Point2f[][]

positions of diamond corners in the same format returned by detectCharucoDiamond(). (e.g std::vector<std::vector<cv::Point2f>>). For N detected markers, the dimensions of this array should be Nx4. The order of the corners should be clockwise.

diamondIds IEnumerable<Vec4i>

vector of identifiers for diamonds in diamondCorners, in the same format returned by detectCharucoDiamond() (e.g. std::vector<Vec4i>). Optional, if not provided, ids are not painted.

DrawDetectedDiamonds(InputArray, Point2f[][], IEnumerable<Vec4i>?, Scalar)

Draw a set of detected ChArUco Diamond markers.

public static void DrawDetectedDiamonds(InputArray image, Point2f[][] diamondCorners, IEnumerable<Vec4i>? diamondIds, Scalar borderColor)

Parameters

image InputArray

input/output image. It must have 1 or 3 channels. The number of channels is not altered.

diamondCorners Point2f[][]

positions of diamond corners in the same format returned by detectCharucoDiamond(). (e.g std::vector<std::vector<cv::Point2f>>). For N detected markers, the dimensions of this array should be Nx4. The order of the corners should be clockwise.

diamondIds IEnumerable<Vec4i>

vector of identifiers for diamonds in diamondCorners, in the same format returned by detectCharucoDiamond() (e.g. std::vector<Vec4i>). Optional, if not provided, ids are not painted.

borderColor Scalar

color of marker borders. Rest of colors (text color and first corner color) are calculated based on this one.

DrawDetectedMarkers(InputArray, Point2f[][], IEnumerable<int>)

Draw detected markers in image

public static void DrawDetectedMarkers(InputArray image, Point2f[][] corners, IEnumerable<int> ids)

Parameters

image InputArray

input/output image. It must have 1 or 3 channels. The number of channels is not altered.

corners Point2f[][]

positions of marker corners on input image. For N detected markers, the dimensions of this array should be Nx4.The order of the corners should be clockwise.

ids IEnumerable<int>

vector of identifiers for markers in markersCorners. Optional, if not provided, ids are not painted.

DrawDetectedMarkers(InputArray, Point2f[][], IEnumerable<int>?, Scalar)

Draw detected markers in image

public static void DrawDetectedMarkers(InputArray image, Point2f[][] corners, IEnumerable<int>? ids, Scalar borderColor)

Parameters

image InputArray

input/output image. It must have 1 or 3 channels. The number of channels is not altered.

corners Point2f[][]

positions of marker corners on input image. For N detected markers, the dimensions of this array should be Nx4.The order of the corners should be clockwise.

ids IEnumerable<int>

vector of identifiers for markers in markersCorners. Optional, if not provided, ids are not painted.

borderColor Scalar

color of marker borders. Rest of colors (text color and first corner color) are calculated based on this one to improve visualization.

EstimatePoseSingleMarkers(Point2f[][], float, InputArray, InputArray, OutputArray, OutputArray, OutputArray?)

Pose estimation for single markers

public static void EstimatePoseSingleMarkers(Point2f[][] corners, float markerLength, InputArray cameraMatrix, InputArray distortionCoefficients, OutputArray rvec, OutputArray tvec, OutputArray? objPoints = null)

Parameters

corners Point2f[][]

corners vector of already detected markers 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 should be Nx4. The order of the corners should be clockwise.

markerLength float

the length of the markers' side. The returning translation vectors will be in the same unit.Normally, unit is meters.

cameraMatrix InputArray

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

distortionCoefficients InputArray

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

rvec OutputArray

array of output rotation vectors (@sa Rodrigues) (e.g. std::vector<cv::Vec3d>). Each element in rvecs corresponds to the specific marker in imgPoints.

tvec OutputArray

array of output translation vectors (e.g. std::vector<cv::Vec3d>). Each element in tvecs corresponds to the specific marker in imgPoints.

objPoints OutputArray

array of object points of all the marker corners

GetPredefinedDictionary(PredefinedDictionaryType)

Returns one of the predefined dictionaries defined in PREDEFINED_DICTIONARY_NAME

public static Dictionary GetPredefinedDictionary(PredefinedDictionaryType name)

Parameters

name PredefinedDictionaryType

Returns

Dictionary

InterpolateCornersCharuco(InputArray, int, int, float, float, PredefinedDictionaryType, Point2f[][], IEnumerable<int>, out Point2f[], out int[])

public static void InterpolateCornersCharuco(InputArray image, int squaresX, int squaresY, float squareLength, float markerLength, PredefinedDictionaryType arucoDictId, Point2f[][] markerCorners, IEnumerable<int> markerIds, out Point2f[] charucoCorners, out int[] charucoIds)

Parameters

image InputArray

input image necessary for corner refinement.

squaresX int

number of chessboard squares in x directions.

squaresY int

number of chessboard squares in y directions.

squareLength float

chessboard square side length (normally in meters).

markerLength float

marker side length (same unit than squareLength).

arucoDictId PredefinedDictionaryType

dictionary of markers indicating the type of markers.

markerCorners Point2f[][]

list of detected marker corners.

markerIds IEnumerable<int>

ids of the corners in markerCorners.

charucoCorners Point2f[]

output list of detected charuco corners.

charucoIds int[]

ids of the charucos in charucoCorners.

ReadDictionary(string)

Reads a new dictionary from FileNode.

public static Dictionary ReadDictionary(string dictionaryFile)

Parameters

dictionaryFile string

The path of the dictionary file

Returns

Dictionary

Instance of a Dictionary

Remarks

Dictionary format is YAML see sample below

nmarkers: 35
markersize: 6
maxCorrectionBits: 5
marker_0: "101011111011111001001001101100000000"
...
marker_34: "011111010000111011111110110101100101"