19 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
22 nargchk(nrhs>=5 && (nrhs%2)==1 && nlhs<=1);
25 vector<MxArray> rhs(prhs, prhs+nrhs);
29 Scalar matchColor(Scalar::all(-1));
30 Scalar singlePointColor(Scalar::all(-1));
31 vector<char> matchesMask;
32 int flags = DrawMatchesFlags::DEFAULT;
33 for (
int i=5; i<nrhs; i+=2) {
34 string key(rhs[i].toString());
35 if (key==
"MatchColor")
36 matchColor = rhs[i+1].toScalar();
37 else if (key==
"SinglePointColor")
38 singlePointColor = rhs[i+1].toScalar();
39 else if (key==
"MatchesMask")
40 rhs[i+1].toMat(CV_8S).reshape(1,1).copyTo(matchesMask);
41 else if (key==
"NotDrawSinglePoints")
43 DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
44 else if (key==
"DrawRichKeypoints")
46 DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
47 else if (key==
"OutImage") {
48 outImg = rhs[i+1].toMat(CV_8U);
49 flags |= DrawMatchesFlags::DRAW_OVER_OUTIMG;
52 mexErrMsgIdAndTxt(
"mexopencv:error",
"Unrecognized option");
56 Mat img1(rhs[0].toMat(CV_8U)),
57 img2(rhs[2].toMat(CV_8U));
58 vector<KeyPoint> keypoints1(rhs[1].toVector<KeyPoint>()),
59 keypoints2(rhs[3].toVector<KeyPoint>());
60 vector<DMatch> matches1to2(rhs[4].toVector<DMatch>());
61 drawMatches(img1, keypoints1, img2, keypoints2, matches1to2, outImg,
62 matchColor, singlePointColor, matchesMask, flags);
#define UPDATE_FLAG(NUM, TF, BIT)
set or clear a bit in flag depending on bool value
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Global constant definitions.