VectorFeature.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * @file VectorFeature.h
  3. * @brief feature class to use feature raw data stored in Examples
  4. * @author Johannes Ruehle
  5. * @date 04/11/2014
  6. */
  7. #ifndef VectorFeatureINCLUDE
  8. #define VectorFeatureINCLUDE
  9. #include "vislearning/cbaselib/Feature.h"
  10. namespace OBJREC {
  11. class VectorFeature : public Feature
  12. {
  13. protected:
  14. //! feature dimension
  15. int dimension;
  16. //! index of the feature
  17. int feature_index;
  18. public:
  19. /**
  20. * internally used by VectorFeature::explode
  21. * @param _dimension new dimension
  22. * @param _feature_index new featureindex
  23. */
  24. VectorFeature ( int _dimension, int _feature_index = 0 ):
  25. dimension(_dimension), feature_index(_feature_index)
  26. {}
  27. /**
  28. * simple destructor
  29. */
  30. virtual ~VectorFeature();
  31. /**
  32. * returns the value of the sparse feature stored in example
  33. * @param example input example
  34. * @return feature value
  35. */
  36. double val( const Example *example ) const;
  37. /**
  38. * creates for each feature a own SparseVectorFeature in featurepool
  39. * @param featurePool the feature pool
  40. * @param variableWindow
  41. */
  42. void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
  43. Feature *clone() const;
  44. Feature *generateFirstParameter () const;
  45. /**
  46. * store the data
  47. * @param is input stream
  48. * @param format
  49. */
  50. void restore (std::istream & is, int format = 0);
  51. /**
  52. * read the data
  53. * @param os
  54. * @param format
  55. */
  56. void store (std::ostream & os, int format = 0) const;
  57. /**
  58. * does nothing
  59. */
  60. void clear ();
  61. /**
  62. * returns the feature index and the dimension
  63. * @param feature_index
  64. * @param dimension
  65. */
  66. void getStump ( int & feature_index, int & dimension ) const;
  67. };
  68. } // namespace
  69. #endif