Commit 62f8240b authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

fix videostab module compilation

parent 03ae1e5a
...@@ -121,7 +121,7 @@ public: ...@@ -121,7 +121,7 @@ public:
cuda::GpuMat &status); cuda::GpuMat &status);
private: private:
cuda::PyrLKOpticalFlow optFlowEstimator_; Ptr<cuda::SparsePyrLKOpticalFlow> optFlowEstimator_;
cuda::GpuMat frame0_, frame1_, points0_, points1_, status_, errors_; cuda::GpuMat frame0_, frame1_, points0_, points1_, status_, errors_;
}; };
...@@ -136,7 +136,7 @@ public: ...@@ -136,7 +136,7 @@ public:
OutputArray errors); OutputArray errors);
private: private:
cuda::PyrLKOpticalFlow optFlowEstimator_; Ptr<cuda::DensePyrLKOpticalFlow> optFlowEstimator_;
cuda::GpuMat frame0_, frame1_, flowX_, flowY_, errors_; cuda::GpuMat frame0_, frame1_, flowX_, flowY_, errors_;
}; };
......
...@@ -45,6 +45,10 @@ ...@@ -45,6 +45,10 @@
#include "opencv2/videostab/optical_flow.hpp" #include "opencv2/videostab/optical_flow.hpp"
#include "opencv2/videostab/ring_buffer.hpp" #include "opencv2/videostab/ring_buffer.hpp"
#ifdef HAVE_OPENCV_CUDAARITHM
#include "opencv2/cudaarithm.hpp"
#endif
namespace cv namespace cv
{ {
namespace videostab namespace videostab
...@@ -63,6 +67,7 @@ void SparsePyrLkOptFlowEstimator::run( ...@@ -63,6 +67,7 @@ void SparsePyrLkOptFlowEstimator::run(
SparsePyrLkOptFlowEstimatorGpu::SparsePyrLkOptFlowEstimatorGpu() SparsePyrLkOptFlowEstimatorGpu::SparsePyrLkOptFlowEstimatorGpu()
{ {
CV_Assert(cuda::getCudaEnabledDeviceCount() > 0); CV_Assert(cuda::getCudaEnabledDeviceCount() > 0);
optFlowEstimator_ = cuda::SparsePyrLKOpticalFlow::create();
} }
...@@ -91,9 +96,9 @@ void SparsePyrLkOptFlowEstimatorGpu::run( ...@@ -91,9 +96,9 @@ void SparsePyrLkOptFlowEstimatorGpu::run(
const cuda::GpuMat &frame0, const cuda::GpuMat &frame1, const cuda::GpuMat &points0, const cuda::GpuMat &frame0, const cuda::GpuMat &frame1, const cuda::GpuMat &points0,
cuda::GpuMat &points1, cuda::GpuMat &status, cuda::GpuMat &errors) cuda::GpuMat &points1, cuda::GpuMat &status, cuda::GpuMat &errors)
{ {
optFlowEstimator_.winSize = winSize_; optFlowEstimator_->setWinSize(winSize_);
optFlowEstimator_.maxLevel = maxLevel_; optFlowEstimator_->setMaxLevel(maxLevel_);
optFlowEstimator_.sparse(frame0, frame1, points0, points1, status, &errors); optFlowEstimator_->calc(frame0, frame1, points0, points1, status, errors);
} }
...@@ -101,15 +106,16 @@ void SparsePyrLkOptFlowEstimatorGpu::run( ...@@ -101,15 +106,16 @@ void SparsePyrLkOptFlowEstimatorGpu::run(
const cuda::GpuMat &frame0, const cuda::GpuMat &frame1, const cuda::GpuMat &points0, const cuda::GpuMat &frame0, const cuda::GpuMat &frame1, const cuda::GpuMat &points0,
cuda::GpuMat &points1, cuda::GpuMat &status) cuda::GpuMat &points1, cuda::GpuMat &status)
{ {
optFlowEstimator_.winSize = winSize_; optFlowEstimator_->setWinSize(winSize_);
optFlowEstimator_.maxLevel = maxLevel_; optFlowEstimator_->setMaxLevel(maxLevel_);
optFlowEstimator_.sparse(frame0, frame1, points0, points1, status); optFlowEstimator_->calc(frame0, frame1, points0, points1, status);
} }
DensePyrLkOptFlowEstimatorGpu::DensePyrLkOptFlowEstimatorGpu() DensePyrLkOptFlowEstimatorGpu::DensePyrLkOptFlowEstimatorGpu()
{ {
CV_Assert(cuda::getCudaEnabledDeviceCount() > 0); CV_Assert(cuda::getCudaEnabledDeviceCount() > 0);
optFlowEstimator_ = cuda::DensePyrLKOpticalFlow::create();
} }
...@@ -120,16 +126,24 @@ void DensePyrLkOptFlowEstimatorGpu::run( ...@@ -120,16 +126,24 @@ void DensePyrLkOptFlowEstimatorGpu::run(
frame0_.upload(frame0.getMat()); frame0_.upload(frame0.getMat());
frame1_.upload(frame1.getMat()); frame1_.upload(frame1.getMat());
optFlowEstimator_.winSize = winSize_; optFlowEstimator_->setWinSize(winSize_);
optFlowEstimator_.maxLevel = maxLevel_; optFlowEstimator_->setMaxLevel(maxLevel_);
if (errors.needed()) if (errors.needed())
{ {
optFlowEstimator_.dense(frame0_, frame1_, flowX_, flowY_, &errors_); CV_Error(Error::StsNotImplemented, "DensePyrLkOptFlowEstimatorGpu doesn't support errors calculation");
errors_.download(errors.getMatRef());
} }
else 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()); flowX_.download(flowX.getMatRef());
flowY_.download(flowY.getMatRef()); flowY_.download(flowY.getMatRef());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment