mexopencv  0.1
mex interface for opencv library
FAST.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
12 namespace {
15  ("TYPE_5_8", cv::FastFeatureDetector::TYPE_5_8)
16  ("TYPE_7_12", cv::FastFeatureDetector::TYPE_7_12)
17  ("TYPE_9_16", cv::FastFeatureDetector::TYPE_9_16);
18 }
19 
27 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
28 {
29  // Check the number of arguments
30  nargchk(nrhs>=1 && (nrhs%2)==1 && nlhs<=1);
31 
32  // Argument vector
33  vector<MxArray> rhs(prhs, prhs+nrhs);
34 
35  // Option processing
36  int threshold = 10;
37  bool nonmaxSupression = true;
38  int type = cv::FastFeatureDetector::TYPE_9_16;
39  for (int i=1; i<nrhs; i+=2) {
40  string key(rhs[i].toString());
41  if (key == "Threshold")
42  threshold = rhs[i+1].toInt();
43  else if (key == "NonmaxSuppression")
44  nonmaxSupression = rhs[i+1].toBool();
45  else if (key == "Type")
46  type = FASTTypeMap[rhs[i+1].toString()];
47  else
48  mexErrMsgIdAndTxt("mexopencv:error",
49  "Unrecognized option %s",key.c_str());
50  }
51 
52  // Process
53  Mat image(rhs[0].toMat(CV_8U));
54  vector<KeyPoint> keypoints;
55  FAST(image, keypoints, threshold, nonmaxSupression, type);
56  plhs[0] = MxArray(keypoints);
57 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: FAST.cpp:27
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Definition: mexopencv.hpp:166
Global constant definitions.
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
const ConstMap< std::string, int > FASTTypeMap
FAST types.