25 const Mat& R,
const Mat&
T,
double rms)
27 const char* fieldnames[] = {
"cameraMatrix1",
"distCoeffs1",
28 "cameraMatrix2",
"distCoeffs2",
"R",
"T",
"reprojErr"};
30 s.
set(
"cameraMatrix1", K1);
31 s.
set(
"distCoeffs1", D1);
32 s.
set(
"cameraMatrix2", K2);
33 s.
set(
"distCoeffs2", D2);
36 s.
set(
"reprojErr", rms);
51 nargchk(nrhs>=4 && (nrhs%2)==0 && nlhs<=1);
59 TermCriteria criteria(TermCriteria::COUNT+TermCriteria::EPS, 100, DBL_EPSILON);
60 for (
int i=4; i<nrhs; i+=2) {
61 string key(rhs[i].toString());
62 if (key ==
"CameraMatrix1")
63 K1 = rhs[i+1].toMat(
CV_64F);
64 else if (key ==
"DistCoeffs1")
65 D1 = rhs[i+1].toMat(
CV_64F);
66 else if (key ==
"CameraMatrix2")
67 K2 = rhs[i+1].toMat(
CV_64F);
68 else if (key ==
"DistCoeffs2")
69 D2 = rhs[i+1].toMat(
CV_64F);
70 else if (key ==
"UseIntrinsicGuess")
72 else if (key ==
"RecomputeExtrinsic")
74 else if (key ==
"CheckCond")
76 else if (key ==
"FixSkew")
78 else if (key ==
"FixK1")
80 else if (key ==
"FixK2")
82 else if (key ==
"FixK3")
84 else if (key ==
"FixK4")
86 else if (key ==
"FixIntrinsic")
88 else if (key ==
"Criteria")
89 criteria = rhs[i+1].toTermCriteria();
92 "Unrecognized option %s", key.
c_str());
99 Size imageSize(rhs[3].toSize());
102 K1, D1, K2, D2, imageSize, R,
T, flags, criteria);
103 plhs[0] =
toStruct(K1, D1, K2, D2, R,
T, rms);
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
struct mxArray_tag mxArray
Forward declaration for mxArray.
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
double stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1, InputOutputArray cameraMatrix2, InputOutputArray distCoeffs2, Size imageSize, InputOutputArray R, InputOutputArray T, OutputArray E, OutputArray F, OutputArray perViewErrors, int flags=CALIB_FIX_INTRINSIC, TermCriteria criteria=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
CALIB_USE_INTRINSIC_GUESS
#define UPDATE_FLAG(NUM, TF, BIT)
set or clear a bit in flag depending on bool value
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output 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.
CALIB_RECOMPUTE_EXTRINSIC
MxArray toStruct(const Mat &K1, const Mat &D1, const Mat &K2, const Mat &D2, const Mat &R, const Mat &T, double rms)
Create a new MxArray from stereo calibration results.