mexopencv  0.1
mex interface for opencv library
evaluateFeatureDetector.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
10 #include "opencv2/features2d.hpp"
11 using namespace std;
12 using namespace cv;
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<=2);
25 
26  // Argument vector
27  vector<MxArray> rhs(prhs, prhs+nrhs);
28 
29  // Option processing
30  Ptr<FeatureDetector> fdetector;
31  for (int i=5; i<nrhs; i+=2) {
32  string key(rhs[i].toString());
33  if (key == "Detector") {
34  if (rhs[i+1].isChar())
35  fdetector = createFeatureDetector(
36  rhs[i+1].toString(), rhs.end(), rhs.end());
37  else if (rhs[i+1].isCell() && rhs[i+1].numel() >= 1) {
38  vector<MxArray> args(rhs[i+1].toVector<MxArray>());
39  fdetector = createFeatureDetector(
40  args[0].toString(), args.begin() + 1, args.end());
41  }
42  else
43  mexErrMsgIdAndTxt("mexopencv:error","Invalid arguments");
44  }
45  else
46  mexErrMsgIdAndTxt("mexopencv:error",
47  "Unrecognized option %s", key.c_str());
48  }
49 
50  // Process
51  Mat img1(rhs[0].toMat()),
52  img2(rhs[1].toMat()),
53  H1to2(rhs[2].toMat(CV_64F));
54  vector<KeyPoint> keypoints1(rhs[3].toVector<KeyPoint>()),
55  keypoints2(rhs[4].toVector<KeyPoint>());
56  float repeatability = -1.0f;
57  int correspCount = -1;
58  evaluateFeatureDetector(img1, img2, H1to2, &keypoints1, &keypoints2,
59  repeatability, correspCount, fdetector);
60  plhs[0] = MxArray(repeatability);
61  if (nlhs>1)
62  plhs[1] = MxArray(correspCount);
63 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
cv::Ptr< cv::FeatureDetector > createFeatureDetector(const std::string &type, std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Factory function for FeatureDetector creation.
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
Common definitions for the features2d and xfeatures2d modules.
Global constant definitions.