Commit 1a424f8009483849c036f52fbf166bd8345d4fe0
1 parent
11bf404b
implemented IUMTransform
Showing
6 changed files
with
117 additions
and
21 deletions
sdk/core/common.h
| ... | ... | @@ -119,7 +119,7 @@ MeanStdDev |
| 119 | 119 | Returns the mean and standard deviation of a vector of values. |
| 120 | 120 | ****/ |
| 121 | 121 | template <typename T> |
| 122 | -void MeanStdDev(const QList<T> &vals, double *mean, double *stddev) | |
| 122 | +void Mean(const QList<T> &vals, double *mean) | |
| 123 | 123 | { |
| 124 | 124 | const int size = vals.size(); |
| 125 | 125 | |
| ... | ... | @@ -127,6 +127,19 @@ void MeanStdDev(const QList<T> &vals, double *mean, double *stddev) |
| 127 | 127 | double sum = 0; |
| 128 | 128 | for (int i=0; i<size; i++) sum += vals[i]; |
| 129 | 129 | *mean = (size == 0) ? 0 : sum / size; |
| 130 | +} | |
| 131 | + | |
| 132 | + | |
| 133 | +/**** | |
| 134 | +MeanStdDev | |
| 135 | + Returns the mean and standard deviation of a vector of values. | |
| 136 | +****/ | |
| 137 | +template <typename T> | |
| 138 | +void MeanStdDev(const QList<T> &vals, double *mean, double *stddev) | |
| 139 | +{ | |
| 140 | + const int size = vals.size(); | |
| 141 | + | |
| 142 | + Mean(vals, mean); | |
| 130 | 143 | |
| 131 | 144 | // Compute Standard Deviation |
| 132 | 145 | double variance = 0; | ... | ... |
sdk/openbr_plugin.cpp
| ... | ... | @@ -31,6 +31,7 @@ |
| 31 | 31 | #include "version.h" |
| 32 | 32 | #include "core/bee.h" |
| 33 | 33 | #include "core/common.h" |
| 34 | +#include "core/opencvutils.h" | |
| 34 | 35 | #include "core/qtutils.h" |
| 35 | 36 | |
| 36 | 37 | using namespace br; |
| ... | ... | @@ -403,6 +404,17 @@ int FileList::failures() const |
| 403 | 404 | return failures; |
| 404 | 405 | } |
| 405 | 406 | |
| 407 | +/* Template - global methods */ | |
| 408 | +QDataStream &br::operator<<(QDataStream &stream, const Template &t) | |
| 409 | +{ | |
| 410 | + return stream << static_cast<const QList<cv::Mat>&>(t) << t.file; | |
| 411 | +} | |
| 412 | + | |
| 413 | +QDataStream &br::operator>>(QDataStream &stream, Template &t) | |
| 414 | +{ | |
| 415 | + return stream >> static_cast<QList<cv::Mat>&>(t) >> t.file; | |
| 416 | +} | |
| 417 | + | |
| 406 | 418 | /* TemplateList - public methods */ |
| 407 | 419 | TemplateList TemplateList::fromInput(const br::File &input) |
| 408 | 420 | { |
| ... | ... | @@ -1327,6 +1339,14 @@ float Distance::compare(const Template &target, const Template &query) const |
| 1327 | 1339 | return a * (_compare(target, query) - b); |
| 1328 | 1340 | } |
| 1329 | 1341 | |
| 1342 | +QList<float> Distance::compare(const TemplateList &targets, const Template &query) const | |
| 1343 | +{ | |
| 1344 | + QList<float> scores; scores.reserve(targets.size()); | |
| 1345 | + foreach (const Template &target, targets) | |
| 1346 | + scores.append(compare(target, query)); | |
| 1347 | + return scores; | |
| 1348 | +} | |
| 1349 | + | |
| 1330 | 1350 | /* Distance - private methods */ |
| 1331 | 1351 | void Distance::compareBlock(const TemplateList &target, const TemplateList &query, Output *output, int targetOffset, int queryOffset) const |
| 1332 | 1352 | { | ... | ... |
sdk/openbr_plugin.h
| ... | ... | @@ -301,6 +301,16 @@ struct Template : public QList<cv::Mat> |
| 301 | 301 | }; |
| 302 | 302 | |
| 303 | 303 | /*! |
| 304 | + * \brief Serialize a template. | |
| 305 | + */ | |
| 306 | +BR_EXPORT QDataStream &operator<<(QDataStream &stream, const Template &t); | |
| 307 | + | |
| 308 | +/*! | |
| 309 | + * \brief Deserialize a template. | |
| 310 | + */ | |
| 311 | +BR_EXPORT QDataStream &operator>>(QDataStream &stream, Template &t); | |
| 312 | + | |
| 313 | +/*! | |
| 304 | 314 | * \brief A list of templates. |
| 305 | 315 | * |
| 306 | 316 | * Convenience class for working with a list of templates. |
| ... | ... | @@ -1066,6 +1076,7 @@ public: |
| 1066 | 1076 | virtual void train(const TemplateList &src); /*!< \brief Train the distance. */ |
| 1067 | 1077 | virtual void compare(const TemplateList &target, const TemplateList &query, Output *output) const; /*!< \brief Compare two template lists. */ |
| 1068 | 1078 | float compare(const Template &target, const Template &query) const; /*!< \brief Compute the normalized distance between two templates. */ |
| 1079 | + QList<float> compare(const TemplateList &targets, const Template &query) const; /*!< \brief Compute the normalized distance between a template and a template list. */ | |
| 1069 | 1080 | |
| 1070 | 1081 | private: |
| 1071 | 1082 | virtual void compareBlock(const TemplateList &target, const TemplateList &query, Output *output, int targetOffset, int queryOffset) const; | ... | ... |
sdk/plugins/gallery.cpp
| ... | ... | @@ -31,16 +31,6 @@ |
| 31 | 31 | namespace br |
| 32 | 32 | { |
| 33 | 33 | |
| 34 | -QDataStream &operator<<(QDataStream &stream, const Template &t) | |
| 35 | -{ | |
| 36 | - return stream << static_cast<const QList<cv::Mat>&>(t) << t.file; | |
| 37 | -} | |
| 38 | - | |
| 39 | -QDataStream &operator>>(QDataStream &stream, Template &t) | |
| 40 | -{ | |
| 41 | - return stream >> static_cast<QList<cv::Mat>&>(t) >> t.file; | |
| 42 | -} | |
| 43 | - | |
| 44 | 34 | /*! |
| 45 | 35 | * \ingroup galleries |
| 46 | 36 | * \brief A binary gallery. | ... | ... |
sdk/plugins/quality.cpp
0 โ 100644
| 1 | +#include <openbr_plugin.h> | |
| 2 | + | |
| 3 | +#include "core/common.h" | |
| 4 | + | |
| 5 | +using namespace br; | |
| 6 | + | |
| 7 | +namespace br | |
| 8 | +{ | |
| 9 | + | |
| 10 | +/*! | |
| 11 | + * \ingroup transforms | |
| 12 | + * \brief Impostor Uniqueness Measure \cite klare12 | |
| 13 | + * \author Josh Klontz \cite jklontz | |
| 14 | + */ | |
| 15 | +class IUMTransform : public Transform | |
| 16 | +{ | |
| 17 | + Q_OBJECT | |
| 18 | + Q_PROPERTY(br::Distance* distance READ get_distance WRITE set_distance RESET reset_distance) | |
| 19 | + BR_PROPERTY(br::Distance*, distance, Factory<Distance>::make(".Dist(L2)")) | |
| 20 | + br::TemplateList impostors; | |
| 21 | + | |
| 22 | + void train(const TemplateList &data) | |
| 23 | + { | |
| 24 | + distance->train(data); | |
| 25 | + impostors = data; | |
| 26 | + } | |
| 27 | + | |
| 28 | + void project(const Template &src, Template &dst) const | |
| 29 | + { | |
| 30 | + QList<float> scores = distance->compare(impostors, src); | |
| 31 | + float min, max; | |
| 32 | + Common::MinMax(scores, &min, &max); | |
| 33 | + double mean; | |
| 34 | + Common::Mean(scores, &mean); | |
| 35 | + dst = src; | |
| 36 | + dst.file.insert("IUM", float((max-mean)/(max-min))); | |
| 37 | + } | |
| 38 | + | |
| 39 | + void store(QDataStream &stream) const | |
| 40 | + { | |
| 41 | + distance->store(stream); | |
| 42 | + stream << impostors; | |
| 43 | + } | |
| 44 | + | |
| 45 | + void load(QDataStream &stream) | |
| 46 | + { | |
| 47 | + distance->load(stream); | |
| 48 | + stream >> impostors; | |
| 49 | + } | |
| 50 | +}; | |
| 51 | + | |
| 52 | +BR_REGISTER(Transform, IUMTransform) | |
| 53 | + | |
| 54 | +} // namespace br | |
| 55 | + | |
| 56 | +#include "quality.moc" | ... | ... |
share/openbr/openbr.bib
| ... | ... | @@ -21,8 +21,6 @@ |
| 21 | 21 | |
| 22 | 22 | @misc{sklum, |
| 23 | 23 | Author = {Scott J. Klum}, |
| 24 | - Date-Added = {2013-01-11 18:03:58 +0000}, | |
| 25 | - Date-Modified = {2013-01-11 18:05:56 +0000}, | |
| 26 | 24 | Howpublished = {https://github.com/sklum}, |
| 27 | 25 | Title = {scott.klum at gmail.com}} |
| 28 | 26 | |
| ... | ... | @@ -68,6 +66,7 @@ |
| 68 | 66 | Title = {PittPatt {SDK} 5.2.2}, |
| 69 | 67 | Year = {2011}} |
| 70 | 68 | |
| 69 | + | |
| 71 | 70 | % Datasets |
| 72 | 71 | @misc{GBU, |
| 73 | 72 | Author = {NIST}, |
| ... | ... | @@ -81,11 +80,12 @@ |
| 81 | 80 | Title = {{NIST} Special Database 32 - Multiple Encounter Dataset ({MEDS})}, |
| 82 | 81 | Year = {2011}} |
| 83 | 82 | |
| 83 | + | |
| 84 | 84 | % Papers |
| 85 | 85 | @inproceedings{belhumeur11, |
| 86 | 86 | Author = {Belhumeur, P.N. and Jacobs, D.W. and Kriegman, D.J. and Kumar, N.}, |
| 87 | 87 | Booktitle = {Computer Vision and Pattern Recognition (CVPR), 2011 IEEE Conference on}, |
| 88 | - Month = jun, | |
| 88 | + Month = {jun}, | |
| 89 | 89 | Pages = {545-552}, |
| 90 | 90 | Title = {Localizing parts of faces using a consensus of exemplars}, |
| 91 | 91 | Year = {2011}} |
| ... | ... | @@ -93,7 +93,7 @@ |
| 93 | 93 | @inproceedings{bolme09, |
| 94 | 94 | Author = {Bolme, D.S. and Draper, B.A. and Beveridge, J.R.}, |
| 95 | 95 | Booktitle = {Computer Vision and Pattern Recognition, 2009. CVPR 2009. IEEE Conference on}, |
| 96 | - Month = jun, | |
| 96 | + Month = {jun}, | |
| 97 | 97 | Pages = {2105-2112}, |
| 98 | 98 | Title = {Average of Synthetic Exact Filters}, |
| 99 | 99 | Year = {2009}} |
| ... | ... | @@ -101,7 +101,7 @@ |
| 101 | 101 | @article{jegou11, |
| 102 | 102 | Author = {J{\'e}gou, H. and Douze, M. and Schmid, C.}, |
| 103 | 103 | Journal = {Pattern Analysis and Machine Intelligence, IEEE Transactions on}, |
| 104 | - Month = jan, | |
| 104 | + Month = {jan}, | |
| 105 | 105 | Number = {1}, |
| 106 | 106 | Pages = {117-128}, |
| 107 | 107 | Title = {Product Quantization for Nearest Neighbor Search}, |
| ... | ... | @@ -114,10 +114,16 @@ |
| 114 | 114 | Title = {Spectrally Sampled Structural Subspace Features ({4SF})}, |
| 115 | 115 | Year = {2011}} |
| 116 | 116 | |
| 117 | +@inproceedings{klare12, | |
| 118 | + Author={Klare, B.F. and Jain, A.K.}, | |
| 119 | + Booktitle={Biometrics: Theory, Applications and Systems (BTAS), 2012 IEEE Fifth International Conference on}, | |
| 120 | + Title={Face recognition: Impostor-based measures of uniqueness and quality}, | |
| 121 | + Year={2012}, | |
| 122 | + Month={sept.}, | |
| 123 | + Pages={237-244}} | |
| 124 | + | |
| 117 | 125 | @article{meyers08, |
| 118 | 126 | Author = {Meyers, E. and Wolf, L.}, |
| 119 | - Date-Added = {2013-01-11 18:46:12 +0000}, | |
| 120 | - Date-Modified = {2013-01-11 18:47:57 +0000}, | |
| 121 | 127 | Journal = {Int. Journal of Computer Vision}, |
| 122 | 128 | Number = {1}, |
| 123 | 129 | Pages = {93-104}, |
| ... | ... | @@ -135,7 +141,7 @@ |
| 135 | 141 | @article{moghaddam97, |
| 136 | 142 | Author = {Moghaddam, B. and Pentland, A.}, |
| 137 | 143 | Journal = {Pattern Analysis and Machine Intelligence, IEEE Transactions on}, |
| 138 | - Month = jul, | |
| 144 | + Month = {jul}, | |
| 139 | 145 | Number = {7}, |
| 140 | 146 | Pages = {696-710}, |
| 141 | 147 | Title = {Probabilistic Visual Learning for Object Representation}, |
| ... | ... | @@ -145,7 +151,7 @@ |
| 145 | 151 | @inproceedings{phillips11, |
| 146 | 152 | Author = {Phillips, P.J. and Beveridge, J.R. and Draper, B.A. and Givens, G. and O'Toole, A.J. and Bolme, D.S. and Dunlop, J. and Yui Man Lui and Sahibzada, H. and Weimer, S.}, |
| 147 | 153 | Booktitle = {Automatic Face Gesture Recognition and Workshops (FG 2011), 2011 IEEE International Conference on}, |
| 148 | - Month = mar, | |
| 154 | + Month = {mar}, | |
| 149 | 155 | Pages = {346-353}, |
| 150 | 156 | Title = {An Introduction to the Good, the Bad, and the Ugly Face Recognition Challenge Problem}, |
| 151 | 157 | Year = {2011}} |
| ... | ... | @@ -165,7 +171,7 @@ |
| 165 | 171 | @inproceedings{zhu11, |
| 166 | 172 | Author = {Zhu, C. and Wen, F. and Sun J.}, |
| 167 | 173 | Booktitle = {Computer Vision and Pattern Recognition (CVPR), 2011 IEEE Conference on}, |
| 168 | - Month = jun, | |
| 174 | + Month = {jun}, | |
| 169 | 175 | Pages = {481-488}, |
| 170 | 176 | Title = {A Rank-Order Distance Based Clustering Algorithm for Face Tagging}, |
| 171 | 177 | Year = {2011}} | ... | ... |