FeatureLearningGeneric.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**
  2. * @file FeatureLearningGeneric.h
  3. * @brief abstract interface for feature learning algorithms
  4. * @author Alexander Freytag
  5. * @date 16-04-2013 (dd-mm-yyyy)
  6. */
  7. #ifndef _INCLUDEFEATURELEARNING
  8. #define _INCLUDEFEATURELEARNING
  9. #define ROADWORKS fthrow(NICE::Exception, "Feature Learning -- not yet implemented!");
  10. //STL
  11. #include <string>
  12. //
  13. //core
  14. #include <core/basics/Config.h>
  15. #include <core/image/ImageT.h>
  16. #include <core/vector/VVector.h>
  17. //
  18. //vislearning
  19. #include <vislearning/cbaselib/CachedExample.h>
  20. namespace OBJREC
  21. {
  22. /**
  23. * @class FeatureLearningGeneric
  24. * @brief abstract interface for feature learning algorithms
  25. * @author Alexander Freytag
  26. * @date 16-04-2013 (dd-mm-yyyy)
  27. */
  28. class FeatureLearningGeneric
  29. {
  30. protected:
  31. /************************
  32. *
  33. * protected variables
  34. *
  35. **************************/
  36. //! section information for parsing config files
  37. std::string section;
  38. //! Configuration File
  39. const NICE::Config *conf;
  40. //! where should an initial codebook be located, i.e., read from and written to?
  41. std::string cacheInitialCodebook;
  42. //! was an initial codebook already computed?
  43. bool b_loadInitialCodebook;
  44. //!shall the initially computed codebook be stored somewhere?
  45. bool b_saveInitialCodebook;
  46. //! additional evaluation in the process of feature learning, e.g., visualize the most useful features in the current image
  47. bool b_evaluationWhileFeatureLearning;
  48. bool b_showTrainingImages;
  49. bool b_showResults;
  50. std::string s_resultdir;
  51. /************************
  52. *
  53. * protected methods
  54. *
  55. **************************/
  56. /**
  57. * @brief Load a previously computed codebook which serves as initial codebook
  58. * @author Alexander Freytag
  59. * @date 17-04-2013 (dd-mm-yyyy)
  60. * @return bool (success of loading)
  61. * @note This function has to be overloaded by all subclasses!
  62. */
  63. virtual bool loadInitialCodebook ( ) = 0;
  64. /**
  65. * @brief Store the initially computed codebook
  66. * @author Alexander Freytag
  67. * @date 17-04-2013 (dd-mm-yyyy)
  68. * @return bool (success of writing)
  69. * @note This function has to be overloaded by all subclasses!
  70. */
  71. virtual bool writeInitialCodebook ( ) = 0;
  72. public:
  73. /**
  74. * @brief simple constructor
  75. * @author Alexander Freytag
  76. * @date 16-04-2013 (dd-mm-yyyy)
  77. * @param _conf global settings
  78. * @param _section section information for parsing config files
  79. */
  80. FeatureLearningGeneric ( const NICE::Config *_conf, const std::string & _section = "featureLearning" );
  81. /** simple destructor */
  82. virtual ~FeatureLearningGeneric();
  83. /**
  84. * @brief Learn new features to explain a previously unseen image with novel content
  85. * @author Alexander Freytag
  86. * @date 16-04-2013 (dd-mm-yyyy)
  87. * @param _filename of the new image
  88. * @note This function has to be overloaded by all subclasses!
  89. */
  90. virtual void learnNewFeatures ( const std::string & _filename) = 0;
  91. virtual NICE::FloatImage evaluateCurrentCodebookByDistance ( const std::string & _filename , const bool & beforeComputingNewFeatures = true) = 0;
  92. virtual NICE::ImageT<int> evaluateCurrentCodebookByAssignments ( const std::string & _filename , const bool & beforeComputingNewFeatures = true, const bool & _binaryShowLatestPrototype = false) = 0;
  93. virtual void evaluateCurrentCodebookByConfusionMatrix( NICE::Matrix & _confusionMat ) = 0;
  94. virtual NICE::VVector * getCurrentCodebook() = 0;
  95. };
  96. } // namespace
  97. #endif