BoWFeatureConverter.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. * @file BoWFeatureConverter.h
  3. * @brief Convert a set of features into a Bag of visual Words histogram (either by Vector Quantization, or Hard / Soft Assignment)
  4. * @author Alexander Freytag
  5. * @date 11-06-2013 (dd-mm-yyyy)
  6. */
  7. #ifndef BOWFEATURECONVERTERINCLUDE
  8. #define BOWFEATURECONVERTERINCLUDE
  9. #include "core/vector/VectorT.h"
  10. #include "core/vector/VVector.h"
  11. #include "core/vector/MatrixT.h"
  12. #include "core/basics/Config.h"
  13. #include "Codebook.h"
  14. namespace OBJREC {
  15. /**
  16. * @class BoWFeatureConverter
  17. * @brief Convert a set of features into a Bag of visual Words histogram (either by Vector Quantization, or Hard / Soft Assignment)
  18. * @author Alexander Freytag
  19. * @date 11-06-2013 (dd-mm-yyyy)
  20. */
  21. class BoWFeatureConverter
  22. {
  23. protected:
  24. //! normalization method used (enum type)
  25. int n_normalizationMethod;
  26. //! quantization method used (enum type)
  27. int n_quantizationMethod;
  28. //! pointer to our codebook
  29. const Codebook *codebook;
  30. //! the section name if we want to read something from the config file lateron
  31. std::string s_section;
  32. //! the config file to specify parameter settings
  33. const NICE::Config * p_conf;
  34. public:
  35. //! enum type used for normalization method
  36. enum {
  37. NORMALIZE_RAW = 0,
  38. NORMALIZE_BINZERO,
  39. NORMALIZE_SUM,
  40. NORMALIZE_THRESH
  41. };
  42. //! enum type used to specify feature -> clusters (vector quant. , or vector assignment (either hard or soft) )
  43. enum {
  44. VECTOR_QUANTIZATION = 0,
  45. VECTOR_ASSIGNMENT
  46. };
  47. /**
  48. * @brief standard constructor
  49. *
  50. * @param conf pointer to a Config object with some parameter settings (currently not used)
  51. * @param codebook pointer to the codebook (keep the pointer!)
  52. */
  53. BoWFeatureConverter( const NICE::Config *conf,
  54. const Codebook *codebook, const std::string _section = "BoWFeatureConverter" );
  55. /** simple destructor */
  56. virtual ~BoWFeatureConverter();
  57. void calcHistogram ( const NICE::VVector & features,
  58. NICE::Vector & histogram, const bool & b_resetHistogram = true );
  59. void normalizeHistogram ( NICE::Vector & histogram );
  60. /**
  61. * @brief set the type of the normalization method (see the enum of the class)
  62. *
  63. * @param normalizationMethod see enum type
  64. */
  65. void setNormalizationMethod ( int normalizationMethod );
  66. /**
  67. * @brief get the currently used normalization method
  68. *
  69. * @return see enum type
  70. */
  71. int getNormalizationMethod () const;
  72. };
  73. } // namespace
  74. #endif