From 0dcb4f1f661ba4a38973e9781a67cd89c578706f Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:01:59 +0400 Subject: [PATCH] Boring changes - videostab. --- modules/videostab/src/frame_source.cpp | 8 ++++---- modules/videostab/src/global_motion.cpp | 12 ++++++------ modules/videostab/src/inpainting.cpp | 2 +- modules/videostab/src/motion_stabilizing.cpp | 4 ++-- modules/videostab/src/stabilizer.cpp | 24 ++++++++++++------------ modules/videostab/src/wobble_suppression.cpp | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/modules/videostab/src/frame_source.cpp b/modules/videostab/src/frame_source.cpp index 0032202..7ca4b73 100644 --- a/modules/videostab/src/frame_source.cpp +++ b/modules/videostab/src/frame_source.cpp @@ -111,10 +111,10 @@ VideoFileSource::VideoFileSource(const String &path, bool volatileFrame) void VideoFileSource::reset() { impl->reset(); } Mat VideoFileSource::nextFrame() { return impl->nextFrame(); } -int VideoFileSource::width() { return ((VideoFileSourceImpl*)impl.obj)->width(); } -int VideoFileSource::height() { return ((VideoFileSourceImpl*)impl.obj)->height(); } -int VideoFileSource::count() { return ((VideoFileSourceImpl*)impl.obj)->count(); } -double VideoFileSource::fps() { return ((VideoFileSourceImpl*)impl.obj)->fps(); } +int VideoFileSource::width() { return ((VideoFileSourceImpl*)impl.get())->width(); } +int VideoFileSource::height() { return ((VideoFileSourceImpl*)impl.get())->height(); } +int VideoFileSource::count() { return ((VideoFileSourceImpl*)impl.get())->count(); } +double VideoFileSource::fps() { return ((VideoFileSourceImpl*)impl.get())->fps(); } } // namespace videostab } // namespace cv diff --git a/modules/videostab/src/global_motion.cpp b/modules/videostab/src/global_motion.cpp index 383a10d..c9f15a6 100644 --- a/modules/videostab/src/global_motion.cpp +++ b/modules/videostab/src/global_motion.cpp @@ -671,9 +671,9 @@ Mat ToFileMotionWriter::estimate(const Mat &frame0, const Mat &frame1, bool *ok) KeypointBasedMotionEstimator::KeypointBasedMotionEstimator(Ptr estimator) : ImageMotionEstimatorBase(estimator->motionModel()), motionEstimator_(estimator) { - setDetector(new GoodFeaturesToTrackDetector()); - setOpticalFlowEstimator(new SparsePyrLkOptFlowEstimator()); - setOutlierRejector(new NullOutlierRejector()); + setDetector(makePtr()); + setOpticalFlowEstimator(makePtr()); + setOutlierRejector(makePtr()); } @@ -708,7 +708,7 @@ Mat KeypointBasedMotionEstimator::estimate(const Mat &frame0, const Mat &frame1, // perform outlier rejection - IOutlierRejector *outlRejector = static_cast(outlierRejector_); + IOutlierRejector *outlRejector = outlierRejector_.get(); if (!dynamic_cast(outlRejector)) { pointsPrev_.swap(pointsPrevGood_); @@ -745,7 +745,7 @@ KeypointBasedMotionEstimatorGpu::KeypointBasedMotionEstimatorGpu(Ptr 0); - setOutlierRejector(new NullOutlierRejector()); + setOutlierRejector(makePtr()); } @@ -784,7 +784,7 @@ Mat KeypointBasedMotionEstimatorGpu::estimate(const gpu::GpuMat &frame0, const g // perform outlier rejection - IOutlierRejector *rejector = static_cast(outlierRejector_); + IOutlierRejector *rejector = outlierRejector_.get(); if (!dynamic_cast(rejector)) { outlierRejector_->process(frame0.size(), hostPointsPrev_, hostPoints_, rejectionStatus_); diff --git a/modules/videostab/src/inpainting.cpp b/modules/videostab/src/inpainting.cpp index b309204..7f5368c 100644 --- a/modules/videostab/src/inpainting.cpp +++ b/modules/videostab/src/inpainting.cpp @@ -324,7 +324,7 @@ public: MotionInpainter::MotionInpainter() { #ifdef HAVE_OPENCV_GPUOPTFLOW - setOptFlowEstimator(new DensePyrLkOptFlowEstimatorGpu()); + setOptFlowEstimator(makePtr()); #else CV_Error(Error::StsNotImplemented, "Current implementation of MotionInpainter requires GPU"); #endif diff --git a/modules/videostab/src/motion_stabilizing.cpp b/modules/videostab/src/motion_stabilizing.cpp index c1f3442..65bbd73 100644 --- a/modules/videostab/src/motion_stabilizing.cpp +++ b/modules/videostab/src/motion_stabilizing.cpp @@ -532,9 +532,9 @@ void LpMotionStabilizer::stabilize( model.scaling(1); ClpPresolve presolveInfo; - Ptr presolvedModel = presolveInfo.presolvedModel(model); + Ptr presolvedModel(presolveInfo.presolvedModel(model)); - if (!presolvedModel.empty()) + if (presolvedModel) { presolvedModel->dual(); presolveInfo.postsolve(true); diff --git a/modules/videostab/src/stabilizer.cpp b/modules/videostab/src/stabilizer.cpp index 50ac05c..f9c09ba 100644 --- a/modules/videostab/src/stabilizer.cpp +++ b/modules/videostab/src/stabilizer.cpp @@ -54,11 +54,11 @@ namespace videostab StabilizerBase::StabilizerBase() { - setLog(new LogToStdout()); - setFrameSource(new NullFrameSource()); - setMotionEstimator(new KeypointBasedMotionEstimator(new MotionEstimatorRansacL2())); - setDeblurer(new NullDeblurer()); - setInpainter(new NullInpainter()); + setLog(makePtr()); + setFrameSource(makePtr()); + setMotionEstimator(makePtr(makePtr())); + setDeblurer(makePtr()); + setInpainter(makePtr()); setRadius(15); setTrimRatio(0); setCorrectionForInclusion(false); @@ -156,7 +156,7 @@ bool StabilizerBase::doOneIteration() void StabilizerBase::setUp(const Mat &firstFrame) { - InpainterBase *inpaint = static_cast(inpainter_); + InpainterBase *inpaint = inpainter_.get(); doInpainting_ = dynamic_cast(inpaint) == 0; if (doInpainting_) { @@ -167,7 +167,7 @@ void StabilizerBase::setUp(const Mat &firstFrame) inpainter_->setStabilizationMotions(stabilizationMotions_); } - DeblurerBase *deblurer = static_cast(deblurer_); + DeblurerBase *deblurer = deblurer_.get(); doDeblurring_ = dynamic_cast(deblurer) == 0; if (doDeblurring_) { @@ -252,7 +252,7 @@ void StabilizerBase::logProcessingTime() OnePassStabilizer::OnePassStabilizer() { - setMotionFilter(new GaussianMotionFilter()); + setMotionFilter(makePtr()); reset(); } @@ -308,8 +308,8 @@ Mat OnePassStabilizer::postProcessFrame(const Mat &frame) TwoPassStabilizer::TwoPassStabilizer() { - setMotionStabilizer(new GaussianMotionFilter()); - setWobbleSuppressor(new NullWobbleSuppressor()); + setMotionStabilizer(makePtr()); + setWobbleSuppressor(makePtr()); setEstimateTrimRatio(false); reset(); } @@ -371,7 +371,7 @@ void TwoPassStabilizer::runPrePassIfNecessary() { // check if we must do wobble suppression - WobbleSuppressorBase *wobble = static_cast(wobbleSuppressor_); + WobbleSuppressorBase *wobble = wobbleSuppressor_.get(); doWobbleSuppression_ = dynamic_cast(wobble) == 0; // estimate motions @@ -469,7 +469,7 @@ void TwoPassStabilizer::setUp(const Mat &firstFrame) for (int i = -radius_; i <= 0; ++i) at(i, frames_) = firstFrame; - WobbleSuppressorBase *wobble = static_cast(wobbleSuppressor_); + WobbleSuppressorBase *wobble = wobbleSuppressor_.get(); doWobbleSuppression_ = dynamic_cast(wobble) == 0; if (doWobbleSuppression_) { diff --git a/modules/videostab/src/wobble_suppression.cpp b/modules/videostab/src/wobble_suppression.cpp index c9d8ac9..0b652b9 100644 --- a/modules/videostab/src/wobble_suppression.cpp +++ b/modules/videostab/src/wobble_suppression.cpp @@ -60,7 +60,7 @@ namespace videostab WobbleSuppressorBase::WobbleSuppressorBase() : motions_(0), stabilizationMotions_(0) { - setMotionEstimator(new KeypointBasedMotionEstimator(new MotionEstimatorRansacL2(MM_HOMOGRAPHY))); + setMotionEstimator(makePtr(makePtr(MM_HOMOGRAPHY))); } -- 2.7.4