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

This commit is contained in:
Alexander Shishkov 2010-07-12 11:56:11 +00:00
parent c3eb7881f1
commit fd16d49d85
4 changed files with 14 additions and 15 deletions

View File

@ -1400,7 +1400,7 @@ protected:
SURF surf;
};
CV_EXPORTS FeatureDetector* createDetector( const string& detectorType );
CV_EXPORTS Ptr<FeatureDetector> createDetector( const string& detectorType );
/****************************************************************************************\
* DescriptorExtractor *
@ -1473,7 +1473,7 @@ protected:
SURF surf;
};
CV_EXPORTS DescriptorExtractor* createDescriptorExtractor( const string& descriptorExtractorType );
CV_EXPORTS Ptr<DescriptorExtractor> createDescriptorExtractor( const string& descriptorExtractorType );
/****************************************************************************************\
* Distance *
@ -1880,7 +1880,7 @@ template<>
void BruteForceMatcher<L2<float> >::matchImpl( const Mat& descriptors_1, const Mat& descriptors_2,
const Mat& mask, vector<int>& matches ) const;
CV_EXPORTS DescriptorMatcher* createDescriptorMatcher( const string& descriptorMatcherType );
CV_EXPORTS Ptr<DescriptorMatcher> createDescriptorMatcher( const string& descriptorMatcherType );
/****************************************************************************************\
* GenericDescriptorMatch *
@ -2177,7 +2177,7 @@ protected:
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 *
\****************************************************************************************/
@ -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 Extractor, class Matcher>
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> extractor;
Ptr<Matcher> matcher;
Ptr<DescriptorExtractor> extractor;
Ptr<DescriptorMatcher> matcher;
//vector<int> classIds;
};

View File

@ -228,7 +228,7 @@ void SurfDescriptorExtractor::write( FileStorage &fs ) const
fs << "extended" << surf.extended;
}
DescriptorExtractor* createDescriptorExtractor( const string& descriptorExtractorType )
Ptr<DescriptorExtractor> 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<DescriptorMatcher> 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 &paramsFilename )
Ptr<GenericDescriptorMatch> createGenericDescriptorMatch( const string& genericDescritptorMatchType, const string &paramsFilename )
{
GenericDescriptorMatch *descriptorMatch = 0;
if( ! genericDescritptorMatchType.compare ("ONEWAY") )

View File

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

View File

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