Boring changes - samples.

This commit is contained in:
Roman Donchenko 2013-08-13 18:49:29 +04:00
parent 34af7eeb84
commit 62353b7980
19 changed files with 157 additions and 135 deletions

View File

@ -26,7 +26,7 @@ public:
Detector(detector) Detector(detector)
{ {
LOGD("CascadeDetectorAdapter::Detect::Detect"); LOGD("CascadeDetectorAdapter::Detect::Detect");
CV_Assert(!detector.empty()); CV_Assert(detector);
} }
void detect(const cv::Mat &Image, std::vector<cv::Rect> &objects) void detect(const cv::Mat &Image, std::vector<cv::Rect> &objects)
@ -57,11 +57,11 @@ struct DetectorAgregator
mainDetector(_mainDetector), mainDetector(_mainDetector),
trackingDetector(_trackingDetector) trackingDetector(_trackingDetector)
{ {
CV_Assert(!_mainDetector.empty()); CV_Assert(_mainDetector);
CV_Assert(!_trackingDetector.empty()); CV_Assert(_trackingDetector);
DetectionBasedTracker::Parameters DetectorParams; DetectionBasedTracker::Parameters DetectorParams;
tracker = new DetectionBasedTracker(mainDetector.ptr<DetectionBasedTracker::IDetector>(), trackingDetector.ptr<DetectionBasedTracker::IDetector>(), DetectorParams); tracker = makePtr<DetectionBasedTracker>(mainDetector, trackingDetector, DetectorParams);
} }
}; };
@ -77,8 +77,10 @@ JNIEXPORT jlong JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker
try try
{ {
cv::Ptr<CascadeDetectorAdapter> mainDetector = new CascadeDetectorAdapter(new CascadeClassifier(stdFileName)); cv::Ptr<CascadeDetectorAdapter> mainDetector = makePtr<CascadeDetectorAdapter>(
cv::Ptr<CascadeDetectorAdapter> trackingDetector = new CascadeDetectorAdapter(new CascadeClassifier(stdFileName)); makePtr<CascadeClassifier>(stdFileName));
cv::Ptr<CascadeDetectorAdapter> trackingDetector = makePtr<CascadeDetectorAdapter>(
makePtr<CascadeClassifier>(stdFileName));
result = (jlong)new DetectorAgregator(mainDetector, trackingDetector); result = (jlong)new DetectorAgregator(mainDetector, trackingDetector);
if (faceSize > 0) if (faceSize > 0)
{ {

View File

@ -2563,19 +2563,19 @@ int main(int argc, char** argv)
Ptr<FeatureDetector> featureDetector = FeatureDetector::create( ddmParams.detectorType ); Ptr<FeatureDetector> featureDetector = FeatureDetector::create( ddmParams.detectorType );
Ptr<DescriptorExtractor> descExtractor = DescriptorExtractor::create( ddmParams.descriptorType ); Ptr<DescriptorExtractor> descExtractor = DescriptorExtractor::create( ddmParams.descriptorType );
Ptr<BOWImgDescriptorExtractor> bowExtractor; Ptr<BOWImgDescriptorExtractor> bowExtractor;
if( featureDetector.empty() || descExtractor.empty() ) if( !featureDetector || !descExtractor )
{ {
cout << "featureDetector or descExtractor was not created" << endl; cout << "featureDetector or descExtractor was not created" << endl;
return -1; return -1;
} }
{ {
Ptr<DescriptorMatcher> descMatcher = DescriptorMatcher::create( ddmParams.matcherType ); Ptr<DescriptorMatcher> descMatcher = DescriptorMatcher::create( ddmParams.matcherType );
if( featureDetector.empty() || descExtractor.empty() || descMatcher.empty() ) if( !featureDetector || !descExtractor || !descMatcher )
{ {
cout << "descMatcher was not created" << endl; cout << "descMatcher was not created" << endl;
return -1; return -1;
} }
bowExtractor = new BOWImgDescriptorExtractor( descExtractor, descMatcher ); bowExtractor = makePtr<BOWImgDescriptorExtractor>( descExtractor, descMatcher );
} }
// Print configuration to screen // Print configuration to screen

View File

@ -35,7 +35,7 @@ int main(int argc, char** argv)
setNumThreads(8); setNumThreads(8);
Ptr<BackgroundSubtractor> fgbg = createBackgroundSubtractorGMG(20, 0.7); Ptr<BackgroundSubtractor> fgbg = createBackgroundSubtractorGMG(20, 0.7);
if (fgbg.empty()) if (!fgbg)
{ {
std::cerr << "Failed to create BackgroundSubtractor.GMG Algorithm." << std::endl; std::cerr << "Failed to create BackgroundSubtractor.GMG Algorithm." << std::endl;
return -1; return -1;

View File

@ -22,7 +22,7 @@ class CascadeDetectorAdapter: public DetectionBasedTracker::IDetector
IDetector(), IDetector(),
Detector(detector) Detector(detector)
{ {
CV_Assert(!detector.empty()); CV_Assert(detector);
} }
void detect(const cv::Mat &Image, std::vector<cv::Rect> &objects) void detect(const cv::Mat &Image, std::vector<cv::Rect> &objects)
@ -51,11 +51,11 @@ int main(int , char** )
} }
std::string cascadeFrontalfilename = "../../data/lbpcascades/lbpcascade_frontalface.xml"; std::string cascadeFrontalfilename = "../../data/lbpcascades/lbpcascade_frontalface.xml";
cv::Ptr<cv::CascadeClassifier> cascade = new cv::CascadeClassifier(cascadeFrontalfilename); cv::Ptr<cv::CascadeClassifier> cascade = makePtr<cv::CascadeClassifier>(cascadeFrontalfilename);
cv::Ptr<DetectionBasedTracker::IDetector> MainDetector = new CascadeDetectorAdapter(cascade); cv::Ptr<DetectionBasedTracker::IDetector> MainDetector = makePtr<CascadeDetectorAdapter>(cascade);
cascade = new cv::CascadeClassifier(cascadeFrontalfilename); cascade = makePtr<cv::CascadeClassifier>(cascadeFrontalfilename);
cv::Ptr<DetectionBasedTracker::IDetector> TrackingDetector = new CascadeDetectorAdapter(cascade); cv::Ptr<DetectionBasedTracker::IDetector> TrackingDetector = makePtr<CascadeDetectorAdapter>(cascade);
DetectionBasedTracker::Parameters params; DetectionBasedTracker::Parameters params;
DetectionBasedTracker Detector(MainDetector, TrackingDetector, params); DetectionBasedTracker Detector(MainDetector, TrackingDetector, params);

View File

@ -153,7 +153,7 @@ static void doIteration( const Mat& img1, Mat& img2, bool isWarpPerspective,
{ {
cout << "< Evaluate descriptor matcher..." << endl; cout << "< Evaluate descriptor matcher..." << endl;
vector<Point2f> curve; vector<Point2f> curve;
Ptr<GenericDescriptorMatcher> gdm = new VectorDescriptorMatcher( descriptorExtractor, descriptorMatcher ); Ptr<GenericDescriptorMatcher> gdm = makePtr<VectorDescriptorMatcher>( descriptorExtractor, descriptorMatcher );
evaluateGenericDescriptorMatcher( img1, img2, H12, keypoints1, keypoints2, 0, 0, curve, gdm ); evaluateGenericDescriptorMatcher( img1, img2, H12, keypoints1, keypoints2, 0, 0, curve, gdm );
Point2f firstPoint = *curve.begin(); Point2f firstPoint = *curve.begin();
@ -253,7 +253,7 @@ int main(int argc, char** argv)
int mactherFilterType = getMatcherFilterType( argv[4] ); int mactherFilterType = getMatcherFilterType( argv[4] );
bool eval = !isWarpPerspective ? false : (atoi(argv[6]) == 0 ? false : true); bool eval = !isWarpPerspective ? false : (atoi(argv[6]) == 0 ? false : true);
cout << ">" << endl; cout << ">" << endl;
if( detector.empty() || descriptorExtractor.empty() || descriptorMatcher.empty() ) if( !detector || !descriptorExtractor || !descriptorMatcher )
{ {
cout << "Can not create detector or descriptor exstractor or descriptor matcher of given types" << endl; cout << "Can not create detector or descriptor exstractor or descriptor matcher of given types" << endl;
return -1; return -1;

View File

@ -67,7 +67,7 @@ class CascadeDetectorAdapter: public DetectionBasedTracker::IDetector
CascadeDetectorAdapter(cv::Ptr<cv::CascadeClassifier> detector): CascadeDetectorAdapter(cv::Ptr<cv::CascadeClassifier> detector):
Detector(detector) Detector(detector)
{ {
CV_Assert(!detector.empty()); CV_Assert(detector);
} }
void detect(const cv::Mat &Image, std::vector<cv::Rect> &objects) void detect(const cv::Mat &Image, std::vector<cv::Rect> &objects)
@ -117,11 +117,11 @@ static int test_FaceDetector(int argc, char *argv[])
} }
std::string cascadeFrontalfilename=cascadefile; std::string cascadeFrontalfilename=cascadefile;
cv::Ptr<cv::CascadeClassifier> cascade = new cv::CascadeClassifier(cascadeFrontalfilename); cv::Ptr<cv::CascadeClassifier> cascade = makePtr<cv::CascadeClassifier>(cascadeFrontalfilename);
cv::Ptr<DetectionBasedTracker::IDetector> MainDetector = new CascadeDetectorAdapter(cascade); cv::Ptr<DetectionBasedTracker::IDetector> MainDetector = makePtr<CascadeDetectorAdapter>(cascade);
cascade = new cv::CascadeClassifier(cascadeFrontalfilename); cascade = makePtr<cv::CascadeClassifier>(cascadeFrontalfilename);
cv::Ptr<DetectionBasedTracker::IDetector> TrackingDetector = new CascadeDetectorAdapter(cascade); cv::Ptr<DetectionBasedTracker::IDetector> TrackingDetector = makePtr<CascadeDetectorAdapter>(cascade);
DetectionBasedTracker::Parameters params; DetectionBasedTracker::Parameters params;
DetectionBasedTracker fd(MainDetector, TrackingDetector, params); DetectionBasedTracker fd(MainDetector, TrackingDetector, params);

View File

@ -535,7 +535,7 @@ void DetectorQualityEvaluator::readAlgorithm ()
{ {
defaultDetector = FeatureDetector::create( algName ); defaultDetector = FeatureDetector::create( algName );
specificDetector = FeatureDetector::create( algName ); specificDetector = FeatureDetector::create( algName );
if( defaultDetector.empty() ) if( !defaultDetector )
{ {
printf( "Algorithm can not be read\n" ); printf( "Algorithm can not be read\n" );
exit(-1); exit(-1);
@ -769,14 +769,14 @@ void DescriptorQualityEvaluator::readAlgorithm( )
defaultDescMatcher = GenericDescriptorMatcher::create( algName ); defaultDescMatcher = GenericDescriptorMatcher::create( algName );
specificDescMatcher = GenericDescriptorMatcher::create( algName ); specificDescMatcher = GenericDescriptorMatcher::create( algName );
if( defaultDescMatcher.empty() ) if( !defaultDescMatcher )
{ {
Ptr<DescriptorExtractor> extractor = DescriptorExtractor::create( algName ); Ptr<DescriptorExtractor> extractor = DescriptorExtractor::create( algName );
Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create( matcherName ); Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create( matcherName );
defaultDescMatcher = new VectorDescriptorMatch( extractor, matcher ); defaultDescMatcher = makePtr<VectorDescriptorMatch>( extractor, matcher );
specificDescMatcher = new VectorDescriptorMatch( extractor, matcher ); specificDescMatcher = makePtr<VectorDescriptorMatch>( extractor, matcher );
if( extractor.empty() || matcher.empty() ) if( !extractor || !matcher )
{ {
printf("Algorithm can not be read\n"); printf("Algorithm can not be read\n");
exit(-1); exit(-1);
@ -881,8 +881,9 @@ public:
virtual void readAlgorithm( ) virtual void readAlgorithm( )
{ {
string classifierFile = data_path + "/features2d/calonder_classifier.rtc"; string classifierFile = data_path + "/features2d/calonder_classifier.rtc";
defaultDescMatcher = new VectorDescriptorMatch( new CalonderDescriptorExtractor<float>( classifierFile ), defaultDescMatcher = makePtr<VectorDescriptorMatch>(
new BFMatcher(NORM_L2) ); makePtr<CalonderDescriptorExtractor<float> >( classifierFile ),
makePtr<BFMatcher>(int(NORM_L2)));
specificDescMatcher = defaultDescMatcher; specificDescMatcher = defaultDescMatcher;
} }
}; };
@ -922,10 +923,11 @@ void OneWayDescriptorQualityTest::processRunParamsFile ()
readAllDatasetsRunParams(); readAllDatasetsRunParams();
OneWayDescriptorBase *base = new OneWayDescriptorBase(patchSize, poseCount, pcaFilename, Ptr<OneWayDescriptorBase> base(
trainPath, trainImagesList); new OneWayDescriptorBase(patchSize, poseCount, pcaFilename,
trainPath, trainImagesList));
OneWayDescriptorMatch *match = new OneWayDescriptorMatch (); Ptr<OneWayDescriptorMatch> match = makePtr<OneWayDescriptorMatch>();
match->initialize( OneWayDescriptorMatch::Params (), base ); match->initialize( OneWayDescriptorMatch::Params (), base );
defaultDescMatcher = match; defaultDescMatcher = match;
writeAllDatasetsRunParams(); writeAllDatasetsRunParams();
@ -958,18 +960,18 @@ int main( int argc, char** argv )
Ptr<BaseQualityEvaluator> evals[] = Ptr<BaseQualityEvaluator> evals[] =
{ {
new DetectorQualityEvaluator( "FAST", "quality-detector-fast" ), makePtr<DetectorQualityEvaluator>( "FAST", "quality-detector-fast" ),
new DetectorQualityEvaluator( "GFTT", "quality-detector-gftt" ), makePtr<DetectorQualityEvaluator>( "GFTT", "quality-detector-gftt" ),
new DetectorQualityEvaluator( "HARRIS", "quality-detector-harris" ), makePtr<DetectorQualityEvaluator>( "HARRIS", "quality-detector-harris" ),
new DetectorQualityEvaluator( "MSER", "quality-detector-mser" ), makePtr<DetectorQualityEvaluator>( "MSER", "quality-detector-mser" ),
new DetectorQualityEvaluator( "STAR", "quality-detector-star" ), makePtr<DetectorQualityEvaluator>( "STAR", "quality-detector-star" ),
new DetectorQualityEvaluator( "SIFT", "quality-detector-sift" ), makePtr<DetectorQualityEvaluator>( "SIFT", "quality-detector-sift" ),
new DetectorQualityEvaluator( "SURF", "quality-detector-surf" ), makePtr<DetectorQualityEvaluator>( "SURF", "quality-detector-surf" ),
new DescriptorQualityEvaluator( "SIFT", "quality-descriptor-sift", "BruteForce" ), makePtr<DescriptorQualityEvaluator>( "SIFT", "quality-descriptor-sift", "BruteForce" ),
new DescriptorQualityEvaluator( "SURF", "quality-descriptor-surf", "BruteForce" ), makePtr<DescriptorQualityEvaluator>( "SURF", "quality-descriptor-surf", "BruteForce" ),
new DescriptorQualityEvaluator( "FERN", "quality-descriptor-fern"), makePtr<DescriptorQualityEvaluator>( "FERN", "quality-descriptor-fern"),
new CalonderDescriptorQualityEvaluator() makePtr<CalonderDescriptorQualityEvaluator>()
}; };
for( size_t i = 0; i < sizeof(evals)/sizeof(evals[0]); i++ ) for( size_t i = 0; i < sizeof(evals)/sizeof(evals[0]); i++ )

View File

@ -131,11 +131,11 @@ int main(int argc, char * argv[]) {
//generate test data //generate test data
cout << "Extracting Test Data from images" << endl << cout << "Extracting Test Data from images" << endl <<
endl; endl;
Ptr<FeatureDetector> detector = Ptr<FeatureDetector> detector(
new DynamicAdaptedFeatureDetector( new DynamicAdaptedFeatureDetector(
AdjusterAdapter::create("STAR"), 130, 150, 5); AdjusterAdapter::create("STAR"), 130, 150, 5));
Ptr<DescriptorExtractor> extractor = Ptr<DescriptorExtractor> extractor(
new SurfDescriptorExtractor(1000, 4, 2, false, true); new SurfDescriptorExtractor(1000, 4, 2, false, true));
Ptr<DescriptorMatcher> matcher = Ptr<DescriptorMatcher> matcher =
DescriptorMatcher::create("FlannBased"); DescriptorMatcher::create("FlannBased");
@ -183,8 +183,8 @@ int main(int argc, char * argv[]) {
endl; endl;
Ptr<of2::FabMap> fabmap; Ptr<of2::FabMap> fabmap;
fabmap = new of2::FabMap2(tree, 0.39, 0, of2::FabMap::SAMPLED | fabmap.reset(new of2::FabMap2(tree, 0.39, 0, of2::FabMap::SAMPLED |
of2::FabMap::CHOW_LIU); of2::FabMap::CHOW_LIU));
fabmap->addTraining(trainData); fabmap->addTraining(trainData);
vector<of2::IMatch> matches; vector<of2::IMatch> matches;

View File

@ -33,7 +33,7 @@ int main(int argc, char** argv)
std::string params_filename = std::string(argv[4]); std::string params_filename = std::string(argv[4]);
Ptr<GenericDescriptorMatcher> descriptorMatcher = GenericDescriptorMatcher::create(alg_name, params_filename); Ptr<GenericDescriptorMatcher> descriptorMatcher = GenericDescriptorMatcher::create(alg_name, params_filename);
if( descriptorMatcher.empty() ) if( !descriptorMatcher )
{ {
printf ("Cannot create descriptor\n"); printf ("Cannot create descriptor\n");
return 0; return 0;

View File

@ -31,8 +31,8 @@ int main( int argc, char** argv )
help(); help();
const char* imagename = argc > 1 ? argv[1] : "lena.jpg"; const char* imagename = argc > 1 ? argv[1] : "lena.jpg";
#if DEMO_MIXED_API_USE #if DEMO_MIXED_API_USE
Ptr<IplImage> iplimg = cvLoadImage(imagename); // Ptr<T> is safe ref-conting pointer class Ptr<IplImage> iplimg(cvLoadImage(imagename)); // Ptr<T> is safe ref-counting pointer class
if(iplimg.empty()) if(!iplimg)
{ {
fprintf(stderr, "Can not load image %s\n", imagename); fprintf(stderr, "Can not load image %s\n", imagename);
return -1; return -1;

View File

@ -114,7 +114,7 @@ private:
// Functions to store detector and templates in single XML/YAML file // Functions to store detector and templates in single XML/YAML file
static cv::Ptr<cv::linemod::Detector> readLinemod(const std::string& filename) static cv::Ptr<cv::linemod::Detector> readLinemod(const std::string& filename)
{ {
cv::Ptr<cv::linemod::Detector> detector = new cv::linemod::Detector; cv::Ptr<cv::linemod::Detector> detector = cv::makePtr<cv::linemod::Detector>();
cv::FileStorage fs(filename, cv::FileStorage::READ); cv::FileStorage fs(filename, cv::FileStorage::READ);
detector->read(fs.root()); detector->read(fs.root());

View File

@ -84,7 +84,7 @@ static bool createDetectorDescriptorMatcher( const string& detectorType, const s
descriptorMatcher = DescriptorMatcher::create( matcherType ); descriptorMatcher = DescriptorMatcher::create( matcherType );
cout << ">" << endl; cout << ">" << endl;
bool isCreated = !( featureDetector.empty() || descriptorExtractor.empty() || descriptorMatcher.empty() ); bool isCreated = featureDetector && descriptorExtractor && descriptorMatcher;
if( !isCreated ) if( !isCreated )
cout << "Can not create feature detector or descriptor extractor or descriptor matcher of given types." << endl << ">" << endl; cout << "Can not create feature detector or descriptor extractor or descriptor matcher of given types." << endl << ">" << endl;

View File

@ -358,14 +358,14 @@ int main(int argc, char* argv[])
{ {
#ifdef HAVE_OPENCV_NONFREE #ifdef HAVE_OPENCV_NONFREE
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0) if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
finder = new SurfFeaturesFinderGpu(); finder = makePtr<SurfFeaturesFinderGpu>();
else else
#endif #endif
finder = new SurfFeaturesFinder(); finder = makePtr<SurfFeaturesFinder>();
} }
else if (features_type == "orb") else if (features_type == "orb")
{ {
finder = new OrbFeaturesFinder(); finder = makePtr<OrbFeaturesFinder>();
} }
else else
{ {
@ -484,8 +484,8 @@ int main(int argc, char* argv[])
} }
Ptr<detail::BundleAdjusterBase> adjuster; Ptr<detail::BundleAdjusterBase> adjuster;
if (ba_cost_func == "reproj") adjuster = new detail::BundleAdjusterReproj(); if (ba_cost_func == "reproj") adjuster = makePtr<detail::BundleAdjusterReproj>();
else if (ba_cost_func == "ray") adjuster = new detail::BundleAdjusterRay(); else if (ba_cost_func == "ray") adjuster = makePtr<detail::BundleAdjusterRay>();
else else
{ {
cout << "Unknown bundle adjustment cost function: '" << ba_cost_func << "'.\n"; cout << "Unknown bundle adjustment cost function: '" << ba_cost_func << "'.\n";
@ -555,31 +555,49 @@ int main(int argc, char* argv[])
#ifdef HAVE_OPENCV_GPUWARPING #ifdef HAVE_OPENCV_GPUWARPING
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0) if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
{ {
if (warp_type == "plane") warper_creator = new cv::PlaneWarperGpu(); if (warp_type == "plane")
else if (warp_type == "cylindrical") warper_creator = new cv::CylindricalWarperGpu(); warper_creator = makePtr<cv::PlaneWarperGpu>();
else if (warp_type == "spherical") warper_creator = new cv::SphericalWarperGpu(); else if (warp_type == "cylindrical")
warper_creator = makePtr<cv::CylindricalWarperGpu>();
else if (warp_type == "spherical")
warper_creator = makePtr<cv::SphericalWarperGpu>();
} }
else else
#endif #endif
{ {
if (warp_type == "plane") warper_creator = new cv::PlaneWarper(); if (warp_type == "plane")
else if (warp_type == "cylindrical") warper_creator = new cv::CylindricalWarper(); warper_creator = makePtr<cv::PlaneWarper>();
else if (warp_type == "spherical") warper_creator = new cv::SphericalWarper(); else if (warp_type == "cylindrical")
else if (warp_type == "fisheye") warper_creator = new cv::FisheyeWarper(); warper_creator = makePtr<cv::CylindricalWarper>();
else if (warp_type == "stereographic") warper_creator = new cv::StereographicWarper(); else if (warp_type == "spherical")
else if (warp_type == "compressedPlaneA2B1") warper_creator = new cv::CompressedRectilinearWarper(2, 1); warper_creator = makePtr<cv::SphericalWarper>();
else if (warp_type == "compressedPlaneA1.5B1") warper_creator = new cv::CompressedRectilinearWarper(1.5, 1); else if (warp_type == "fisheye")
else if (warp_type == "compressedPlanePortraitA2B1") warper_creator = new cv::CompressedRectilinearPortraitWarper(2, 1); warper_creator = makePtr<cv::FisheyeWarper>();
else if (warp_type == "compressedPlanePortraitA1.5B1") warper_creator = new cv::CompressedRectilinearPortraitWarper(1.5, 1); else if (warp_type == "stereographic")
else if (warp_type == "paniniA2B1") warper_creator = new cv::PaniniWarper(2, 1); warper_creator = makePtr<cv::StereographicWarper>();
else if (warp_type == "paniniA1.5B1") warper_creator = new cv::PaniniWarper(1.5, 1); else if (warp_type == "compressedPlaneA2B1")
else if (warp_type == "paniniPortraitA2B1") warper_creator = new cv::PaniniPortraitWarper(2, 1); warper_creator = makePtr<cv::CompressedRectilinearWarper>(2.0f, 1.0f);
else if (warp_type == "paniniPortraitA1.5B1") warper_creator = new cv::PaniniPortraitWarper(1.5, 1); else if (warp_type == "compressedPlaneA1.5B1")
else if (warp_type == "mercator") warper_creator = new cv::MercatorWarper(); warper_creator = makePtr<cv::CompressedRectilinearWarper>(1.5f, 1.0f);
else if (warp_type == "transverseMercator") warper_creator = new cv::TransverseMercatorWarper(); else if (warp_type == "compressedPlanePortraitA2B1")
warper_creator = makePtr<cv::CompressedRectilinearPortraitWarper>(2.0f, 1.0f);
else if (warp_type == "compressedPlanePortraitA1.5B1")
warper_creator = makePtr<cv::CompressedRectilinearPortraitWarper>(1.5f, 1.0f);
else if (warp_type == "paniniA2B1")
warper_creator = makePtr<cv::PaniniWarper>(2.0f, 1.0f);
else if (warp_type == "paniniA1.5B1")
warper_creator = makePtr<cv::PaniniWarper>(1.5f, 1.0f);
else if (warp_type == "paniniPortraitA2B1")
warper_creator = makePtr<cv::PaniniPortraitWarper>(2.0f, 1.0f);
else if (warp_type == "paniniPortraitA1.5B1")
warper_creator = makePtr<cv::PaniniPortraitWarper>(1.5f, 1.0f);
else if (warp_type == "mercator")
warper_creator = makePtr<cv::MercatorWarper>();
else if (warp_type == "transverseMercator")
warper_creator = makePtr<cv::TransverseMercatorWarper>();
} }
if (warper_creator.empty()) if (!warper_creator)
{ {
cout << "Can't create the following warper '" << warp_type << "'\n"; cout << "Can't create the following warper '" << warp_type << "'\n";
return 1; return 1;
@ -612,32 +630,32 @@ int main(int argc, char* argv[])
Ptr<SeamFinder> seam_finder; Ptr<SeamFinder> seam_finder;
if (seam_find_type == "no") if (seam_find_type == "no")
seam_finder = new detail::NoSeamFinder(); seam_finder = makePtr<detail::NoSeamFinder>();
else if (seam_find_type == "voronoi") else if (seam_find_type == "voronoi")
seam_finder = new detail::VoronoiSeamFinder(); seam_finder = makePtr<detail::VoronoiSeamFinder>();
else if (seam_find_type == "gc_color") else if (seam_find_type == "gc_color")
{ {
#ifdef HAVE_OPENCV_GPU #ifdef HAVE_OPENCV_GPU
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0) if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
seam_finder = new detail::GraphCutSeamFinderGpu(GraphCutSeamFinderBase::COST_COLOR); seam_finder = makePtr<detail::GraphCutSeamFinderGpu>(GraphCutSeamFinderBase::COST_COLOR);
else else
#endif #endif
seam_finder = new detail::GraphCutSeamFinder(GraphCutSeamFinderBase::COST_COLOR); seam_finder = makePtr<detail::GraphCutSeamFinder>(GraphCutSeamFinderBase::COST_COLOR);
} }
else if (seam_find_type == "gc_colorgrad") else if (seam_find_type == "gc_colorgrad")
{ {
#ifdef HAVE_OPENCV_GPU #ifdef HAVE_OPENCV_GPU
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0) if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
seam_finder = new detail::GraphCutSeamFinderGpu(GraphCutSeamFinderBase::COST_COLOR_GRAD); seam_finder = makePtr<detail::GraphCutSeamFinderGpu>(GraphCutSeamFinderBase::COST_COLOR_GRAD);
else else
#endif #endif
seam_finder = new detail::GraphCutSeamFinder(GraphCutSeamFinderBase::COST_COLOR_GRAD); seam_finder = makePtr<detail::GraphCutSeamFinder>(GraphCutSeamFinderBase::COST_COLOR_GRAD);
} }
else if (seam_find_type == "dp_color") else if (seam_find_type == "dp_color")
seam_finder = new detail::DpSeamFinder(DpSeamFinder::COLOR); seam_finder = makePtr<detail::DpSeamFinder>(DpSeamFinder::COLOR);
else if (seam_find_type == "dp_colorgrad") else if (seam_find_type == "dp_colorgrad")
seam_finder = new detail::DpSeamFinder(DpSeamFinder::COLOR_GRAD); seam_finder = makePtr<detail::DpSeamFinder>(DpSeamFinder::COLOR_GRAD);
if (seam_finder.empty()) if (!seam_finder)
{ {
cout << "Can't create the following seam finder '" << seam_find_type << "'\n"; cout << "Can't create the following seam finder '" << seam_find_type << "'\n";
return 1; return 1;
@ -735,7 +753,7 @@ int main(int argc, char* argv[])
resize(dilated_mask, seam_mask, mask_warped.size()); resize(dilated_mask, seam_mask, mask_warped.size());
mask_warped = seam_mask & mask_warped; mask_warped = seam_mask & mask_warped;
if (blender.empty()) if (!blender)
{ {
blender = Blender::createDefault(blend_type, try_gpu); blender = Blender::createDefault(blend_type, try_gpu);
Size dst_sz = resultRoi(corners, sizes).size(); Size dst_sz = resultRoi(corners, sizes).size();
@ -744,13 +762,13 @@ int main(int argc, char* argv[])
blender = Blender::createDefault(Blender::NO, try_gpu); blender = Blender::createDefault(Blender::NO, try_gpu);
else if (blend_type == Blender::MULTI_BAND) else if (blend_type == Blender::MULTI_BAND)
{ {
MultiBandBlender* mb = dynamic_cast<MultiBandBlender*>(static_cast<Blender*>(blender)); MultiBandBlender* mb = dynamic_cast<MultiBandBlender*>(blender.get());
mb->setNumBands(static_cast<int>(ceil(log(blend_width)/log(2.)) - 1.)); mb->setNumBands(static_cast<int>(ceil(log(blend_width)/log(2.)) - 1.));
LOGLN("Multi-band blender, number of bands: " << mb->numBands()); LOGLN("Multi-band blender, number of bands: " << mb->numBands());
} }
else if (blend_type == Blender::FEATHER) else if (blend_type == Blender::FEATHER)
{ {
FeatherBlender* fb = dynamic_cast<FeatherBlender*>(static_cast<Blender*>(blender)); FeatherBlender* fb = dynamic_cast<FeatherBlender*>(blender.get());
fb->setSharpness(1.f/blend_width); fb->setSharpness(1.f/blend_width);
LOGLN("Feather blender, sharpness: " << fb->sharpness()); LOGLN("Feather blender, sharpness: " << fb->sharpness());
} }

View File

@ -32,8 +32,8 @@ int main( int argc, char** argv )
const char* imagename = argc > 1 ? argv[1] : "lena.jpg"; const char* imagename = argc > 1 ? argv[1] : "lena.jpg";
#ifdef DEMO_MIXED_API_USE #ifdef DEMO_MIXED_API_USE
Ptr<IplImage> IplI = cvLoadImage(imagename); // Ptr<T> is safe ref-counting pointer class Ptr<IplImage> IplI(cvLoadImage(imagename)); // Ptr<T> is a safe ref-counting pointer class
if(IplI.empty()) if(!IplI)
{ {
cerr << "Can not load image " << imagename << endl; cerr << "Can not load image " << imagename << endl;
return -1; return -1;

View File

@ -152,7 +152,7 @@ int main(int ac, char ** av)
Mat train_desc, query_desc; Mat train_desc, query_desc;
const int DESIRED_FTRS = 500; const int DESIRED_FTRS = 500;
GridAdaptedFeatureDetector detector(new FastFeatureDetector(10, true), DESIRED_FTRS, 4, 4); GridAdaptedFeatureDetector detector(makePtr<FastFeatureDetector>(10, true), DESIRED_FTRS, 4, 4);
Mat H_prev = Mat::eye(3, 3, CV_32FC1); Mat H_prev = Mat::eye(3, 3, CV_32FC1);
for (;;) for (;;)

View File

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

View File

@ -1261,7 +1261,7 @@ TEST(FarnebackOpticalFlow)
namespace cv namespace cv
{ {
template<> void Ptr<CvBGStatModel>::delete_obj() template<> void DefaultDeleter<CvBGStatModel>::operator ()(CvBGStatModel* obj) const
{ {
cvReleaseBGStatModel(&obj); cvReleaseBGStatModel(&obj);
} }

View File

@ -291,11 +291,11 @@ StereoMultiGpuStream::StereoMultiGpuStream()
{ {
gpu::setDevice(0); gpu::setDevice(0);
d_algs[0] = gpu::createStereoBM(256); d_algs[0] = gpu::createStereoBM(256);
streams[0] = new Stream; streams[0] = makePtr<Stream>();
gpu::setDevice(1); gpu::setDevice(1);
d_algs[1] = gpu::createStereoBM(256); d_algs[1] = gpu::createStereoBM(256);
streams[1] = new Stream; streams[1] = makePtr<Stream>();
} }
StereoMultiGpuStream::~StereoMultiGpuStream() StereoMultiGpuStream::~StereoMultiGpuStream()

View File

@ -53,7 +53,7 @@ static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name, bool useGpu)
{ {
cerr << "Incorrect Optical Flow algorithm - " << name << endl; cerr << "Incorrect Optical Flow algorithm - " << name << endl;
} }
return 0; return Ptr<DenseOpticalFlowExt>();
} }
#if defined(HAVE_OPENCV_OCL) #if defined(HAVE_OPENCV_OCL)
static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name) static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name)
@ -73,7 +73,7 @@ static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name)
else if (name == "brox") else if (name == "brox")
{ {
std::cout<<"brox has not been implemented!\n"; std::cout<<"brox has not been implemented!\n";
return NULL; return Ptr<DenseOpticalFlowExt>();
} }
else if (name == "pyrlk") else if (name == "pyrlk")
return createOptFlow_PyrLK_OCL(); return createOptFlow_PyrLK_OCL();
@ -81,7 +81,7 @@ static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name)
{ {
cerr << "Incorrect Optical Flow algorithm - " << name << endl; cerr << "Incorrect Optical Flow algorithm - " << name << endl;
} }
return 0; return Ptr<DenseOpticalFlowExt>();
} }
#endif #endif
int main(int argc, const char* argv[]) int main(int argc, const char* argv[])
@ -197,7 +197,7 @@ int main(int argc, const char* argv[])
frameSource.release(); frameSource.release();
} }
} }
if (frameSource.empty()) if (!frameSource)
frameSource = createFrameSource_Video(inputVideoName); frameSource = createFrameSource_Video(inputVideoName);
// skip first frame, it is usually corrupted // skip first frame, it is usually corrupted