Feature.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * @file Feature.h
  3. * @brief abstraction of a feature
  4. * @author Erik Rodner
  5. * @date 04/21/2008
  6. */
  7. #ifndef FEATUREINCLUDE
  8. #define FEATUREINCLUDE
  9. #include <set>
  10. #include <map>
  11. #include "vislearning/cbaselib/CachedExample.h"
  12. #include "vislearning/cbaselib/Example.h"
  13. #include "core/basics/Persistent.h"
  14. #include "core/basics/triplet.h"
  15. #include "core/basics/quadruplet.h"
  16. //#include "FeaturePool.h"
  17. namespace OBJREC {
  18. class FeaturePool;
  19. #define ROADWORKS { fprintf(stderr, "not yet implemented !\n"); exit(-1); }
  20. /* stores a sorted set of feature values: value classno index weight **/
  21. class FeatureValues : public std::set< NICE::quadruplet<double, int, int, double> > {};
  22. class FeatureStorage : public std::map< int, FeatureValues > {};
  23. /* stores an unsorted set of feature values: value classno index weight **/
  24. class FeatureValuesUnsorted : public std::vector< NICE::quadruplet<double, int, int, double > > {};
  25. class FeatureStorageUnsorted : public std::map< int, FeatureValuesUnsorted > {};
  26. /** abstraction of a feature */
  27. class Feature : public NICE::Persistent
  28. {
  29. protected:
  30. public:
  31. /** simple constructor */
  32. Feature();
  33. /** simple destructor */
  34. virtual ~Feature();
  35. virtual double val( const Example *example ) const = 0;
  36. virtual Feature *clone() const = 0;
  37. virtual void explode ( FeaturePool & featurePool, bool variableWindow = true ) const = 0;
  38. virtual void calcFeatureValues ( const Examples & examples,
  39. std::vector<int> & examples_selection,
  40. FeatureValuesUnsorted & values ) const;
  41. virtual void calcFeatureValues ( const Examples & examples,
  42. std::vector<int> & examples_selection,
  43. FeatureValues & values ) const;
  44. };
  45. } // namespace
  46. #undef ROADWORKS
  47. #endif