15 (
"Ransac", cv::RANSAC)
26 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
29 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=2);
32 vector<MxArray> rhs(prhs, prhs+nrhs);
35 Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
36 int method = cv::RANSAC;
38 double threshold = 1.0;
39 for (
int i=2; i<nrhs; i+=2) {
40 string key(rhs[i].toString());
41 if (key ==
"CameraMatrix")
42 cameraMatrix = rhs[i+1].toMat(CV_64F);
43 else if (key ==
"Method")
44 method = (rhs[i+1].isChar()) ?
45 Method[rhs[i+1].toString()] : rhs[i+1].toInt();
46 else if (key ==
"Confidence")
47 prob = rhs[i+1].toDouble();
48 else if (key ==
"Threshold")
49 threshold = rhs[i+1].toDouble();
51 mexErrMsgIdAndTxt(
"mexopencv:error",
52 "Unrecognized option %s",key.c_str());
57 if (rhs[0].isNumeric() && rhs[1].isNumeric()) {
58 Mat points1(rhs[0].toMat(CV_64F)),
59 points2(rhs[1].toMat(CV_64F));
60 E = findEssentialMat(points1, points2, cameraMatrix, method,
61 prob, threshold, (nlhs>1 ? mask : noArray()));
63 else if (rhs[0].isCell() && rhs[1].isCell()) {
64 vector<Point2d> points1(rhs[0].toVector<Point2d>()),
65 points2(rhs[1].toVector<Point2d>());
66 E = findEssentialMat(points1, points2, cameraMatrix, method,
67 prob, threshold, (nlhs>1 ? mask : noArray()));
70 mexErrMsgIdAndTxt(
"mexopencv:error",
"Invalid input");
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.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.