LFWriteCache.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /**
  2. * @file LFWriteCache.h
  3. * @brief Write local features to file (whenever a descriptor is computed, it will be checked whether a corresponding file already exists. If not, we save the descriptor)
  4. * @author Erik Rodner, Alexander Freytag
  5. * @date 02/14/2008
  6. */
  7. #ifndef LFWriteCacheINCLUDE
  8. #define LFWriteCacheINCLUDE
  9. #include "core/vector/VectorT.h"
  10. #include "core/vector/MatrixT.h"
  11. #include "core/image/ImageT.h"
  12. #include "LocalFeatureRepresentation.h"
  13. #include "core/basics/Config.h"
  14. namespace OBJREC {
  15. /** @class LFWriteCache
  16. * @brief Write local features to file (whenever a descriptor is computed, it will be checked whether a corresponding file already exists. If not, we save the descriptor)
  17. *
  18. */
  19. class LFWriteCache : public LocalFeatureRepresentation
  20. {
  21. protected:
  22. LocalFeatureRepresentation *lfrep;
  23. std::string cachedir;
  24. int descFormat;
  25. int cachemode;
  26. void setDescFormat ( const std::string & _descFormat_s );
  27. public:
  28. ///////////////////// ///////////////////// /////////////////////
  29. // CONSTRUCTORS / DESTRUCTORS
  30. ///////////////////// ///////////////////// /////////////////////
  31. /**
  32. * @brief default constructor
  33. * @date 10-02-2014 (dd-mm-yyyy )
  34. * @author Alexander Freytag
  35. */
  36. LFWriteCache ( );
  37. /**
  38. * @brief standard constructor
  39. * @date 10-02-2014 (dd-mm-yyyy )
  40. * @author Alexander Freytag
  41. * @param conf Configuration
  42. * @param _section specify the block in the config object we read
  43. */
  44. LFWriteCache( const NICE::Config * _conf,
  45. const std::string & _confSection = "LFWriteCache" /*NOTE previous default: "cache"*/
  46. );
  47. /** simple constructor */
  48. LFWriteCache( const NICE::Config *conf,
  49. LocalFeatureRepresentation *lfrep,
  50. const std::string & _section = "cache"
  51. );
  52. /** simple destructor */
  53. virtual ~LFWriteCache();
  54. /**
  55. * @brief Jobs previously performed in the config-version of the constructor, read settings etc.
  56. * @author Alexander Freytag
  57. * @date 10-02-2014 ( dd-mm-yyyy )
  58. */
  59. void initFromConfig ( const NICE::Config * _conf, const std::string & _confSection = "LFWriteCache");
  60. ///////////////////// ///////////////////// /////////////////////
  61. // FEATURE STUFF
  62. ///////////////////// ///////////////////// //////////////////
  63. int getDescSize () const;
  64. /**
  65. * extract features for gray images
  66. * @param img input image
  67. * @param features output features
  68. * @param positions position of the features
  69. * @return
  70. */
  71. int extractFeatures ( const NICE::Image & img,
  72. NICE::VVector & features,
  73. NICE::VVector & positions ) const;
  74. /**
  75. * extract features for color images
  76. * @param img input image
  77. * @param features output features
  78. * @param positions position of the features
  79. * @return
  80. */
  81. int extractFeatures ( const NICE::ColorImage & img,
  82. NICE::VVector & features,
  83. NICE::VVector & positions ) const;
  84. void visualize ( NICE::Image & img,
  85. const NICE::Vector & feature ) const;
  86. void visualizeFeatures ( NICE::Image & mark,
  87. const NICE::VVector & positions,
  88. size_t color ) const;
  89. ///////////////////// INTERFACE PERSISTENT /////////////////////
  90. // interface specific methods for store and restore
  91. ///////////////////// INTERFACE PERSISTENT /////////////////////
  92. /**
  93. * @brief Load object from external file (stream)
  94. * @author Alexander Freytag
  95. * @date 10-02-2014 ( dd-mmyyyy)
  96. */
  97. virtual void restore ( std::istream & is, int format = 0 );
  98. /**
  99. * @brief Save object to external file (stream)
  100. * @author Alexander Freytag
  101. * @date 10-02-2014 ( dd-mmyyyy)
  102. */
  103. virtual void store( std::ostream & os, int format = 0 ) const;
  104. /**
  105. * @brief Clear object
  106. * @author Alexander Freytag
  107. * @date 10-02-2014 ( dd-mmyyyy)
  108. */
  109. virtual void clear ();
  110. };
  111. } // namespace
  112. #endif