ConvolutionFeature.h 3.4 KB

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