Codebook.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/SparseVector.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 () { return false; };
  33. virtual void add ( const Codebook *codebook ) = 0;
  34. virtual void copy ( const Codebook *codebook );
  35. virtual Codebook *clone () const = 0;
  36. size_t getCodebookSize() const { return informativeMeasure.size(); };
  37. void reinit ( int numCodebookEntries );
  38. const NICE::Vector & getThresholds () const { return thresholds; };
  39. const NICE::Vector & getInformativeMeasure () const { return informativeMeasure; };
  40. const NICE::VectorT<int> & getClassNos () const { return classnos; };
  41. void setThresholds ( const NICE::Vector & _thresholds ) { thresholds = _thresholds; };
  42. void setInformativeMeasure ( const NICE::Vector & _informativeMeasure ) { informativeMeasure = _informativeMeasure; };
  43. void setClassNos ( const NICE::VectorT<int> & _classnos ) { classnos = _classnos; };
  44. virtual void clear ();
  45. virtual void restore ( std::istream & is, int format );
  46. virtual void store ( std::ostream & os, int format ) const;
  47. };
  48. } // namespace
  49. #endif