19 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
22 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=4);
25 vector<MxArray> rhs(prhs, prhs+nrhs);
28 Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
30 for (
int i=3; i<nrhs; i+=2) {
31 string key(rhs[i].toString());
32 if (key ==
"CameraMatrix")
33 cameraMatrix = rhs[i+1].toMat(CV_64F);
34 else if (key ==
"Mask")
35 mask = rhs[i+1].toMat(CV_8U);
37 mexErrMsgIdAndTxt(
"mexopencv:error",
38 "Unrecognized option %s",key.c_str());
42 Mat E(rhs[0].toMat(rhs[0].isSingle() ? CV_32F : CV_64F)),
45 if (rhs[1].isNumeric() && rhs[2].isNumeric()) {
46 Mat points1(rhs[1].toMat(CV_64F)),
47 points2(rhs[2].toMat(CV_64F));
48 good = recoverPose(E, points1, points2, cameraMatrix, R, t,
49 (nlhs>3 ? mask : noArray()));
51 else if (rhs[1].isCell() && rhs[2].isCell()) {
52 vector<Point2d> points1(rhs[1].toVector<Point2d>()),
53 points2(rhs[2].toVector<Point2d>());
54 good = recoverPose(E, points1, points2, cameraMatrix, R, t,
55 (nlhs>3 ? mask : noArray()));
58 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.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.