9 #include "opencv2/videostab.hpp" 17 (
"Translation", cv::videostab::MM_TRANSLATION)
18 (
"TranslationAndScale", cv::videostab::MM_TRANSLATION_AND_SCALE)
19 (
"Rotation", cv::videostab::MM_ROTATION)
20 (
"Rigid", cv::videostab::MM_RIGID)
21 (
"Similarity", cv::videostab::MM_SIMILARITY)
22 (
"Affine", cv::videostab::MM_AFFINE)
23 (
"Homography", cv::videostab::MM_HOMOGRAPHY)
24 (
"Unknown", cv::videostab::MM_UNKNOWN);
34 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
37 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=2);
40 vector<MxArray> rhs(prhs, prhs+nrhs);
43 int model = cv::videostab::MM_AFFINE;
44 for (
int i=2; i<nrhs; i+=2) {
45 string key(rhs[i].toString());
46 if (key ==
"MotionModel")
47 model = MotionModelMap[rhs[i+1].toString()];
49 mexErrMsgIdAndTxt(
"mexopencv:error",
50 "Unrecognized option %s", key.c_str());
56 if (rhs[0].isNumeric() && rhs[1].isNumeric()) {
57 Mat points0(rhs[0].toMat(CV_32F)),
58 points1(rhs[1].toMat(CV_32F));
59 M = estimateGlobalMotionLeastSquares(points0, points1, model, &rmse);
61 else if (rhs[0].isCell() && rhs[1].isCell()) {
62 vector<Point2f> points0(rhs[0].toVector<Point2f>()),
63 points1(rhs[1].toVector<Point2f>());
64 M = estimateGlobalMotionLeastSquares(points0, points1, model, &rmse);
67 mexErrMsgIdAndTxt(
"mexopencv:error",
"Invalid argument");
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
const ConstMap< std::string, cv::videostab::MotionModel > MotionModelMap
motion model types for option processing
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Global constant definitions.
std::map wrapper with one-line initialization and lookup method.