123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- #ifndef _NICE_OBJREC_LOCALFEATURESELECTION_INCLUDE
- #define _NICE_OBJREC_LOCALFEATURESELECTION_INCLUDE
- #include "vislearning/features/localfeatures/LocalFeatureRepresentation.h"
- #include "vislearning/features/localfeatures/LocalFeatureRGBSift.h"
- #include "vislearning/features/localfeatures/LocalFeatureOpponnentSift.h"
- #include "vislearning/features/localfeatures/LocalFeatureColorWeijer.h"
- #include "vislearning/features/localfeatures/LocalFeatureCentrist.h"
- #include "vislearning/features/localfeatures/LocalFeatureSift.h"
- namespace OBJREC {
-
-
- class GenericLocalFeatureSelection
- {
- public:
-
- static OBJREC::LocalFeature *selectLocalFeature ( const NICE::Config *conf, std::string section = "Features" )
- {
-
- LocalFeature *lf = NULL;
-
- std::string localfeature_type = conf->gS ( section, "localfeature_type", "not defined" );
-
-
-
- if ( ( localfeature_type == "NICE_SIFT" ) || ( localfeature_type == "LocalFeatureSift" ) )
- {
- lf = new OBJREC::LocalFeatureSift ( conf );
- }
- else if ( ( localfeature_type == "NICE_RGBSIFT" ) || ( localfeature_type == "LocalFeatureRGBSift" ) )
- {
- lf = new OBJREC::LocalFeatureRGBSift ( conf );
- }
- else if ( ( localfeature_type == "NICE_OPPSIFT" ) || ( localfeature_type == "LocalFeatureOpponnentSift" ) )
- {
- lf = new OBJREC::LocalFeatureOpponnentSift ( conf );
- }
- else if ( ( localfeature_type == "colornames" ) || ( localfeature_type == "LocalFeatureColorWeijer" ) )
- {
- lf = new OBJREC::LocalFeatureColorWeijer ( conf );
- }
- else if ( ( localfeature_type == "centrist" ) || ( localfeature_type == "LocalFeatureCentrist" ) )
- {
- lf = new OBJREC::LocalFeatureCentrist ( conf );
- }
-
-
- if ( lf == NULL )
- fthrow ( NICE::Exception, "Local feature type not found: " << localfeature_type << " for section " << section);
- return lf;
- };
-
- static
- void restoreLocalFeature ( OBJREC::LocalFeature * _lf, std::istream & is, int format = 0 )
- {
-
- if ( is.good() )
- {
- if ( _lf != NULL )
- delete _lf;
-
-
- std::string className;
- is >> className;
-
-
- if ( className == "<LocalFeatureSift>" )
- {
- _lf = new OBJREC::LocalFeatureSift();
- }
- else if ( className == "<LocalFeatureRGBSift>" )
- {
- _lf = new OBJREC::LocalFeatureRGBSift();
- }
- else if ( className == "<LocalFeatureOpponnentSift>" )
- {
- _lf = new OBJREC::LocalFeatureOpponnentSift();
- }
- else if ( className == "<LocalFeatureColorWeijer>" )
- {
- _lf = new OBJREC::LocalFeatureColorWeijer();
- }
- else if ( className == "<LocalFeatureCentrist>" )
- {
- _lf = new OBJREC::LocalFeatureCentrist();
- }
- else
- {
- fthrow ( NICE::Exception, "GenericLocalFeatureSelection::restoreLocalFeatureRep -- class name " << className << "unknown. Aborting." );
- }
-
-
-
- for ( uint i = 0; i < className.size(); i++)
- {
- is.unget();
- }
-
-
-
- _lf->restore ( is );
-
- }
- else
- {
- fthrow ( NICE::Exception, "GenericLocalFeatureSelection::restoreLocalFeatureRep -- InStream not initialized - restoring not possible!" );
- }
- };
- };
- }
- #endif
|