Enrollment 28.2.0
Loading...
Searching...
No Matches

Gallery of references identifiers. More...

#include <IndexedModalitiesGallery.h>

Collaboration diagram for IndexedModalitiesGallery:

Classes

class  ModalitiesIdentifiers
 Contains candidates per each modality. More...

Public Types

using Identifier = size_t
 Index identifier of reference in gallery.

Public Member Functions

virtual void Add (Identifier identifier, const std::shared_ptr< ModalitiesTemplate > &templ)
 Adds reference template under index identifier into gallery.
virtual void Remove (Identifier identifier)
 Removes reference template under provided index identifier from the gallery.
virtual std::shared_ptr< ModalitiesIdentifiers > IdentifyModalities (const std::shared_ptr< ModalitiesTemplate > &probe, size_t maxCandidates) const
 Search for given probe.

Static Public Member Functions

static std::shared_ptr< IndexedModalitiesGallery > Create (IndexedModalitiesGalleryConfig config)
 Create indexed gallery of references.

Detailed Description

Gallery of references identifiers.

Note
The number of references in any IndexedModalitiesGallery is limited by license. You can have more created galleries in your code. The number limits overall references in all galleries.

The IndexedModalitiesGallery stores only the data necessary for identification. Relevant data from ModalitiesTemplate is copied into the gallery using the IndexedModalitiesGallery::Add() function.

The IndexedModalitiesGallery::IdentifyModalities() function returns reference index identifiers to the user.

Adding data to the gallery can be faster in higher-level language bindings and consumes less memory, as only the essential identification data is stored compared to ModalitiesGallery. However, the user must maintain a mapping between their reference representation and the identifier provided to IndexedModalitiesGallery::Add().

It is recommended to use IndexedModalitiesGallery for performance- and memory-critical use cases and to prefer it over the more convenient ModalitiesGallery.

  • c++
    // Recreate your own data types from data stored during enrollment
    auto templates =
    std::unordered_map<size_t, std::shared_ptr<ModalitiesTemplate>>{};
    templates.emplace(
    1, ModalitiesTemplate::Create(BinaryFile::ReadAll("output/1.tmpl")));
    templates.emplace(
    2, ModalitiesTemplate::Create(BinaryFile::ReadAll("output/2.tmpl")));
    // Create a gallery and add users.
    gallery->Add(1, templates[1]);
    gallery->Add(2, templates[2]);
    auto probe = templates[1];
    // Identify a probe in the gallery.
    constexpr size_t MaxCandidates = 2; // size of result set of candidates
    auto result = gallery->IdentifyModalities(probe, MaxCandidates);
    // Output identification results.
    for (const auto& id : result->GetPrintIdentifiers())
    {
    std::cout << " Found Id is " << id << std::endl;
    }
  • java
    // Recreate your own data types from data stored during enrollment
    HashMap<Long, ModalitiesTemplate> templates
    = new HashMap<Long, ModalitiesTemplate>();
    templates.put(1L, ModalitiesTemplate.Create(BinaryFile.ReadAll("output/1.tmpl")));
    templates.put(2L, ModalitiesTemplate.Create(BinaryFile.ReadAll("output/2.tmpl")));
    ModalitiesTemplate probe = templates.get(1L);
    // Create a gallery and add users.
    IndexedModalitiesGallery gallery = IndexedModalitiesGallery.Create(
    new IndexedModalitiesGalleryConfig());
    gallery.Add(1, templates.get(1L));
    gallery.Add(2, templates.get(2L));
    // Identify a probe in the gallery.
    long maxCandidates = 2; // size of result set of candidates
    IndexedModalitiesGallery.ModalitiesIdentifiers result = gallery.IdentifyModalities(
    probe, maxCandidates);
    // Output identification results.
    for (long id : result.GetPrintIdentifiers()) {
    System.out.println(" Found Id is " + id);
    }
  • csharp
    // Recreate your own data types from data stored during enrollment
    var templates = new Dictionary<uint, ModalitiesTemplate>();
    templates.Add(1, ModalitiesTemplate.Create(BinaryFile.ReadAll("output/1.tmpl")));
    templates.Add(2, ModalitiesTemplate.Create(BinaryFile.ReadAll("output/2.tmpl")));
    var probe = templates[1];
    // Create a gallery and add users.
    var gallery =
    IndexedModalitiesGallery.Create(new IndexedModalitiesGalleryConfig());
    gallery.Add(1, templates[1]);
    gallery.Add(2, templates[2]);
    // Identify a probe in the gallery.
    var maxCandidates = 2U; // size of result set of candidates
    var result = gallery.IdentifyModalities(probe, maxCandidates);
    // Output identification results.
    foreach (uint id in result.GetPrintIdentifiers())
    {
    System.Console.WriteLine(" Found Id is " + id);
    }

Once the candidates are identified, you can use ModalitiesGallery::Consolidate() static function to get unique list of candidates with scores.

  • c++
    // Create print candidates for consolidation
    auto printCandidates = std::vector<std::shared_ptr<ModalitiesGalleryReference>>{};
    for (const auto& id : result->GetPrintIdentifiers())
    {
    printCandidates.push_back(
    std::make_shared<ModalitiesGalleryIndexedTemplate>(id, templates[id]));
    }
    // Create type that holds all necessary information for consolidation.
    auto consolidationCandidates =
    std::make_shared<ModalitiesGallery::ModalitiesCandidates>(
    std::move(printCandidates),
    std::vector<std::shared_ptr<ModalitiesGalleryReference>>{},
    std::vector<std::shared_ptr<ModalitiesGalleryReference>>{},
    probe);
    // Consolidate
    auto candidates = ModalitiesGallery::Consolidate(consolidationCandidates, 2);
    // Output identification results.
    for (const auto& c : candidates)
    {
    std::cout << " Id is " << c.GetCandidate()->GetIndex() << " score is ["
    << c.GetScore().GetPrintScore() << ", "
    << c.GetScore().GetFaceScore() << ", "
    << c.GetScore().GetIrisScore() << "]" << std::endl;
    }
  • java
    // Create print candidates for consolidation
    ArrayList<ModalitiesGalleryReference> printCandidates
    = new ArrayList<ModalitiesGalleryReference>();
    for (long id : result.GetPrintIdentifiers()) {
    printCandidates.add(
    new ModalitiesGalleryIndexedTemplate(id, templates.get(id)));
    }
    // Create type that holds all necessary information for consolidation.
    ModalitiesGallery.ModalitiesCandidates consolidationCandidates
    = new ModalitiesGallery.ModalitiesCandidates(printCandidates,
    new ArrayList<ModalitiesGalleryReference>(),
    new ArrayList<ModalitiesGalleryReference>(), probe);
    // Consolidate
    ArrayList<ModalitiesGallery.Candidate> candidates = ModalitiesGallery.Consolidate(
    consolidationCandidates, maxCandidates);
    // Print result
    for (ModalitiesGallery.Candidate c : candidates) {
    System.out.println(" Id is " + c.GetCandidate().GetIndex() + " score is ["
    + c.GetScore().GetPrintScore() + ", "
    + c.GetScore().GetFaceScore() + ", "
    + c.GetScore().GetIrisScore() + "]");
    }
  • csharp
    // Create print candidates for consolidation
    var printCandidates = new List<ModalitiesGalleryReference>();
    foreach (uint id in result.GetPrintIdentifiers())
    {
    printCandidates.Add(new ModalitiesGalleryIndexedTemplate(id, templates[id]));
    }
    // Create type that holds all necessary information for consolidation.
    var consolidationCandidates = new ModalitiesGallery.ModalitiesCandidates(
    printCandidates, new List<ModalitiesGalleryReference>(),
    new List<ModalitiesGalleryReference>(), probe);
    // Consolidate
    var candidates = ModalitiesGallery.Consolidate(consolidationCandidates, 2);
    // Print result
    foreach (ModalitiesGallery.Candidate c in candidates)
    {
    System.Console.WriteLine(" Id is " + c.GetCandidate().GetIndex() +
    " score is [" + c.GetScore().GetPrintScore() +
    ", " + c.GetScore().GetFaceScore() + ", " +
    c.GetScore().GetIrisScore() + "]");
    }

Member Function Documentation

◆ Add()

virtual void Add ( Identifier identifier,
const std::shared_ptr< ModalitiesTemplate > & templ )
inlinevirtual

Adds reference template under index identifier into gallery.

It copies necessary data for identification into gallery. It is not necessary to keep given templ.

Parameters
identifierreference identifier
templreference ModalitiesTemplate
Exceptions
EnrollmentExceptionwhen it is not possible to add reference
NullArgumentExceptionwhen templ is null
EnrollmentInvalidArgumentExceptionwhen at least one probe print has position different as PrintPosition::LEFT_INDEX, PrintPosition::LEFT_LITTLE, PrintPosition::LEFT_MIDDLE, PrintPosition::LEFT_THUMB, PrintPosition::LEFT_RING, PrintPosition::RIGHT_INDEX, PrintPosition::RIGHT_LITTLE, PrintPosition::RIGHT_MIDDLE, PrintPosition::RIGHT_THUMB, PrintPosition::RIGHT_RING or no position.
NullArgumentExceptionwhen some print in probe prints is null.
NullArgumentExceptionwhen some face in probe faces is null.
NullArgumentExceptionwhen some iris in probe irises is null.

◆ Create()

std::shared_ptr< IndexedModalitiesGallery > Create ( IndexedModalitiesGalleryConfig config)
inlinestatic

Create indexed gallery of references.

Parameters
configConfig of gallery
Returns
created gallery
Exceptions
EnrollmentExceptionwhen it is not possible to create gallery

Referenced by ModalitiesGallery::Create(), ModalitiesGallery::Create(), and ModalitiesGallery::Create().

Here is the caller graph for this function:

◆ IdentifyModalities()

virtual std::shared_ptr< ModalitiesIdentifiers > IdentifyModalities ( const std::shared_ptr< ModalitiesTemplate > & probe,
size_t maxCandidates ) const
inlinenodiscardvirtual

Search for given probe.

Parameters
probeprobe that is searched in gallery
maxCandidatesmaximum number of returned identified candidates
Returns
identified candidates per modalities without score. To get scores and unique candidates list use function ModalitiesGallery::Consolidate().
Exceptions
EnrollmentExceptionwhen it is not possible to identify probe
NullArgumentExceptionwhen probe is null
NullArgumentExceptionwhen some print in probe prints is null.
NullArgumentExceptionwhen some face in probe faces is null.
NullArgumentExceptionwhen some iris in probe irises is null.

◆ Remove()

virtual void Remove ( Identifier identifier)
inlinevirtual

Removes reference template under provided index identifier from the gallery.

Parameters
identifierreference identifier
Exceptions
EnrollmentExceptionwhen the provided identifier is not in the gallery

The documentation for this class was generated from the following file: