LFGenericLocal.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * @file LFGenericLocal.cpp
  3. * @brief generic local features
  4. * @author Erik Rodner
  5. * @date 02/05/2008
  6. */
  7. #include <iostream>
  8. #include <sstream>
  9. #include "vislearning/features/localfeatures/LFGenericLocal.h"
  10. #include "vislearning/features/localfeatures/LocalFeatureSift.h"
  11. #include "vislearning/features/localfeatures/IDRandomSampling.h"
  12. using namespace OBJREC;
  13. using namespace std;
  14. using namespace NICE;
  15. ///////////////////// ///////////////////// /////////////////////
  16. // CONSTRUCTORS / DESTRUCTORS
  17. ///////////////////// ///////////////////// /////////////////
  18. LFGenericLocal::LFGenericLocal()
  19. {
  20. this->lf = NULL;
  21. this->id = NULL;
  22. }
  23. LFGenericLocal::LFGenericLocal( const Config *conf, int numFeatures )
  24. {
  25. lf = new LocalFeatureSift(conf);
  26. id = new IDRandomSampling(conf, numFeatures);
  27. }
  28. LFGenericLocal::~LFGenericLocal()
  29. {
  30. if ( this->lf != NULL )
  31. {
  32. delete this->lf;
  33. this->lf = NULL;
  34. }
  35. if ( this->id != NULL )
  36. {
  37. delete this->id;
  38. this->id = NULL;
  39. }
  40. }
  41. ///////////////////// ///////////////////// /////////////////////
  42. // FEATURE STUFF
  43. ///////////////////// ///////////////////// //////////////////
  44. int LFGenericLocal::getDescSize () const
  45. {
  46. return lf->getDescSize();
  47. }
  48. int LFGenericLocal::extractFeatures ( const NICE::Image & img,
  49. VVector & features,
  50. VVector & positions ) const
  51. {
  52. id->getInterests ( img, positions );
  53. lf->getDescriptors ( img, positions, features );
  54. return 0;
  55. }
  56. void LFGenericLocal::visualizeFeatures ( NICE::Image & mark,
  57. const VVector & positions,
  58. size_t color ) const
  59. {
  60. lf->visualizeFeatures ( mark, positions, color );
  61. }
  62. ///////////////////// INTERFACE PERSISTENT /////////////////////
  63. // interface specific methods for store and restore
  64. ///////////////////// INTERFACE PERSISTENT /////////////////////
  65. void LFGenericLocal::restore ( std::istream & is, int format )
  66. {
  67. fthrow ( Exception, "LFGenericLocal::restore not implemented yet." );
  68. //TODO
  69. }
  70. void LFGenericLocal::store ( std::ostream & os, int format ) const
  71. {
  72. fthrow ( Exception, "LFGenericLocal::store not implemented yet." );
  73. //TODO
  74. }
  75. void LFGenericLocal::clear ()
  76. {
  77. if ( this->lf != NULL )
  78. {
  79. delete this->lf;
  80. this->lf = NULL;
  81. }
  82. if ( this->id != NULL )
  83. {
  84. delete this->id;
  85. this->id = NULL;
  86. }
  87. }