#include "VectorFeature.h" #include "HaarFeature.h" #include "PixelPairFeature.h" #include "SemanticFeature.h" #include "HOGFeature.h" #include "EOHFeature.h" #include "SparseVectorFeature.h" #include "ColorHistogramFeature.h" #include "ConvolutionFeature.h" #include "createFeatures.h" using namespace OBJREC; using namespace NICE; using namespace std; Feature *OBJREC::createFeatureFromTag ( const Config *conf, const std::string & tag ) { if ( tag == "HAARFEATURE" ) { return new HaarFeature ( conf ); } else if ( tag == "PIXELPAIRFEATURE" ) { return new PixelPairFeature ( conf ); } else if ( ( tag == "HOGFEATURE" ) || ( tag == "HOGFeature" ) ) { return new HOGFeature ( conf ); } else if ( ( tag == "EOHFEATURE" ) || ( tag == "EOHFeature" ) ){ return new EOHFeature ( conf ); // } else if ( tag == "TEXTONFEATURE" ) { // return new TextonFeature ( conf ); } else if ( ( tag == "SEMANTICFEATURE" ) || ( tag == "SemanticFeature" ) ){ return new SemanticFeature ( conf ); } else if ( ( tag == "ColorHistogramFeature" ) || ( tag == "COLORHISTOGRAMFEATURE" ) ){ return new ColorHistogramFeature ( conf ); } else if ( ( tag == "VECTORFEATURE" ) || ( tag == "VectorFeature" ) ){ return new VectorFeature ( 4711 ); // bogus dimension value only needed for explode } else if ( ( tag == "SVECTORFEATURE" ) || ( tag == "SparseVectorFeature" ) ){ return new SparseVectorFeature ( 4711 ); // bogus dimension value only needed for explode } else if ( ( tag == "CONVOLUTIONFEATURE") || ( tag == "ConvolutionFeature" ) ) { return new ConvolutionFeature ( conf ); } else { return NULL; } } void OBJREC::restoreFeaturePool ( FeaturePool & pool, const Config *conf, istream & is, int format) { assert ( conf != NULL ); while ( !is.eof() ) { double weight = 1.0; if ( !(is >> weight) ) break; std::string feature_tag; if ( !(is >> feature_tag) ) break; Feature *f = createFeatureFromTag ( conf, feature_tag ); if ( f == NULL ) { fprintf (stderr, "Unknown feature description: %s\n", feature_tag.c_str() ); exit(-1); } f->restore ( is, format ); pool.push_back ( pair ( weight, f ) ); } }