34 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=3);
40 Mat distCoeffs, rvec, tvec;
41 bool useExtrinsicGuess =
false;
43 for (
int i=3; i<nrhs; i+=2) {
44 string key(rhs[i].toString());
45 if (key ==
"DistCoeffs")
46 distCoeffs = rhs[i+1].toMat(
CV_64F);
47 else if (key ==
"UseExtrinsicGuess")
48 useExtrinsicGuess = rhs[i+1].toBool();
49 else if (key ==
"Rvec")
50 rvec = rhs[i+1].toMat(
CV_64F);
51 else if (key ==
"Tvec")
52 tvec = rhs[i+1].toMat(
CV_64F);
53 else if (key ==
"Method")
57 "Unrecognized option %s", key.
c_str());
60 useExtrinsicGuess =
true;
65 if (rhs[0].isNumeric() && rhs[1].isNumeric()) {
68 success =
solvePnP(objectPoints, imagePoints, cameraMatrix, distCoeffs,
69 rvec, tvec, useExtrinsicGuess, flags);
71 else if (rhs[0].isCell() && rhs[1].isCell()) {
74 success =
solvePnP(objectPoints, imagePoints, cameraMatrix, distCoeffs,
75 rvec, tvec, useExtrinsicGuess, flags);
const ConstMap< string, int > PnPMethod
Method used for solving the pose estimation problem.
struct mxArray_tag mxArray
Forward declaration for mxArray.
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...
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
Global constant definitions.
bool solvePnP(InputArray objectPoints, InputArray imagePoints, InputArray cameraMatrix, InputArray distCoeffs, OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess=false, int flags=SOLVEPNP_ITERATIVE)
std::map wrapper with one-line initialization and lookup method.