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
imageInputArrayinput image necessary for corner refinement.
squaresXintnumber of chessboard squares in x directions.
squaresYintnumber of chessboard squares in y directions.
squareLengthfloatchessboard square side length (normally in meters).
markerLengthfloatmarker side length (same unit than squareLength).
arucoDictIdPredefinedDictionaryTypedictionary of markers indicating the type of markers.
charucoCornersPoint2f[]output list of detected charuco corners.
charucoIdsint[]ids of the charucos in charucoCorners.
markerCornersPoint2f[][]output list of detected marker corners.
markerIdsint[]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
imageInputArrayinput image necessary for corner subpixel.
markerCornersPoint2f[][]list of detected marker corners from detectMarkers function.
markerIdsIEnumerable<int>list of marker ids in markerCorners.
squareMarkerLengthRatefloatrate between square and marker length: squareMarkerLengthRate = squareLength/markerLength. The real units are not necessary.
diamondCornersPoint2f[][]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>>).
diamondIdsVec4i[]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.
cameraMatrixInputArrayOptional camera calibration matrix.
distCoeffsInputArrayOptional 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
imageInputArrayinput image
dictionaryDictionaryindicates the type of markers that will be searched
cornersPoint2f[][]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.
idsint[]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.
parametersDetectorParametersmarker detection parameters
rejectedImgPointsPoint2f[][]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
imageInputArrayinput/output image. It must have 1 or 3 channels. The number of channels is not altered.
charucoCornersPoint2f[]vector of detected charuco corners.
charucoIdsIEnumerable<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
imageInputArrayinput/output image. It must have 1 or 3 channels. The number of channels is not altered.
charucoCornersPoint2f[]vector of detected charuco corners.
charucoIdsIEnumerable<int>list of identifiers for each corner in charucoCorners.
cornerColorScalarcolor 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
imageInputArrayinput/output image. It must have 1 or 3 channels. The number of channels is not altered.
diamondCornersPoint2f[][]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.
diamondIdsIEnumerable<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
imageInputArrayinput/output image. It must have 1 or 3 channels. The number of channels is not altered.
diamondCornersPoint2f[][]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.
diamondIdsIEnumerable<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.
borderColorScalarcolor 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
imageInputArrayinput/output image. It must have 1 or 3 channels. The number of channels is not altered.
cornersPoint2f[][]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.
idsIEnumerable<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
imageInputArrayinput/output image. It must have 1 or 3 channels. The number of channels is not altered.
cornersPoint2f[][]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.
idsIEnumerable<int>vector of identifiers for markers in markersCorners. Optional, if not provided, ids are not painted.
borderColorScalarcolor 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
cornersPoint2f[][]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.
markerLengthfloatthe length of the markers' side. The returning translation vectors will be in the same unit.Normally, unit is meters.
cameraMatrixInputArrayinput 3x3 floating-point camera matrix \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
distortionCoefficientsInputArrayvector 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
rvecOutputArrayarray of output rotation vectors (@sa Rodrigues) (e.g. std::vector<cv::Vec3d>). Each element in rvecs corresponds to the specific marker in imgPoints.
tvecOutputArrayarray of output translation vectors (e.g. std::vector<cv::Vec3d>). Each element in tvecs corresponds to the specific marker in imgPoints.
objPointsOutputArrayarray 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
Returns
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
imageInputArrayinput image necessary for corner refinement.
squaresXintnumber of chessboard squares in x directions.
squaresYintnumber of chessboard squares in y directions.
squareLengthfloatchessboard square side length (normally in meters).
markerLengthfloatmarker side length (same unit than squareLength).
arucoDictIdPredefinedDictionaryTypedictionary of markers indicating the type of markers.
markerCornersPoint2f[][]list of detected marker corners.
markerIdsIEnumerable<int>ids of the corners in markerCorners.
charucoCornersPoint2f[]output list of detected charuco corners.
charucoIdsint[]ids of the charucos in charucoCorners.
ReadDictionary(string)
Reads a new dictionary from FileNode.
public static Dictionary ReadDictionary(string dictionaryFile)
Parameters
dictionaryFilestringThe 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"