FeatureLearningGeneric.h 3.3 KB

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