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++
auto templates =
std::unordered_map<size_t, std::shared_ptr<ModalitiesTemplate>>{};
templates.emplace(
templates.emplace(
gallery->Add(1, templates[1]);
gallery->Add(2, templates[2]);
auto probe = templates[1];
constexpr size_t MaxCandidates = 2;
auto result = gallery->IdentifyModalities(probe, MaxCandidates);
for (const auto& id : result->GetPrintIdentifiers())
{
std::cout << " Found Id is " << id << std::endl;
}
-
java
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);
IndexedModalitiesGallery gallery = IndexedModalitiesGallery.
Create(
new IndexedModalitiesGalleryConfig());
gallery.
Add(1, templates.get(1L));
gallery.
Add(2, templates.get(2L));
long maxCandidates = 2;
probe, maxCandidates);
System.out.println(" Found Id is " + id);
}
-
csharp
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];
var gallery =
IndexedModalitiesGallery.Create(new IndexedModalitiesGalleryConfig());
gallery.Add(1, templates[1]);
gallery.Add(2, templates[2]);
var maxCandidates = 2U;
var result = gallery.IdentifyModalities(probe, maxCandidates);
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++
auto printCandidates = std::vector<std::shared_ptr<ModalitiesGalleryReference>>{};
for (const auto& id : result->GetPrintIdentifiers())
{
printCandidates.push_back(
std::make_shared<ModalitiesGalleryIndexedTemplate>(id, templates[id]));
}
auto consolidationCandidates =
std::make_shared<ModalitiesGallery::ModalitiesCandidates>(
std::move(printCandidates),
std::vector<std::shared_ptr<ModalitiesGalleryReference>>{},
std::vector<std::shared_ptr<ModalitiesGalleryReference>>{},
probe);
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
ArrayList<ModalitiesGalleryReference> printCandidates
= new ArrayList<ModalitiesGalleryReference>();
printCandidates.add(
new ModalitiesGalleryIndexedTemplate(id, templates.get(id)));
}
ModalitiesGallery.ModalitiesCandidates consolidationCandidates
= new ModalitiesGallery.ModalitiesCandidates(printCandidates,
new ArrayList<ModalitiesGalleryReference>(),
new ArrayList<ModalitiesGalleryReference>(), probe);
ArrayList<ModalitiesGallery.Candidate> candidates = ModalitiesGallery.Consolidate(
consolidationCandidates, maxCandidates);
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
var printCandidates = new List<ModalitiesGalleryReference>();
foreach (uint id in result.GetPrintIdentifiers())
{
printCandidates.Add(new ModalitiesGalleryIndexedTemplate(id, templates[id]));
}
var consolidationCandidates = new ModalitiesGallery.ModalitiesCandidates(
printCandidates, new List<ModalitiesGalleryReference>(),
new List<ModalitiesGalleryReference>(), probe);
var candidates = ModalitiesGallery.Consolidate(consolidationCandidates, 2);
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() + "]");
}