mexopencv  3.4.1
MEX interface for OpenCV library
drawMarkerAruco.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 
15 //HACK: renamed to drawMarkerAruco to avoid name conflict with imgproc function
16 
24 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
25 {
26  // Check the number of arguments
27  nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
28 
29  // Argument vector
30  vector<MxArray> rhs(prhs, prhs+nrhs);
31 
32  // Option processing
33  int borderBits = 1;
34  for (int i=3; i<nrhs; i+=2) {
35  string key(rhs[i].toString());
36  if (key == "BorderBits")
37  borderBits = rhs[i+1].toInt();
38  else
39  mexErrMsgIdAndTxt("mexopencv:error",
40  "Unrecognized option %s", key.c_str());
41  }
42 
43  // Process
44  Ptr<Dictionary> dictionary = MxArrayToDictionary(rhs[0]);
45  int id = rhs[1].toInt(),
46  sidePixels = rhs[2].toInt();
47  Mat img;
48  drawMarker(dictionary, id, sidePixels, img, borderBits);
49  plhs[0] = MxArray(img);
50 }
STL namespace.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
Common definitions for the aruco module.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
cv::Ptr< cv::aruco::Dictionary > MxArrayToDictionary(const MxArray &arr)
Convert MxArray to cv::Ptr<cv::aruco::Dictionary>
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...
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/output arguments number check.
Definition: mexopencv.hpp:181
STL class.
Global constant definitions.
void drawMarker(Mat &img, Point position, const Scalar &color, int markerType=MARKER_CROSS, int markerSize=20, int thickness=1, int line_type=8)
T c_str(T... args)