Codebook.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 <vislearning/nice.h>
  10. #include <string>
  11. #include "core/basics/Persistent.h"
  12. #include "core/vector/SparseVector.h"
  13. namespace OBJREC {
  14. /** feature codebook */
  15. class Codebook : public NICE::Persistent
  16. {
  17. protected:
  18. NICE::Vector thresholds;
  19. NICE::Vector informativeMeasure;
  20. NICE::VectorT<int> classnos;
  21. public:
  22. /** simple destructor */
  23. virtual ~Codebook() {};
  24. virtual void vote ( const NICE::Vector & feature, int & codebookEntry,
  25. double & weight, double & distance ) const = 0;
  26. virtual void vote ( const NICE::Vector & feature, NICE::Vector & histogram, int & codebookEntry,
  27. double & weight, double & distance ) const;
  28. virtual void vote ( const NICE::Vector & feature, NICE::SparseVector & votes ) const;
  29. virtual bool allowsMultipleVoting () { return false; };
  30. virtual void add ( const Codebook *codebook ) = 0;
  31. virtual void copy ( const Codebook *codebook );
  32. virtual Codebook *clone () const = 0;
  33. size_t getCodebookSize() const { return informativeMeasure.size(); };
  34. void reinit ( int numCodebookEntries );
  35. const NICE::Vector & getThresholds () const { return thresholds; };
  36. const NICE::Vector & getInformativeMeasure () const { return informativeMeasure; };
  37. const NICE::VectorT<int> & getClassNos () const { return classnos; };
  38. void setThresholds ( const NICE::Vector & _thresholds ) { thresholds = _thresholds; };
  39. void setInformativeMeasure ( const NICE::Vector & _informativeMeasure ) { informativeMeasure = _informativeMeasure; };
  40. void setClassNos ( const NICE::VectorT<int> & _classnos ) { classnos = _classnos; };
  41. virtual void clear ();
  42. virtual void restore ( std::istream & is, int format );
  43. virtual void store ( std::ostream & os, int format ) const;
  44. };
  45. } // namespace
  46. #endif