mexopencv  0.1
mex interface for opencv library
AGAST.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  ("AGAST_5_8", cv::AgastFeatureDetector::AGAST_5_8)
16  ("AGAST_7_12d", cv::AgastFeatureDetector::AGAST_7_12d)
17  ("AGAST_7_12s", cv::AgastFeatureDetector::AGAST_7_12s)
18  ("OAST_9_16", cv::AgastFeatureDetector::OAST_9_16);
19 }
20 
28 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
29 {
30  // Check the number of arguments
31  nargchk(nrhs>=1 && (nrhs%2)==1 && nlhs<=1);
32 
33  // Argument vector
34  vector<MxArray> rhs(prhs, prhs+nrhs);
35 
36  // Option processing
37  int threshold = 10;
38  bool nonmaxSupression = true;
39  int type = cv::AgastFeatureDetector::OAST_9_16;
40  for (int i=1; i<nrhs; i+=2) {
41  string key(rhs[i].toString());
42  if (key == "Threshold")
43  threshold = rhs[i+1].toInt();
44  else if (key == "NonmaxSuppression")
45  nonmaxSupression = rhs[i+1].toBool();
46  else if (key == "Type")
47  type = AgastTypeMap[rhs[i+1].toString()];
48  else
49  mexErrMsgIdAndTxt("mexopencv:error",
50  "Unrecognized option %s",key.c_str());
51  }
52 
53  // Process
54  Mat image(rhs[0].toMat(CV_8U));
55  vector<KeyPoint> keypoints;
56  AGAST(image, keypoints, threshold, nonmaxSupression, type);
57  plhs[0] = MxArray(keypoints);
58 }
const ConstMap< std::string, int > AgastTypeMap
AGAST neighborhood types.
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.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: AGAST.cpp:28
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927