Commit 2a3fcf3d4321a47654df57dff5620a6cdd9a7c0d
Merge pull request #68 from biometrics/onlineDistance
Online distance metric added
Showing
1 changed file
with
28 additions
and
1 deletions
openbr/plugins/distance.cpp
| ... | ... | @@ -298,6 +298,33 @@ class IdenticalDistance : public Distance |
| 298 | 298 | |
| 299 | 299 | BR_REGISTER(Distance, IdenticalDistance) |
| 300 | 300 | |
| 301 | -} // namespace br | |
| 302 | 301 | |
| 302 | +/*! | |
| 303 | + * \ingroup distances | |
| 304 | + * \brief Online distance metric to attenuate match scores across multiple frames | |
| 305 | + * \author Brendan klare \cite bklare | |
| 306 | + */ | |
| 307 | +class OnlineDistance : public Distance | |
| 308 | +{ | |
| 309 | + Q_OBJECT | |
| 310 | + Q_PROPERTY(br::Distance* distance READ get_distance WRITE set_distance RESET reset_distance STORED false) | |
| 311 | + Q_PROPERTY(float alpha READ get_alpha WRITE set_alpha RESET reset_alpha STORED false) | |
| 312 | + BR_PROPERTY(br::Distance*, distance, NULL) | |
| 313 | + BR_PROPERTY(float, alpha, 0.1f); | |
| 314 | + | |
| 315 | + mutable QHash<QString,float> scoreHash; | |
| 316 | + mutable QMutex mutex; | |
| 317 | + | |
| 318 | + float compare(const Template &target, const Template &query) const | |
| 319 | + { | |
| 320 | + float currentScore = distance->compare(target, query); | |
| 321 | + | |
| 322 | + QMutexLocker mutexLocker(&mutex); | |
| 323 | + return scoreHash[target.file.name] = (1.0- alpha) * scoreHash[target.file.name] + alpha * currentScore; | |
| 324 | + } | |
| 325 | +}; | |
| 326 | + | |
| 327 | +BR_REGISTER(Distance, OnlineDistance) | |
| 328 | + | |
| 329 | +} // namespace br | |
| 303 | 330 | #include "distance.moc" | ... | ... |