ConvolutionFeature.h 3.4 KB

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