CodebookPrototypes.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * @file CodebookPrototypes.h
  3. * @brief feature CodebookPrototypes
  4. * @author Erik Rodner, Alexander Freytag
  5. * @date 05-06-2013 (dd-mm-yyyy ) (original: 02/15/2008)
  6. */
  7. #ifndef CodebookPrototypesINCLUDE
  8. #define CodebookPrototypesINCLUDE
  9. #include "core/vector/VectorT.h"
  10. #include "core/vector/MatrixT.h"
  11. #include <string>
  12. #include "core/vector/VVector.h"
  13. #include <core/vector/Distance.h>
  14. #include "Codebook.h"
  15. namespace OBJREC {
  16. /** feature CodebookPrototypes */
  17. class CodebookPrototypes : public Codebook, public NICE::VVector
  18. {
  19. protected:
  20. //! specify which distance to use for calculating assignments
  21. std::string distanceType;
  22. //! the actual distance metric
  23. NICE::VectorDistance<double> *distancefunction;
  24. public:
  25. /** simple constructor */
  26. CodebookPrototypes();
  27. /** constructor reading the codebook from a file*/
  28. CodebookPrototypes( const std::string & filename );
  29. /** constructor taking the given VVector as new codebook prototypes*/
  30. CodebookPrototypes( const NICE::VVector & vv );
  31. /** copy constructor*/
  32. CodebookPrototypes( const CodebookPrototypes *cs );
  33. /** recommended constructor*/
  34. CodebookPrototypes( NICE::Config * _conf, const std::string & _section);
  35. /** simple destructor */
  36. virtual ~CodebookPrototypes();
  37. //vote for a single feature vector
  38. /**
  39. * @brief Vector Quantization for a single vector
  40. */
  41. void voteVQ ( const NICE::Vector & feature, int & codebookEntry, double & weight, double & distance ) const;
  42. /**
  43. * @brief Hard or Soft Assignment into NICE::Vector for a single vector
  44. */
  45. virtual void voteVA ( const NICE::Vector & feature, NICE::Vector & votes ) const;
  46. /**
  47. * @brief Hard or Soft Assignment into NICE::SparseVector for a single vector
  48. */
  49. virtual void voteVA ( const NICE::Vector & feature, NICE::SparseVector & votes ) const;
  50. void add ( const Codebook *codebook );
  51. void copy ( const Codebook *codebook );
  52. Codebook *clone () const;
  53. void clear ();
  54. void restore ( std::istream & is, int format );
  55. void store ( std::ostream & os, int format ) const;
  56. void displayCodebook (int xsize, int ysize) const;
  57. };
  58. } // namespace
  59. #endif