19 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
22 nargchk(nrhs>=1 && (nrhs%2)==1 && nlhs<=1);
25 vector<MxArray> rhs(prhs, prhs+nrhs);
28 int distType = cv::DIST_L2;
32 for (
int i=1; i<nrhs; i+=2) {
33 string key(rhs[i].toString());
35 distType =
DistType[rhs[i+1].toString()];
36 else if (key==
"Param")
37 param = rhs[i+1].toDouble();
38 else if (key==
"RadiusEps")
39 reps = rhs[i+1].toDouble();
40 else if (key==
"AngleEps")
41 aeps = rhs[i+1].toDouble();
43 mexErrMsgIdAndTxt(
"mexopencv:error",
"Unrecognized option");
48 if (rhs[0].isNumeric()) {
49 Mat points(rhs[0].toMat(CV_32F));
50 fitLine(points, line, distType, param, reps, aeps);
52 else if (rhs[0].isCell() && !rhs[0].isEmpty()) {
53 mwSize n = rhs[0].at<
MxArray>(0).numel();
55 vector<Point2f> points(rhs[0].toVector<Point2f>());
56 fitLine(points, line, distType, param, reps, aeps);
59 vector<Point3f> points(rhs[0].toVector<Point3f>());
60 fitLine(points, line, distType, param, reps, aeps);
63 mexErrMsgIdAndTxt(
"mexopencv:error",
"Invalid input");
66 mexErrMsgIdAndTxt(
"mexopencv:error",
"Invalid input");
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
const ConstMap< std::string, int > DistType
Distance types for Distance Transform and M-estimators.
Global constant definitions.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.