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,7 +119,7 @@ MeanStdDev | ||
| 119 | Returns the mean and standard deviation of a vector of values. | 119 | Returns the mean and standard deviation of a vector of values. |
| 120 | ****/ | 120 | ****/ |
| 121 | template <typename T> | 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 | const int size = vals.size(); | 124 | const int size = vals.size(); |
| 125 | 125 | ||
| @@ -127,6 +127,19 @@ void MeanStdDev(const QList<T> &vals, double *mean, double *stddev) | @@ -127,6 +127,19 @@ void MeanStdDev(const QList<T> &vals, double *mean, double *stddev) | ||
| 127 | double sum = 0; | 127 | double sum = 0; |
| 128 | for (int i=0; i<size; i++) sum += vals[i]; | 128 | for (int i=0; i<size; i++) sum += vals[i]; |
| 129 | *mean = (size == 0) ? 0 : sum / size; | 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 | // Compute Standard Deviation | 144 | // Compute Standard Deviation |
| 132 | double variance = 0; | 145 | double variance = 0; |
sdk/openbr_plugin.cpp
| @@ -31,6 +31,7 @@ | @@ -31,6 +31,7 @@ | ||
| 31 | #include "version.h" | 31 | #include "version.h" |
| 32 | #include "core/bee.h" | 32 | #include "core/bee.h" |
| 33 | #include "core/common.h" | 33 | #include "core/common.h" |
| 34 | +#include "core/opencvutils.h" | ||
| 34 | #include "core/qtutils.h" | 35 | #include "core/qtutils.h" |
| 35 | 36 | ||
| 36 | using namespace br; | 37 | using namespace br; |
| @@ -403,6 +404,17 @@ int FileList::failures() const | @@ -403,6 +404,17 @@ int FileList::failures() const | ||
| 403 | return failures; | 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 | /* TemplateList - public methods */ | 418 | /* TemplateList - public methods */ |
| 407 | TemplateList TemplateList::fromInput(const br::File &input) | 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,6 +1339,14 @@ float Distance::compare(const Template &target, const Template &query) const | ||
| 1327 | return a * (_compare(target, query) - b); | 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 | /* Distance - private methods */ | 1350 | /* Distance - private methods */ |
| 1331 | void Distance::compareBlock(const TemplateList &target, const TemplateList &query, Output *output, int targetOffset, int queryOffset) const | 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,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 | * \brief A list of templates. | 314 | * \brief A list of templates. |
| 305 | * | 315 | * |
| 306 | * Convenience class for working with a list of templates. | 316 | * Convenience class for working with a list of templates. |
| @@ -1066,6 +1076,7 @@ public: | @@ -1066,6 +1076,7 @@ public: | ||
| 1066 | virtual void train(const TemplateList &src); /*!< \brief Train the distance. */ | 1076 | virtual void train(const TemplateList &src); /*!< \brief Train the distance. */ |
| 1067 | virtual void compare(const TemplateList &target, const TemplateList &query, Output *output) const; /*!< \brief Compare two template lists. */ | 1077 | virtual void compare(const TemplateList &target, const TemplateList &query, Output *output) const; /*!< \brief Compare two template lists. */ |
| 1068 | float compare(const Template &target, const Template &query) const; /*!< \brief Compute the normalized distance between two templates. */ | 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 | private: | 1081 | private: |
| 1071 | virtual void compareBlock(const TemplateList &target, const TemplateList &query, Output *output, int targetOffset, int queryOffset) const; | 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,16 +31,6 @@ | ||
| 31 | namespace br | 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 | * \ingroup galleries | 35 | * \ingroup galleries |
| 46 | * \brief A binary gallery. | 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,8 +21,6 @@ | ||
| 21 | 21 | ||
| 22 | @misc{sklum, | 22 | @misc{sklum, |
| 23 | Author = {Scott J. Klum}, | 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 | Howpublished = {https://github.com/sklum}, | 24 | Howpublished = {https://github.com/sklum}, |
| 27 | Title = {scott.klum at gmail.com}} | 25 | Title = {scott.klum at gmail.com}} |
| 28 | 26 | ||
| @@ -68,6 +66,7 @@ | @@ -68,6 +66,7 @@ | ||
| 68 | Title = {PittPatt {SDK} 5.2.2}, | 66 | Title = {PittPatt {SDK} 5.2.2}, |
| 69 | Year = {2011}} | 67 | Year = {2011}} |
| 70 | 68 | ||
| 69 | + | ||
| 71 | % Datasets | 70 | % Datasets |
| 72 | @misc{GBU, | 71 | @misc{GBU, |
| 73 | Author = {NIST}, | 72 | Author = {NIST}, |
| @@ -81,11 +80,12 @@ | @@ -81,11 +80,12 @@ | ||
| 81 | Title = {{NIST} Special Database 32 - Multiple Encounter Dataset ({MEDS})}, | 80 | Title = {{NIST} Special Database 32 - Multiple Encounter Dataset ({MEDS})}, |
| 82 | Year = {2011}} | 81 | Year = {2011}} |
| 83 | 82 | ||
| 83 | + | ||
| 84 | % Papers | 84 | % Papers |
| 85 | @inproceedings{belhumeur11, | 85 | @inproceedings{belhumeur11, |
| 86 | Author = {Belhumeur, P.N. and Jacobs, D.W. and Kriegman, D.J. and Kumar, N.}, | 86 | Author = {Belhumeur, P.N. and Jacobs, D.W. and Kriegman, D.J. and Kumar, N.}, |
| 87 | Booktitle = {Computer Vision and Pattern Recognition (CVPR), 2011 IEEE Conference on}, | 87 | Booktitle = {Computer Vision and Pattern Recognition (CVPR), 2011 IEEE Conference on}, |
| 88 | - Month = jun, | 88 | + Month = {jun}, |
| 89 | Pages = {545-552}, | 89 | Pages = {545-552}, |
| 90 | Title = {Localizing parts of faces using a consensus of exemplars}, | 90 | Title = {Localizing parts of faces using a consensus of exemplars}, |
| 91 | Year = {2011}} | 91 | Year = {2011}} |
| @@ -93,7 +93,7 @@ | @@ -93,7 +93,7 @@ | ||
| 93 | @inproceedings{bolme09, | 93 | @inproceedings{bolme09, |
| 94 | Author = {Bolme, D.S. and Draper, B.A. and Beveridge, J.R.}, | 94 | Author = {Bolme, D.S. and Draper, B.A. and Beveridge, J.R.}, |
| 95 | Booktitle = {Computer Vision and Pattern Recognition, 2009. CVPR 2009. IEEE Conference on}, | 95 | Booktitle = {Computer Vision and Pattern Recognition, 2009. CVPR 2009. IEEE Conference on}, |
| 96 | - Month = jun, | 96 | + Month = {jun}, |
| 97 | Pages = {2105-2112}, | 97 | Pages = {2105-2112}, |
| 98 | Title = {Average of Synthetic Exact Filters}, | 98 | Title = {Average of Synthetic Exact Filters}, |
| 99 | Year = {2009}} | 99 | Year = {2009}} |
| @@ -101,7 +101,7 @@ | @@ -101,7 +101,7 @@ | ||
| 101 | @article{jegou11, | 101 | @article{jegou11, |
| 102 | Author = {J{\'e}gou, H. and Douze, M. and Schmid, C.}, | 102 | Author = {J{\'e}gou, H. and Douze, M. and Schmid, C.}, |
| 103 | Journal = {Pattern Analysis and Machine Intelligence, IEEE Transactions on}, | 103 | Journal = {Pattern Analysis and Machine Intelligence, IEEE Transactions on}, |
| 104 | - Month = jan, | 104 | + Month = {jan}, |
| 105 | Number = {1}, | 105 | Number = {1}, |
| 106 | Pages = {117-128}, | 106 | Pages = {117-128}, |
| 107 | Title = {Product Quantization for Nearest Neighbor Search}, | 107 | Title = {Product Quantization for Nearest Neighbor Search}, |
| @@ -114,10 +114,16 @@ | @@ -114,10 +114,16 @@ | ||
| 114 | Title = {Spectrally Sampled Structural Subspace Features ({4SF})}, | 114 | Title = {Spectrally Sampled Structural Subspace Features ({4SF})}, |
| 115 | Year = {2011}} | 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 | @article{meyers08, | 125 | @article{meyers08, |
| 118 | Author = {Meyers, E. and Wolf, L.}, | 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 | Journal = {Int. Journal of Computer Vision}, | 127 | Journal = {Int. Journal of Computer Vision}, |
| 122 | Number = {1}, | 128 | Number = {1}, |
| 123 | Pages = {93-104}, | 129 | Pages = {93-104}, |
| @@ -135,7 +141,7 @@ | @@ -135,7 +141,7 @@ | ||
| 135 | @article{moghaddam97, | 141 | @article{moghaddam97, |
| 136 | Author = {Moghaddam, B. and Pentland, A.}, | 142 | Author = {Moghaddam, B. and Pentland, A.}, |
| 137 | Journal = {Pattern Analysis and Machine Intelligence, IEEE Transactions on}, | 143 | Journal = {Pattern Analysis and Machine Intelligence, IEEE Transactions on}, |
| 138 | - Month = jul, | 144 | + Month = {jul}, |
| 139 | Number = {7}, | 145 | Number = {7}, |
| 140 | Pages = {696-710}, | 146 | Pages = {696-710}, |
| 141 | Title = {Probabilistic Visual Learning for Object Representation}, | 147 | Title = {Probabilistic Visual Learning for Object Representation}, |
| @@ -145,7 +151,7 @@ | @@ -145,7 +151,7 @@ | ||
| 145 | @inproceedings{phillips11, | 151 | @inproceedings{phillips11, |
| 146 | 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.}, | 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 | Booktitle = {Automatic Face Gesture Recognition and Workshops (FG 2011), 2011 IEEE International Conference on}, | 153 | Booktitle = {Automatic Face Gesture Recognition and Workshops (FG 2011), 2011 IEEE International Conference on}, |
| 148 | - Month = mar, | 154 | + Month = {mar}, |
| 149 | Pages = {346-353}, | 155 | Pages = {346-353}, |
| 150 | Title = {An Introduction to the Good, the Bad, and the Ugly Face Recognition Challenge Problem}, | 156 | Title = {An Introduction to the Good, the Bad, and the Ugly Face Recognition Challenge Problem}, |
| 151 | Year = {2011}} | 157 | Year = {2011}} |
| @@ -165,7 +171,7 @@ | @@ -165,7 +171,7 @@ | ||
| 165 | @inproceedings{zhu11, | 171 | @inproceedings{zhu11, |
| 166 | Author = {Zhu, C. and Wen, F. and Sun J.}, | 172 | Author = {Zhu, C. and Wen, F. and Sun J.}, |
| 167 | Booktitle = {Computer Vision and Pattern Recognition (CVPR), 2011 IEEE Conference on}, | 173 | Booktitle = {Computer Vision and Pattern Recognition (CVPR), 2011 IEEE Conference on}, |
| 168 | - Month = jun, | 174 | + Month = {jun}, |
| 169 | Pages = {481-488}, | 175 | Pages = {481-488}, |
| 170 | Title = {A Rank-Order Distance Based Clustering Algorithm for Face Tagging}, | 176 | Title = {A Rank-Order Distance Based Clustering Algorithm for Face Tagging}, |
| 171 | Year = {2011}} | 177 | Year = {2011}} |