ConvolutionFeature.h 4.0 KB

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