LFonHSG.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /**
  2. * @file LFonHSG.h
  3. * @brief This class can be used to calculate the positions of keyfeatures in a Honeyrate Structure Grid (HSG). Also the class call the normal getDescriptors methode from a given type of LocalFeature.
  4. * @author Eric Bach, Alexander Freytag
  5. * @date 26-10-2011 (dd-mm-yyyy)
  6. */
  7. #ifndef LFonHSGINCLUDE
  8. #define LFonHSGINCLUDE
  9. /** standard includes **/
  10. #include <iostream>
  11. #include <sstream>
  12. #include <string>
  13. #include <vector>
  14. /** NICE includes **/
  15. #include <core/basics/Config.h>
  16. //
  17. #include <core/image/Convert.h>
  18. #include <core/image/ImageT.h>
  19. //
  20. #include <core/vector/VectorT.h>
  21. #include <core/vector/MatrixT.h>
  22. #include <core/vector/VVector.h>
  23. /** LocalFeature*-header includes **/
  24. #include "LocalFeatureRepresentation.h"
  25. #include "GenericLocalFeatureSelection.h"
  26. /** STRINGTOOLS **/
  27. /** 1) boost **/
  28. #ifdef NICE_USELIB_BOOST
  29. #include <boost/tokenizer.hpp>
  30. /** 2) NICE (standard) **/
  31. #else
  32. #include <core/basics/StringTools.h>
  33. #endif
  34. namespace OBJREC
  35. {
  36. class LFonHSG : public LocalFeatureRepresentation
  37. {
  38. /* private member */
  39. private:
  40. //! if true, print some log-output
  41. bool debug;
  42. /* parameter for the grid */
  43. //! stepwidhts of the grid
  44. int sampleScaling;
  45. //! which scales should be used
  46. std::string scales;
  47. //! vector which save the different scales
  48. std::vector <float> scalesV;
  49. //! the descriptor instance
  50. OBJREC::LocalFeature* lf;
  51. /** Calculate the keypoint-positions by given imagesize, sample-spacing and scales.
  52. @brief The methode returns the calculated positions on a honeyrate-grid. This
  53. positions starts with (0;0).
  54. @param[in] unsigned int imageWidth - width (x) of the given image
  55. @param[in] unsigned int imageHeight - heigth (y) of the given image
  56. @param[in,out] NICE::VVector positions - destination for the calculated positions
  57. **/
  58. void getPositionsOnHSG ( const unsigned int imageWidth,
  59. const unsigned int imageHeight,
  60. NICE::VVector& positions ) const;
  61. protected:
  62. void convertScalesStringToScaleList ( );
  63. /* public member */
  64. public:
  65. ///////////////////// ///////////////////// /////////////////////
  66. // CONSTRUCTORS / DESTRUCTORS
  67. ///////////////////// ///////////////////// /////////////////////
  68. /**
  69. * @brief default constructor
  70. * @date 10-02-2014 (dd-mm-yyyy )
  71. * @author Alexander Freytag
  72. */
  73. LFonHSG ( );
  74. //! simple contructor
  75. LFonHSG ( const NICE::Config * _conf, const std::string _confSection = "LFonHSG" /*NOTE previous default: "HSG"*/);
  76. //! simple desctructor
  77. virtual ~LFonHSG();
  78. /**
  79. * @brief Jobs previously performed in the config-version of the constructor, read settings etc.
  80. * @author Alexander Freytag
  81. * @date 10-02-2014 ( dd-mm-yyyy )
  82. */
  83. void initFromConfig ( const NICE::Config * _conf, const std::string & _confSection = "LFonHSG");
  84. ///////////////////// ///////////////////// /////////////////////
  85. // FEATURE STUFF
  86. ///////////////////// ///////////////////// //////////////////
  87. //! Returns the descriptorsize
  88. int getDescSize() const;
  89. //! Extract the descriptor-Values from a given grayscale-Image.
  90. int extractFeatures ( const NICE::Image & img, NICE::VVector & features, NICE::VVector & positions ) const;
  91. //! Extract the descriptor-Values from a given color-Image.
  92. int extractFeatures ( const NICE::ColorImage & cimg, NICE::VVector & features, NICE::VVector & positions ) const;
  93. //! Visualisierung
  94. void visualizeFeatures ( NICE::Image & mark, const NICE::VVector & positions, size_t color ) const;
  95. ///////////////////// INTERFACE PERSISTENT /////////////////////
  96. // interface specific methods for store and restore
  97. ///////////////////// INTERFACE PERSISTENT /////////////////////
  98. /**
  99. * @brief Load object from external file (stream)
  100. * @author Alexander Freytag
  101. * @date 10-02-2014 ( dd-mmyyyy)
  102. */
  103. virtual void restore ( std::istream & is, int format = 0 );
  104. /**
  105. * @brief Save object to external file (stream)
  106. * @author Alexander Freytag
  107. * @date 10-02-2014 ( dd-mmyyyy)
  108. */
  109. virtual void store( std::ostream & os, int format = 0 ) const;
  110. /**
  111. * @brief Clear object
  112. * @author Alexander Freytag
  113. * @date 10-02-2014 ( dd-mmyyyy)
  114. */
  115. virtual void clear ();
  116. };
  117. }
  118. #endif