added empty() method to common features2d classes; fixed #831
This commit is contained in:
@@ -860,8 +860,11 @@ int RTreeClassifier::countNonZeroElements(float *vec, int n, double tol)
|
||||
void RTreeClassifier::read(const char* file_name)
|
||||
{
|
||||
std::ifstream file(file_name, std::ifstream::binary);
|
||||
read(file);
|
||||
file.close();
|
||||
if( file.is_open() )
|
||||
{
|
||||
read(file);
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void RTreeClassifier::read(std::istream &is)
|
||||
|
@@ -96,6 +96,11 @@ void DescriptorExtractor::read( const FileNode& )
|
||||
void DescriptorExtractor::write( FileStorage& ) const
|
||||
{}
|
||||
|
||||
bool DescriptorExtractor::empty() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void DescriptorExtractor::removeBorderKeypoints( vector<KeyPoint>& keypoints,
|
||||
Size imageSize, int borderSize )
|
||||
{
|
||||
@@ -361,4 +366,9 @@ int OpponentColorDescriptorExtractor::descriptorType() const
|
||||
return descriptorExtractor->descriptorType();
|
||||
}
|
||||
|
||||
bool OpponentColorDescriptorExtractor::empty() const
|
||||
{
|
||||
return descriptorExtractor.empty() || (DescriptorExtractor*)(descriptorExtractor)->empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -96,6 +96,11 @@ void FeatureDetector::read( const FileNode& )
|
||||
void FeatureDetector::write( FileStorage& ) const
|
||||
{}
|
||||
|
||||
bool FeatureDetector::empty() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Ptr<FeatureDetector> FeatureDetector::create( const string& detectorType )
|
||||
{
|
||||
FeatureDetector* fd = 0;
|
||||
@@ -488,6 +493,11 @@ GridAdaptedFeatureDetector::GridAdaptedFeatureDetector( const Ptr<FeatureDetecto
|
||||
: detector(_detector), maxTotalKeypoints(_maxTotalKeypoints), gridRows(_gridRows), gridCols(_gridCols)
|
||||
{}
|
||||
|
||||
bool GridAdaptedFeatureDetector::empty() const
|
||||
{
|
||||
return detector.empty() || (FeatureDetector*)detector->empty();
|
||||
}
|
||||
|
||||
struct ResponseComparator
|
||||
{
|
||||
bool operator() (const KeyPoint& a, const KeyPoint& b)
|
||||
@@ -544,6 +554,11 @@ PyramidAdaptedFeatureDetector::PyramidAdaptedFeatureDetector( const Ptr<FeatureD
|
||||
: detector(_detector), levels(_levels)
|
||||
{}
|
||||
|
||||
bool PyramidAdaptedFeatureDetector::empty() const
|
||||
{
|
||||
return detector.empty() || (FeatureDetector*)detector->empty();
|
||||
}
|
||||
|
||||
void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
||||
{
|
||||
Mat src = image;
|
||||
|
@@ -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
|
||||
|
@@ -771,6 +771,10 @@ void FernClassifier::clear()
|
||||
vector<float>().swap(posteriors);
|
||||
}
|
||||
|
||||
bool FernClassifier::empty() const
|
||||
{
|
||||
return features.empty();
|
||||
}
|
||||
|
||||
int FernClassifier::getLeaf(int fern, const Mat& _patch) const
|
||||
{
|
||||
|
Reference in New Issue
Block a user