10 #include "opencv2/features2d.hpp" 21 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
24 nargchk(nrhs>=5 && (nrhs%2)==1 && nlhs<=2);
27 vector<MxArray> rhs(prhs, prhs+nrhs);
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())
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>());
40 args[0].toString(), args.begin() + 1, args.end());
43 mexErrMsgIdAndTxt(
"mexopencv:error",
"Invalid arguments");
46 mexErrMsgIdAndTxt(
"mexopencv:error",
47 "Unrecognized option %s", key.c_str());
51 Mat img1(rhs[0].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);
62 plhs[1] =
MxArray(correspCount);
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.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Common definitions for the features2d and xfeatures2d modules.
Global constant definitions.