Table of Contents

Class CharucoBoard

Namespace
OpenCvSharp.Aruco
Assembly
OpenCvSharp.dll

ChArUco board — a planar chessboard where the markers are placed inside the white squares.

public class CharucoBoard : Board, IDisposable
Inheritance
CharucoBoard
Implements
Inherited Members

Constructors

CharucoBoard(int, int, float, float, Dictionary, IEnumerable<int>?)

Creates a CharucoBoard.

public CharucoBoard(int squaresX, int squaresY, float squareLength, float markerLength, Dictionary dictionary, IEnumerable<int>? ids = null)

Parameters

squaresX int

number of chessboard squares in x direction

squaresY int

number of chessboard squares in y direction

squareLength float

chessboard square side length (normally in meters)

markerLength float

marker side length (same unit as squareLength)

dictionary Dictionary

dictionary of markers

ids IEnumerable<int>

array of id used markers. The first markers in the dictionary are used to fill the white chessboard squares if null.

Properties

ChessboardSize

Gets the number of chessboard squares in x and y directions.

public Size ChessboardSize { get; }

Property Value

Size

LegacyPattern

Gets or sets the legacy pattern mode for compatibility with patterns created before OpenCV 4.6.

public bool LegacyPattern { get; set; }

Property Value

bool

MarkerLength

Gets the marker side length.

public float MarkerLength { get; }

Property Value

float

SquareLength

Gets the chessboard square side length.

public float SquareLength { get; }

Property Value

float

Methods

CheckCharucoCornersCollinear(InputArray)

Check whether the ChArUco markers are collinear.

public bool CheckCharucoCornersCollinear(InputArray charucoIds)

Parameters

charucoIds InputArray

Returns

bool

GenerateImage(Size, OutputArray, int, int)

Generate the board image.

public void GenerateImage(Size outSize, OutputArray img, int marginSize = 0, int borderBits = 1)

Parameters

outSize Size
img OutputArray
marginSize int
borderBits int

Remarks

Hides GenerateImage(Size, OutputArray, int, int) to call the CharucoBoard-specific native override directly (cv::aruco::CharucoBoardImpl overrides generateImage, so the inherited Board method would in fact dispatch to the same implementation via its virtual PIMPL — this override is kept for clarity/directness).

GetChessboardCorners()

Get CharucoBoard::chessboardCorners

public Point3f[] GetChessboardCorners()

Returns

Point3f[]

GetNearestMarkerCorners()

Get CharucoBoard::nearestMarkerCorners, for each charuco corner, nearest marker corner id of each marker

public int[][] GetNearestMarkerCorners()

Returns

int[][]

GetNearestMarkerIdx()

Get CharucoBoard::nearestMarkerIdx, for each charuco corner, nearest marker index in ids array

public int[][] GetNearestMarkerIdx()

Returns

int[][]

MatchImagePoints(Point2f[], InputArray, OutputArray, OutputArray)

Given a board configuration and a set of detected ChArUco corners, returns the corresponding image points and object points, can be used in solvePnP(). Overload of MatchImagePoints(Point2f[][], InputArray, OutputArray, OutputArray) for CharucoBoard, whose detected corners are a flat list of ChArUco corners rather than a jagged per-marker array.

public void MatchImagePoints(Point2f[] detectedCorners, InputArray detectedIds, OutputArray objPoints, OutputArray imgPoints)

Parameters

detectedCorners Point2f[]

List of detected ChArUco corners of the board.

detectedIds InputArray

List of identifiers for each charuco corner.

objPoints OutputArray

Vector of marker points in the board coordinate space.

imgPoints OutputArray

Vector of marker points in the image coordinate space.