mexopencv  3.4.1
MEX interface for OpenCV library
FASTForPointSet.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 
14 namespace {
20 }
21 
29 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
30 {
31  // Check the number of arguments
32  nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
33 
34  // Argument vector
35  vector<MxArray> rhs(prhs, prhs+nrhs);
36 
37  // Option processing
38  int threshold = 10;
39  bool nonmaxSupression = true;
41  for (int i=2; i<nrhs; i+=2) {
42  string key(rhs[i].toString());
43  if (key == "Threshold")
44  threshold = rhs[i+1].toInt();
45  else if (key == "NonmaxSuppression")
46  nonmaxSupression = rhs[i+1].toBool();
47  else if (key == "Type")
48  type = FASTTypeMap[rhs[i+1].toString()];
49  else
50  mexErrMsgIdAndTxt("mexopencv:error",
51  "Unrecognized option %s", key.c_str());
52  }
53 
54  // Process
55  Mat image(rhs[0].toMat(CV_8U));
56  vector<KeyPoint> keypoints(rhs[1].toVector<KeyPoint>());
57  FASTForPointSet(image, keypoints, threshold, nonmaxSupression, type);
58  plhs[0] = MxArray(keypoints);
59 }
void FASTForPointSet(InputArray image, std::vector< KeyPoint > &keypoints, int threshold, bool nonmaxSuppression=true, int type=FastFeatureDetector::TYPE_9_16)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
#define CV_8U
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.
Global constant definitions.
T c_str(T... args)
double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type)
int type() const
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
cv::Mat toMat() const
const ConstMap< std::string, int > FASTTypeMap
FAST types.