GenericLocalFeatureSelection.h 3.0 KB

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