mirror of
https://github.com/opencv/opencv.git
synced 2024-11-25 03:30:34 +08:00
fix videostab module compilation
This commit is contained in:
parent
03ae1e5aae
commit
62f8240b00
@ -121,7 +121,7 @@ public:
|
||||
cuda::GpuMat &status);
|
||||
|
||||
private:
|
||||
cuda::PyrLKOpticalFlow optFlowEstimator_;
|
||||
Ptr<cuda::SparsePyrLKOpticalFlow> optFlowEstimator_;
|
||||
cuda::GpuMat frame0_, frame1_, points0_, points1_, status_, errors_;
|
||||
};
|
||||
|
||||
@ -136,7 +136,7 @@ public:
|
||||
OutputArray errors);
|
||||
|
||||
private:
|
||||
cuda::PyrLKOpticalFlow optFlowEstimator_;
|
||||
Ptr<cuda::DensePyrLKOpticalFlow> optFlowEstimator_;
|
||||
cuda::GpuMat frame0_, frame1_, flowX_, flowY_, errors_;
|
||||
};
|
||||
|
||||
|
@ -45,6 +45,10 @@
|
||||
#include "opencv2/videostab/optical_flow.hpp"
|
||||
#include "opencv2/videostab/ring_buffer.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCV_CUDAARITHM
|
||||
#include "opencv2/cudaarithm.hpp"
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace videostab
|
||||
@ -63,6 +67,7 @@ void SparsePyrLkOptFlowEstimator::run(
|
||||
SparsePyrLkOptFlowEstimatorGpu::SparsePyrLkOptFlowEstimatorGpu()
|
||||
{
|
||||
CV_Assert(cuda::getCudaEnabledDeviceCount() > 0);
|
||||
optFlowEstimator_ = cuda::SparsePyrLKOpticalFlow::create();
|
||||
}
|
||||
|
||||
|
||||
@ -91,9 +96,9 @@ void SparsePyrLkOptFlowEstimatorGpu::run(
|
||||
const cuda::GpuMat &frame0, const cuda::GpuMat &frame1, const cuda::GpuMat &points0,
|
||||
cuda::GpuMat &points1, cuda::GpuMat &status, cuda::GpuMat &errors)
|
||||
{
|
||||
optFlowEstimator_.winSize = winSize_;
|
||||
optFlowEstimator_.maxLevel = maxLevel_;
|
||||
optFlowEstimator_.sparse(frame0, frame1, points0, points1, status, &errors);
|
||||
optFlowEstimator_->setWinSize(winSize_);
|
||||
optFlowEstimator_->setMaxLevel(maxLevel_);
|
||||
optFlowEstimator_->calc(frame0, frame1, points0, points1, status, errors);
|
||||
}
|
||||
|
||||
|
||||
@ -101,15 +106,16 @@ void SparsePyrLkOptFlowEstimatorGpu::run(
|
||||
const cuda::GpuMat &frame0, const cuda::GpuMat &frame1, const cuda::GpuMat &points0,
|
||||
cuda::GpuMat &points1, cuda::GpuMat &status)
|
||||
{
|
||||
optFlowEstimator_.winSize = winSize_;
|
||||
optFlowEstimator_.maxLevel = maxLevel_;
|
||||
optFlowEstimator_.sparse(frame0, frame1, points0, points1, status);
|
||||
optFlowEstimator_->setWinSize(winSize_);
|
||||
optFlowEstimator_->setMaxLevel(maxLevel_);
|
||||
optFlowEstimator_->calc(frame0, frame1, points0, points1, status);
|
||||
}
|
||||
|
||||
|
||||
DensePyrLkOptFlowEstimatorGpu::DensePyrLkOptFlowEstimatorGpu()
|
||||
{
|
||||
CV_Assert(cuda::getCudaEnabledDeviceCount() > 0);
|
||||
optFlowEstimator_ = cuda::DensePyrLKOpticalFlow::create();
|
||||
}
|
||||
|
||||
|
||||
@ -120,16 +126,24 @@ void DensePyrLkOptFlowEstimatorGpu::run(
|
||||
frame0_.upload(frame0.getMat());
|
||||
frame1_.upload(frame1.getMat());
|
||||
|
||||
optFlowEstimator_.winSize = winSize_;
|
||||
optFlowEstimator_.maxLevel = maxLevel_;
|
||||
optFlowEstimator_->setWinSize(winSize_);
|
||||
optFlowEstimator_->setMaxLevel(maxLevel_);
|
||||
|
||||
if (errors.needed())
|
||||
{
|
||||
optFlowEstimator_.dense(frame0_, frame1_, flowX_, flowY_, &errors_);
|
||||
errors_.download(errors.getMatRef());
|
||||
CV_Error(Error::StsNotImplemented, "DensePyrLkOptFlowEstimatorGpu doesn't support errors calculation");
|
||||
}
|
||||
else
|
||||
optFlowEstimator_.dense(frame0_, frame1_, flowX_, flowY_);
|
||||
{
|
||||
cuda::GpuMat flow;
|
||||
optFlowEstimator_->calc(frame0_, frame1_, flow);
|
||||
|
||||
cuda::GpuMat flows[2];
|
||||
cuda::split(flow, flows);
|
||||
|
||||
flowX_ = flows[0];
|
||||
flowY_ = flows[1];
|
||||
}
|
||||
|
||||
flowX_.download(flowX.getMatRef());
|
||||
flowY_.download(flowY.getMatRef());
|
||||
|
Loading…
Reference in New Issue
Block a user