16 (
"Ransac", cv::RANSAC)
28 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
31 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=2);
34 vector<MxArray> rhs(prhs, prhs+nrhs);
38 double ransacReprojThreshold = 3.0;
40 double confidence = 0.995;
41 for (
int i=2; i<nrhs; i+=2) {
42 string key(rhs[i].toString());
44 method = (rhs[i+1].isChar()) ?
45 Method[rhs[i+1].toString()] : rhs[i+1].toInt();
46 else if (key==
"RansacReprojThreshold")
47 ransacReprojThreshold = rhs[i+1].toDouble();
48 else if (key==
"MaxIters")
49 maxIters = rhs[i+1].toInt();
50 else if (key==
"Confidence")
51 confidence = rhs[i+1].toDouble();
53 mexErrMsgIdAndTxt(
"mexopencv:error",
"Unrecognized option");
58 if (rhs[0].isNumeric() && rhs[1].isNumeric()) {
59 Mat points1(rhs[0].toMat(CV_32F).reshape(2,0)),
60 points2(rhs[1].toMat(CV_32F).reshape(2,0));
61 H = findHomography(points1, points2, method, ransacReprojThreshold,
62 (nlhs>1 ? mask : noArray()), maxIters, confidence);
64 else if (rhs[0].isCell() && rhs[1].isCell()) {
65 vector<Point2f> points1(rhs[0].toVector<Point2f>()),
66 points2(rhs[1].toVector<Point2f>());
67 H = findHomography(points1, points2, method, ransacReprojThreshold,
68 (nlhs>1 ? mask : noArray()), maxIters, confidence);
71 mexErrMsgIdAndTxt(
"mexopencv:error",
"Invalid argument");
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Global constant definitions.
std::map wrapper with one-line initialization and lookup method.