Enrollment 28.2.0
Loading...
Searching...
No Matches
ExtractedPrint.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "enrollment/Export.h"
22#include <algorithm>
23#include <mutex>
24
25// cppcoreguidelines-non-private-member-variables-in-classes,misc-non-private-member-variables-in-classes: This is not a
26// problem because we are using them only as read only.
27// cppcoreguidelines-avoid-const-or-ref-data-members: We design te API with const member variables instead of
28// implementing getter methods. This is nicely transformed in C# to properties. Usually our objects are immutable by
29// intention to have no problem in multithreaded applications.
30// NOLINTBEGIN(cppcoreguidelines-non-private-member-variables-in-classes,misc-non-private-member-variables-in-classes,cppcoreguidelines-avoid-const-or-ref-data-members)
31namespace inno
32{
35 */
36 class ExtractedPrint final : public ICSTemplate
37 {
38 public:
40 const std::shared_ptr<Print> print;
41
50 */
51 static std::vector<std::shared_ptr<ICSTemplate>> ToICSTemplates(
52 const std::vector<std::shared_ptr<ExtractedPrint>>& prints)
53 {
54 std::vector<std::shared_ptr<ICSTemplate>> templates(prints.size());
55 std::transform(prints.begin(), prints.end(), templates.begin(), [](const auto& t) { return t; });
56 return templates;
57 }
58
67 */
68 static std::vector<std::shared_ptr<PrintTemplate>> ToTemplates(
69 const std::vector<std::shared_ptr<ExtractedPrint>>& prints)
70 {
71 std::vector<std::shared_ptr<PrintTemplate>> templates(prints.size());
72 std::transform(prints.begin(),
73 prints.end(),
74 templates.begin(),
75 [](const auto& t)
76 {
77 if (t->HasEmbeddingRepresentation())
78 {
79 return std::make_shared<PrintTemplate>(t, t->e);
80 }
81 return std::make_shared<PrintTemplate>(t);
82 });
83 return templates;
84 }
85
95 */
96 void EnhanceWithEmbedding(std::shared_ptr<ExtractedPrintEmbedding> embedding)
97 {
98 if (embedding == nullptr)
99 {
100 throw NullArgumentException("Embedding can not be null");
101 }
102 if (print != embedding->print)
103 {
105 "ExtractedPrint and embedding were not created from same print");
106 }
107 const std::scoped_lock lock(embeddingMutex);
108 e = std::move(embedding);
109 }
110
119 */
120 void EnhanceWithEmbedding(const EmbeddingExtractor& extractor)
121 {
122 const std::scoped_lock lock(embeddingMutex);
123 e = extractor.Extract(print);
124 }
132 */
133 std::shared_ptr<ExtractedPrintEmbedding> GetEmbeddingRepresentation() const
134 {
135 const std::scoped_lock lock(embeddingMutex);
136 return e;
137 }
138
146 */
147 bool HasEmbeddingRepresentation() const
148 {
149 const std::scoped_lock lock(embeddingMutex);
150 return e != nullptr;
151 }
157 */
158 ExtractedPrint(std::vector<uint8_t>&& d, std::shared_ptr<Print> fp)
159 : ICSTemplate(std::move(d), GetSafePrintPosition(fp))
160 , print(std::move(fp))
161 {
162 }
163
172 */
173 ExtractedPrint(std::vector<uint8_t>&& d, std::shared_ptr<Print> fp, std::shared_ptr<PrintExecutor> executor)
174 : ICSTemplate(std::move(d), GetSafePrintPosition(fp), std::move(executor))
175 , print(std::move(fp))
176 {
177 }
178
184 */
185 std::shared_ptr<ISOTemplate> ToISO() const
186 {
188 }
189
195 */
196 std::shared_ptr<ANSITemplate> ToANSI() const
197 {
199 }
201 void WriteTo(Writer& w) const final
202 {
203 w.Write("p", print);
205 const std::scoped_lock lock(embeddingMutex);
206 w.Write("e", e);
207 }
208
209 ExtractedPrint(const ExtractedPrint&) = delete;
210 ExtractedPrint(ExtractedPrint&&) = delete;
211 ExtractedPrint& operator=(const ExtractedPrint&) = delete;
212 ExtractedPrint& operator=(ExtractedPrint&&) = delete;
213 ExtractedPrint() = delete;
214 virtual ~ExtractedPrint() = default;
215
216 private:
217 mutable std::mutex embeddingMutex;
218 std::shared_ptr<ExtractedPrintEmbedding> e;
219
220 static PrintPosition GetSafePrintPosition(const std::shared_ptr<Print>& p)
221 {
222 if (p == nullptr)
223 {
224 throw EnrollmentRuntimeException("Print cannot be null in ExtractedPrint");
225 }
226
227 return p->position;
228 }
229 };
230
231} // namespace inno
232// NOLINTEND(cppcoreguidelines-non-private-member-variables-in-classes,misc-non-private-member-variables-in-classes,cppcoreguidelines-avoid-const-or-ref-data-members)
Definition EmbeddingExtractor.h:21
virtual std::shared_ptr< ExtractedPrintEmbedding > Extract(const std::shared_ptr< Print > &print) const =0
Function creates embedding template for given Print.
Base exception for all enrollment-sdk invalid argument exceptions.
Definition EnrollmentException.h:96
Base exception for all enrollment-sdk runtime exceptions.
Definition EnrollmentException.h:84
Print template in ICS format used for biometric operations with Print that was extracted.
Definition ExtractedPrint.h:36
void EnhanceWithEmbedding(const EmbeddingExtractor &extractor)
Enhances the object with an embedding representation using an embedding extractor.
Definition ExtractedPrint.h:119
std::shared_ptr< ExtractedPrintEmbedding > GetEmbeddingRepresentation() const
Retrieves the embedding representation associated with the object.
Definition ExtractedPrint.h:132
std::shared_ptr< ISOTemplate > ToISO() const
Convert this ExtractedPrint to into ISO/IEC 19794-2 compliant template.
Definition ExtractedPrint.h:184
ExtractedPrint(std::vector< uint8_t > &&d, std::shared_ptr< Print > fp, std::shared_ptr< PrintExecutor > executor)
Create ExtractedPrint object.
Definition ExtractedPrint.h:172
bool HasEmbeddingRepresentation() const
Checks if the object has an embedding representation.
Definition ExtractedPrint.h:146
ExtractedPrint(std::vector< uint8_t > &&d, std::shared_ptr< Print > fp)
Create ExtractedPrint object.
Definition ExtractedPrint.h:157
void EnhanceWithEmbedding(std::shared_ptr< ExtractedPrintEmbedding > embedding)
Enhances the object with an embedding representation.
Definition ExtractedPrint.h:95
static std::vector< std::shared_ptr< ICSTemplate > > ToICSTemplates(const std::vector< std::shared_ptr< ExtractedPrint > > &prints)
Converts a vector of ExtractedPrint objects into a vector of ICSTemplate objects.
Definition ExtractedPrint.h:50
void WriteTo(Writer &w) const final
Write itself into writer.
Definition ExtractedPrint.h:200
static std::vector< std::shared_ptr< PrintTemplate > > ToTemplates(const std::vector< std::shared_ptr< ExtractedPrint > > &prints)
Converts a vector of ExtractedPrint objects into a vector of PrintTemplate objects.
Definition ExtractedPrint.h:67
const std::shared_ptr< Print > print
Print that was extracted.
Definition ExtractedPrint.h:39
std::shared_ptr< ANSITemplate > ToANSI() const
Convert this ExtractedPrint to into ANSI/INCITS 378 compliant template.
Definition ExtractedPrint.h:195
std::shared_ptr< ISOTemplate > ToISO(const std::shared_ptr< const Print > &print) const
Convert this ICSTemplate to into ISO/IEC 19794-2 compliant template.
Definition ICSTemplate.h:231
ICSTemplate(std::vector< uint8_t > d)
Create ICSTemplate object GlobalPrintExecutor is used to execute template functionality.
Definition ICSTemplate.h:110
std::shared_ptr< ANSITemplate > ToANSI(const std::shared_ptr< const Print > &print) const
Convert this ICSTemplate to into ANSI/INCITS 378 compliant template.
Definition ICSTemplate.h:261
void WriteTo(Writer &w) const override
Write itself into writer.
Definition ICSTemplate.h:370
Null argument is not allowed.
Definition EnrollmentException.h:156
Provides interface for serialization of all classes.
Definition Writer.h:164
PrintPosition
It is position of finger on hands.
Definition PrintPosition.h:29