genericDistance.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef _NICE_OBJREC_GENERICDISTANCESELECTION_INCLUDE
  2. #define _NICE_OBJREC_GENERICDISTANCESELECTION_INCLUDE
  3. #include <core/vector/Distance.h>
  4. namespace OBJREC
  5. {
  6. class GenericDistanceSelection
  7. {
  8. public:
  9. static NICE::VectorDistance<double> *selectDistance (
  10. std::string distance_type )
  11. {
  12. NICE::VectorDistance<double> *distance = NULL;
  13. if ( distance_type == "euclidean" )
  14. {
  15. distance = new NICE::EuclidianDistance<double>();
  16. }
  17. else if ( distance_type == "manhattan" || distance_type == "cityblock" )
  18. {
  19. distance = new NICE::ManhattanDistance<double>();
  20. }
  21. else if ( distance_type == "median" )
  22. {
  23. distance = new NICE::MedianDistance<double>();
  24. }
  25. else if ( distance_type == "cosinus" )
  26. {
  27. distance = new NICE::CosDistance<double>();
  28. }
  29. else if ( distance_type == "spherical" )
  30. {
  31. distance = new NICE::SphericalDistance<double>();
  32. }
  33. else if ( distance_type == "chisquare" || distance_type == "chi2" )
  34. {
  35. distance = new NICE::Chi2Distance<double>();
  36. }
  37. else if ( distance_type == "kl" || distance_type == "kullbackleibler" )
  38. {
  39. distance = new NICE::KLDistance<double>();
  40. }
  41. else if ( distance_type == "bhattacharyya" )
  42. {
  43. distance = new NICE::BhattacharyyaDistance<double>();
  44. }
  45. else
  46. {
  47. fthrow ( NICE::Exception, "Distance type " << distance_type << " is unknown - euclidean distance used" );
  48. distance = new NICE::EuclidianDistance<double>();
  49. }
  50. return distance;
  51. }
  52. };
  53. } //namespace
  54. #endif