Boring changes - samples.
This commit is contained in:
@@ -193,7 +193,7 @@ public:
|
||||
|
||||
virtual Ptr<ImageMotionEstimatorBase> build()
|
||||
{
|
||||
MotionEstimatorRansacL2 *est = new MotionEstimatorRansacL2(motionModel(arg(prefix + "model")));
|
||||
Ptr<MotionEstimatorRansacL2> est = makePtr<MotionEstimatorRansacL2>(motionModel(arg(prefix + "model")));
|
||||
|
||||
RansacParams ransac = est->ransacParams();
|
||||
if (arg(prefix + "subset") != "auto")
|
||||
@@ -205,10 +205,10 @@ public:
|
||||
|
||||
est->setMinInlierRatio(argf(prefix + "min-inlier-ratio"));
|
||||
|
||||
Ptr<IOutlierRejector> outlierRejector = new NullOutlierRejector();
|
||||
Ptr<IOutlierRejector> outlierRejector = makePtr<NullOutlierRejector>();
|
||||
if (arg(prefix + "local-outlier-rejection") == "yes")
|
||||
{
|
||||
TranslationBasedLocalOutlierRejector *tblor = new TranslationBasedLocalOutlierRejector();
|
||||
Ptr<TranslationBasedLocalOutlierRejector> tblor = makePtr<TranslationBasedLocalOutlierRejector>();
|
||||
RansacParams ransacParams = tblor->ransacParams();
|
||||
if (arg(prefix + "thresh") != "auto")
|
||||
ransacParams.thresh = argf(prefix + "thresh");
|
||||
@@ -219,14 +219,14 @@ public:
|
||||
#if defined(HAVE_OPENCV_GPUIMGPROC) && defined(HAVE_OPENCV_GPU) && defined(HAVE_OPENCV_GPUOPTFLOW)
|
||||
if (gpu)
|
||||
{
|
||||
KeypointBasedMotionEstimatorGpu *kbest = new KeypointBasedMotionEstimatorGpu(est);
|
||||
Ptr<KeypointBasedMotionEstimatorGpu> kbest = makePtr<KeypointBasedMotionEstimatorGpu>(est);
|
||||
kbest->setOutlierRejector(outlierRejector);
|
||||
return kbest;
|
||||
}
|
||||
#endif
|
||||
|
||||
KeypointBasedMotionEstimator *kbest = new KeypointBasedMotionEstimator(est);
|
||||
kbest->setDetector(new GoodFeaturesToTrackDetector(argi(prefix + "nkps")));
|
||||
Ptr<KeypointBasedMotionEstimator> kbest = makePtr<KeypointBasedMotionEstimator>(est);
|
||||
kbest->setDetector(makePtr<GoodFeaturesToTrackDetector>(argi(prefix + "nkps")));
|
||||
kbest->setOutlierRejector(outlierRejector);
|
||||
return kbest;
|
||||
}
|
||||
@@ -244,12 +244,12 @@ public:
|
||||
|
||||
virtual Ptr<ImageMotionEstimatorBase> build()
|
||||
{
|
||||
MotionEstimatorL1 *est = new MotionEstimatorL1(motionModel(arg(prefix + "model")));
|
||||
Ptr<MotionEstimatorL1> est = makePtr<MotionEstimatorL1>(motionModel(arg(prefix + "model")));
|
||||
|
||||
Ptr<IOutlierRejector> outlierRejector = new NullOutlierRejector();
|
||||
Ptr<IOutlierRejector> outlierRejector = makePtr<NullOutlierRejector>();
|
||||
if (arg(prefix + "local-outlier-rejection") == "yes")
|
||||
{
|
||||
TranslationBasedLocalOutlierRejector *tblor = new TranslationBasedLocalOutlierRejector();
|
||||
Ptr<TranslationBasedLocalOutlierRejector> tblor = makePtr<TranslationBasedLocalOutlierRejector>();
|
||||
RansacParams ransacParams = tblor->ransacParams();
|
||||
if (arg(prefix + "thresh") != "auto")
|
||||
ransacParams.thresh = argf(prefix + "thresh");
|
||||
@@ -260,14 +260,14 @@ public:
|
||||
#if defined(HAVE_OPENCV_GPUIMGPROC) && defined(HAVE_OPENCV_GPU) && defined(HAVE_OPENCV_GPUOPTFLOW)
|
||||
if (gpu)
|
||||
{
|
||||
KeypointBasedMotionEstimatorGpu *kbest = new KeypointBasedMotionEstimatorGpu(est);
|
||||
Ptr<KeypointBasedMotionEstimatorGpu> kbest = makePtr<KeypointBasedMotionEstimatorGpu>(est);
|
||||
kbest->setOutlierRejector(outlierRejector);
|
||||
return kbest;
|
||||
}
|
||||
#endif
|
||||
|
||||
KeypointBasedMotionEstimator *kbest = new KeypointBasedMotionEstimator(est);
|
||||
kbest->setDetector(new GoodFeaturesToTrackDetector(argi(prefix + "nkps")));
|
||||
Ptr<KeypointBasedMotionEstimator> kbest = makePtr<KeypointBasedMotionEstimator>(est);
|
||||
kbest->setDetector(makePtr<GoodFeaturesToTrackDetector>(argi(prefix + "nkps")));
|
||||
kbest->setOutlierRejector(outlierRejector);
|
||||
return kbest;
|
||||
}
|
||||
@@ -363,7 +363,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
// get source video parameters
|
||||
|
||||
VideoFileSource *source = new VideoFileSource(inputPath);
|
||||
Ptr<VideoFileSource> source = makePtr<VideoFileSource>(inputPath);
|
||||
cout << "frame count (rough): " << source->count() << endl;
|
||||
if (arg("fps") == "auto")
|
||||
outputFps = source->fps();
|
||||
@@ -374,15 +374,15 @@ int main(int argc, const char **argv)
|
||||
|
||||
Ptr<IMotionEstimatorBuilder> motionEstBuilder;
|
||||
if (arg("lin-prog-motion-est") == "yes")
|
||||
motionEstBuilder = new MotionEstimatorL1Builder(cmd, arg("gpu") == "yes");
|
||||
motionEstBuilder.reset(new MotionEstimatorL1Builder(cmd, arg("gpu") == "yes"));
|
||||
else
|
||||
motionEstBuilder = new MotionEstimatorRansacL2Builder(cmd, arg("gpu") == "yes");
|
||||
motionEstBuilder.reset(new MotionEstimatorRansacL2Builder(cmd, arg("gpu") == "yes"));
|
||||
|
||||
Ptr<IMotionEstimatorBuilder> wsMotionEstBuilder;
|
||||
if (arg("ws-lp") == "yes")
|
||||
wsMotionEstBuilder = new MotionEstimatorL1Builder(cmd, arg("gpu") == "yes", "ws-");
|
||||
wsMotionEstBuilder.reset(new MotionEstimatorL1Builder(cmd, arg("gpu") == "yes", "ws-"));
|
||||
else
|
||||
wsMotionEstBuilder = new MotionEstimatorRansacL2Builder(cmd, arg("gpu") == "yes", "ws-");
|
||||
wsMotionEstBuilder.reset(new MotionEstimatorRansacL2Builder(cmd, arg("gpu") == "yes", "ws-"));
|
||||
|
||||
// determine whether we must use one pass or two pass stabilizer
|
||||
bool isTwoPass =
|
||||
@@ -400,7 +400,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
if (arg("lin-prog-stab") == "yes")
|
||||
{
|
||||
LpMotionStabilizer *stab = new LpMotionStabilizer();
|
||||
Ptr<LpMotionStabilizer> stab = makePtr<LpMotionStabilizer>();
|
||||
stab->setFrameSize(Size(source->width(), source->height()));
|
||||
stab->setTrimRatio(arg("lps-trim-ratio") == "auto" ? argf("trim-ratio") : argf("lps-trim-ratio"));
|
||||
stab->setWeight1(argf("lps-w1"));
|
||||
@@ -410,18 +410,18 @@ int main(int argc, const char **argv)
|
||||
twoPassStabilizer->setMotionStabilizer(stab);
|
||||
}
|
||||
else if (arg("stdev") == "auto")
|
||||
twoPassStabilizer->setMotionStabilizer(new GaussianMotionFilter(argi("radius")));
|
||||
twoPassStabilizer->setMotionStabilizer(makePtr<GaussianMotionFilter>(argi("radius")));
|
||||
else
|
||||
twoPassStabilizer->setMotionStabilizer(new GaussianMotionFilter(argi("radius"), argf("stdev")));
|
||||
twoPassStabilizer->setMotionStabilizer(makePtr<GaussianMotionFilter>(argi("radius"), argf("stdev")));
|
||||
|
||||
// init wobble suppressor if necessary
|
||||
|
||||
if (arg("wobble-suppress") == "yes")
|
||||
{
|
||||
MoreAccurateMotionWobbleSuppressorBase *ws = new MoreAccurateMotionWobbleSuppressor();
|
||||
Ptr<MoreAccurateMotionWobbleSuppressorBase> ws = makePtr<MoreAccurateMotionWobbleSuppressor>();
|
||||
if (arg("gpu") == "yes")
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
ws = new MoreAccurateMotionWobbleSuppressorGpu();
|
||||
ws = makePtr<MoreAccurateMotionWobbleSuppressorGpu>();
|
||||
#else
|
||||
throw runtime_error("OpenCV is built without GPU support");
|
||||
#endif
|
||||
@@ -433,12 +433,12 @@ int main(int argc, const char **argv)
|
||||
MotionModel model = ws->motionEstimator()->motionModel();
|
||||
if (arg("load-motions2") != "no")
|
||||
{
|
||||
ws->setMotionEstimator(new FromFileMotionReader(arg("load-motions2")));
|
||||
ws->setMotionEstimator(makePtr<FromFileMotionReader>(arg("load-motions2")));
|
||||
ws->motionEstimator()->setMotionModel(model);
|
||||
}
|
||||
if (arg("save-motions2") != "no")
|
||||
{
|
||||
ws->setMotionEstimator(new ToFileMotionWriter(arg("save-motions2"), ws->motionEstimator()));
|
||||
ws->setMotionEstimator(makePtr<ToFileMotionWriter>(arg("save-motions2"), ws->motionEstimator()));
|
||||
ws->motionEstimator()->setMotionModel(model);
|
||||
}
|
||||
}
|
||||
@@ -450,26 +450,26 @@ int main(int argc, const char **argv)
|
||||
OnePassStabilizer *onePassStabilizer = new OnePassStabilizer();
|
||||
stabilizer = onePassStabilizer;
|
||||
if (arg("stdev") == "auto")
|
||||
onePassStabilizer->setMotionFilter(new GaussianMotionFilter(argi("radius")));
|
||||
onePassStabilizer->setMotionFilter(makePtr<GaussianMotionFilter>(argi("radius")));
|
||||
else
|
||||
onePassStabilizer->setMotionFilter(new GaussianMotionFilter(argi("radius"), argf("stdev")));
|
||||
onePassStabilizer->setMotionFilter(makePtr<GaussianMotionFilter>(argi("radius"), argf("stdev")));
|
||||
}
|
||||
|
||||
stabilizer->setFrameSource(source);
|
||||
stabilizer->setMotionEstimator(motionEstBuilder->build());
|
||||
|
||||
// cast stabilizer to simple frame source interface to read stabilized frames
|
||||
stabilizedFrames = dynamic_cast<IFrameSource*>(stabilizer);
|
||||
stabilizedFrames.reset(dynamic_cast<IFrameSource*>(stabilizer));
|
||||
|
||||
MotionModel model = stabilizer->motionEstimator()->motionModel();
|
||||
if (arg("load-motions") != "no")
|
||||
{
|
||||
stabilizer->setMotionEstimator(new FromFileMotionReader(arg("load-motions")));
|
||||
stabilizer->setMotionEstimator(makePtr<FromFileMotionReader>(arg("load-motions")));
|
||||
stabilizer->motionEstimator()->setMotionModel(model);
|
||||
}
|
||||
if (arg("save-motions") != "no")
|
||||
{
|
||||
stabilizer->setMotionEstimator(new ToFileMotionWriter(arg("save-motions"), stabilizer->motionEstimator()));
|
||||
stabilizer->setMotionEstimator(makePtr<ToFileMotionWriter>(arg("save-motions"), stabilizer->motionEstimator()));
|
||||
stabilizer->motionEstimator()->setMotionModel(model);
|
||||
}
|
||||
|
||||
@@ -478,7 +478,7 @@ int main(int argc, const char **argv)
|
||||
// init deblurer
|
||||
if (arg("deblur") == "yes")
|
||||
{
|
||||
WeightingDeblurer *deblurer = new WeightingDeblurer();
|
||||
Ptr<WeightingDeblurer> deblurer = makePtr<WeightingDeblurer>();
|
||||
deblurer->setRadius(argi("radius"));
|
||||
deblurer->setSensitivity(argf("deblur-sens"));
|
||||
stabilizer->setDeblurer(deblurer);
|
||||
@@ -503,22 +503,22 @@ int main(int argc, const char **argv)
|
||||
Ptr<InpainterBase> inpainters_(inpainters);
|
||||
if (arg("mosaic") == "yes")
|
||||
{
|
||||
ConsistentMosaicInpainter *inp = new ConsistentMosaicInpainter();
|
||||
Ptr<ConsistentMosaicInpainter> inp = makePtr<ConsistentMosaicInpainter>();
|
||||
inp->setStdevThresh(argf("mosaic-stdev"));
|
||||
inpainters->pushBack(inp);
|
||||
}
|
||||
if (arg("motion-inpaint") == "yes")
|
||||
{
|
||||
MotionInpainter *inp = new MotionInpainter();
|
||||
Ptr<MotionInpainter> inp = makePtr<MotionInpainter>();
|
||||
inp->setDistThreshold(argf("mi-dist-thresh"));
|
||||
inpainters->pushBack(inp);
|
||||
}
|
||||
if (arg("color-inpaint") == "average")
|
||||
inpainters->pushBack(new ColorAverageInpainter());
|
||||
inpainters->pushBack(makePtr<ColorAverageInpainter>());
|
||||
else if (arg("color-inpaint") == "ns")
|
||||
inpainters->pushBack(new ColorInpainter(INPAINT_NS, argd("ci-radius")));
|
||||
inpainters->pushBack(makePtr<ColorInpainter>(int(INPAINT_NS), argd("ci-radius")));
|
||||
else if (arg("color-inpaint") == "telea")
|
||||
inpainters->pushBack(new ColorInpainter(INPAINT_TELEA, argd("ci-radius")));
|
||||
inpainters->pushBack(makePtr<ColorInpainter>(int(INPAINT_TELEA), argd("ci-radius")));
|
||||
else if (arg("color-inpaint") != "no")
|
||||
throw runtime_error("unknown color inpainting method: " + arg("color-inpaint"));
|
||||
if (!inpainters->empty())
|
||||
|
Reference in New Issue
Block a user