43
#ifndef OPENCV_VIDEOSTAB_GLOBAL_MOTION_HPP
44
#define OPENCV_VIDEOSTAB_GLOBAL_MOTION_HPP
48
#include "opencv2/core.hpp"
49
#include "opencv2/features2d.hpp"
50
#include "opencv2/opencv_modules.hpp"
51
#include "opencv2/videostab/optical_flow.hpp"
52
#include "opencv2/videostab/motion_core.hpp"
53
#include "opencv2/videostab/outlier_rejection.hpp"
55
#ifdef HAVE_OPENCV_CUDAIMGPROC
56
# include "opencv2/cudaimgproc.hpp"
91
InputArray points0, InputArray points1,
int
model = MM_AFFINE,
93
float
*rmse = 0,
int
*ninliers = 0);
120
virtual
Mat
estimate(InputArray points0, InputArray points1,
bool
*ok = 0) = 0;
136
void
setRansacParams(
const
RansacParams
&val) { ransacParams_ = val; }
137
RansacParams
ransacParams()
const
{
return
ransacParams_; }
139
void
setMinInlierRatio(
float
val) { minInlierRatio_ = val; }
140
float
minInlierRatio()
const
{
return
minInlierRatio_; }
142
virtual
Mat
estimate(InputArray points0, InputArray points1,
bool
*ok = 0) CV_OVERRIDE;
146
float
minInlierRatio_;
158
virtual
Mat
estimate(InputArray points0, InputArray points1,
bool
*ok = 0) CV_OVERRIDE;
161
std::vector<
double> obj_, collb_, colub_;
162
std::vector<
double> elems_, rowlb_, rowub_;
163
std::vector<
int> rows_, cols_;
165
void
set(
int
row,
int
col,
double
coef)
168
cols_.push_back(col);
169
elems_.push_back(coef);
180
virtual
void
setMotionModel(
MotionModel
val) { motionModel_ = val; }
181
virtual
MotionModel
motionModel()
const
{
return
motionModel_; }
183
virtual
void
setFrameMask(InputArray mask)
186
CV_Error(Error::StsNotImplemented,
"Mask support is not implemented.");
189
virtual
Mat
estimate(
const
Mat
&frame0,
const
Mat
&frame1,
bool
*ok = 0) = 0;
203
virtual
Mat
estimate(
const
Mat
&frame0,
const
Mat
&frame1,
bool
*ok = 0) CV_OVERRIDE;
214
virtual
void
setMotionModel(
MotionModel
val) CV_OVERRIDE { motionEstimator_->setMotionModel(val); }
215
virtual
MotionModel
motionModel()
const
CV_OVERRIDE {
return
motionEstimator_->motionModel(); }
217
virtual
void
setFrameMask(InputArray mask) CV_OVERRIDE { motionEstimator_->setFrameMask(mask); }
219
virtual
Mat
estimate(
const
Mat
&frame0,
const
Mat
&frame1,
bool
*ok = 0) CV_OVERRIDE;
234
virtual
void
setMotionModel(
MotionModel
val) CV_OVERRIDE { motionEstimator_->setMotionModel(val); }
235
virtual
MotionModel
motionModel()
const
CV_OVERRIDE {
return
motionEstimator_->motionModel(); }
246
virtual
void
setFrameMask(InputArray mask) CV_OVERRIDE { mask_ = mask.getMat(); }
248
virtual
Mat
estimate(
const
Mat
&frame0,
const
Mat
&frame1,
bool
*ok = 0) CV_OVERRIDE;
249
Mat
estimate(InputArray frame0, InputArray frame1,
bool
*ok = 0);
258
std::vector<uchar> status_;
259
std::vector<KeyPoint> keypointsPrev_;
260
std::vector<Point2f> pointsPrev_, points_;
261
std::vector<Point2f> pointsPrevGood_, pointsGood_;
264
#if defined(HAVE_OPENCV_CUDAIMGPROC) && defined(HAVE_OPENCV_CUDAOPTFLOW)
271
virtual
void
setMotionModel(
MotionModel
val) CV_OVERRIDE { motionEstimator_->setMotionModel(val); }
272
virtual
MotionModel
motionModel() const CV_OVERRIDE {
return
motionEstimator_->motionModel(); }
274
void
setOutlierRejector(Ptr<IOutlierRejector> val) { outlierRejector_ = val; }
275
Ptr<IOutlierRejector> outlierRejector()
const
{
return
outlierRejector_; }
277
virtual
Mat estimate(
const
Mat &frame0,
const
Mat &frame1,
bool
*ok = 0) CV_OVERRIDE;
278
Mat estimate(const cuda::GpuMat &frame0, const cuda::GpuMat &frame1,
bool
*ok = 0);
281
Ptr<MotionEstimatorBase> motionEstimator_;
282
Ptr<cuda::CornersDetector> detector_;
283
SparsePyrLkOptFlowEstimatorGpu optFlowEstimator_;
284
Ptr<IOutlierRejector> outlierRejector_;
286
cuda::GpuMat frame0_, grayFrame0_, frame1_;
287
cuda::GpuMat pointsPrev_, points_;
288
cuda::GpuMat status_;
290
Mat hostPointsPrev_, hostPoints_;
291
std::vector<Point2f> hostPointsPrevTmp_, hostPointsTmp_;
292
std::vector<uchar> rejectionStatus_;
304
CV_EXPORTS
Mat
getMotion(
int
from,
int
to,
const
std::vector<Mat> &motions);
n-dimensional dense array class
Definition:
mat.hpp:802
void push_back(const _Tp &elem)
Adds elements to the bottom of the matrix.
Definition:
global_motion.hpp:199
Base class for global 2D motion estimation methods which take frames as input.
Definition:
global_motion.hpp:176
Describes a global 2D motion estimation method which uses keypoints detection and optical flow for ma...
Definition:
global_motion.hpp:230
Base class for all global motion estimation methods.
Definition:
global_motion.hpp:98
virtual MotionModel motionModel() const
Definition:
global_motion.hpp:111
virtual void setMotionModel(MotionModel val)
Sets motion model.
Definition:
global_motion.hpp:106
virtual Mat estimate(InputArray points0, InputArray points1, bool *ok=0)=0
Estimates global motion between two 2D point clouds.
Describes a global 2D motion estimation method which minimizes L1 error.
Definition:
global_motion.hpp:154
virtual Mat estimate(InputArray points0, InputArray points1, bool *ok=0) CV_OVERRIDE
Estimates global motion between two 2D point clouds.
Describes a robust RANSAC-based global 2D motion estimation method which minimizes L2 error.
Definition:
global_motion.hpp:132
virtual Mat estimate(InputArray points0, InputArray points1, bool *ok=0) CV_OVERRIDE
Estimates global motion between two 2D point clouds.
Definition:
global_motion.hpp:210
#define CV_Error(code, msg)
Call the error handler.
Definition:
base.hpp:320
CV_EXPORTS Mat getMotion(int from, int to, const std::vector< Mat > &motions)
Computes motion between two frames assuming that all the intermediate motions are known.
CV_EXPORTS Mat estimateGlobalMotionRansac(InputArray points0, InputArray points1, int model=MM_AFFINE, const RansacParams ¶ms=RansacParams::default2dMotion(MM_AFFINE), float *rmse=0, int *ninliers=0)
Estimates best global motion between two 2D point clouds robustly (using RANSAC method).
CV_EXPORTS Mat estimateGlobalMotionLeastSquares(InputOutputArray points0, InputOutputArray points1, int model=MM_AFFINE, float *rmse=0)
Estimates best global motion between two 2D point clouds in the least-squares sense.
MotionModel
Describes motion model between two point clouds.
Definition:
motion_core.hpp:60
"black box" representation of the file storage associated with a file on disk.
Definition:
aruco.hpp:75
Definition:
cvstd_wrapper.hpp:74
Describes RANSAC method parameters.
Definition:
motion_core.hpp:74
static RansacParams default2dMotion(MotionModel model)
Definition:
motion_core.hpp:102