27 const Mat& P1,
const Mat& P2,
const Mat& P3,
const Mat& Q,
28 const Rect& roi1,
const Rect& roi2,
float ratio)
30 const char* fieldnames[] = {
"R1",
"R2",
"R3",
"P1",
"P2",
"P3",
"Q",
31 "roi1",
"roi2",
"ratio"};
42 s.
set(
"ratio", ratio);
54 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
57 nargchk(nrhs>=11 && (nrhs%2)==1 && nlhs<=1);
60 vector<MxArray> rhs(prhs, prhs+nrhs);
63 vector<Point2f> imgpt1, imgpt3;
66 int flags = cv::CALIB_ZERO_DISPARITY;
67 for (
int i=11; i<nrhs; i+=2) {
68 string key(rhs[i].toString());
69 if (key ==
"ImgPoints1")
70 imgpt1 = rhs[i+1].toVector<Point2f>();
71 else if (key ==
"ImgPoints3")
72 imgpt3 = rhs[i+1].toVector<Point2f>();
73 else if (key ==
"Alpha")
74 alpha = rhs[i+1].toDouble();
75 else if (key ==
"NewImageSize")
76 newImageSize = rhs[i+1].toSize();
77 else if (key ==
"ZeroDisparity")
78 UPDATE_FLAG(flags, rhs[i+1].toBool(), cv::CALIB_ZERO_DISPARITY);
80 mexErrMsgIdAndTxt(
"mexopencv:error",
81 "Unrecognized option %s",key.c_str());
85 Mat cameraMatrix1(rhs[0].toMat(CV_64F)),
86 distCoeffs1(rhs[1].toMat(CV_64F)),
87 cameraMatrix2(rhs[2].toMat(CV_64F)),
88 distCoeffs2(rhs[3].toMat(CV_64F)),
89 cameraMatrix3(rhs[4].toMat(CV_64F)),
90 distCoeffs3(rhs[5].toMat(CV_64F)),
91 R12(rhs[7].toMat(CV_64F)),
92 T12(rhs[8].toMat(CV_64F)),
93 R13(rhs[9].toMat(CV_64F)),
94 T13(rhs[10].toMat(CV_64F)),
95 R1, R2, R3, P1, P2, P3, Q;
96 Size imageSize(rhs[6].toSize());
98 float ratio = rectify3Collinear(cameraMatrix1, distCoeffs1,
99 cameraMatrix2, distCoeffs2, cameraMatrix3, distCoeffs3,
100 imgpt1, imgpt3, imageSize, R12, T12, R13, T13,
101 R1, R2, R3, P1, P2, P3, Q, alpha, newImageSize, &roi1, &roi2, flags);
102 plhs[0] =
toStruct(R1, R2, R3, P1, P2, P3, Q, roi1, roi2, ratio);
#define UPDATE_FLAG(NUM, TF, BIT)
set or clear a bit in flag depending on bool value
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
MxArray toStruct(const std::vector< cv::ml::DTrees::Node > &nodes)
Convert tree nodes to struct array.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
static MxArray Struct(const char **fields=NULL, int nfields=0, mwSize m=1, mwSize n=1)
Create a new struct array.
Global constant definitions.