ConvolutionFeature.h 3.6 KB

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