123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #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<double, Feature *> ( weight, f ) );
- }
- }
|