mexopencv  3.4.1
MEX interface for OpenCV library
FAST.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 #include "opencv2/features2d.hpp"
10 using namespace std;
11 using namespace cv;
12 
13 namespace {
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;
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 = FASTTypeMap[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  FAST(image, keypoints, threshold, nonmaxSupression, type);
57  plhs[0] = MxArray(keypoints);
58 }
#define CV_8U
STL namespace.
void FAST(InputArray image, std::vector< KeyPoint > &keypoints, int threshold, bool nonmaxSuppression=true)
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...
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: FAST.cpp:28
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.