Commit 0dcb4f1f authored by Roman Donchenko's avatar Roman Donchenko

Boring changes - videostab.

parent 808e0cf1
...@@ -111,10 +111,10 @@ VideoFileSource::VideoFileSource(const String &path, bool volatileFrame) ...@@ -111,10 +111,10 @@ VideoFileSource::VideoFileSource(const String &path, bool volatileFrame)
void VideoFileSource::reset() { impl->reset(); } void VideoFileSource::reset() { impl->reset(); }
Mat VideoFileSource::nextFrame() { return impl->nextFrame(); } Mat VideoFileSource::nextFrame() { return impl->nextFrame(); }
int VideoFileSource::width() { return ((VideoFileSourceImpl*)impl.obj)->width(); } int VideoFileSource::width() { return ((VideoFileSourceImpl*)impl.get())->width(); }
int VideoFileSource::height() { return ((VideoFileSourceImpl*)impl.obj)->height(); } int VideoFileSource::height() { return ((VideoFileSourceImpl*)impl.get())->height(); }
int VideoFileSource::count() { return ((VideoFileSourceImpl*)impl.obj)->count(); } int VideoFileSource::count() { return ((VideoFileSourceImpl*)impl.get())->count(); }
double VideoFileSource::fps() { return ((VideoFileSourceImpl*)impl.obj)->fps(); } double VideoFileSource::fps() { return ((VideoFileSourceImpl*)impl.get())->fps(); }
} // namespace videostab } // namespace videostab
} // namespace cv } // namespace cv
...@@ -671,9 +671,9 @@ Mat ToFileMotionWriter::estimate(const Mat &frame0, const Mat &frame1, bool *ok) ...@@ -671,9 +671,9 @@ Mat ToFileMotionWriter::estimate(const Mat &frame0, const Mat &frame1, bool *ok)
KeypointBasedMotionEstimator::KeypointBasedMotionEstimator(Ptr<MotionEstimatorBase> estimator) KeypointBasedMotionEstimator::KeypointBasedMotionEstimator(Ptr<MotionEstimatorBase> estimator)
: ImageMotionEstimatorBase(estimator->motionModel()), motionEstimator_(estimator) : ImageMotionEstimatorBase(estimator->motionModel()), motionEstimator_(estimator)
{ {
setDetector(new GoodFeaturesToTrackDetector()); setDetector(makePtr<GoodFeaturesToTrackDetector>());
setOpticalFlowEstimator(new SparsePyrLkOptFlowEstimator()); setOpticalFlowEstimator(makePtr<SparsePyrLkOptFlowEstimator>());
setOutlierRejector(new NullOutlierRejector()); setOutlierRejector(makePtr<NullOutlierRejector>());
} }
...@@ -708,7 +708,7 @@ Mat KeypointBasedMotionEstimator::estimate(const Mat &frame0, const Mat &frame1, ...@@ -708,7 +708,7 @@ Mat KeypointBasedMotionEstimator::estimate(const Mat &frame0, const Mat &frame1,
// perform outlier rejection // perform outlier rejection
IOutlierRejector *outlRejector = static_cast<IOutlierRejector*>(outlierRejector_); IOutlierRejector *outlRejector = outlierRejector_.get();
if (!dynamic_cast<NullOutlierRejector*>(outlRejector)) if (!dynamic_cast<NullOutlierRejector*>(outlRejector))
{ {
pointsPrev_.swap(pointsPrevGood_); pointsPrev_.swap(pointsPrevGood_);
...@@ -745,7 +745,7 @@ KeypointBasedMotionEstimatorGpu::KeypointBasedMotionEstimatorGpu(Ptr<MotionEstim ...@@ -745,7 +745,7 @@ KeypointBasedMotionEstimatorGpu::KeypointBasedMotionEstimatorGpu(Ptr<MotionEstim
detector_ = gpu::createGoodFeaturesToTrackDetector(CV_8UC1); detector_ = gpu::createGoodFeaturesToTrackDetector(CV_8UC1);
CV_Assert(gpu::getCudaEnabledDeviceCount() > 0); CV_Assert(gpu::getCudaEnabledDeviceCount() > 0);
setOutlierRejector(new NullOutlierRejector()); setOutlierRejector(makePtr<NullOutlierRejector>());
} }
...@@ -784,7 +784,7 @@ Mat KeypointBasedMotionEstimatorGpu::estimate(const gpu::GpuMat &frame0, const g ...@@ -784,7 +784,7 @@ Mat KeypointBasedMotionEstimatorGpu::estimate(const gpu::GpuMat &frame0, const g
// perform outlier rejection // perform outlier rejection
IOutlierRejector *rejector = static_cast<IOutlierRejector*>(outlierRejector_); IOutlierRejector *rejector = outlierRejector_.get();
if (!dynamic_cast<NullOutlierRejector*>(rejector)) if (!dynamic_cast<NullOutlierRejector*>(rejector))
{ {
outlierRejector_->process(frame0.size(), hostPointsPrev_, hostPoints_, rejectionStatus_); outlierRejector_->process(frame0.size(), hostPointsPrev_, hostPoints_, rejectionStatus_);
......
...@@ -324,7 +324,7 @@ public: ...@@ -324,7 +324,7 @@ public:
MotionInpainter::MotionInpainter() MotionInpainter::MotionInpainter()
{ {
#ifdef HAVE_OPENCV_GPUOPTFLOW #ifdef HAVE_OPENCV_GPUOPTFLOW
setOptFlowEstimator(new DensePyrLkOptFlowEstimatorGpu()); setOptFlowEstimator(makePtr<DensePyrLkOptFlowEstimatorGpu>());
#else #else
CV_Error(Error::StsNotImplemented, "Current implementation of MotionInpainter requires GPU"); CV_Error(Error::StsNotImplemented, "Current implementation of MotionInpainter requires GPU");
#endif #endif
......
...@@ -532,9 +532,9 @@ void LpMotionStabilizer::stabilize( ...@@ -532,9 +532,9 @@ void LpMotionStabilizer::stabilize(
model.scaling(1); model.scaling(1);
ClpPresolve presolveInfo; ClpPresolve presolveInfo;
Ptr<ClpSimplex> presolvedModel = presolveInfo.presolvedModel(model); Ptr<ClpSimplex> presolvedModel(presolveInfo.presolvedModel(model));
if (!presolvedModel.empty()) if (presolvedModel)
{ {
presolvedModel->dual(); presolvedModel->dual();
presolveInfo.postsolve(true); presolveInfo.postsolve(true);
......
...@@ -54,11 +54,11 @@ namespace videostab ...@@ -54,11 +54,11 @@ namespace videostab
StabilizerBase::StabilizerBase() StabilizerBase::StabilizerBase()
{ {
setLog(new LogToStdout()); setLog(makePtr<LogToStdout>());
setFrameSource(new NullFrameSource()); setFrameSource(makePtr<NullFrameSource>());
setMotionEstimator(new KeypointBasedMotionEstimator(new MotionEstimatorRansacL2())); setMotionEstimator(makePtr<KeypointBasedMotionEstimator>(makePtr<MotionEstimatorRansacL2>()));
setDeblurer(new NullDeblurer()); setDeblurer(makePtr<NullDeblurer>());
setInpainter(new NullInpainter()); setInpainter(makePtr<NullInpainter>());
setRadius(15); setRadius(15);
setTrimRatio(0); setTrimRatio(0);
setCorrectionForInclusion(false); setCorrectionForInclusion(false);
...@@ -156,7 +156,7 @@ bool StabilizerBase::doOneIteration() ...@@ -156,7 +156,7 @@ bool StabilizerBase::doOneIteration()
void StabilizerBase::setUp(const Mat &firstFrame) void StabilizerBase::setUp(const Mat &firstFrame)
{ {
InpainterBase *inpaint = static_cast<InpainterBase*>(inpainter_); InpainterBase *inpaint = inpainter_.get();
doInpainting_ = dynamic_cast<NullInpainter*>(inpaint) == 0; doInpainting_ = dynamic_cast<NullInpainter*>(inpaint) == 0;
if (doInpainting_) if (doInpainting_)
{ {
...@@ -167,7 +167,7 @@ void StabilizerBase::setUp(const Mat &firstFrame) ...@@ -167,7 +167,7 @@ void StabilizerBase::setUp(const Mat &firstFrame)
inpainter_->setStabilizationMotions(stabilizationMotions_); inpainter_->setStabilizationMotions(stabilizationMotions_);
} }
DeblurerBase *deblurer = static_cast<DeblurerBase*>(deblurer_); DeblurerBase *deblurer = deblurer_.get();
doDeblurring_ = dynamic_cast<NullDeblurer*>(deblurer) == 0; doDeblurring_ = dynamic_cast<NullDeblurer*>(deblurer) == 0;
if (doDeblurring_) if (doDeblurring_)
{ {
...@@ -252,7 +252,7 @@ void StabilizerBase::logProcessingTime() ...@@ -252,7 +252,7 @@ void StabilizerBase::logProcessingTime()
OnePassStabilizer::OnePassStabilizer() OnePassStabilizer::OnePassStabilizer()
{ {
setMotionFilter(new GaussianMotionFilter()); setMotionFilter(makePtr<GaussianMotionFilter>());
reset(); reset();
} }
...@@ -308,8 +308,8 @@ Mat OnePassStabilizer::postProcessFrame(const Mat &frame) ...@@ -308,8 +308,8 @@ Mat OnePassStabilizer::postProcessFrame(const Mat &frame)
TwoPassStabilizer::TwoPassStabilizer() TwoPassStabilizer::TwoPassStabilizer()
{ {
setMotionStabilizer(new GaussianMotionFilter()); setMotionStabilizer(makePtr<GaussianMotionFilter>());
setWobbleSuppressor(new NullWobbleSuppressor()); setWobbleSuppressor(makePtr<NullWobbleSuppressor>());
setEstimateTrimRatio(false); setEstimateTrimRatio(false);
reset(); reset();
} }
...@@ -371,7 +371,7 @@ void TwoPassStabilizer::runPrePassIfNecessary() ...@@ -371,7 +371,7 @@ void TwoPassStabilizer::runPrePassIfNecessary()
{ {
// check if we must do wobble suppression // check if we must do wobble suppression
WobbleSuppressorBase *wobble = static_cast<WobbleSuppressorBase*>(wobbleSuppressor_); WobbleSuppressorBase *wobble = wobbleSuppressor_.get();
doWobbleSuppression_ = dynamic_cast<NullWobbleSuppressor*>(wobble) == 0; doWobbleSuppression_ = dynamic_cast<NullWobbleSuppressor*>(wobble) == 0;
// estimate motions // estimate motions
...@@ -469,7 +469,7 @@ void TwoPassStabilizer::setUp(const Mat &firstFrame) ...@@ -469,7 +469,7 @@ void TwoPassStabilizer::setUp(const Mat &firstFrame)
for (int i = -radius_; i <= 0; ++i) for (int i = -radius_; i <= 0; ++i)
at(i, frames_) = firstFrame; at(i, frames_) = firstFrame;
WobbleSuppressorBase *wobble = static_cast<WobbleSuppressorBase*>(wobbleSuppressor_); WobbleSuppressorBase *wobble = wobbleSuppressor_.get();
doWobbleSuppression_ = dynamic_cast<NullWobbleSuppressor*>(wobble) == 0; doWobbleSuppression_ = dynamic_cast<NullWobbleSuppressor*>(wobble) == 0;
if (doWobbleSuppression_) if (doWobbleSuppression_)
{ {
......
...@@ -60,7 +60,7 @@ namespace videostab ...@@ -60,7 +60,7 @@ namespace videostab
WobbleSuppressorBase::WobbleSuppressorBase() : motions_(0), stabilizationMotions_(0) WobbleSuppressorBase::WobbleSuppressorBase() : motions_(0), stabilizationMotions_(0)
{ {
setMotionEstimator(new KeypointBasedMotionEstimator(new MotionEstimatorRansacL2(MM_HOMOGRAPHY))); setMotionEstimator(makePtr<KeypointBasedMotionEstimator>(makePtr<MotionEstimatorRansacL2>(MM_HOMOGRAPHY)));
} }
......
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