GenericLocalFeatureSelection.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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
  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. // non-color-descriptor
  14. #include "vislearning/features/localfeatures/LocalFeatureSift.h"
  15. /** NOTE: This class only returns Descriptors, which NEED given positions. NO Descriptors calculate there own positions. **/
  16. namespace OBJREC {
  17. class GenericLocalFeatureSelection
  18. {
  19. public:
  20. /** LocalFeature Selector
  21. * @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.
  22. * @param[in] Config* - A pointer to the given configfile, which must contain "section" - "localfeature_type"
  23. * @param[in] string - This string defines the value for "section" in the configfile.
  24. * @return LocalFeatureRepresentation* - The LocalFeatureRepresentation which contains the selected LocalFeature-Type.
  25. */
  26. static LocalFeature *selectLocalFeature ( const NICE::Config *conf, std::string section = "Features" )
  27. {
  28. // return Value
  29. LocalFeature *lf = NULL;
  30. // string which defines the localfeature_type (for Ex. RGB, OppSift, Sift...)
  31. std::string localfeature_type = conf->gS ( section, "localfeature_type", "not defined" );
  32. // The prefix NICE_* indicates that this implementation comes from a NICE-Developer.
  33. // Extern implementations can be added without NICE_* in this selection-class.
  34. if ( localfeature_type == "NICE_SIFT" )
  35. {
  36. lf = new LocalFeatureSift ( conf );
  37. }
  38. else if ( localfeature_type == "NICE_RGBSIFT" )
  39. {
  40. lf = new LocalFeatureRGBSift ( conf );
  41. }
  42. else if ( localfeature_type == "NICE_OPPSIFT" )
  43. {
  44. lf = new LocalFeatureOpponnentSift ( conf );
  45. }
  46. // no correct localfeature_type was given
  47. if ( lf == NULL )
  48. fthrow ( NICE::Exception, "Local feature type not found: " << localfeature_type );
  49. return lf;
  50. }
  51. };
  52. }
  53. #endif