diff --git a/sdk/openbr_plugin.cpp b/sdk/openbr_plugin.cpp index 7215a29..3941a46 100644 --- a/sdk/openbr_plugin.cpp +++ b/sdk/openbr_plugin.cpp @@ -1256,6 +1256,13 @@ float Distance::compare(const Template &target, const Template &query) const } } + if (Globals->ageDelta < std::numeric_limits::max()) { + const float targetAge = target.file.getFloat("Age", -1); + const float queryAge = target.file.getFloat("Age", -1); + if ((targetAge != -1) && (queryAge != -1) && (abs(targetAge - queryAge) > Globals->ageDelta)) + return -std::numeric_limits::max(); + } + return a * (_compare(target, query) - b); } diff --git a/sdk/openbr_plugin.h b/sdk/openbr_plugin.h index f040c99..0a0bd66 100644 --- a/sdk/openbr_plugin.h +++ b/sdk/openbr_plugin.h @@ -488,9 +488,15 @@ public: /*! * \brief Keys to use when matching templates to automatically determine non-match based on template metadata. */ - Q_PROPERTY(QStringList demographicFilters READ get_demographicFilters WRITE set_demographicFilters) + Q_PROPERTY(QStringList demographicFilters READ get_demographicFilters WRITE set_demographicFilters RESET reset_demographicFilters) BR_PROPERTY(QStringList, demographicFilters, QStringList()) + /*! + * \brief Allowable age difference when matching templates. + */ + Q_PROPERTY(float ageDelta READ get_ageDelta WRITE set_ageDelta RESET reset_ageDelta) + BR_PROPERTY(float, ageDelta, std::numeric_limits::max()) + QHash abbreviations; /*!< \brief Used by br::Transform::make() to expand abbreviated algorithms into their complete definitions. */ QHash classes; /*!< \brief Used by classifiers to associate text class labels with unique integers IDs. */ QTime startTime; /*!< \brief Used to estimate timeRemaining(). */