GenericLocalFeatureSelection.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * @file GenericLocalFeatureSelection.h
  3. * @brief This class provides a generic chooser function for different descriptors, which are derived from LocalFeature.
  4. * @author Eric Bach, Alexander Freytag
  5. * @date 26.10.2011
  6. */
  7. #ifndef _NICE_OBJREC_LOCALFEATURESELECTION_INCLUDE
  8. #define _NICE_OBJREC_LOCALFEATURESELECTION_INCLUDE
  9. #include "vislearning/features/localfeatures/LocalFeatureRepresentation.h"
  10. // color-descriptor
  11. #include "vislearning/features/localfeatures/LocalFeatureRGBSift.h"
  12. #include "vislearning/features/localfeatures/LocalFeatureOpponnentSift.h"
  13. #include "vislearning/features/localfeatures/LocalFeatureColorWeijer.h"
  14. // non-color-descriptor
  15. #include "vislearning/features/localfeatures/LocalFeatureSift.h"
  16. /** NOTE: This class only returns Descriptors, which NEED given positions. NO Descriptors calculate there own positions. **/
  17. namespace OBJREC {
  18. /** @class GenericLocalFeatureSelection
  19. * @brief Select a specific LocalFeature-Type. LocalFeatures compute Descriptors, which DO need given positions (no internal position calculation)!
  20. *
  21. */
  22. class GenericLocalFeatureSelection
  23. {
  24. public:
  25. /** LocalFeature Selector
  26. * @brief This methode switches between the different LocalFeature-Types. One has to set the "localfeature_type" on a valid value and the methode returns a LocalFeatureRepresentation derived Object.
  27. * @param[in] Config* - A pointer to the given configfile, which must contain "section" - "localfeature_type"
  28. * @param[in] string - This string defines the value for "section" in the configfile.
  29. * @return LocalFeature* - The LocalFeature which contains the selected LocalFeature-Type.
  30. */
  31. static LocalFeature *selectLocalFeature ( const NICE::Config *conf, std::string section = "Features" )
  32. {
  33. // return Value
  34. LocalFeature *lf = NULL;
  35. // string which defines the localfeature_type (for Ex. RGB, OppSift, Sift...)
  36. std::string localfeature_type = conf->gS ( section, "localfeature_type", "not defined" );
  37. // The prefix NICE_* indicates that this implementation comes from a NICE-Developer.
  38. // Extern implementations can be added without NICE_* in this selection-class.
  39. if ( localfeature_type == "NICE_SIFT" )
  40. {
  41. lf = new OBJREC::LocalFeatureSift ( conf );
  42. }
  43. else if ( localfeature_type == "NICE_RGBSIFT" )
  44. {
  45. lf = new OBJREC::LocalFeatureRGBSift ( conf );
  46. }
  47. else if ( localfeature_type == "NICE_OPPSIFT" )
  48. {
  49. lf = new OBJREC::LocalFeatureOpponnentSift ( conf );
  50. }
  51. else if ( localfeature_type == "colornames" )
  52. {
  53. lf = new OBJREC::LocalFeatureColorWeijer ( conf );
  54. }
  55. // no correct localfeature_type was given
  56. if ( lf == NULL )
  57. fthrow ( NICE::Exception, "Local feature type not found: " << localfeature_type );
  58. return lf;
  59. }
  60. };
  61. }
  62. #endif