GenericLocalFeatureSelection.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. * @brief Select a specific LocalFeature-Type. LocalFeatures compute Descriptors, which DO need given positions (no internal position calculation)!
  19. *
  20. */
  21. class GenericLocalFeatureSelection
  22. {
  23. public:
  24. /** LocalFeature Selector
  25. * @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.
  26. * @param[in] Config* - A pointer to the given configfile, which must contain "section" - "localfeature_type"
  27. * @param[in] string - This string defines the value for "section" in the configfile.
  28. * @return LocalFeatureRepresentation* - The LocalFeatureRepresentation which contains the selected LocalFeature-Type.
  29. */
  30. static LocalFeature *selectLocalFeature ( const NICE::Config *conf, std::string section = "Features" )
  31. {
  32. // return Value
  33. LocalFeature *lf = NULL;
  34. // string which defines the localfeature_type (for Ex. RGB, OppSift, Sift...)
  35. std::string localfeature_type = conf->gS ( section, "localfeature_type", "not defined" );
  36. // The prefix NICE_* indicates that this implementation comes from a NICE-Developer.
  37. // Extern implementations can be added without NICE_* in this selection-class.
  38. if ( localfeature_type == "NICE_SIFT" )
  39. {
  40. lf = new LocalFeatureSift ( conf );
  41. }
  42. else if ( localfeature_type == "NICE_RGBSIFT" )
  43. {
  44. lf = new LocalFeatureRGBSift ( conf );
  45. }
  46. else if ( localfeature_type == "NICE_OPPSIFT" )
  47. {
  48. lf = new LocalFeatureOpponnentSift ( conf );
  49. }
  50. // no correct localfeature_type was given
  51. if ( lf == NULL )
  52. fthrow ( NICE::Exception, "Local feature type not found: " << localfeature_type );
  53. return lf;
  54. }
  55. };
  56. }
  57. #endif