From 99e31d428c3b1c50134cbf598cab93f8db434ae0 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Thu, 25 Apr 2013 12:07:59 -0400 Subject: [PATCH] added NegativeLogPlusOneDistance --- openbr/plugins/distance.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+), 0 deletions(-) diff --git a/openbr/plugins/distance.cpp b/openbr/plugins/distance.cpp index f0eb470..a1306c7 100644 --- a/openbr/plugins/distance.cpp +++ b/openbr/plugins/distance.cpp @@ -241,6 +241,40 @@ BR_REGISTER(Distance, HalfByteL1Distance) /*! * \ingroup distances + * \brief Returns -log(distance(a,b)+1) + * \author Josh Klontz \cite jklontz + */ +class NegativeLogPlusOneDistance : public Distance +{ + Q_OBJECT + Q_PROPERTY(br::Distance* distance READ get_distance WRITE set_distance RESET reset_distance STORED false) + BR_PROPERTY(br::Distance*, distance, NULL) + + void train(const TemplateList &src) + { + distance->train(src); + } + + float compare(const Template &a, const Template &b) const + { + return -log(distance->compare(a,b)+1); + } + + void store(QDataStream &stream) const + { + distance->store(stream); + } + + void load(QDataStream &stream) + { + distance->load(stream); + } +}; + +BR_REGISTER(Distance, NegativeLogPlusOneDistance) + +/*! + * \ingroup distances * \brief Returns \c true if the templates are identical, \c false otherwise. * \author Josh Klontz \cite jklontz */ -- libgit2 0.21.4