FeatureLearningPrototypes.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * @file FeatureLearningPrototypes.h
  3. * @brief compute new histogram entries somehow, represent clusters only based on representatives, no additional information like dimensionwise variances...
  4. * @author Alexander Freytag
  5. * @date 17-04-2013 (dd-mm-yyyy)
  6. */
  7. #ifndef _INCLUDEFEATURELEARNINGPROTOTYPES
  8. #define _INCLUDEFEATURELEARNINGPROTOTYPES
  9. #include "FeatureLearningGeneric.h"
  10. #include <core/vector/Distance.h>
  11. #include <core/vector/VVector.h>
  12. #include <vislearning/cbaselib/MultiDataset.h>
  13. //
  14. #include <vislearning/features/localfeatures/GenericLocalFeatureSelection.h>
  15. //
  16. #include <vislearning/math/cluster/ClusterAlgorithm.h>
  17. namespace OBJREC
  18. {
  19. /**
  20. * @class FeatureLearningPrototypes
  21. * @brief compute new histogram entries somehow, represent clusters only based on representatives, no additional information like dimensionwise variances...
  22. * @author Alexander Freytag
  23. * @date 17-04-2013 (dd-mm-yyyy)
  24. */
  25. class FeatureLearningPrototypes : public FeatureLearningGeneric
  26. {
  27. protected:
  28. /************************
  29. *
  30. * protected variables
  31. *
  32. **************************/
  33. bool showTrainingImages;
  34. //! define the initial number of clusters our codebook shall contain
  35. int initialNumberOfClusters;
  36. OBJREC::ClusterAlgorithm * clusterAlgo;
  37. NICE::VectorDistance<double> * distFunction;
  38. LocalFeatureRepresentation * featureExtractor;
  39. //! The currently known "cluster" centers, which are used for BoW histogram computation
  40. NICE::VVector prototypes;
  41. int newImageCounter;
  42. //just needed for visualisation
  43. double oldMaxDist;
  44. //TODO stupid!!!
  45. double maxValForVisualization;
  46. /************************
  47. *
  48. * protected methods
  49. *
  50. **************************/
  51. void setClusterAlgo( const std::string & _clusterAlgoString);
  52. void extractFeaturesFromTrainingImages( const OBJREC::MultiDataset *_md, NICE::VVector & examplesTraining );
  53. void train ( const OBJREC::MultiDataset *_md );
  54. virtual bool loadInitialCodebook ( );
  55. virtual bool writeInitialCodebook ( );
  56. public:
  57. /** constructor
  58. * @param _conf needs a configfile
  59. * @param _md and a MultiDataset (contains images and other things)
  60. */
  61. FeatureLearningPrototypes ( const NICE::Config *_conf, const OBJREC::MultiDataset *_md , const std::string & _section = "featureLearning");
  62. /** simple destructor */
  63. virtual ~FeatureLearningPrototypes();
  64. /** this function has to be overloaded by all subclasses
  65. @param imgWithNovelContent
  66. */
  67. virtual void learnNewFeatures ( const std::string & filename ) = 0 ;
  68. virtual NICE::FloatImage evaluateCurrentCodebook ( const std::string & filename , const bool & beforeComputingNewFeatures = true );
  69. };
  70. } // namespace
  71. #endif