FeatureLearningGeneric.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. /** abstract interface for feature learning algorithms */
  17. class FeatureLearningGeneric
  18. {
  19. protected:
  20. //! section information for parsing config files
  21. std::string section;
  22. //! Configuration File
  23. const NICE::Config *conf;
  24. //! where should an initial codebook be located, i.e., read from and written to?
  25. std::string cacheInitialCodebook;
  26. //! was an initial codebook already computed?
  27. bool b_loadInitialCodebook;
  28. //!shall the initially computed codebook be stored somewhere?
  29. bool b_saveInitialCodebook;
  30. //! additional evaluation in the process of feature learning, e.g., visualize the most useful features in the current image
  31. bool b_evaluationWhileFeatureLearning;
  32. /**
  33. * @brief Load a previously computed codebook which serves as initial codebook
  34. * @author Alexander Freytag
  35. * @date 17-04-2013 (dd-mm-yyyy)
  36. * @return bool (success of loading)
  37. * @note This function has to be overloaded by all subclasses!
  38. */
  39. virtual bool loadInitialCodebook ( ) = 0;
  40. /**
  41. * @brief Store the initially computed codebook
  42. * @author Alexander Freytag
  43. * @date 17-04-2013 (dd-mm-yyyy)
  44. * @return bool (success of writing)
  45. * @note This function has to be overloaded by all subclasses!
  46. */
  47. virtual bool writeInitialCodebook ( ) = 0;
  48. public:
  49. /**
  50. * @brief simple constructor
  51. * @author Alexander Freytag
  52. * @date 16-04-2013 (dd-mm-yyyy)
  53. * @param _conf global settings
  54. * @param _section section information for parsing config files
  55. */
  56. FeatureLearningGeneric ( const NICE::Config *_conf, const std::string & _section = "featureLearning" );
  57. /** simple destructor */
  58. virtual ~FeatureLearningGeneric();
  59. /** this function has to be overloaded by all subclasses
  60. @param imgWithNovelContent
  61. */
  62. virtual void learnNewFeatures ( const std::string & _filename) = 0;
  63. virtual NICE::FloatImage evaluateCurrentCodebook ( const std::string & filename , const bool & beforeComputingNewFeatures = true) = 0;
  64. };
  65. } // namespace
  66. #endif