From 34127ba80f4394457c5121a814a180e66d900d7d Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:24:30 +0400 Subject: [PATCH] Boring changes - contrib. --- .../contrib/src/detection_based_tracker.cpp | 24 +++++++++---------- modules/contrib/src/facerec.cpp | 6 ++--- modules/contrib/src/featuretracker.cpp | 6 ++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/contrib/src/detection_based_tracker.cpp b/modules/contrib/src/detection_based_tracker.cpp index 91bb0b1710..27807290af 100644 --- a/modules/contrib/src/detection_based_tracker.cpp +++ b/modules/contrib/src/detection_based_tracker.cpp @@ -128,7 +128,7 @@ cv::DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork(Detectio stateThread(STATE_THREAD_STOPPED), timeWhenDetectingThreadStartedWork(-1) { - CV_Assert(!_detector.empty()); + CV_Assert(_detector); cascadeInThread = _detector; @@ -462,11 +462,11 @@ cv::DetectionBasedTracker::DetectionBasedTracker(cv::Ptr mainDetector cascadeForTracking(trackingDetector) { CV_Assert( (params.maxTrackLifetime >= 0) -// && (!mainDetector.empty()) - && (!trackingDetector.empty()) ); +// && mainDetector + && trackingDetector ); - if (!mainDetector.empty()) { - separateDetectionWork = new SeparateDetectionWork(*this, mainDetector); + if (mainDetector) { + separateDetectionWork.reset(new SeparateDetectionWork(*this, mainDetector)); } weightsPositionsSmoothing.push_back(1); @@ -483,7 +483,7 @@ void DetectionBasedTracker::process(const Mat& imageGray) { CV_Assert(imageGray.type()==CV_8UC1); - if ( (!separateDetectionWork.empty()) && (!separateDetectionWork->isWorking()) ) { + if ( separateDetectionWork && !separateDetectionWork->isWorking() ) { separateDetectionWork->run(); } @@ -501,7 +501,7 @@ void DetectionBasedTracker::process(const Mat& imageGray) std::vector rectsWhereRegions; bool shouldHandleResult=false; - if (!separateDetectionWork.empty()) { + if (separateDetectionWork) { shouldHandleResult = separateDetectionWork->communicateWithDetectingThread(imageGray, rectsWhereRegions); } @@ -589,7 +589,7 @@ void cv::DetectionBasedTracker::getObjects(std::vector& result) const bool cv::DetectionBasedTracker::run() { - if (!separateDetectionWork.empty()) { + if (separateDetectionWork) { return separateDetectionWork->run(); } return false; @@ -597,14 +597,14 @@ bool cv::DetectionBasedTracker::run() void cv::DetectionBasedTracker::stop() { - if (!separateDetectionWork.empty()) { + if (separateDetectionWork) { separateDetectionWork->stop(); } } void cv::DetectionBasedTracker::resetTracking() { - if (!separateDetectionWork.empty()) { + if (separateDetectionWork) { separateDetectionWork->resetTracking(); } trackedObjects.clear(); @@ -876,11 +876,11 @@ bool cv::DetectionBasedTracker::setParameters(const Parameters& params) return false; } - if (!separateDetectionWork.empty()) { + if (separateDetectionWork) { separateDetectionWork->lock(); } parameters=params; - if (!separateDetectionWork.empty()) { + if (separateDetectionWork) { separateDetectionWork->unlock(); } return true; diff --git a/modules/contrib/src/facerec.cpp b/modules/contrib/src/facerec.cpp index d1050ebb76..c7e432248c 100644 --- a/modules/contrib/src/facerec.cpp +++ b/modules/contrib/src/facerec.cpp @@ -851,18 +851,18 @@ int LBPH::predict(InputArray _src) const { Ptr createEigenFaceRecognizer(int num_components, double threshold) { - return new Eigenfaces(num_components, threshold); + return makePtr(num_components, threshold); } Ptr createFisherFaceRecognizer(int num_components, double threshold) { - return new Fisherfaces(num_components, threshold); + return makePtr(num_components, threshold); } Ptr createLBPHFaceRecognizer(int radius, int neighbors, int grid_x, int grid_y, double threshold) { - return new LBPH(radius, neighbors, grid_x, grid_y, threshold); + return makePtr(radius, neighbors, grid_x, grid_y, threshold); } CV_INIT_ALGORITHM(Eigenfaces, "FaceRecognizer.Eigenfaces", diff --git a/modules/contrib/src/featuretracker.cpp b/modules/contrib/src/featuretracker.cpp index e14c55c23f..795c1a08fa 100644 --- a/modules/contrib/src/featuretracker.cpp +++ b/modules/contrib/src/featuretracker.cpp @@ -54,7 +54,7 @@ CvFeatureTracker::CvFeatureTracker(CvFeatureTrackerParams _params) : { case CvFeatureTrackerParams::SIFT: dd = Algorithm::create("Feature2D.SIFT"); - if( dd.empty() ) + if( !dd ) CV_Error(CV_StsNotImplemented, "OpenCV has been compiled without SIFT support"); dd->set("nOctaveLayers", 5); dd->set("contrastThreshold", 0.04); @@ -62,7 +62,7 @@ CvFeatureTracker::CvFeatureTracker(CvFeatureTrackerParams _params) : break; case CvFeatureTrackerParams::SURF: dd = Algorithm::create("Feature2D.SURF"); - if( dd.empty() ) + if( !dd ) CV_Error(CV_StsNotImplemented, "OpenCV has been compiled without SURF support"); dd->set("hessianThreshold", 400); dd->set("nOctaves", 3); @@ -73,7 +73,7 @@ CvFeatureTracker::CvFeatureTracker(CvFeatureTrackerParams _params) : break; } - matcher = new BFMatcher(NORM_L2); + matcher = makePtr(int(NORM_L2)); } CvFeatureTracker::~CvFeatureTracker()