Commit 99e31d428c3b1c50134cbf598cab93f8db434ae0

Authored by Josh Klontz
1 parent 3dc36a53

added NegativeLogPlusOneDistance

Showing 1 changed file with 34 additions and 0 deletions
openbr/plugins/distance.cpp
@@ -241,6 +241,40 @@ BR_REGISTER(Distance, HalfByteL1Distance) @@ -241,6 +241,40 @@ BR_REGISTER(Distance, HalfByteL1Distance)
241 241
242 /*! 242 /*!
243 * \ingroup distances 243 * \ingroup distances
  244 + * \brief Returns -log(distance(a,b)+1)
  245 + * \author Josh Klontz \cite jklontz
  246 + */
  247 +class NegativeLogPlusOneDistance : public Distance
  248 +{
  249 + Q_OBJECT
  250 + Q_PROPERTY(br::Distance* distance READ get_distance WRITE set_distance RESET reset_distance STORED false)
  251 + BR_PROPERTY(br::Distance*, distance, NULL)
  252 +
  253 + void train(const TemplateList &src)
  254 + {
  255 + distance->train(src);
  256 + }
  257 +
  258 + float compare(const Template &a, const Template &b) const
  259 + {
  260 + return -log(distance->compare(a,b)+1);
  261 + }
  262 +
  263 + void store(QDataStream &stream) const
  264 + {
  265 + distance->store(stream);
  266 + }
  267 +
  268 + void load(QDataStream &stream)
  269 + {
  270 + distance->load(stream);
  271 + }
  272 +};
  273 +
  274 +BR_REGISTER(Distance, NegativeLogPlusOneDistance)
  275 +
  276 +/*!
  277 + * \ingroup distances
244 * \brief Returns \c true if the templates are identical, \c false otherwise. 278 * \brief Returns \c true if the templates are identical, \c false otherwise.
245 * \author Josh Klontz \cite jklontz 279 * \author Josh Klontz \cite jklontz
246 */ 280 */