Changed VectorDescriptorMatch interface to add factory capabilities and changed factory functions interface (return smart pointer)

pull/13383/head
Alexander Shishkov 15 years ago
parent c3eb7881f1
commit fd16d49d85
  1. 17
      modules/features2d/include/opencv2/features2d/features2d.hpp
  2. 6
      modules/features2d/src/descriptors.cpp
  3. 2
      modules/features2d/src/detectors.cpp
  4. 4
      tests/cv/src/adetectordescriptor_evaluation.cpp

@ -1400,7 +1400,7 @@ protected:
SURF surf; SURF surf;
}; };
CV_EXPORTS FeatureDetector* createDetector( const string& detectorType ); CV_EXPORTS Ptr<FeatureDetector> createDetector( const string& detectorType );
/****************************************************************************************\ /****************************************************************************************\
* DescriptorExtractor * * DescriptorExtractor *
@ -1473,7 +1473,7 @@ protected:
SURF surf; SURF surf;
}; };
CV_EXPORTS DescriptorExtractor* createDescriptorExtractor( const string& descriptorExtractorType ); CV_EXPORTS Ptr<DescriptorExtractor> createDescriptorExtractor( const string& descriptorExtractorType );
/****************************************************************************************\ /****************************************************************************************\
* Distance * * Distance *
@ -1880,7 +1880,7 @@ template<>
void BruteForceMatcher<L2<float> >::matchImpl( const Mat& descriptors_1, const Mat& descriptors_2, void BruteForceMatcher<L2<float> >::matchImpl( const Mat& descriptors_1, const Mat& descriptors_2,
const Mat& mask, vector<int>& matches ) const; const Mat& mask, vector<int>& matches ) const;
CV_EXPORTS DescriptorMatcher* createDescriptorMatcher( const string& descriptorMatcherType ); CV_EXPORTS Ptr<DescriptorMatcher> createDescriptorMatcher( const string& descriptorMatcherType );
/****************************************************************************************\ /****************************************************************************************\
* GenericDescriptorMatch * * GenericDescriptorMatch *
@ -2177,7 +2177,7 @@ protected:
Params params; Params params;
}; };
CV_EXPORTS GenericDescriptorMatch* createGenericDescriptorMatch( const string& genericDescritptorMatchType, const string &paramsFilename = string () ); CV_EXPORTS Ptr<GenericDescriptorMatch> createGenericDescriptorMatch( const string& genericDescritptorMatchType, const string &paramsFilename = string () );
/****************************************************************************************\ /****************************************************************************************\
* VectorDescriptorMatch * * 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 * A class used for matching descriptors that can be described as vectors in a finite-dimensional space
*/ */
template<class Extractor, class Matcher>
class CV_EXPORTS VectorDescriptorMatch : public GenericDescriptorMatch class CV_EXPORTS VectorDescriptorMatch : public GenericDescriptorMatch
{ {
public: public:
using GenericDescriptorMatch::add; using GenericDescriptorMatch::add;
VectorDescriptorMatch( Extractor *_extractor = 0, Matcher * _matcher = 0 ) : VectorDescriptorMatch( DescriptorExtractor *_extractor = 0, DescriptorMatcher * _matcher = 0 ) :
extractor(_extractor), matcher(_matcher) {} extractor( _extractor ), matcher( _matcher ) {}
~VectorDescriptorMatch() {} ~VectorDescriptorMatch() {}
@ -2252,8 +2251,8 @@ public:
extractor->write (fs); extractor->write (fs);
} }
protected: protected:
Ptr<Extractor> extractor; Ptr<DescriptorExtractor> extractor;
Ptr<Matcher> matcher; Ptr<DescriptorMatcher> matcher;
//vector<int> classIds; //vector<int> classIds;
}; };

@ -228,7 +228,7 @@ void SurfDescriptorExtractor::write( FileStorage &fs ) const
fs << "extended" << surf.extended; fs << "extended" << surf.extended;
} }
DescriptorExtractor* createDescriptorExtractor( const string& descriptorExtractorType ) Ptr<DescriptorExtractor> createDescriptorExtractor( const string& descriptorExtractorType )
{ {
DescriptorExtractor* de = 0; DescriptorExtractor* de = 0;
if( !descriptorExtractorType.compare( "SIFT" ) ) if( !descriptorExtractorType.compare( "SIFT" ) )
@ -251,7 +251,7 @@ DescriptorExtractor* createDescriptorExtractor( const string& descriptorExtracto
return de; return de;
} }
DescriptorMatcher* createDescriptorMatcher( const string& descriptorMatcherType ) Ptr<DescriptorMatcher> createDescriptorMatcher( const string& descriptorMatcherType )
{ {
DescriptorMatcher* dm = 0; DescriptorMatcher* dm = 0;
if( !descriptorMatcherType.compare( "BruteForce" ) ) if( !descriptorMatcherType.compare( "BruteForce" ) )
@ -394,7 +394,7 @@ void GenericDescriptorMatch::clear()
collection.clear(); collection.clear();
} }
GenericDescriptorMatch* createGenericDescriptorMatch( const string& genericDescritptorMatchType, const string &paramsFilename ) Ptr<GenericDescriptorMatch> createGenericDescriptorMatch( const string& genericDescritptorMatchType, const string &paramsFilename )
{ {
GenericDescriptorMatch *descriptorMatch = 0; GenericDescriptorMatch *descriptorMatch = 0;
if( ! genericDescritptorMatchType.compare ("ONEWAY") ) if( ! genericDescritptorMatchType.compare ("ONEWAY") )

@ -316,7 +316,7 @@ void SurfFeatureDetector::detectImpl( const Mat& image, const Mat& mask,
surf(image, mask, keypoints); surf(image, mask, keypoints);
} }
FeatureDetector* createDetector( const string& detectorType ) Ptr<FeatureDetector> createDetector( const string& detectorType )
{ {
FeatureDetector* fd = 0; FeatureDetector* fd = 0;
if( !detectorType.compare( "FAST" ) ) if( !detectorType.compare( "FAST" ) )

@ -1332,8 +1332,8 @@ void DescriptorQualityTest::readAlgorithm( )
{ {
DescriptorExtractor *extractor = createDescriptorExtractor( algName ); DescriptorExtractor *extractor = createDescriptorExtractor( algName );
DescriptorMatcher *matcher = createDescriptorMatcher( matcherName ); DescriptorMatcher *matcher = createDescriptorMatcher( matcherName );
defaultDescMatch = new VectorDescriptorMatch<DescriptorExtractor, DescriptorMatcher >( extractor, matcher ); defaultDescMatch = new VectorDescriptorMatch( extractor, matcher );
specificDescMatch = new VectorDescriptorMatch<DescriptorExtractor, DescriptorMatcher >( extractor, matcher ); specificDescMatch = new VectorDescriptorMatch( extractor, matcher );
if( extractor == 0 || matcher == 0 ) if( extractor == 0 || matcher == 0 )
{ {

Loading…
Cancel
Save