Table of Contents

Class ArucoInvoke

Namespace
Emgu.CV.Aruco
Assembly
Emgu.CV.dll

Entry points for the Aruco module.

public static class ArucoInvoke
Inheritance
ArucoInvoke
Inherited Members

Methods

CalibrateCameraAruco(IInputArrayOfArrays, IInputArray, IInputArray, IBoard, Size, IInputOutputArray, IInputOutputArray, IOutputArray, IOutputArray, CalibType, MCvTermCriteria)

Calibrate a camera using aruco markers.

public static double CalibrateCameraAruco(IInputArrayOfArrays corners, IInputArray ids, IInputArray counter, IBoard board, Size imageSize, IInputOutputArray cameraMatrix, IInputOutputArray distCoeffs, IOutputArray rvecs, IOutputArray tvecs, CalibType flags, MCvTermCriteria criteria)

Parameters

corners IInputArrayOfArrays

Vector of detected marker corners in all frames. The corners should have the same format returned by detectMarkers

ids IInputArray

List of identifiers for each marker in corners

counter IInputArray

Number of markers in each frame so that corners and ids can be split

board IBoard

Marker Board layout

imageSize Size

Size of the image used only to initialize the intrinsic camera matrix.

cameraMatrix IInputOutputArray

Output 3x3 floating-point camera matrix.

distCoeffs IInputOutputArray

Output vector of distortion coefficients (k1,k2,p1,p2[,k3[,k4,k5,k6],[s1,s2,s3,s4]]) of 4, 5, 8 or 12 elements

rvecs IOutputArray

Output vector of rotation vectors (see Rodrigues ) estimated for each board view (e.g. std::vector<cv::Mat>). That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the board pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the board pattern in the k-th pattern view (k=0.. M -1).

tvecs IOutputArray

Output vector of translation vectors estimated for each pattern view.

flags CalibType

Flags Different flags for the calibration process

criteria MCvTermCriteria

Termination criteria for the iterative optimization algorithm.

Returns

double

The final re-projection error.

CalibrateCameraAruco(IInputArrayOfArrays, IInputArray, IInputArray, IBoard, Size, IInputOutputArray, IInputOutputArray, IOutputArray, IOutputArray, IOutputArray, IOutputArray, IOutputArray, CalibType, MCvTermCriteria)

Calibrate a camera using aruco markers.

public static double CalibrateCameraAruco(IInputArrayOfArrays corners, IInputArray ids, IInputArray counter, IBoard board, Size imageSize, IInputOutputArray cameraMatrix, IInputOutputArray distCoeffs, IOutputArray rvecs, IOutputArray tvecs, IOutputArray stdDeviationsIntrinsics, IOutputArray stdDeviationsExtrinsics, IOutputArray perViewErrors, CalibType flags, MCvTermCriteria criteria)

Parameters

corners IInputArrayOfArrays

Vector of detected marker corners in all frames. The corners should have the same format returned by detectMarkers

ids IInputArray

List of identifiers for each marker in corners

counter IInputArray

Number of markers in each frame so that corners and ids can be split

board IBoard

Marker Board layout

imageSize Size

Size of the image used only to initialize the intrinsic camera matrix.

cameraMatrix IInputOutputArray

Output 3x3 floating-point camera matrix.

distCoeffs IInputOutputArray

Output vector of distortion coefficients (k1,k2,p1,p2[,k3[,k4,k5,k6],[s1,s2,s3,s4]]) of 4, 5, 8 or 12 elements

rvecs IOutputArray

Output vector of rotation vectors (see Rodrigues ) estimated for each board view (e.g. std::vector<cv::Mat>). That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the board pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the board pattern in the k-th pattern view (k=0.. M -1).

tvecs IOutputArray

Output vector of translation vectors estimated for each pattern view.

stdDeviationsIntrinsics IOutputArray

Output vector of standard deviations estimated for intrinsic parameters. Order of deviations values: (fx,fy,cx,cy,k1,k2,p1,p2,k3,k4,k5,k6,s1,s2,s3,s4,τx,τy) If one of parameters is not estimated, it's deviation is equals to zero.

stdDeviationsExtrinsics IOutputArray

Output vector of standard deviations estimated for extrinsic parameters. Order of deviations values: (R1,T1,…,RM,TM) where M is number of pattern views, Ri,Ti are concatenated 1x3 vectors.

perViewErrors IOutputArray

Output vector of average re-projection errors estimated for each pattern view.

flags CalibType

Flags Different flags for the calibration process

criteria MCvTermCriteria

Termination criteria for the iterative optimization algorithm.

Returns

double

The final re-projection error.

CalibrateCameraCharuco(IInputArrayOfArrays, IInputArrayOfArrays, CharucoBoard, Size, IInputOutputArray, IInputOutputArray, IOutputArray, IOutputArray, CalibType, MCvTermCriteria)

Calibrate a camera using Charuco corners.

public static double CalibrateCameraCharuco(IInputArrayOfArrays charucoCorners, IInputArrayOfArrays charucoIds, CharucoBoard board, Size imageSize, IInputOutputArray cameraMatrix, IInputOutputArray distCoeffs, IOutputArray rvecs, IOutputArray tvecs, CalibType flags, MCvTermCriteria criteria)

Parameters

charucoCorners IInputArrayOfArrays

Vector of detected charuco corners per frame

charucoIds IInputArrayOfArrays

List of identifiers for each corner in charucoCorners per frame

board CharucoBoard

Marker Board layout

imageSize Size

Size of the image used only to initialize the intrinsic camera matrix.

cameraMatrix IInputOutputArray

Output 3x3 floating-point camera matrix.

distCoeffs IInputOutputArray

Output vector of distortion coefficients (k1,k2,p1,p2[,k3[,k4,k5,k6],[s1,s2,s3,s4]]) of 4, 5, 8 or 12 elements

rvecs IOutputArray

Output vector of rotation vectors (see Rodrigues ) estimated for each board view (e.g. std::vector<cv::Mat>). That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the board pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the board pattern in the k-th pattern view (k=0.. M -1).

tvecs IOutputArray

Output vector of translation vectors estimated for each pattern view.

flags CalibType

Flags Different flags for the calibration process

criteria MCvTermCriteria

Termination criteria for the iterative optimization algorithm.

Returns

double

The final re-projection error.

CalibrateCameraCharuco(IInputArrayOfArrays, IInputArrayOfArrays, CharucoBoard, Size, IInputOutputArray, IInputOutputArray, IOutputArray, IOutputArray, IOutputArray, IOutputArray, IOutputArray, CalibType, MCvTermCriteria)

Calibrate a camera using Charuco corners.

public static double CalibrateCameraCharuco(IInputArrayOfArrays charucoCorners, IInputArrayOfArrays charucoIds, CharucoBoard board, Size imageSize, IInputOutputArray cameraMatrix, IInputOutputArray distCoeffs, IOutputArray rvecs, IOutputArray tvecs, IOutputArray stdDeviationsIntrinsics, IOutputArray stdDeviationsExtrinsics, IOutputArray perViewErrors, CalibType flags, MCvTermCriteria criteria)

Parameters

charucoCorners IInputArrayOfArrays

Vector of detected charuco corners per frame

charucoIds IInputArrayOfArrays

List of identifiers for each corner in charucoCorners per frame

board CharucoBoard

Marker Board layout

imageSize Size

Size of the image used only to initialize the intrinsic camera matrix.

cameraMatrix IInputOutputArray

Output 3x3 floating-point camera matrix.

distCoeffs IInputOutputArray

Output vector of distortion coefficients (k1,k2,p1,p2[,k3[,k4,k5,k6],[s1,s2,s3,s4]]) of 4, 5, 8 or 12 elements

rvecs IOutputArray

Output vector of rotation vectors (see Rodrigues ) estimated for each board view (e.g. std::vector<cv::Mat>). That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the board pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the board pattern in the k-th pattern view (k=0.. M -1).

tvecs IOutputArray

Output vector of translation vectors estimated for each pattern view.

stdDeviationsIntrinsics IOutputArray

Output vector of standard deviations estimated for intrinsic parameters. Order of deviations values: (fx,fy,cx,cy,k1,k2,p1,p2,k3,k4,k5,k6,s1,s2,s3,s4,τx,τy) If one of parameters is not estimated, it's deviation is equals to zero.

stdDeviationsExtrinsics IOutputArray

Output vector of standard deviations estimated for extrinsic parameters. Order of deviations values: (R1,T1,…,RM,TM) where M is number of pattern views, Ri,Ti are concatenated 1x3 vectors.

perViewErrors IOutputArray

Output vector of average re-projection errors estimated for each pattern view.

flags CalibType

Flags Different flags for the calibration process

criteria MCvTermCriteria

Termination criteria for the iterative optimization algorithm.

Returns

double

The final re-projection error.

DetectCharucoDiamond(IInputArray, IInputArray, IInputArray, float, IOutputArray, IOutputArray, IInputArray, IInputArray)

Detect ChArUco Diamond markers

public static void DetectCharucoDiamond(IInputArray image, IInputArray markerCorners, IInputArray markerIds, float squareMarkerLengthRate, IOutputArray diamondCorners, IOutputArray diamondIds, IInputArray cameraMatrix = null, IInputArray distCoeffs = null)

Parameters

image IInputArray

input image necessary for corner subpixel.

markerCorners IInputArray

list of detected marker corners from detectMarkers function.

markerIds IInputArray

list of marker ids in markerCorners.

squareMarkerLengthRate float

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

diamondCorners IOutputArray

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 VectorOfVectorOfPointF ).

diamondIds IOutputArray

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 IInputArray

Optional camera calibration matrix.

distCoeffs IInputArray

Optional camera distortion coefficients.

DetectMarkers(IInputArray, Dictionary, IOutputArrayOfArrays, IOutputArray, DetectorParameters, IOutputArrayOfArrays)

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.

public static void DetectMarkers(IInputArray image, Dictionary dict, IOutputArrayOfArrays corners, IOutputArray ids, DetectorParameters parameters, IOutputArrayOfArrays rejectedImgPoints = null)

Parameters

image IInputArray

input image

dict Dictionary

indicates the type of markers that will be searched

corners IOutputArrayOfArrays

Vector of detected marker corners. For each marker, its four corners are provided, (e.g VectorOfVectorOfPointF ). For N detected markers, the dimensions of this array is Nx4. The order of the corners is clockwise.

ids IOutputArray

vector of identifiers of the detected markers. The identifier is of type int (e.g. VectorOfInt). 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 IOutputArrayOfArrays

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

DrawCharucoDiamond(Dictionary, int[], int, int, IOutputArray, int, int)

Draw a ChArUco Diamond marker

public static void DrawCharucoDiamond(Dictionary dictionary, int[] ids, int squareLength, int markerLength, IOutputArray img, int marginSize = 0, int borderBits = 1)

Parameters

dictionary Dictionary

dictionary of markers indicating the type of markers.

ids int[]

list of 4 ids for each ArUco marker in the ChArUco marker.

squareLength int

size of the chessboard squares in pixels.

markerLength int

size of the markers in pixels.

img IOutputArray

output image with the marker. The size of this image will be 3squareLength + 2marginSize.

marginSize int

minimum margins (in pixels) of the marker in the output image

borderBits int

width of the marker borders.

DrawDetectedCornersCharuco(IInputOutputArray, IInputArray, IInputArray, MCvScalar)

Draws a set of Charuco corners

public static void DrawDetectedCornersCharuco(IInputOutputArray image, IInputArray charucoCorners, IInputArray charucoIds, MCvScalar cornerColor)

Parameters

image IInputOutputArray

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

charucoCorners IInputArray

vector of detected charuco corners

charucoIds IInputArray

list of identifiers for each corner in charucoCorners

cornerColor MCvScalar

color of the square surrounding each corner

DrawDetectedDiamonds(IInputOutputArray, IInputArrayOfArrays, IInputArray, MCvScalar)

Draw a set of detected ChArUco Diamond markers

public static void DrawDetectedDiamonds(IInputOutputArray image, IInputArrayOfArrays diamondCorners, IInputArray diamondIds, MCvScalar borderColor)

Parameters

image IInputOutputArray

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

diamondCorners IInputArrayOfArrays

positions of diamond corners in the same format returned by detectCharucoDiamond(). (e.g VectorOfVectorOfPointF ). For N detected markers, the dimensions of this array should be Nx4. The order of the corners should be clockwise.

diamondIds IInputArray

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

borderColor MCvScalar

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

DrawDetectedMarkers(IInputOutputArray, IInputArray, IInputArray, MCvScalar)

Draw detected markers in image.

public static void DrawDetectedMarkers(IInputOutputArray image, IInputArray corners, IInputArray ids, MCvScalar borderColor)

Parameters

image IInputOutputArray

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

corners IInputArray

Positions of marker corners on input image. (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.

ids IInputArray

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

borderColor MCvScalar

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

DrawPlanarBoard(IBoard, Size, IOutputArray, int, int)

Draw a planar board.

public static void DrawPlanarBoard(IBoard board, Size outSize, IOutputArray img, int marginSize = 0, int borderBits = 1)

Parameters

board IBoard

Layout of the board that will be drawn. The board should be planar, z coordinate is ignored

outSize Size

Size of the output image in pixels.

img IOutputArray

Output image with the board. The size of this image will be outSize and the board will be on the center, keeping the board proportions.

marginSize int

Minimum margins (in pixels) of the board in the output image

borderBits int

Width of the marker borders.

EstimatePoseBoard(IInputArrayOfArrays, IInputArray, IBoard, IInputArray, IInputArray, IInputOutputArray, IInputOutputArray, bool)

Pose estimation for a board of markers.

public static int EstimatePoseBoard(IInputArrayOfArrays corners, IInputArray ids, IBoard board, IInputArray cameraMatrix, IInputArray distCoeffs, IInputOutputArray rvec, IInputOutputArray tvec, bool useExtrinsicGuess = false)

Parameters

corners IInputArrayOfArrays

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.

ids IInputArray

List of identifiers for each marker in corners

board IBoard

Layout of markers in the board. The layout is composed by the marker identifiers and the positions of each marker corner in the board reference system.

cameraMatrix IInputArray

Input 3x3 floating-point camera matrix

distCoeffs IInputArray

Vector of distortion coefficients (k1,k2,p1,p2[,k3[,k4,k5,k6],[s1,s2,s3,s4]]) of 4, 5, 8 or 12 elements

rvec IInputOutputArray

Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board (see cv::Rodrigues). Used as initial guess if not empty.

tvec IInputOutputArray

Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.

useExtrinsicGuess bool

Defines whether initial guess for rvec and tvec will be used or not. Used as initial guess if not empty.

Returns

int

The function returns the number of markers from the input employed for the board pose estimation. Note that returning a 0 means the pose has not been estimated.

EstimatePoseCharucoBoard(IInputArray, IInputArray, CharucoBoard, IInputArray, IInputArray, IInputOutputArray, IInputOutputArray, bool)

Pose estimation for a ChArUco board given some of their corners

public static bool EstimatePoseCharucoBoard(IInputArray charucoCorners, IInputArray charucoIds, CharucoBoard board, IInputArray cameraMatrix, IInputArray distCoeffs, IInputOutputArray rvec, IInputOutputArray tvec, bool useExtrinsicGuess = false)

Parameters

charucoCorners IInputArray

vector of detected charuco corners

charucoIds IInputArray

list of identifiers for each corner in charucoCorners

board CharucoBoard

layout of ChArUco board.

cameraMatrix IInputArray

input 3x3 floating-point camera matrix

distCoeffs IInputArray

vector of distortion coefficients, 4, 5, 8 or 12 elements

rvec IInputOutputArray

Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board

tvec IInputOutputArray

Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.

useExtrinsicGuess bool

defines whether initial guess for rvec and tvec will be used or not.

Returns

bool

If pose estimation is valid, returns true, else returns false.

EstimatePoseSingleMarkers(IInputArrayOfArrays, float, IInputArray, IInputArray, IOutputArrayOfArrays, IOutputArrayOfArrays)

This function receives the detected markers and returns their pose estimation respect to the camera individually. So for each marker, one rotation and translation vector is returned. The returned transformation is the one that transforms points from each marker coordinate system to the camera coordinate system. The marker corrdinate system is centered on the middle of the marker, with the Z axis perpendicular to the marker plane. The coordinates of the four corners of the marker in its own coordinate system are: (-markerLength/2, markerLength/2, 0), (markerLength/2, markerLength/2, 0), (markerLength/2, -markerLength/2, 0), (-markerLength/2, -markerLength/2, 0)

public static void EstimatePoseSingleMarkers(IInputArrayOfArrays corners, float markerLength, IInputArray cameraMatrix, IInputArray distCoeffs, IOutputArrayOfArrays rvecs, IOutputArrayOfArrays tvecs)

Parameters

corners IInputArrayOfArrays

vector of already detected markers corners. For each marker, its four corners are provided, (e.g VectorOfVectorOfPointF ). 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 IInputArray

input 3x3 floating-point camera matrix

distCoeffs IInputArray

vector of distortion coefficients (k1,k2,p1,p2[,k3[,k4,k5,k6],[s1,s2,s3,s4]]) of 4, 5, 8 or 12 elements

rvecs IOutputArrayOfArrays

array of output rotation vectors. Each element in rvecs corresponds to the specific marker in imgPoints.

tvecs IOutputArrayOfArrays

array of output translation vectors (e.g. VectorOfPoint3D32F ). Each element in tvecs corresponds to the specific marker in imgPoints.

GenerateImage(IBoard, Size, IOutputArray, int, int)

Draw a planar board.

public static void GenerateImage(this IBoard board, Size outSize, IOutputArray img, int marginSize = 0, int borderBits = 1)

Parameters

board IBoard

Layout of the board that will be drawn. The board should be planar, z coordinate is ignored

outSize Size

Size of the output image in pixels.

img IOutputArray

Output image with the board. The size of this image will be outSize and the board will be on the center, keeping the board proportions.

marginSize int

Minimum margins (in pixels) of the board in the output image

borderBits int

Width of the marker borders.

GetBoardObjectAndImagePoints(IBoard, IInputArray, IInputArray, IOutputArray, IOutputArray)

Given a board configuration and a set of detected markers, returns the corresponding image points and object points to call solvePnP.

public static void GetBoardObjectAndImagePoints(IBoard board, IInputArray detectedCorners, IInputArray detectedIds, IOutputArray objPoints, IOutputArray imgPoints)

Parameters

board IBoard

Marker board layout.

detectedCorners IInputArray

List of detected marker corners of the board.

detectedIds IInputArray

List of identifiers for each marker.

objPoints IOutputArray

Vector of vectors of board marker points in the board coordinate space.

imgPoints IOutputArray

Vector of vectors of the projections of board marker corner points.

InterpolateCornersCharuco(IInputArrayOfArrays, IInputArray, IInputArray, CharucoBoard, IOutputArray, IOutputArray, IInputArray, IInputArray, int)

Interpolate position of ChArUco board corners

public static int InterpolateCornersCharuco(IInputArrayOfArrays markerCorners, IInputArray markerIds, IInputArray image, CharucoBoard board, IOutputArray charucoCorners, IOutputArray charucoIds, IInputArray cameraMatrix = null, IInputArray distCoeffs = null, int minMarkers = 2)

Parameters

markerCorners IInputArrayOfArrays

vector of already detected markers corners. For each marker, its four corners are provided, (e.g VectorOfVectorOfPointF ). For N detected markers, the dimensions of this array should be Nx4.The order of the corners should be clockwise.

markerIds IInputArray

list of identifiers for each marker in corners

image IInputArray

input image necesary for corner refinement. Note that markers are not detected and should be sent in corners and ids parameters.

board CharucoBoard

layout of ChArUco board.

charucoCorners IOutputArray

interpolated chessboard corners

charucoIds IOutputArray

interpolated chessboard corners identifiers

cameraMatrix IInputArray

optional 3x3 floating-point camera matrix

distCoeffs IInputArray

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

minMarkers int

number of adjacent markers that must be detected to return a charuco corner

Returns

int

The number of interpolated corners.

RefineDetectedMarkers(IInputArray, IBoard, IInputOutputArray, IInputOutputArray, IInputOutputArray, IInputArray, IInputArray, float, float, bool, IOutputArray, DetectorParameters)

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

public static void RefineDetectedMarkers(IInputArray image, IBoard board, IInputOutputArray detectedCorners, IInputOutputArray detectedIds, IInputOutputArray rejectedCorners, IInputArray cameraMatrix, IInputArray distCoeffs, float minRepDistance, float errorCorrectionRate, bool checkAllOrders, IOutputArray recoveredIdxs, DetectorParameters parameters)

Parameters

image IInputArray

Input image

board IBoard

Layout of markers in the board.

detectedCorners IInputOutputArray

Vector of already detected marker corners.

detectedIds IInputOutputArray

Vector of already detected marker identifiers.

rejectedCorners IInputOutputArray

Vector of rejected candidates during the marker detection process

cameraMatrix IInputArray

Optional input 3x3 floating-point camera matrix

distCoeffs IInputArray

Optional vector of distortion coefficients (k1,k2,p1,p2[,k3[,k4,k5,k6],[s1,s2,s3,s4]]) of 4, 5, 8 or 12 elements

minRepDistance float

Minimum distance between the corners of the rejected candidate and the reprojected marker in order to consider it as a correspondence. (default 10)

errorCorrectionRate float

Rate of allowed erroneous bits respect to the error correction capability of the used dictionary. -1 ignores the error correction step. (default 3)

checkAllOrders bool

Consider the four posible corner orders in the rejectedCorners array. If it set to false, only the provided corner order is considered (default true).

recoveredIdxs IOutputArray

Optional array to returns the indexes of the recovered candidates in the original rejectedCorners array.

parameters DetectorParameters

marker detection parameters