LFReadCache.h 4.5 KB

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