Added support of homography estimation into videostab module
This commit is contained in:
@@ -58,7 +58,9 @@ enum MotionModel
|
||||
TRANSLATION = 0,
|
||||
TRANSLATION_AND_SCALE = 1,
|
||||
LINEAR_SIMILARITY = 2,
|
||||
AFFINE = 3
|
||||
AFFINE = 3,
|
||||
HOMOGRAPHY = 4,
|
||||
UNKNOWN = 5
|
||||
};
|
||||
|
||||
CV_EXPORTS Mat estimateGlobalMotionLeastSquares(
|
||||
@@ -76,10 +78,11 @@ struct CV_EXPORTS RansacParams
|
||||
RansacParams(int size, float thresh, float eps, float prob)
|
||||
: size(size), thresh(thresh), eps(eps), prob(prob) {}
|
||||
|
||||
static RansacParams translationMotionStd() { return RansacParams(2, 0.5f, 0.5f, 0.99f); }
|
||||
static RansacParams translation2dMotionStd() { return RansacParams(2, 0.5f, 0.5f, 0.99f); }
|
||||
static RansacParams translationAndScale2dMotionStd() { return RansacParams(3, 0.5f, 0.5f, 0.99f); }
|
||||
static RansacParams linearSimilarityMotionStd() { return RansacParams(4, 0.5f, 0.5f, 0.99f); }
|
||||
static RansacParams linearSimilarity2dMotionStd() { return RansacParams(4, 0.5f, 0.5f, 0.99f); }
|
||||
static RansacParams affine2dMotionStd() { return RansacParams(6, 0.5f, 0.5f, 0.99f); }
|
||||
static RansacParams homography2dMotionStd() { return RansacParams(8, 0.5f, 0.5f, 0.99f); }
|
||||
};
|
||||
|
||||
CV_EXPORTS Mat estimateGlobalMotionRobust(
|
||||
@@ -87,14 +90,22 @@ CV_EXPORTS Mat estimateGlobalMotionRobust(
|
||||
int model = AFFINE, const RansacParams ¶ms = RansacParams::affine2dMotionStd(),
|
||||
float *rmse = 0, int *ninliers = 0);
|
||||
|
||||
class CV_EXPORTS IGlobalMotionEstimator
|
||||
class CV_EXPORTS GlobalMotionEstimatorBase
|
||||
{
|
||||
public:
|
||||
virtual ~IGlobalMotionEstimator() {}
|
||||
GlobalMotionEstimatorBase() : motionModel_(UNKNOWN) {}
|
||||
virtual ~GlobalMotionEstimatorBase() {}
|
||||
|
||||
virtual void setMotionModel(MotionModel val) { motionModel_ = val; }
|
||||
virtual MotionModel motionModel() const { return motionModel_; }
|
||||
|
||||
virtual Mat estimate(const Mat &frame0, const Mat &frame1) = 0;
|
||||
|
||||
protected:
|
||||
MotionModel motionModel_;
|
||||
};
|
||||
|
||||
class CV_EXPORTS PyrLkRobustMotionEstimator : public IGlobalMotionEstimator
|
||||
class CV_EXPORTS PyrLkRobustMotionEstimator : public GlobalMotionEstimatorBase
|
||||
{
|
||||
public:
|
||||
PyrLkRobustMotionEstimator();
|
||||
@@ -105,9 +116,6 @@ public:
|
||||
void setOptFlowEstimator(Ptr<ISparseOptFlowEstimator> val) { optFlowEstimator_ = val; }
|
||||
Ptr<ISparseOptFlowEstimator> optFlowEstimator() const { return optFlowEstimator_; }
|
||||
|
||||
void setMotionModel(MotionModel val) { motionModel_ = val; }
|
||||
MotionModel motionModel() const { return motionModel_; }
|
||||
|
||||
void setRansacParams(const RansacParams &val) { ransacParams_ = val; }
|
||||
RansacParams ransacParams() const { return ransacParams_; }
|
||||
|
||||
@@ -122,7 +130,6 @@ public:
|
||||
private:
|
||||
Ptr<FeatureDetector> detector_;
|
||||
Ptr<ISparseOptFlowEstimator> optFlowEstimator_;
|
||||
MotionModel motionModel_;
|
||||
RansacParams ransacParams_;
|
||||
std::vector<uchar> status_;
|
||||
std::vector<KeyPoint> keypointsPrev_;
|
||||
|
@@ -47,6 +47,7 @@
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/videostab/optical_flow.hpp"
|
||||
#include "opencv2/videostab/fast_marching.hpp"
|
||||
#include "opencv2/videostab/global_motion.hpp"
|
||||
#include "opencv2/photo/photo.hpp"
|
||||
|
||||
namespace cv
|
||||
@@ -66,6 +67,9 @@ public:
|
||||
virtual void setRadius(int val) { radius_ = val; }
|
||||
virtual int radius() const { return radius_; }
|
||||
|
||||
virtual void setMotionModel(MotionModel val) { motionModel_ = val; }
|
||||
virtual MotionModel motionModel() const { return motionModel_; }
|
||||
|
||||
virtual void setFrames(const std::vector<Mat> &val) { frames_ = &val; }
|
||||
virtual const std::vector<Mat>& frames() const { return *frames_; }
|
||||
|
||||
@@ -82,6 +86,7 @@ public:
|
||||
|
||||
protected:
|
||||
int radius_;
|
||||
MotionModel motionModel_;
|
||||
const std::vector<Mat> *frames_;
|
||||
const std::vector<Mat> *motions_;
|
||||
const std::vector<Mat> *stabilizedFrames_;
|
||||
@@ -101,6 +106,7 @@ public:
|
||||
bool empty() const { return inpainters_.empty(); }
|
||||
|
||||
virtual void setRadius(int val);
|
||||
virtual void setMotionModel(MotionModel val);
|
||||
virtual void setFrames(const std::vector<Mat> &val);
|
||||
virtual void setMotions(const std::vector<Mat> &val);
|
||||
virtual void setStabilizedFrames(const std::vector<Mat> &val);
|
||||
|
@@ -72,8 +72,8 @@ public:
|
||||
void setFrameSource(Ptr<IFrameSource> val) { frameSource_ = val; }
|
||||
Ptr<IFrameSource> frameSource() const { return frameSource_; }
|
||||
|
||||
void setMotionEstimator(Ptr<IGlobalMotionEstimator> val) { motionEstimator_ = val; }
|
||||
Ptr<IGlobalMotionEstimator> motionEstimator() const { return motionEstimator_; }
|
||||
void setMotionEstimator(Ptr<GlobalMotionEstimatorBase> val) { motionEstimator_ = val; }
|
||||
Ptr<GlobalMotionEstimatorBase> motionEstimator() const { return motionEstimator_; }
|
||||
|
||||
void setDeblurer(Ptr<DeblurerBase> val) { deblurer_ = val; }
|
||||
Ptr<DeblurerBase> deblurrer() const { return deblurer_; }
|
||||
@@ -104,7 +104,7 @@ protected:
|
||||
|
||||
Ptr<ILog> log_;
|
||||
Ptr<IFrameSource> frameSource_;
|
||||
Ptr<IGlobalMotionEstimator> motionEstimator_;
|
||||
Ptr<GlobalMotionEstimatorBase> motionEstimator_;
|
||||
Ptr<DeblurerBase> deblurer_;
|
||||
Ptr<InpainterBase> inpainter_;
|
||||
int radius_;
|
||||
|
Reference in New Issue
Block a user