From 1a424f8009483849c036f52fbf166bd8345d4fe0 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Thu, 24 Jan 2013 12:32:18 -0500 Subject: [PATCH] implemented IUMTransform --- sdk/core/common.h | 15 ++++++++++++++- sdk/openbr_plugin.cpp | 20 ++++++++++++++++++++ sdk/openbr_plugin.h | 11 +++++++++++ sdk/plugins/gallery.cpp | 10 ---------- sdk/plugins/quality.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ share/openbr/openbr.bib | 26 ++++++++++++++++---------- 6 files changed, 117 insertions(+), 21 deletions(-) create mode 100644 sdk/plugins/quality.cpp diff --git a/sdk/core/common.h b/sdk/core/common.h index 9e8bb0c..c522cea 100644 --- a/sdk/core/common.h +++ b/sdk/core/common.h @@ -119,7 +119,7 @@ MeanStdDev Returns the mean and standard deviation of a vector of values. ****/ template -void MeanStdDev(const QList &vals, double *mean, double *stddev) +void Mean(const QList &vals, double *mean) { const int size = vals.size(); @@ -127,6 +127,19 @@ void MeanStdDev(const QList &vals, double *mean, double *stddev) double sum = 0; for (int i=0; i +void MeanStdDev(const QList &vals, double *mean, double *stddev) +{ + const int size = vals.size(); + + Mean(vals, mean); // Compute Standard Deviation double variance = 0; diff --git a/sdk/openbr_plugin.cpp b/sdk/openbr_plugin.cpp index 1270fe5..ec78665 100644 --- a/sdk/openbr_plugin.cpp +++ b/sdk/openbr_plugin.cpp @@ -31,6 +31,7 @@ #include "version.h" #include "core/bee.h" #include "core/common.h" +#include "core/opencvutils.h" #include "core/qtutils.h" using namespace br; @@ -403,6 +404,17 @@ int FileList::failures() const return failures; } +/* Template - global methods */ +QDataStream &br::operator<<(QDataStream &stream, const Template &t) +{ + return stream << static_cast&>(t) << t.file; +} + +QDataStream &br::operator>>(QDataStream &stream, Template &t) +{ + return stream >> static_cast&>(t) >> t.file; +} + /* TemplateList - public methods */ TemplateList TemplateList::fromInput(const br::File &input) { @@ -1327,6 +1339,14 @@ float Distance::compare(const Template &target, const Template &query) const return a * (_compare(target, query) - b); } +QList Distance::compare(const TemplateList &targets, const Template &query) const +{ + QList scores; scores.reserve(targets.size()); + foreach (const Template &target, targets) + scores.append(compare(target, query)); + return scores; +} + /* Distance - private methods */ void Distance::compareBlock(const TemplateList &target, const TemplateList &query, Output *output, int targetOffset, int queryOffset) const { diff --git a/sdk/openbr_plugin.h b/sdk/openbr_plugin.h index 24450ae..a045a63 100644 --- a/sdk/openbr_plugin.h +++ b/sdk/openbr_plugin.h @@ -301,6 +301,16 @@ struct Template : public QList }; /*! + * \brief Serialize a template. + */ +BR_EXPORT QDataStream &operator<<(QDataStream &stream, const Template &t); + +/*! + * \brief Deserialize a template. + */ +BR_EXPORT QDataStream &operator>>(QDataStream &stream, Template &t); + +/*! * \brief A list of templates. * * Convenience class for working with a list of templates. @@ -1066,6 +1076,7 @@ public: virtual void train(const TemplateList &src); /*!< \brief Train the distance. */ virtual void compare(const TemplateList &target, const TemplateList &query, Output *output) const; /*!< \brief Compare two template lists. */ float compare(const Template &target, const Template &query) const; /*!< \brief Compute the normalized distance between two templates. */ + QList compare(const TemplateList &targets, const Template &query) const; /*!< \brief Compute the normalized distance between a template and a template list. */ private: virtual void compareBlock(const TemplateList &target, const TemplateList &query, Output *output, int targetOffset, int queryOffset) const; diff --git a/sdk/plugins/gallery.cpp b/sdk/plugins/gallery.cpp index eef6a8e..83b53cb 100644 --- a/sdk/plugins/gallery.cpp +++ b/sdk/plugins/gallery.cpp @@ -31,16 +31,6 @@ namespace br { -QDataStream &operator<<(QDataStream &stream, const Template &t) -{ - return stream << static_cast&>(t) << t.file; -} - -QDataStream &operator>>(QDataStream &stream, Template &t) -{ - return stream >> static_cast&>(t) >> t.file; -} - /*! * \ingroup galleries * \brief A binary gallery. diff --git a/sdk/plugins/quality.cpp b/sdk/plugins/quality.cpp new file mode 100644 index 0000000..14039bc --- /dev/null +++ b/sdk/plugins/quality.cpp @@ -0,0 +1,56 @@ +#include + +#include "core/common.h" + +using namespace br; + +namespace br +{ + +/*! + * \ingroup transforms + * \brief Impostor Uniqueness Measure \cite klare12 + * \author Josh Klontz \cite jklontz + */ +class IUMTransform : public Transform +{ + Q_OBJECT + Q_PROPERTY(br::Distance* distance READ get_distance WRITE set_distance RESET reset_distance) + BR_PROPERTY(br::Distance*, distance, Factory::make(".Dist(L2)")) + br::TemplateList impostors; + + void train(const TemplateList &data) + { + distance->train(data); + impostors = data; + } + + void project(const Template &src, Template &dst) const + { + QList scores = distance->compare(impostors, src); + float min, max; + Common::MinMax(scores, &min, &max); + double mean; + Common::Mean(scores, &mean); + dst = src; + dst.file.insert("IUM", float((max-mean)/(max-min))); + } + + void store(QDataStream &stream) const + { + distance->store(stream); + stream << impostors; + } + + void load(QDataStream &stream) + { + distance->load(stream); + stream >> impostors; + } +}; + +BR_REGISTER(Transform, IUMTransform) + +} // namespace br + +#include "quality.moc" diff --git a/share/openbr/openbr.bib b/share/openbr/openbr.bib index 3195f7b..3214f57 100644 --- a/share/openbr/openbr.bib +++ b/share/openbr/openbr.bib @@ -21,8 +21,6 @@ @misc{sklum, Author = {Scott J. Klum}, - Date-Added = {2013-01-11 18:03:58 +0000}, - Date-Modified = {2013-01-11 18:05:56 +0000}, Howpublished = {https://github.com/sklum}, Title = {scott.klum at gmail.com}} @@ -68,6 +66,7 @@ Title = {PittPatt {SDK} 5.2.2}, Year = {2011}} + % Datasets @misc{GBU, Author = {NIST}, @@ -81,11 +80,12 @@ Title = {{NIST} Special Database 32 - Multiple Encounter Dataset ({MEDS})}, Year = {2011}} + % Papers @inproceedings{belhumeur11, Author = {Belhumeur, P.N. and Jacobs, D.W. and Kriegman, D.J. and Kumar, N.}, Booktitle = {Computer Vision and Pattern Recognition (CVPR), 2011 IEEE Conference on}, - Month = jun, + Month = {jun}, Pages = {545-552}, Title = {Localizing parts of faces using a consensus of exemplars}, Year = {2011}} @@ -93,7 +93,7 @@ @inproceedings{bolme09, Author = {Bolme, D.S. and Draper, B.A. and Beveridge, J.R.}, Booktitle = {Computer Vision and Pattern Recognition, 2009. CVPR 2009. IEEE Conference on}, - Month = jun, + Month = {jun}, Pages = {2105-2112}, Title = {Average of Synthetic Exact Filters}, Year = {2009}} @@ -101,7 +101,7 @@ @article{jegou11, Author = {J{\'e}gou, H. and Douze, M. and Schmid, C.}, Journal = {Pattern Analysis and Machine Intelligence, IEEE Transactions on}, - Month = jan, + Month = {jan}, Number = {1}, Pages = {117-128}, Title = {Product Quantization for Nearest Neighbor Search}, @@ -114,10 +114,16 @@ Title = {Spectrally Sampled Structural Subspace Features ({4SF})}, Year = {2011}} +@inproceedings{klare12, + Author={Klare, B.F. and Jain, A.K.}, + Booktitle={Biometrics: Theory, Applications and Systems (BTAS), 2012 IEEE Fifth International Conference on}, + Title={Face recognition: Impostor-based measures of uniqueness and quality}, + Year={2012}, + Month={sept.}, + Pages={237-244}} + @article{meyers08, Author = {Meyers, E. and Wolf, L.}, - Date-Added = {2013-01-11 18:46:12 +0000}, - Date-Modified = {2013-01-11 18:47:57 +0000}, Journal = {Int. Journal of Computer Vision}, Number = {1}, Pages = {93-104}, @@ -135,7 +141,7 @@ @article{moghaddam97, Author = {Moghaddam, B. and Pentland, A.}, Journal = {Pattern Analysis and Machine Intelligence, IEEE Transactions on}, - Month = jul, + Month = {jul}, Number = {7}, Pages = {696-710}, Title = {Probabilistic Visual Learning for Object Representation}, @@ -145,7 +151,7 @@ @inproceedings{phillips11, 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.}, Booktitle = {Automatic Face Gesture Recognition and Workshops (FG 2011), 2011 IEEE International Conference on}, - Month = mar, + Month = {mar}, Pages = {346-353}, Title = {An Introduction to the Good, the Bad, and the Ugly Face Recognition Challenge Problem}, Year = {2011}} @@ -165,7 +171,7 @@ @inproceedings{zhu11, Author = {Zhu, C. and Wen, F. and Sun J.}, Booktitle = {Computer Vision and Pattern Recognition (CVPR), 2011 IEEE Conference on}, - Month = jun, + Month = {jun}, Pages = {481-488}, Title = {A Rank-Order Distance Based Clustering Algorithm for Face Tagging}, Year = {2011}} -- libgit2 0.21.4