videostab module fixes
This commit is contained in:
parent
fdeec6896c
commit
13d087e62d
@ -1,3 +1,4 @@
|
|||||||
set(the_description "Video stabilization")
|
set(the_description "Video stabilization")
|
||||||
ocv_define_module(videostab opencv_imgproc opencv_features2d opencv_video opencv_photo opencv_calib3d OPTIONAL opencv_gpu opencv_highgui)
|
ocv_define_module(videostab opencv_imgproc opencv_features2d opencv_video opencv_photo opencv_calib3d
|
||||||
|
OPTIONAL opencv_gpu opencv_gpuwarping opencv_gpuoptflow opencv_highgui)
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@
|
|||||||
#include "opencv2/videostab/motion_core.hpp"
|
#include "opencv2/videostab/motion_core.hpp"
|
||||||
#include "opencv2/videostab/outlier_rejection.hpp"
|
#include "opencv2/videostab/outlier_rejection.hpp"
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#ifdef HAVE_OPENCV_GPUIMGPROC
|
||||||
#include "opencv2/gpu.hpp"
|
# include "opencv2/gpuimgproc.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
@ -199,7 +199,8 @@ private:
|
|||||||
std::vector<Point2f> pointsPrevGood_, pointsGood_;
|
std::vector<Point2f> pointsPrevGood_, pointsGood_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPUIMGPROC) && defined(HAVE_OPENCV_GPU) && defined(HAVE_OPENCV_GPUOPTFLOW)
|
||||||
|
|
||||||
class CV_EXPORTS KeypointBasedMotionEstimatorGpu : public ImageMotionEstimatorBase
|
class CV_EXPORTS KeypointBasedMotionEstimatorGpu : public ImageMotionEstimatorBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -228,7 +229,8 @@ private:
|
|||||||
std::vector<Point2f> hostPointsPrevTmp_, hostPointsTmp_;
|
std::vector<Point2f> hostPointsPrevTmp_, hostPointsTmp_;
|
||||||
std::vector<uchar> rejectionStatus_;
|
std::vector<uchar> rejectionStatus_;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
#endif // defined(HAVE_OPENCV_GPUIMGPROC) && defined(HAVE_OPENCV_GPU) && defined(HAVE_OPENCV_GPUOPTFLOW)
|
||||||
|
|
||||||
CV_EXPORTS Mat getMotion(int from, int to, const std::vector<Mat> &motions);
|
CV_EXPORTS Mat getMotion(int from, int to, const std::vector<Mat> &motions);
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@
|
|||||||
#include "opencv2/core.hpp"
|
#include "opencv2/core.hpp"
|
||||||
#include "opencv2/opencv_modules.hpp"
|
#include "opencv2/opencv_modules.hpp"
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#ifdef HAVE_OPENCV_GPUOPTFLOW
|
||||||
#include "opencv2/gpu.hpp"
|
#include "opencv2/gpuoptflow.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
@ -99,7 +99,8 @@ public:
|
|||||||
OutputArray status, OutputArray errors);
|
OutputArray status, OutputArray errors);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#ifdef HAVE_OPENCV_GPUOPTFLOW
|
||||||
|
|
||||||
class CV_EXPORTS SparsePyrLkOptFlowEstimatorGpu
|
class CV_EXPORTS SparsePyrLkOptFlowEstimatorGpu
|
||||||
: public PyrLkOptFlowEstimatorBase, public ISparseOptFlowEstimator
|
: public PyrLkOptFlowEstimatorBase, public ISparseOptFlowEstimator
|
||||||
{
|
{
|
||||||
@ -135,6 +136,7 @@ private:
|
|||||||
gpu::PyrLKOpticalFlow optFlowEstimator_;
|
gpu::PyrLKOpticalFlow optFlowEstimator_;
|
||||||
gpu::GpuMat frame0_, frame1_, flowX_, flowY_, errors_;
|
gpu::GpuMat frame0_, frame1_, flowX_, flowY_, errors_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace videostab
|
} // namespace videostab
|
||||||
|
@ -45,13 +45,10 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "opencv2/core.hpp"
|
#include "opencv2/core.hpp"
|
||||||
|
#include "opencv2/core/gpumat.hpp"
|
||||||
#include "opencv2/videostab/global_motion.hpp"
|
#include "opencv2/videostab/global_motion.hpp"
|
||||||
#include "opencv2/videostab/log.hpp"
|
#include "opencv2/videostab/log.hpp"
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
|
||||||
#include "opencv2/gpu.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
namespace videostab
|
namespace videostab
|
||||||
|
@ -47,6 +47,10 @@
|
|||||||
#include "opencv2/opencv_modules.hpp"
|
#include "opencv2/opencv_modules.hpp"
|
||||||
#include "clp.hpp"
|
#include "clp.hpp"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_GPU
|
||||||
|
# include "opencv2/gpu.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
namespace videostab
|
namespace videostab
|
||||||
@ -728,7 +732,8 @@ Mat KeypointBasedMotionEstimator::estimate(const Mat &frame0, const Mat &frame1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPUIMGPROC) && defined(HAVE_OPENCV_GPU) && defined(HAVE_OPENCV_GPUOPTFLOW)
|
||||||
|
|
||||||
KeypointBasedMotionEstimatorGpu::KeypointBasedMotionEstimatorGpu(Ptr<MotionEstimatorBase> estimator)
|
KeypointBasedMotionEstimatorGpu::KeypointBasedMotionEstimatorGpu(Ptr<MotionEstimatorBase> estimator)
|
||||||
: ImageMotionEstimatorBase(estimator->motionModel()), motionEstimator_(estimator)
|
: ImageMotionEstimatorBase(estimator->motionModel()), motionEstimator_(estimator)
|
||||||
{
|
{
|
||||||
@ -799,7 +804,8 @@ Mat KeypointBasedMotionEstimatorGpu::estimate(const gpu::GpuMat &frame0, const g
|
|||||||
// estimate motion
|
// estimate motion
|
||||||
return motionEstimator_->estimate(hostPointsPrev_, hostPoints_, ok);
|
return motionEstimator_->estimate(hostPointsPrev_, hostPoints_, ok);
|
||||||
}
|
}
|
||||||
#endif // HAVE_OPENCV_GPU
|
|
||||||
|
#endif // defined(HAVE_OPENCV_GPUIMGPROC) && defined(HAVE_OPENCV_GPU) && defined(HAVE_OPENCV_GPUOPTFLOW)
|
||||||
|
|
||||||
|
|
||||||
Mat getMotion(int from, int to, const std::vector<Mat> &motions)
|
Mat getMotion(int from, int to, const std::vector<Mat> &motions)
|
||||||
|
@ -323,7 +323,7 @@ public:
|
|||||||
|
|
||||||
MotionInpainter::MotionInpainter()
|
MotionInpainter::MotionInpainter()
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#ifdef HAVE_OPENCV_GPUOPTFLOW
|
||||||
setOptFlowEstimator(new DensePyrLkOptFlowEstimatorGpu());
|
setOptFlowEstimator(new DensePyrLkOptFlowEstimatorGpu());
|
||||||
#else
|
#else
|
||||||
CV_Error(Error::StsNotImplemented, "Current implementation of MotionInpainter requires GPU");
|
CV_Error(Error::StsNotImplemented, "Current implementation of MotionInpainter requires GPU");
|
||||||
|
@ -58,7 +58,8 @@ void SparsePyrLkOptFlowEstimator::run(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#ifdef HAVE_OPENCV_GPUOPTFLOW
|
||||||
|
|
||||||
SparsePyrLkOptFlowEstimatorGpu::SparsePyrLkOptFlowEstimatorGpu()
|
SparsePyrLkOptFlowEstimatorGpu::SparsePyrLkOptFlowEstimatorGpu()
|
||||||
{
|
{
|
||||||
CV_Assert(gpu::getCudaEnabledDeviceCount() > 0);
|
CV_Assert(gpu::getCudaEnabledDeviceCount() > 0);
|
||||||
@ -133,7 +134,8 @@ void DensePyrLkOptFlowEstimatorGpu::run(
|
|||||||
flowX_.download(flowX.getMatRef());
|
flowX_.download(flowX.getMatRef());
|
||||||
flowY_.download(flowY.getMatRef());
|
flowY_.download(flowY.getMatRef());
|
||||||
}
|
}
|
||||||
#endif // HAVE_OPENCV_GPU
|
|
||||||
|
#endif // HAVE_OPENCV_GPUOPTFLOW
|
||||||
|
|
||||||
} // namespace videostab
|
} // namespace videostab
|
||||||
} // namespace cv
|
} // namespace cv
|
||||||
|
@ -44,6 +44,15 @@
|
|||||||
#include "opencv2/videostab/wobble_suppression.hpp"
|
#include "opencv2/videostab/wobble_suppression.hpp"
|
||||||
#include "opencv2/videostab/ring_buffer.hpp"
|
#include "opencv2/videostab/ring_buffer.hpp"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_GPUWARPING
|
||||||
|
# include "opencv2/gpuwarping.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_GPU
|
||||||
|
# include "opencv2/gpu.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
namespace videostab
|
namespace videostab
|
||||||
@ -113,7 +122,7 @@ void MoreAccurateMotionWobbleSuppressor::suppress(int idx, const Mat &frame, Mat
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#ifdef HAVE_OPENCV_GPUWARPING
|
||||||
void MoreAccurateMotionWobbleSuppressorGpu::suppress(int idx, const gpu::GpuMat &frame, gpu::GpuMat &result)
|
void MoreAccurateMotionWobbleSuppressorGpu::suppress(int idx, const gpu::GpuMat &frame, gpu::GpuMat &result)
|
||||||
{
|
{
|
||||||
CV_Assert(motions_ && stabilizationMotions_);
|
CV_Assert(motions_ && stabilizationMotions_);
|
||||||
|
@ -216,7 +216,7 @@ public:
|
|||||||
outlierRejector = tblor;
|
outlierRejector = tblor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPUIMGPROC) && defined(HAVE_OPENCV_GPU) && defined(HAVE_OPENCV_GPUOPTFLOW)
|
||||||
if (gpu)
|
if (gpu)
|
||||||
{
|
{
|
||||||
KeypointBasedMotionEstimatorGpu *kbest = new KeypointBasedMotionEstimatorGpu(est);
|
KeypointBasedMotionEstimatorGpu *kbest = new KeypointBasedMotionEstimatorGpu(est);
|
||||||
@ -257,7 +257,7 @@ public:
|
|||||||
outlierRejector = tblor;
|
outlierRejector = tblor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPUIMGPROC) && defined(HAVE_OPENCV_GPU) && defined(HAVE_OPENCV_GPUOPTFLOW)
|
||||||
if (gpu)
|
if (gpu)
|
||||||
{
|
{
|
||||||
KeypointBasedMotionEstimatorGpu *kbest = new KeypointBasedMotionEstimatorGpu(est);
|
KeypointBasedMotionEstimatorGpu *kbest = new KeypointBasedMotionEstimatorGpu(est);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user