21 if (s.
isField(
"adaptiveThreshWinSizeMin"))
23 if (s.
isField(
"adaptiveThreshWinSizeMax"))
25 if (s.
isField(
"adaptiveThreshWinSizeStep"))
27 if (s.
isField(
"adaptiveThreshConstant"))
29 if (s.
isField(
"minMarkerPerimeterRate"))
31 if (s.
isField(
"maxMarkerPerimeterRate"))
33 if (s.
isField(
"polygonalApproxAccuracyRate"))
35 s.
at(
"polygonalApproxAccuracyRate").toDouble();
36 if (s.
isField(
"minCornerDistanceRate"))
38 if (s.
isField(
"minDistanceToBorder"))
40 if (s.
isField(
"minMarkerDistanceRate"))
42 if (s.
isField(
"cornerRefinementMethod"))
45 if (s.
isField(
"cornerRefinementWinSize"))
47 if (s.
isField(
"cornerRefinementMaxIterations"))
49 s.
at(
"cornerRefinementMaxIterations").toInt();
50 if (s.
isField(
"cornerRefinementMinAccuracy"))
52 s.
at(
"cornerRefinementMinAccuracy").toDouble();
53 if (s.
isField(
"markerBorderBits"))
55 if (s.
isField(
"perspectiveRemovePixelPerCell"))
57 s.
at(
"perspectiveRemovePixelPerCell").toInt();
58 if (s.
isField(
"perspectiveRemoveIgnoredMarginPerCell"))
60 s.
at(
"perspectiveRemoveIgnoredMarginPerCell").toDouble();
61 if (s.
isField(
"maxErroneousBitsInBorderRate"))
63 s.
at(
"maxErroneousBitsInBorderRate").toDouble();
66 if (s.
isField(
"errorCorrectionRate"))
79 dictionary = makePtr<Dictionary>(
80 arr.
at(
"bytesList").toMat(
CV_8U),
81 arr.
at(
"markerSize").toInt(),
82 arr.
at(
"maxCorrectionBits").toInt());
86 size_t len = args.
size();
88 string type(args[0].toString());
89 if (
type ==
"Predefined") {
91 string name(args[1].toString());
94 else if (
type ==
"Custom") {
96 int nMarkers = args[1].toInt();
97 int markerSize = args[2].toInt();
99 for (
int i=3; i<len; i+=2) {
100 string key(args[i].toString());
101 if (key ==
"BaseDictionary")
103 else if (key ==
"Seed") {
108 srand(args[i+1].toInt());
112 "Unrecognized option %s", key.
c_str());
114 if (baseDictionary.
empty())
115 baseDictionary = makePtr<Dictionary>();
119 else if (
type ==
"Manual") {
128 int markerSize = args[2].toInt();
129 int maxcorr = args[3].toInt();
130 dictionary = makePtr<Dictionary>(bytesList, markerSize, maxcorr);
134 "Unrecognized dictionary type %s",
type.c_str());
136 if (dictionary.
empty())
145 board = makePtr<Board>();
146 board->
objPoints = MxArrayToVectorVectorPoint3<float>(arr.
at(
"objPoints"));
148 board->
ids = arr.
at(
"ids").toVector<
int>();
153 string type(args[0].toString());
156 else if (
type ==
"GridBoard")
158 else if (
type ==
"CharucoBoard")
162 "Unrecognized board type %s",
type.c_str());
171 const char *fields[] = {
"adaptiveThreshWinSizeMin",
172 "adaptiveThreshWinSizeMax",
"adaptiveThreshWinSizeStep",
173 "adaptiveThreshConstant",
"minMarkerPerimeterRate",
174 "maxMarkerPerimeterRate",
"polygonalApproxAccuracyRate",
175 "minCornerDistanceRate",
"minDistanceToBorder",
176 "minMarkerDistanceRate",
"cornerRefinementMethod",
177 "cornerRefinementWinSize",
"cornerRefinementMaxIterations",
178 "cornerRefinementMinAccuracy",
"markerBorderBits",
179 "perspectiveRemovePixelPerCell",
180 "perspectiveRemoveIgnoredMarginPerCell",
181 "maxErroneousBitsInBorderRate",
"minOtsuStdDev",
182 "errorCorrectionRate"};
194 s.
set(
"cornerRefinementMethod",
201 s.
set(
"perspectiveRemoveIgnoredMarginPerCell",
211 const char *fields[] = {
"bytesList",
"markerSize",
"maxCorrectionBits",
"bits"};
231 const char *fields[] = {
"objPoints",
"dictionary",
"ids"};
241 const char *fields[] = {
"objPoints",
"dictionary",
"ids",
242 "gridSize",
"markerLength",
"markerSeparation"};
255 const char *fields[] = {
"objPoints",
"dictionary",
"ids",
256 "chessboardSize",
"squareLength",
"markerLength",
257 "chessboardCorners",
"nearestMarkerIdx",
"nearestMarkerCorners"};
281 MxArrayToVectorVectorPoint3<float>(*first)); ++first;
293 int markersX = first->toInt(); ++first;
294 int markersY = first->toInt(); ++first;
295 float markerLength = first->toFloat(); ++first;
296 float markerSeparation = first->toFloat(); ++first;
299 for (; first != last; first += 2) {
300 string key(first->toString());
301 const MxArray& val = *(first + 1);
302 if (key ==
"FirstMarker")
303 firstMarker = val.
toInt();
306 "Unrecognized option %s", key.c_str());
309 markerLength, markerSeparation, dictionary, firstMarker);
318 int squaresX = first->toInt(); ++first;
319 int squaresY = first->toInt(); ++first;
320 float squareLength = first->toFloat(); ++first;
321 float markerLength = first->toFloat(); ++first;
324 squareLength, markerLength, dictionary);
Ptr< Dictionary > MxArrayToDictionary(const MxArray &arr)
Convert MxArray to cv::Ptr<cv::aruco::Dictionary>
int toInt() const
Convert MxArray to int.
T at(mwIndex index) const
Template for numeric array element accessor.
int adaptiveThreshWinSizeStep
void push_back(const _Tp &elem)
std::vector< std::vector< int > > nearestMarkerIdx
std::string toString() const
Convert MxArray to std::string.
Size getChessboardSize() const
double cornerRefinementMinAccuracy
float getMarkerLength() const
bool isChar() const
Determine whether input is string array.
std::vector< std::vector< int > > nearestMarkerCorners
float getMarkerLength() const
double maxErroneousBitsInBorderRate
const ConstMap< int, std::string > CornerRefineMethodInvMap
Inverse corner refinement methods map.
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
Ptr< Board > create_Board(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of Board using options in arguments.
float getMarkerSeparation() const
std::vector< Point3f > chessboardCorners
MxArray toStruct(const Ptr< DetectorParameters > ¶ms)
Convert detector parameters to scalar struct.
int cornerRefinementMaxIterations
Common definitions for the aruco module.
static Mat getBitsFromByteList(const Mat &byteList, int markerSize)
float getSquareLength() const
double errorCorrectionRate
static Ptr< GridBoard > create(int markersX, int markersY, float markerLength, float markerSeparation, const Ptr< Dictionary > &dictionary, int firstMarker=0)
const ConstMap< std::string, int > CornerRefineMethodMap
Corner refinement methods map.
double maxMarkerPerimeterRate
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
static Mat getByteListFromBits(const Mat &bits)
double adaptiveThreshConstant
Ptr< Dictionary > dictionary
int adaptiveThreshWinSizeMin
bool isField(const std::string &fieldName) const
Determine whether a struct array has a specified field.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
static MxArray Struct(const char **fields=NULL, int nfields=0, mwSize m=1, mwSize n=1)
Create a new struct array.
int adaptiveThreshWinSizeMax
bool isStruct() const
Determine whether input is structure array.
Ptr< CharucoBoard > create_CharucoBoard(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of CharucoBoard using options in arguments.
Ptr< GridBoard > create_GridBoard(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of GridBoard using options in arguments.
int cornerRefinementMethod
std::vector< T > toVector() const
Convert MxArray to std::vector<T> of primitive types.
double minCornerDistanceRate
static Ptr< DetectorParameters > create()
const ConstMap< std::string, cv::aruco::PREDEFINED_DICTIONARY_NAME > PredefinedDictionaryMap
Predefined dictionary types.
Ptr< Dictionary > getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME name)
static Ptr< Board > create(InputArrayOfArrays objPoints, const Ptr< Dictionary > &dictionary, InputArray ids)
std::vector< std::vector< Point3f > > objPoints
int cornerRefinementWinSize
double minMarkerDistanceRate
static Ptr< CharucoBoard > create(int squaresX, int squaresY, float squareLength, float markerLength, const Ptr< Dictionary > &dictionary)
double minMarkerPerimeterRate
Ptr< DetectorParameters > MxArrayToDetectorParameters(const MxArray &s)
Convert MxArray to cv::Ptr<cv::aruco::DetectorParameters>
double perspectiveRemoveIgnoredMarginPerCell
int perspectiveRemovePixelPerCell
Ptr< Board > MxArrayToBoard(const MxArray &arr)
Convert MxArray to cv::Ptr<cv::aruco::Board>
Ptr< Dictionary > generateCustomDictionary(int nMarkers, int markerSize)
double polygonalApproxAccuracyRate