3DiVi Face SDK  3.21.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups
pbio::Recognizer Class Reference

Interface object for creating and matching templates. More...

#include <Recognizer.h>

Classes

struct  MatchResult
 Result of template matching. More...
 
struct  SearchResult
 Result of searching the Template query in the TemplatesIndex. More...
 

Public Types

enum  SearchAccelerationType { NO_SEARCH_ACCELERATION = 0, SEARCH_ACCELERATION_1 = 1 }
 Types of search acceleration. More...
 
typedef LightSmartPtr
< Recognizer >::tPtr 
Ptr
 Alias for the type of a smart pointer to Recognizer.
 

Public Member Functions

std::string getMethodName () const
 Get a method name. Thread-safe. More...
 
MatchResult getROCCurvePointByDistanceThreshold (const double distance_threshold) const
 Get a point on the ROC curve with a given distance threshold. Thread-safe. More...
 
MatchResult getROCCurvePointByFAR (const double desired_far) const
 Get a point on the ROC curve with a given false acceptance rate (FAR). Thread-safe. More...
 
MatchResult getROCCurvePointByFRR (const double desired_frr) const
 Get a point on the ROC curve with a given false rejection rate (FRR). Thread-safe. More...
 
MatchResult getROCCurvePointByScoreThreshold (const double score_threshold) const
 Get a point on the ROC curve with a given similarity score threshold. Thread-safe. More...
 
Template::Ptr processing (const RawSample &sample) const
 Create a template. More...
 
Template::Ptr loadTemplate (std::istream &binary_stream) const
 Load the template. The format is platform-independent. Only the templates that were created with the same method (i.e. with the same ini_file) can be loaded. More...
 
Template::Ptr loadTemplate (pbio::stl_wraps::WrapIStream &binary_stream) const
 Load the template. The format is platform-independent. Only the templates that were created with the same method (i.e. with the same ini_file) can be loaded. More...
 
Template::Ptr loadTemplate (const void *const data, const int size) const
 Load the template. The format is platform-independent. Only the templates that were created with the same method (i.e. with the same ini_file) can be loaded. More...
 
MatchResult verifyMatch (const Template &template1, const Template &template2) const
 Compare two templates. The order of templates does not matter. Only the templates that were created with the same method (i.e. with the same ini_file) can be loaded. More...
 
TemplatesIndex::Ptr createIndex (const std::vector< pbio::Template::Ptr > &templates, const int search_threads_count=1, const int reserve_queries_count=0) const
 Create the TemplatesIndex for quick search. The total size of all indexes is limited by the license. More...
 
std::vector< SearchResultsearch (const pbio::Template &query_template, const pbio::TemplatesIndex &templates_index, const size_t k, const SearchAccelerationType acceleration=SEARCH_ACCELERATION_1) const
 Search for the k nearest Templates in the TemplatesIndex. The search time depends on k and the size of the TemplatesIndex. More...
 
std::vector< std::vector
< SearchResult > > 
search (const std::vector< pbio::Template::Ptr > &queries_templates, const pbio::TemplatesIndex &templates_index, const size_t k, const SearchAccelerationType acceleration=SEARCH_ACCELERATION_1) const
 Search for the k nearest Templates in the TemplatesIndex. The search time depends on k and the size of the TemplatesIndex. More...
 
std::vector< size_t > chooseRepresentativeTemplatesSet (const size_t set_size, const std::vector< pbio::Template::Ptr > &templates, const std::vector< size_t > &inviolable_templates_indexes=std::vector< size_t >())
 Choose templates set that best represent original templates. More...
 

Detailed Description

Interface object for creating and matching templates.

Member Enumeration Documentation

Types of search acceleration.

Enumerator
NO_SEARCH_ACCELERATION 

No acceleration, a standard line search. The result is identical to N calls of Recognizer::verifyMatch.

SEARCH_ACCELERATION_1 

Heuristically accelerated linear search. Heuristics reduces TAR (true acceptance rate) on the 1:N test by no more than 0.1%.

Member Function Documentation

std::vector< size_t > pbio::Recognizer::chooseRepresentativeTemplatesSet ( const size_t  set_size,
const std::vector< pbio::Template::Ptr > &  templates,
const std::vector< size_t > &  inviolable_templates_indexes = std::vector<size_t>() 
)
inline

Choose templates set that best represent original templates.

Parameters
[in]set_sizeRequired set size.
[in]templatesOriginal templates.
[in]inviolable_templates_indexesIndexes of templates, required to be included in the result set.
Returns
Indexes of templates that make up the result set.
TemplatesIndex::Ptr pbio::Recognizer::createIndex ( const std::vector< pbio::Template::Ptr > &  templates,
const int  search_threads_count = 1,
const int  reserve_queries_count = 0 
) const
inline

Create the TemplatesIndex for quick search. The total size of all indexes is limited by the license.

Parameters
[in]templatesVector of templates for creating an index.
[in]search_threads_countCount of threads that will be used while searching in this index.
[in]reserve_queries_countInteger passed to TemplatesIndex::reserveSearchMemory, which is called with the created index.
Returns
Created index.
std::string pbio::Recognizer::getMethodName ( ) const
inline

Get a method name. Thread-safe.

Returns
The name of the method.
Recognizer::MatchResult pbio::Recognizer::getROCCurvePointByDistanceThreshold ( const double  distance_threshold) const
inline

Get a point on the ROC curve with a given distance threshold. Thread-safe.

Returns
Point on the ROC curve in the form of a MatchResult struct.
Recognizer::MatchResult pbio::Recognizer::getROCCurvePointByFAR ( const double  desired_far) const
inline

Get a point on the ROC curve with a given false acceptance rate (FAR). Thread-safe.

Returns
Point on the ROC curve in the form of a MatchResult struct.
Recognizer::MatchResult pbio::Recognizer::getROCCurvePointByFRR ( const double  desired_frr) const
inline

Get a point on the ROC curve with a given false rejection rate (FRR). Thread-safe.

Returns
Point on the ROC curve in the form of a MatchResult struct.
Recognizer::MatchResult pbio::Recognizer::getROCCurvePointByScoreThreshold ( const double  score_threshold) const
inline

Get a point on the ROC curve with a given similarity score threshold. Thread-safe.

Returns
Point on the ROC curve in the form of a MatchResult struct.
Template::Ptr pbio::Recognizer::loadTemplate ( std::istream &  binary_stream) const
inline

Load the template. The format is platform-independent. Only the templates that were created with the same method (i.e. with the same ini_file) can be loaded.

Parameters
[in]binary_streamInput stream object. The file stream (std::ifstream) must be opened with the std::ios_base::binary flag.
Returns
Loaded template.
Template::Ptr pbio::Recognizer::loadTemplate ( pbio::stl_wraps::WrapIStream &  binary_stream) const
inline

Load the template. The format is platform-independent. Only the templates that were created with the same method (i.e. with the same ini_file) can be loaded.

Parameters
[in]binary_streamInput stream object. The file stream (std::ifstream) must be opened with the std::ios_base::binary flag.
Returns
Loaded template.
Template::Ptr pbio::Recognizer::loadTemplate ( const void *const  data,
const int  size 
) const
inline

Load the template. The format is platform-independent. Only the templates that were created with the same method (i.e. with the same ini_file) can be loaded.

Parameters
[in]dataData buffer.
[in]sizeNumber of bytes in the data buffer.
Returns
Loaded template.
Template::Ptr pbio::Recognizer::processing ( const RawSample sample) const
inline

Create a template.

Parameters
[in]sampleFace sample. At the moment, all methods can only be used with frontal samples.
Returns
Created template.
std::vector< Recognizer::SearchResult > pbio::Recognizer::search ( const pbio::Template query_template,
const pbio::TemplatesIndex templates_index,
const size_t  k,
const SearchAccelerationType  acceleration = SEARCH_ACCELERATION_1 
) const
inline

Search for the k nearest Templates in the TemplatesIndex. The search time depends on k and the size of the TemplatesIndex.

Parameters
[in]query_templateThe Template query.
[in]templates_indexTemplatesIndex for search.
[in]kCount of the nearest templates for search.
[in]accelerationAcceleration type.
Returns
Vector with min(k, templates_index.size()) elements in ascending order of distance to the query_template.
std::vector< std::vector< Recognizer::SearchResult > > pbio::Recognizer::search ( const std::vector< pbio::Template::Ptr > &  queries_templates,
const pbio::TemplatesIndex templates_index,
const size_t  k,
const SearchAccelerationType  acceleration = SEARCH_ACCELERATION_1 
) const
inline

Search for the k nearest Templates in the TemplatesIndex. The search time depends on k and the size of the TemplatesIndex.

Parameters
[in]queries_templatesVector of queries.
[in]templates_indexTemplatesIndex for search.
[in]kCount of the nearest templates for search.
[in]accelerationAcceleration type.
Returns
Vector with queries_templates.size() elements, each is a vector with min(k, templates_index.size()) elements in ascending order of distance to the query_template.
Recognizer::MatchResult pbio::Recognizer::verifyMatch ( const Template template1,
const Template template2 
) const
inline

Compare two templates. The order of templates does not matter. Only the templates that were created with the same method (i.e. with the same ini_file) can be loaded.

Parameters
[in]template1Template created by the same method.
[in]template2Template created by the same method.
Returns
Result of the matching.