mexopencv  3.4.1
MEX interface for OpenCV library
boardDump.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 #include "mexopencv_aruco.hpp"
10 #include "opencv2/aruco.hpp"
11 using namespace std;
12 using namespace cv;
13 using namespace cv::aruco;
14 
22 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
23 {
24  // Check the number of arguments
25  nargchk(nrhs==1 && nlhs<=1);
26 
27  // Argument vector
28  vector<MxArray> rhs(prhs, prhs+nrhs);
29 
30  // Process
31  if (rhs[0].isStruct()) {
32  Ptr<Board> board = MxArrayToBoard(rhs[0]);
33  plhs[0] = toStruct(board);
34  }
35  else {
36  vector<MxArray> args(rhs[0].toVector<MxArray>());
37  nargchk(args.size() >= 1);
38  string type(args[0].toString());
39  if (type == "Board") {
40  Ptr<Board> board = create_Board(args.begin() + 1, args.end());
41  plhs[0] = toStruct(board);
42  }
43  else if (type == "GridBoard") {
45  args.begin() + 1, args.end());
46  plhs[0] = toStruct(board);
47  }
48  else if (type == "CharucoBoard") {
50  args.begin() + 1, args.end());
51  plhs[0] = toStruct(board);
52  }
53  else
54  mexErrMsgIdAndTxt("mexopencv:error",
55  "Unrecognized board type %s", type.c_str());
56  }
57 }
STL namespace.
T end(T... args)
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
MxArray toStruct(const std::vector< cv::ml::DTrees::Node > &nodes)
Convert tree nodes to struct array.
cv::Ptr< cv::aruco::GridBoard > create_GridBoard(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of GridBoard using options in arguments.
Common definitions for the aruco module.
cv::Ptr< cv::aruco::Board > MxArrayToBoard(const MxArray &arr)
Convert MxArray to cv::Ptr<cv::aruco::Board>
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...
void nargchk(bool cond)
Alias for input/output arguments number check.
Definition: mexopencv.hpp:181
T size(T... args)
STL class.
Global constant definitions.
T begin(T... args)
int type() const
cv::Ptr< cv::aruco::Board > create_Board(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of Board using options in arguments.
cv::Ptr< cv::aruco::CharucoBoard > create_CharucoBoard(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of CharucoBoard using options in arguments.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: boardDump.cpp:22