Commit 3ae7332d12b380526ad6a8bf27c8da8ff878d94d
1 parent
51a99b9f
Distance::_compare ==> Distance::compare
Showing
8 changed files
with
20 additions
and
21 deletions
sdk/openbr_plugin.cpp
| ... | ... | @@ -1308,11 +1308,6 @@ void Distance::compare(const TemplateList &target, const TemplateList &query, Ou |
| 1308 | 1308 | if (Globals->parallelism) Globals->trackFutures(futures); |
| 1309 | 1309 | } |
| 1310 | 1310 | |
| 1311 | -float Distance::compare(const Template &target, const Template &query) const | |
| 1312 | -{ | |
| 1313 | - return _compare(target, query); | |
| 1314 | -} | |
| 1315 | - | |
| 1316 | 1311 | QList<float> Distance::compare(const TemplateList &targets, const Template &query) const |
| 1317 | 1312 | { |
| 1318 | 1313 | QList<float> scores; scores.reserve(targets.size()); | ... | ... |
sdk/openbr_plugin.h
| ... | ... | @@ -1071,15 +1071,14 @@ public: |
| 1071 | 1071 | static QSharedPointer<Distance> fromAlgorithm(const QString &algorithm); /*!< \brief Retrieve an algorithm's distance. */ |
| 1072 | 1072 | virtual void train(const TemplateList &src) { (void) src; } /*!< \brief Train the distance. */ |
| 1073 | 1073 | virtual void compare(const TemplateList &target, const TemplateList &query, Output *output) const; /*!< \brief Compare two template lists. */ |
| 1074 | - float compare(const Template &target, const Template &query) const; /*!< \brief Compute the normalized distance between two templates. */ | |
| 1075 | 1074 | QList<float> compare(const TemplateList &targets, const Template &query) const; /*!< \brief Compute the normalized distance between a template and a template list. */ |
| 1075 | + virtual float compare(const Template &a, const Template &b) const = 0; /*!< \brief Compute the distance between two templates. */ | |
| 1076 | 1076 | |
| 1077 | 1077 | protected: |
| 1078 | 1078 | inline Distance *make(const QString &description) { return make(description, this); } /*!< \brief Make a subdistance. */ |
| 1079 | 1079 | |
| 1080 | 1080 | private: |
| 1081 | 1081 | virtual void compareBlock(const TemplateList &target, const TemplateList &query, Output *output, int targetOffset, int queryOffset) const; |
| 1082 | - virtual float _compare(const Template &a, const Template &b) const = 0; /*!< \brief Compute the distance between two templates. */ | |
| 1083 | 1082 | }; |
| 1084 | 1083 | |
| 1085 | 1084 | /*! | ... | ... |
sdk/plugins/compare.cpp
| ... | ... | @@ -49,7 +49,7 @@ public: |
| 49 | 49 | private: |
| 50 | 50 | BR_PROPERTY(Metric, metric, L2) |
| 51 | 51 | |
| 52 | - float _compare(const Template &a, const Template &b) const | |
| 52 | + float compare(const Template &a, const Template &b) const | |
| 53 | 53 | { |
| 54 | 54 | if ((a.m().size != b.m().size) || |
| 55 | 55 | (a.m().type() != b.m().type())) |
| ... | ... | @@ -123,7 +123,7 @@ class ByteL1Distance : public Distance |
| 123 | 123 | { |
| 124 | 124 | Q_OBJECT |
| 125 | 125 | |
| 126 | - float _compare(const Template &a, const Template &b) const | |
| 126 | + float compare(const Template &a, const Template &b) const | |
| 127 | 127 | { |
| 128 | 128 | return l1(a.m().data, b.m().data, a.m().total()); |
| 129 | 129 | } |
| ... | ... | @@ -141,7 +141,7 @@ class HalfByteL1Distance : public Distance |
| 141 | 141 | { |
| 142 | 142 | Q_OBJECT |
| 143 | 143 | |
| 144 | - float _compare(const Template &a, const Template &b) const | |
| 144 | + float compare(const Template &a, const Template &b) const | |
| 145 | 145 | { |
| 146 | 146 | return packed_l1(a.m().data, b.m().data, a.m().total()); |
| 147 | 147 | } |
| ... | ... | @@ -158,7 +158,7 @@ class IdenticalDistance : public Distance |
| 158 | 158 | { |
| 159 | 159 | Q_OBJECT |
| 160 | 160 | |
| 161 | - float _compare(const Template &a, const Template &b) const | |
| 161 | + float compare(const Template &a, const Template &b) const | |
| 162 | 162 | { |
| 163 | 163 | const Mat &am = a.m(); |
| 164 | 164 | const Mat &bm = b.m(); | ... | ... |
sdk/plugins/ct8.cpp
| ... | ... | @@ -441,7 +441,7 @@ struct CT8Compare : public Distance, |
| 441 | 441 | Q_OBJECT |
| 442 | 442 | |
| 443 | 443 | // Compare pre-extracted facevacs templates |
| 444 | - float _compare(const Template &srcA, const Template &srcB) const | |
| 444 | + float compare(const Template &srcA, const Template &srcB) const | |
| 445 | 445 | { |
| 446 | 446 | const float DefaultNonMatchScore = 0; |
| 447 | 447 | if (!srcA.m().data || !srcB.m().data) return DefaultNonMatchScore; | ... | ... |
sdk/plugins/keypoint.cpp
| ... | ... | @@ -126,7 +126,7 @@ class KeyPointMatcherTransform : public Distance |
| 126 | 126 | qFatal("KeyPointMatcher::make failed to create DescriptorMatcher: %s", qPrintable(matcher)); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - float _compare(const Template &a, const Template &b) const | |
| 129 | + float compare(const Template &a, const Template &b) const | |
| 130 | 130 | { |
| 131 | 131 | if ((a.m().rows < 2) || (b.m().rows < 2)) return 0; |
| 132 | 132 | ... | ... |
sdk/plugins/nt4.cpp
| ... | ... | @@ -424,7 +424,7 @@ class NT4Compare : public Distance |
| 424 | 424 | |
| 425 | 425 | Resource<NT4Context> contexts; |
| 426 | 426 | |
| 427 | - float _compare(const br::Template &a, const br::Template &b) const | |
| 427 | + float compare(const br::Template &a, const br::Template &b) const | |
| 428 | 428 | { |
| 429 | 429 | const float DefaultNonMatchScore = 0; |
| 430 | 430 | ... | ... |
sdk/plugins/pp5.cpp
| ... | ... | @@ -284,7 +284,7 @@ class PP5Compare : public Distance |
| 284 | 284 | Q_OBJECT |
| 285 | 285 | |
| 286 | 286 | |
| 287 | - float _compare(const Template &target, const Template &query) const | |
| 287 | + float compare(const Template &target, const Template &query) const | |
| 288 | 288 | { |
| 289 | 289 | qFatal("PP5Compare: _compare should never be called"); |
| 290 | 290 | return 0; | ... | ... |
sdk/plugins/quality.cpp
| ... | ... | @@ -181,7 +181,7 @@ class MPDistance : public Distance |
| 181 | 181 | mps.insert(key, MP(genuineScores[key], impostorScores[key])); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - float _compare(const Template &target, const Template &query) const | |
| 184 | + float compare(const Template &target, const Template &query) const | |
| 185 | 185 | { |
| 186 | 186 | return mps[query.file.getString(binKey, "")](distance->compare(target, query), gaussian, log); |
| 187 | 187 | } |
| ... | ... | @@ -221,7 +221,7 @@ class UnitDistance : public Distance |
| 221 | 221 | const TemplateList samples = templates.mid(0, 2000); |
| 222 | 222 | const QList<float> sampleLabels = samples.labels<float>(); |
| 223 | 223 | QScopedPointer<MatrixOutput> memoryOutput(dynamic_cast<MatrixOutput*>(Output::make(".Matrix", FileList(samples.size()), FileList(samples.size())))); |
| 224 | - compare(samples, samples, memoryOutput.data()); | |
| 224 | + Distance::compare(samples, samples, memoryOutput.data()); | |
| 225 | 225 | |
| 226 | 226 | double genuineAccumulator, impostorAccumulator; |
| 227 | 227 | int genuineCount, impostorCount; |
| ... | ... | @@ -254,7 +254,7 @@ class UnitDistance : public Distance |
| 254 | 254 | qDebug("a = %f, b = %f", a, b); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - float _compare(const Template &target, const Template &query) const | |
| 257 | + float compare(const Template &target, const Template &query) const | |
| 258 | 258 | { |
| 259 | 259 | return a * (distance->compare(target, query) - b); |
| 260 | 260 | } |
| ... | ... | @@ -270,10 +270,15 @@ BR_REGISTER(Distance, UnitDistance) |
| 270 | 270 | class MetadataDistance : public Distance |
| 271 | 271 | { |
| 272 | 272 | Q_OBJECT |
| 273 | - Q_PROPERTY(Distance *distance READ get_distance WRITE set_distance RESET reset_distance) | |
| 274 | - BR_PROPERTY(Distance*, distance, make("Dist(L2)")) | |
| 273 | + Q_PROPERTY(br::Distance *distance READ get_distance WRITE set_distance RESET reset_distance) | |
| 274 | + BR_PROPERTY(br::Distance*, distance, make("Dist(L2)")) | |
| 275 | + | |
| 276 | + void train(const TemplateList &src) | |
| 277 | + { | |
| 278 | + distance->train(src); | |
| 279 | + } | |
| 275 | 280 | |
| 276 | - float _compare(const Template &a, const Template &b) const | |
| 281 | + float compare(const Template &a, const Template &b) const | |
| 277 | 282 | { |
| 278 | 283 | foreach (const QString &filter, Globals->demographicFilters.keys()) { |
| 279 | 284 | const QString metadata = a.file.getString(filter, ""); | ... | ... |