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
KeypointBasedMotionEstimator::KeypointBasedMotionEstimator(Ptr<MotionEstimatorBase> estimator)
: ImageMotionEstimatorBase(estimator->motionModel()), motionEstimator_(estimator)
{
- setDetector(new GoodFeaturesToTrackDetector());
- setOpticalFlowEstimator(new SparsePyrLkOptFlowEstimator());
- setOutlierRejector(new NullOutlierRejector());
+ setDetector(makePtr<GoodFeaturesToTrackDetector>());
+ setOpticalFlowEstimator(makePtr<SparsePyrLkOptFlowEstimator>());
+ setOutlierRejector(makePtr<NullOutlierRejector>());
}
// perform outlier rejection
- IOutlierRejector *outlRejector = static_cast<IOutlierRejector*>(outlierRejector_);
+ IOutlierRejector *outlRejector = outlierRejector_.get();
if (!dynamic_cast<NullOutlierRejector*>(outlRejector))
{
pointsPrev_.swap(pointsPrevGood_);
detector_ = gpu::createGoodFeaturesToTrackDetector(CV_8UC1);
CV_Assert(gpu::getCudaEnabledDeviceCount() > 0);
- setOutlierRejector(new NullOutlierRejector());
+ setOutlierRejector(makePtr<NullOutlierRejector>());
}
// perform outlier rejection
- IOutlierRejector *rejector = static_cast<IOutlierRejector*>(outlierRejector_);
+ IOutlierRejector *rejector = outlierRejector_.get();
if (!dynamic_cast<NullOutlierRejector*>(rejector))
{
outlierRejector_->process(frame0.size(), hostPointsPrev_, hostPoints_, rejectionStatus_);
MotionInpainter::MotionInpainter()
{
#ifdef HAVE_OPENCV_GPUOPTFLOW
- setOptFlowEstimator(new DensePyrLkOptFlowEstimatorGpu());
+ setOptFlowEstimator(makePtr<DensePyrLkOptFlowEstimatorGpu>());
#else
CV_Error(Error::StsNotImplemented, "Current implementation of MotionInpainter requires GPU");
#endif
model.scaling(1);
ClpPresolve presolveInfo;
- Ptr<ClpSimplex> presolvedModel = presolveInfo.presolvedModel(model);
+ Ptr<ClpSimplex> presolvedModel(presolveInfo.presolvedModel(model));
- if (!presolvedModel.empty())
+ if (presolvedModel)
{
presolvedModel->dual();
presolveInfo.postsolve(true);
StabilizerBase::StabilizerBase()
{
- setLog(new LogToStdout());
- setFrameSource(new NullFrameSource());
- setMotionEstimator(new KeypointBasedMotionEstimator(new MotionEstimatorRansacL2()));
- setDeblurer(new NullDeblurer());
- setInpainter(new NullInpainter());
+ setLog(makePtr<LogToStdout>());
+ setFrameSource(makePtr<NullFrameSource>());
+ setMotionEstimator(makePtr<KeypointBasedMotionEstimator>(makePtr<MotionEstimatorRansacL2>()));
+ setDeblurer(makePtr<NullDeblurer>());
+ setInpainter(makePtr<NullInpainter>());
setRadius(15);
setTrimRatio(0);
setCorrectionForInclusion(false);
void StabilizerBase::setUp(const Mat &firstFrame)
{
- InpainterBase *inpaint = static_cast<InpainterBase*>(inpainter_);
+ InpainterBase *inpaint = inpainter_.get();
doInpainting_ = dynamic_cast<NullInpainter*>(inpaint) == 0;
if (doInpainting_)
{
inpainter_->setStabilizationMotions(stabilizationMotions_);
}
- DeblurerBase *deblurer = static_cast<DeblurerBase*>(deblurer_);
+ DeblurerBase *deblurer = deblurer_.get();
doDeblurring_ = dynamic_cast<NullDeblurer*>(deblurer) == 0;
if (doDeblurring_)
{
OnePassStabilizer::OnePassStabilizer()
{
- setMotionFilter(new GaussianMotionFilter());
+ setMotionFilter(makePtr<GaussianMotionFilter>());
reset();
}
TwoPassStabilizer::TwoPassStabilizer()
{
- setMotionStabilizer(new GaussianMotionFilter());
- setWobbleSuppressor(new NullWobbleSuppressor());
+ setMotionStabilizer(makePtr<GaussianMotionFilter>());
+ setWobbleSuppressor(makePtr<NullWobbleSuppressor>());
setEstimateTrimRatio(false);
reset();
}
{
// check if we must do wobble suppression
- WobbleSuppressorBase *wobble = static_cast<WobbleSuppressorBase*>(wobbleSuppressor_);
+ WobbleSuppressorBase *wobble = wobbleSuppressor_.get();
doWobbleSuppression_ = dynamic_cast<NullWobbleSuppressor*>(wobble) == 0;
// estimate motions
for (int i = -radius_; i <= 0; ++i)
at(i, frames_) = firstFrame;
- WobbleSuppressorBase *wobble = static_cast<WobbleSuppressorBase*>(wobbleSuppressor_);
+ WobbleSuppressorBase *wobble = wobbleSuppressor_.get();
doWobbleSuppression_ = dynamic_cast<NullWobbleSuppressor*>(wobble) == 0;
if (doWobbleSuppression_)
{
WobbleSuppressorBase::WobbleSuppressorBase() : motions_(0), stabilizationMotions_(0)
{
- setMotionEstimator(new KeypointBasedMotionEstimator(new MotionEstimatorRansacL2(MM_HOMOGRAPHY)));
+ setMotionEstimator(makePtr<KeypointBasedMotionEstimator>(makePtr<MotionEstimatorRansacL2>(MM_HOMOGRAPHY)));
}