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);
33 arr.
at(
"Size").toInt(),
34 arr.
at(
"Thresh").toFloat(),
35 arr.
at(
"Eps").toFloat(),
36 arr.
at(
"Prob").toFloat());
47 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
50 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=3);
53 vector<MxArray> rhs(prhs, prhs+nrhs);
56 int model = cv::videostab::MM_AFFINE;
57 RansacParams params = RansacParams::default2dMotion(cv::videostab::MM_AFFINE);
58 for (
int i=2; i<nrhs; i+=2) {
59 string key(rhs[i].toString());
60 if (key ==
"MotionModel")
61 model = MotionModelMap[rhs[i+1].toString()];
62 else if (key ==
"RansacParams")
64 RansacParams::default2dMotion(MotionModelMap[rhs[i+1].toString()]));
66 mexErrMsgIdAndTxt(
"mexopencv:error",
67 "Unrecognized option %s", key.c_str());
74 if (rhs[0].isNumeric() && rhs[1].isNumeric()) {
75 Mat points0(rhs[0].toMat(CV_32F)),
76 points1(rhs[1].toMat(CV_32F));
77 M = estimateGlobalMotionRansac(points0, points1, model, params,
80 else if (rhs[0].isCell() && rhs[1].isCell()) {
81 vector<Point2f> points0(rhs[0].toVector<Point2f>()),
82 points1(rhs[1].toVector<Point2f>());
83 M = estimateGlobalMotionRansac(points0, points1, model, params,
87 mexErrMsgIdAndTxt(
"mexopencv:error",
"Invalid argument");
cv::videostab::RansacParams toRansacParams(const MxArray &arr)
Convert MxArray to RansacParams.
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.
T at(mwIndex index) const
Template for numeric array element accessor.
std::map wrapper with one-line initialization and lookup method.