Added GPU version of PyrLK based global motion estimator (videostab)
This commit is contained in:
@@ -50,6 +50,10 @@
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/videostab/optical_flow.hpp"
|
||||
|
||||
#if HAVE_OPENCV_GPU
|
||||
#include "opencv2/gpu/gpu.hpp"
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace videostab
|
||||
@@ -161,14 +165,43 @@ private:
|
||||
Ptr<FeatureDetector> detector_;
|
||||
Ptr<ISparseOptFlowEstimator> optFlowEstimator_;
|
||||
RansacParams ransacParams_;
|
||||
float minInlierRatio_;
|
||||
Size gridSize_;
|
||||
|
||||
std::vector<uchar> status_;
|
||||
std::vector<KeyPoint> keypointsPrev_;
|
||||
std::vector<Point2f> pointsPrev_, points_;
|
||||
std::vector<Point2f> pointsPrevGood_, pointsGood_;
|
||||
float minInlierRatio_;
|
||||
Size gridSize_;
|
||||
};
|
||||
|
||||
#if HAVE_OPENCV_GPU
|
||||
class CV_EXPORTS PyrLkRobustMotionEstimatorGpu : public GlobalMotionEstimatorBase
|
||||
{
|
||||
public:
|
||||
PyrLkRobustMotionEstimatorGpu(MotionModel model = MM_AFFINE);
|
||||
|
||||
void setRansacParams(const RansacParams &val) { ransacParams_ = val; }
|
||||
RansacParams ransacParams() const { return ransacParams_; }
|
||||
|
||||
void setMinInlierRatio(float val) { minInlierRatio_ = val; }
|
||||
float minInlierRatio() const { return minInlierRatio_; }
|
||||
|
||||
virtual Mat estimate(const Mat &frame0, const Mat &frame1, bool *ok = 0);
|
||||
Mat estimate(const gpu::GpuMat &frame0, const gpu::GpuMat &frame1, bool *ok = 0);
|
||||
|
||||
private:
|
||||
gpu::GoodFeaturesToTrackDetector_GPU detector_;
|
||||
SparsePyrLkOptFlowEstimatorGpu optFlowEstimator_;
|
||||
RansacParams ransacParams_;
|
||||
float minInlierRatio_;
|
||||
|
||||
gpu::GpuMat frame0_, grayFrame0_, frame1_;
|
||||
gpu::GpuMat pointsPrev_, points_;
|
||||
Mat hostPointsPrev_, hostPoints_;
|
||||
gpu::GpuMat status_;
|
||||
};
|
||||
#endif
|
||||
|
||||
CV_EXPORTS Mat getMotion(int from, int to, const std::vector<Mat> &motions);
|
||||
|
||||
} // namespace videostab
|
||||
|
@@ -47,7 +47,7 @@
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
|
||||
#if HAVE_OPENCV_GPU
|
||||
#include "opencv2/gpu/gpu.hpp"
|
||||
#include "opencv2/gpu/gpu.hpp"
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
@@ -99,6 +99,27 @@ public:
|
||||
};
|
||||
|
||||
#if HAVE_OPENCV_GPU
|
||||
class CV_EXPORTS SparsePyrLkOptFlowEstimatorGpu
|
||||
: public PyrLkOptFlowEstimatorBase, public ISparseOptFlowEstimator
|
||||
{
|
||||
public:
|
||||
SparsePyrLkOptFlowEstimatorGpu();
|
||||
|
||||
virtual void run(
|
||||
InputArray frame0, InputArray frame1, InputArray points0, InputOutputArray points1,
|
||||
OutputArray status, OutputArray errors);
|
||||
|
||||
void run(const gpu::GpuMat &frame0, const gpu::GpuMat &frame1, const gpu::GpuMat &points0, gpu::GpuMat &points1,
|
||||
gpu::GpuMat &status, gpu::GpuMat &errors);
|
||||
|
||||
void run(const gpu::GpuMat &frame0, const gpu::GpuMat &frame1, const gpu::GpuMat &points0, gpu::GpuMat &points1,
|
||||
gpu::GpuMat &status);
|
||||
|
||||
private:
|
||||
gpu::PyrLKOpticalFlow optFlowEstimator_;
|
||||
gpu::GpuMat frame0_, frame1_, points0_, points1_, status_, errors_;
|
||||
};
|
||||
|
||||
class CV_EXPORTS DensePyrLkOptFlowEstimatorGpu
|
||||
: public PyrLkOptFlowEstimatorBase, public IDenseOptFlowEstimator
|
||||
{
|
||||
@@ -108,6 +129,7 @@ public:
|
||||
virtual void run(
|
||||
InputArray frame0, InputArray frame1, InputOutputArray flowX, InputOutputArray flowY,
|
||||
OutputArray errors);
|
||||
|
||||
private:
|
||||
gpu::PyrLKOpticalFlow optFlowEstimator_;
|
||||
gpu::GpuMat frame0_, frame1_, flowX_, flowY_, errors_;
|
||||
|
Reference in New Issue
Block a user