ConvolutionFeature.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. * @file ConvolutionFeature.h
  3. * @brief convolutional feature
  4. * @author Sven Sickert
  5. * @date 10/13/2008
  6. */
  7. #ifndef ConvolutionFeatureINCLUDE
  8. #define ConvolutionFeatureINCLUDE
  9. #include "core/vector/VectorT.h"
  10. #include "core/vector/MatrixT.h"
  11. #include "core/basics/Config.h"
  12. #include "vislearning/cbaselib/Feature.h"
  13. namespace OBJREC{
  14. /** convolutional feature */
  15. class ConvolutionFeature : public Feature
  16. {
  17. protected:
  18. /////////////////////////
  19. /////////////////////////
  20. // PROTECTED VARIABLES //
  21. /////////////////////////
  22. /////////////////////////
  23. /** feature parameter */
  24. int window_size_x;
  25. int window_size_y;
  26. int beta_length;
  27. NICE::Vector *beta;
  28. public:
  29. ///////////////////// ///////////////////// /////////////////////
  30. // CONSTRUCTORS / DESTRUCTORS
  31. ///////////////////// ///////////////////// /////////////////////
  32. /** simple constructor */
  33. ConvolutionFeature ( );
  34. /** default constructor */
  35. ConvolutionFeature ( const NICE::Config *conf );
  36. /** simple destructor */
  37. virtual ~ConvolutionFeature ( );
  38. ///////////////////// ///////////////////// /////////////////////
  39. // FEATURE STUFF
  40. ///////////////////// ///////////////////// /////////////////////
  41. /**
  42. * @brief (re)initialize parameter vector
  43. */
  44. void initializeParameterVector();
  45. /**
  46. * @brief return parameter vector
  47. * @return parameter vector
  48. */
  49. NICE::Vector getParameterVector () const;
  50. /**
  51. * @brief return feature vector
  52. * @param example current example
  53. * @return feature vector
  54. */
  55. NICE::Vector getFeatureVector ( const Example *example );
  56. /**
  57. * @brief return length of parameter vector
  58. * @return length of vector
  59. */
  60. int getParameterLength () const;
  61. /**
  62. * @brief set parameter vector
  63. * @param vec new parameter vector
  64. */
  65. void setParameterVector ( const NICE::Vector &vec );
  66. /**
  67. * @brief return feature value for given example
  68. * @param example given Example
  69. * @return double feature value
  70. */
  71. double val ( const Example *example ) const;
  72. /**
  73. * @brief create feature pool with convolutional features
  74. * @param featurePool to be filled
  75. * @param variableWindow
  76. */
  77. void explode ( FeaturePool &featurePool, bool variableWindow = true ) const;
  78. /**
  79. * @brief clone current feature
  80. * @return clone of current feature
  81. */
  82. Feature *clone () const;
  83. Feature *generateFirstParameter () const;
  84. ///////////////////// INTERFACE PERSISTENT /////////////////////
  85. // interface specific methods for store and restore
  86. ///////////////////// INTERFACE PERSISTENT /////////////////////
  87. /**
  88. * @brief Load convolution feature object from external file (stream)
  89. */
  90. virtual void restore ( std::istream & is, int format = 0 );
  91. /**
  92. * @brief Save convolution feature object to external file (stream)
  93. */
  94. virtual void store( std::ostream & os, int format = 0 ) const;
  95. /**
  96. * @brief Clear convolution feature object
  97. */
  98. virtual void clear ();
  99. };
  100. } //namespace
  101. #endif