Commit 285b68609809ba42e95280c6e493f96d7f0fdd63
Merge branch 'master' of https://github.com/biometrics/openbr
Showing
3 changed files
with
37 additions
and
5 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" | ... | ... |
openbr/plugins/misc.cpp
| ... | ... | @@ -35,6 +35,7 @@ class OpenTransform : public UntrainableMetaTransform |
| 35 | 35 | |
| 36 | 36 | void project(const Template &src, Template &dst) const |
| 37 | 37 | { |
| 38 | + if (!src.isEmpty()) { dst = src; return; } | |
| 38 | 39 | if (Globals->verbose) qDebug("Opening %s", qPrintable(src.file.flat())); |
| 39 | 40 | dst.file = src.file; |
| 40 | 41 | foreach (const File &file, src.file.split()) { | ... | ... |
openbr/plugins/pp5.cpp
| ... | ... | @@ -305,10 +305,14 @@ class PP5CompareDistance : public Distance |
| 305 | 305 | |
| 306 | 306 | float compare(const Template &target, const Template &query) const |
| 307 | 307 | { |
| 308 | - (void) target; | |
| 309 | - (void) query; | |
| 310 | - qFatal("Compare single templates should never be called!"); | |
| 311 | - return 0; | |
| 308 | + TemplateList targetList; | |
| 309 | + targetList.append(target); | |
| 310 | + TemplateList queryList; | |
| 311 | + queryList.append(query); | |
| 312 | + MatrixOutput *score = MatrixOutput::make(targetList.files(), queryList.files()); | |
| 313 | + compare(targetList, queryList, score); | |
| 314 | + return score->data.at<float>(0); | |
| 315 | + | |
| 312 | 316 | } |
| 313 | 317 | |
| 314 | 318 | void compare(const TemplateList &target, const TemplateList &query, Output *output) const | ... | ... |