From fd16d49d857bba88544531f3399a80e2848e41a5 Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Mon, 12 Jul 2010 11:56:11 +0000 Subject: [PATCH] Changed VectorDescriptorMatch interface to add factory capabilities and changed factory functions interface (return smart pointer) --- .../include/opencv2/features2d/features2d.hpp | 17 ++++++++--------- modules/features2d/src/descriptors.cpp | 6 +++--- modules/features2d/src/detectors.cpp | 2 +- tests/cv/src/adetectordescriptor_evaluation.cpp | 4 ++-- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index 0675bcbb90..20010cf591 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -1400,7 +1400,7 @@ protected: SURF surf; }; -CV_EXPORTS FeatureDetector* createDetector( const string& detectorType ); +CV_EXPORTS Ptr createDetector( const string& detectorType ); /****************************************************************************************\ * DescriptorExtractor * @@ -1473,7 +1473,7 @@ protected: SURF surf; }; -CV_EXPORTS DescriptorExtractor* createDescriptorExtractor( const string& descriptorExtractorType ); +CV_EXPORTS Ptr createDescriptorExtractor( const string& descriptorExtractorType ); /****************************************************************************************\ * Distance * @@ -1880,7 +1880,7 @@ template<> void BruteForceMatcher >::matchImpl( const Mat& descriptors_1, const Mat& descriptors_2, const Mat& mask, vector& matches ) const; -CV_EXPORTS DescriptorMatcher* createDescriptorMatcher( const string& descriptorMatcherType ); +CV_EXPORTS Ptr createDescriptorMatcher( const string& descriptorMatcherType ); /****************************************************************************************\ * GenericDescriptorMatch * @@ -2177,7 +2177,7 @@ protected: Params params; }; -CV_EXPORTS GenericDescriptorMatch* createGenericDescriptorMatch( const string& genericDescritptorMatchType, const string ¶msFilename = string () ); +CV_EXPORTS Ptr createGenericDescriptorMatch( const string& genericDescritptorMatchType, const string ¶msFilename = string () ); /****************************************************************************************\ * VectorDescriptorMatch * \****************************************************************************************/ @@ -2185,14 +2185,13 @@ CV_EXPORTS GenericDescriptorMatch* createGenericDescriptorMatch( const string& g /* * A class used for matching descriptors that can be described as vectors in a finite-dimensional space */ -template class CV_EXPORTS VectorDescriptorMatch : public GenericDescriptorMatch { public: using GenericDescriptorMatch::add; - VectorDescriptorMatch( Extractor *_extractor = 0, Matcher * _matcher = 0 ) : - extractor(_extractor), matcher(_matcher) {} + VectorDescriptorMatch( DescriptorExtractor *_extractor = 0, DescriptorMatcher * _matcher = 0 ) : + extractor( _extractor ), matcher( _matcher ) {} ~VectorDescriptorMatch() {} @@ -2252,8 +2251,8 @@ public: extractor->write (fs); } protected: - Ptr extractor; - Ptr matcher; + Ptr extractor; + Ptr matcher; //vector classIds; }; diff --git a/modules/features2d/src/descriptors.cpp b/modules/features2d/src/descriptors.cpp index f7226af431..78aaef95a4 100644 --- a/modules/features2d/src/descriptors.cpp +++ b/modules/features2d/src/descriptors.cpp @@ -228,7 +228,7 @@ void SurfDescriptorExtractor::write( FileStorage &fs ) const fs << "extended" << surf.extended; } -DescriptorExtractor* createDescriptorExtractor( const string& descriptorExtractorType ) +Ptr createDescriptorExtractor( const string& descriptorExtractorType ) { DescriptorExtractor* de = 0; if( !descriptorExtractorType.compare( "SIFT" ) ) @@ -251,7 +251,7 @@ DescriptorExtractor* createDescriptorExtractor( const string& descriptorExtracto return de; } -DescriptorMatcher* createDescriptorMatcher( const string& descriptorMatcherType ) +Ptr createDescriptorMatcher( const string& descriptorMatcherType ) { DescriptorMatcher* dm = 0; if( !descriptorMatcherType.compare( "BruteForce" ) ) @@ -394,7 +394,7 @@ void GenericDescriptorMatch::clear() collection.clear(); } -GenericDescriptorMatch* createGenericDescriptorMatch( const string& genericDescritptorMatchType, const string ¶msFilename ) +Ptr createGenericDescriptorMatch( const string& genericDescritptorMatchType, const string ¶msFilename ) { GenericDescriptorMatch *descriptorMatch = 0; if( ! genericDescritptorMatchType.compare ("ONEWAY") ) diff --git a/modules/features2d/src/detectors.cpp b/modules/features2d/src/detectors.cpp index 4ffd41053e..6e16f28b59 100644 --- a/modules/features2d/src/detectors.cpp +++ b/modules/features2d/src/detectors.cpp @@ -316,7 +316,7 @@ void SurfFeatureDetector::detectImpl( const Mat& image, const Mat& mask, surf(image, mask, keypoints); } -FeatureDetector* createDetector( const string& detectorType ) +Ptr createDetector( const string& detectorType ) { FeatureDetector* fd = 0; if( !detectorType.compare( "FAST" ) ) diff --git a/tests/cv/src/adetectordescriptor_evaluation.cpp b/tests/cv/src/adetectordescriptor_evaluation.cpp index 15049d0c87..c2568431a9 100644 --- a/tests/cv/src/adetectordescriptor_evaluation.cpp +++ b/tests/cv/src/adetectordescriptor_evaluation.cpp @@ -1332,8 +1332,8 @@ void DescriptorQualityTest::readAlgorithm( ) { DescriptorExtractor *extractor = createDescriptorExtractor( algName ); DescriptorMatcher *matcher = createDescriptorMatcher( matcherName ); - defaultDescMatch = new VectorDescriptorMatch( extractor, matcher ); - specificDescMatch = new VectorDescriptorMatch( extractor, matcher ); + defaultDescMatch = new VectorDescriptorMatch( extractor, matcher ); + specificDescMatch = new VectorDescriptorMatch( extractor, matcher ); if( extractor == 0 || matcher == 0 ) { -- GitLab