ConvolutionFeature.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. /** alternative constructor */
  35. ConvolutionFeature ( const int wsize_x, const int wsize_y );
  36. /** default constructor */
  37. ConvolutionFeature ( const NICE::Config *conf );
  38. /** copy constructor */
  39. ConvolutionFeature ( const ConvolutionFeature *convFeat );
  40. /** simple destructor */
  41. virtual ~ConvolutionFeature ( );
  42. ///////////////////// ///////////////////// /////////////////////
  43. // FEATURE STUFF
  44. ///////////////////// ///////////////////// /////////////////////
  45. /**
  46. * @brief (re)initialize parameter vector
  47. */
  48. void initializeParameterVector();
  49. /**
  50. * @brief return parameter vector
  51. * @return parameter vector
  52. */
  53. NICE::Vector getParameterVector () const;
  54. /**
  55. * @brief return feature vector
  56. * @param example current example
  57. * @return feature vector
  58. */
  59. NICE::Vector getFeatureVector ( const Example *example ) const;
  60. /**
  61. * @brief return length of parameter vector
  62. * @return length of vector
  63. */
  64. int getParameterLength () const;
  65. /**
  66. * @brief set parameter vector
  67. * @param vec new parameter vector
  68. */
  69. void setParameterVector ( const NICE::Vector &vec );
  70. /**
  71. * @brief return feature value for given example
  72. * @param example given Example
  73. * @return double feature value
  74. */
  75. double val ( const Example *example ) const;
  76. /**
  77. * @brief create feature pool with convolutional features
  78. * @param featurePool to be filled
  79. * @param variableWindow
  80. */
  81. void explode ( FeaturePool &featurePool, bool variableWindow = true ) const;
  82. /**
  83. * @brief clone current feature
  84. * @return clone of current feature
  85. */
  86. Feature *clone () const;
  87. Feature *generateFirstParameter () const;
  88. ///////////////////// INTERFACE PERSISTENT /////////////////////
  89. // interface specific methods for store and restore
  90. ///////////////////// INTERFACE PERSISTENT /////////////////////
  91. /**
  92. * @brief Load convolution feature object from external file (stream)
  93. */
  94. void restore ( std::istream & is, int format = 0 );
  95. /**
  96. * @brief Save convolution feature object to external file (stream)
  97. */
  98. void store( std::ostream & os, int format = 0 ) const;
  99. /**
  100. * @brief Clear convolution feature object
  101. */
  102. void clear ();
  103. };
  104. } //namespace
  105. #endif