mexopencv  3.4.1
MEX interface for OpenCV library
matchGMS.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
10 using namespace std;
11 using namespace cv;
12 using namespace cv::xfeatures2d;
13 
21 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
22 {
23  // Check the number of arguments
24  nargchk(nrhs>=5 && (nrhs%2)==1 && nlhs<=1);
25 
26  // Argument vector
27  vector<MxArray> rhs(prhs, prhs+nrhs);
28 
29  // Option processing
30  bool withRotation = false;
31  bool withScale = false;
32  double thresholdFactor = 6.0;
33  for (int i=5; i<nrhs; i+=2) {
34  string key(rhs[i].toString());
35  if (key == "WithRotation")
36  withRotation = rhs[i+1].toBool();
37  else if (key == "WithScale")
38  withScale = rhs[i+1].toBool();
39  else if (key == "ThresholdFactor")
40  thresholdFactor = rhs[i+1].toDouble();
41  else
42  mexErrMsgIdAndTxt("mexopencv:error",
43  "Unrecognized option %s", key.c_str());
44  }
45 
46  // Process
47  Size size1(rhs[0].toSize()),
48  size2(rhs[2].toSize());
49  vector<KeyPoint> keypoints1(rhs[1].toVector<KeyPoint>()),
50  keypoints2(rhs[3].toVector<KeyPoint>());
51  vector<DMatch> matches1to2(rhs[4].toVector<DMatch>()),
52  matchesGMS;
53  matchGMS(size1, size2, keypoints1, keypoints2, matches1to2, matchesGMS,
54  withRotation, withScale, thresholdFactor);
55  plhs[0] = MxArray(matchesGMS);
56 }
void matchGMS(const Size &size1, const Size &size2, const std::vector< KeyPoint > &keypoints1, const std::vector< KeyPoint > &keypoints2, const std::vector< DMatch > &matches1to2, std::vector< DMatch > &matchesGMS, const bool withRotation=false, const bool withScale=false, const double thresholdFactor=6.0)
STL namespace.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
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.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: matchGMS.cpp:21
Global constant definitions.
T c_str(T... args)