Codebook.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * @file Codebook.h
  3. * @brief feature codebook
  4. * @author Erik Rodner
  5. * @date 02/15/2008
  6. */
  7. #ifndef CODEBOOKINCLUDE
  8. #define CODEBOOKINCLUDE
  9. #include "core/vector/VectorT.h"
  10. #include "core/vector/MatrixT.h"
  11. #include "core/image/ImageT.h"
  12. #include "core/imagedisplay/ImageDisplay.h"
  13. #include <string>
  14. #include "core/basics/Persistent.h"
  15. #include "core/vector/SparseVectorT.h"
  16. namespace OBJREC {
  17. /** feature codebook */
  18. class Codebook : public NICE::Persistent
  19. {
  20. protected:
  21. NICE::Vector thresholds;
  22. NICE::Vector informativeMeasure;
  23. NICE::VectorT<int> classnos;
  24. public:
  25. /** simple destructor */
  26. virtual ~Codebook() {};
  27. virtual void vote ( const NICE::Vector & feature, int & codebookEntry,
  28. double & weight, double & distance ) const = 0;
  29. virtual void vote ( const NICE::Vector & feature, NICE::Vector & histogram, int & codebookEntry,
  30. double & weight, double & distance ) const;
  31. virtual void vote ( const NICE::Vector & feature, NICE::SparseVector & votes ) const;
  32. virtual bool allowsMultipleVoting () {
  33. return false;
  34. };
  35. virtual void add ( const Codebook *codebook ) = 0;
  36. virtual void copy ( const Codebook *codebook );
  37. virtual Codebook *clone () const = 0;
  38. size_t getCodebookSize() const {
  39. return informativeMeasure.size();
  40. };
  41. void reinit ( int numCodebookEntries );
  42. const NICE::Vector & getThresholds () const {
  43. return thresholds;
  44. };
  45. const NICE::Vector & getInformativeMeasure () const {
  46. return informativeMeasure;
  47. };
  48. const NICE::VectorT<int> & getClassNos () const {
  49. return classnos;
  50. };
  51. void setThresholds ( const NICE::Vector & _thresholds ) {
  52. thresholds = _thresholds;
  53. };
  54. void setInformativeMeasure ( const NICE::Vector & _informativeMeasure ) {
  55. informativeMeasure = _informativeMeasure;
  56. };
  57. void setClassNos ( const NICE::VectorT<int> & _classnos ) {
  58. classnos = _classnos;
  59. };
  60. virtual void clear ();
  61. virtual void restore ( std::istream & is, int format );
  62. virtual void store ( std::ostream & os, int format ) const;
  63. };
  64. } // namespace
  65. #endif