1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #ifndef _NICE_OBJREC_GENERICDISTANCESELECTION_INCLUDE
- #define _NICE_OBJREC_GENERICDISTANCESELECTION_INCLUDE
- #include <core/vector/Distance.h>
- namespace OBJREC
- {
- class GenericDistanceSelection
- {
- public:
- static NICE::VectorDistance<double> *selectDistance (
- std::string distance_type )
- {
- NICE::VectorDistance<double> *distance = NULL;
- if ( distance_type == "euclidean" )
- {
- distance = new NICE::EuclidianDistance<double>();
- }
- else if ( distance_type == "manhattan" || distance_type == "cityblock" )
- {
- distance = new NICE::ManhattanDistance<double>();
- }
- else if ( distance_type == "median" )
- {
- distance = new NICE::MedianDistance<double>();
- }
- else if ( distance_type == "cosinus" )
- {
- distance = new NICE::CosDistance<double>();
- }
- else if ( distance_type == "spherical" )
- {
- distance = new NICE::SphericalDistance<double>();
- }
- else if ( distance_type == "chisquare" || distance_type == "chi2" )
- {
- distance = new NICE::Chi2Distance<double>();
- }
- else if ( distance_type == "kl" || distance_type == "kullbackleibler" )
- {
- distance = new NICE::KLDistance<double>();
- }
- else if ( distance_type == "bhattacharyya" )
- {
- distance = new NICE::BhattacharyyaDistance<double>();
- }
- else
- {
- fthrow ( NICE::Exception, "Distance type " << distance_type << " is unknown - euclidean distance used" );
- distance = new NICE::EuclidianDistance<double>();
- }
- return distance;
- }
- };
- } //namespace
- #endif
|