added empty() method to common features2d classes; fixed #831

This commit is contained in:
Maria Dimashova
2011-01-31 14:18:50 +00:00
parent fa446e7e35
commit 9b4c682623
7 changed files with 112 additions and 19 deletions

View File

@@ -213,7 +213,7 @@ void DescriptorMatcher::clear()
bool DescriptorMatcher::empty() const
{
return trainDescCollection.size() == 0;
return trainDescCollection.empty();
}
void DescriptorMatcher::train()
@@ -848,6 +848,11 @@ void GenericDescriptorMatcher::read( const FileNode& )
void GenericDescriptorMatcher::write( FileStorage& ) const
{}
bool GenericDescriptorMatcher::empty() const
{
return true;
}
/*
* Factory function for GenericDescriptorMatch creating
*/
@@ -994,13 +999,18 @@ void OneWayDescriptorMatcher::write( FileStorage& fs ) const
base->Write (fs);
}
bool OneWayDescriptorMatcher::empty() const
{
return base.empty() || base->empty();
}
Ptr<GenericDescriptorMatcher> OneWayDescriptorMatcher::clone( bool emptyTrainData ) const
{
OneWayDescriptorMatcher* matcher = new OneWayDescriptorMatcher( params );
if( !emptyTrainData )
{
CV_Error( CV_StsNotImplemented, "deep clone dunctionality is not implemented, because "
CV_Error( CV_StsNotImplemented, "deep clone functionality is not implemented, because "
"OneWayDescriptorBase has not copy constructor or clone method ");
//matcher->base;
@@ -1175,6 +1185,11 @@ void FernDescriptorMatcher::write( FileStorage& fs ) const
// classifier->write(fs);
}
bool FernDescriptorMatcher::empty() const
{
return classifier.empty() || classifier->empty();
}
Ptr<GenericDescriptorMatcher> FernDescriptorMatcher::clone( bool emptyTrainData ) const
{
FernDescriptorMatcher* matcher = new FernDescriptorMatcher( params );
@@ -1262,6 +1277,12 @@ void VectorDescriptorMatcher::write (FileStorage& fs) const
extractor->write (fs);
}
bool VectorDescriptorMatcher::empty() const
{
return extractor.empty() || extractor->empty() ||
matcher.empty() || matcher->empty();
}
Ptr<GenericDescriptorMatcher> VectorDescriptorMatcher::clone( bool emptyTrainData ) const
{
// TODO clone extractor