Enrollment 28.2.0
Loading...
Searching...
No Matches
EmbeddingTemplate.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "enrollment/Export.h"
17#include <vector>
18
19// cppcoreguidelines-non-private-member-variables-in-classes,misc-non-private-member-variables-in-classes: This is not a
20// problem because we are using them only as read only.
21// cppcoreguidelines-avoid-const-or-ref-data-members: We design te API with const member variables instead of
22// implementing getter methods. This is nicely transformed in C# to properties. Usually our objects are immutable by
23// intention to have no problem in multithreaded applications.
24// NOLINTBEGIN(cppcoreguidelines-non-private-member-variables-in-classes,misc-non-private-member-variables-in-classes,cppcoreguidelines-avoid-const-or-ref-data-members)
25namespace inno
26{
29 */
30 class EmbeddingTemplate : public Serializable
31 {
32 public:
33 const std::vector<uint8_t> embeddingTemplateData;
34
43 */
44 [[nodiscard]] PrintSimilarityScore SimilarWith(const EmbeddingTemplate& tmpl,
45 const EmbeddingMatcher& matcher) const
46 {
47 return matcher.Match(*this, tmpl);
48 }
49
55 */
56 [[nodiscard]] bool IsEmbeddingTemplateBiometricPositionKnown() const
57 {
58 return pos.has_value();
59 }
60
66 */
68 {
69 if (!pos.has_value())
70 {
71 throw EnrollmentRuntimeException("EmbeddingTemplate has unknown biometric position");
72 }
73
74 return pos.value();
75 }
76
81 */
82 [[nodiscard]] std::string GetVersion() const
83 {
84
85 uint32_t ifingerVersion = 0;
86 uint32_t enrollmentVersion = 0;
87 exec->IFingerGetTemplateVersion(&ifingerVersion,
88 &enrollmentVersion,
89 embeddingTemplateData.data(),
90 static_cast<uint32_t>(embeddingTemplateData.size()),
91 ThrowOnError{});
92
93 return std::to_string(ifingerVersion) + "." + std::to_string(enrollmentVersion);
94 }
95
103 */
104 explicit EmbeddingTemplate(std::vector<uint8_t>&& d)
105 : embeddingTemplateData(std::move(d))
106 , exec(GlobalPrintExecutor::Get())
107 {
108 if (embeddingTemplateData.empty())
109 {
110 throw InvalidTemplateException("Embedding template MUST have data");
111 }
112 }
113
121 */
122 explicit EmbeddingTemplate(const std::vector<uint8_t>& d)
123 : embeddingTemplateData(d)
124 , exec(GlobalPrintExecutor::Get())
125 {
126 if (embeddingTemplateData.empty())
127 {
128 throw InvalidTemplateException("Embedding template MUST have data");
129 }
130 }
131
140 */
141 EmbeddingTemplate(std::vector<uint8_t>&& d, std::shared_ptr<PrintExecutor> executor)
142 : embeddingTemplateData(std::move(d))
143 , exec(std::move(executor))
144 {
145 if (exec == nullptr)
146 {
147 throw NullArgumentException("executor can not be null");
148 }
149 if (embeddingTemplateData.empty())
150 {
151 throw InvalidTemplateException("Embedding template MUST have data");
152 }
153 }
154
163 */
164 EmbeddingTemplate(const std::vector<uint8_t>& d, std::shared_ptr<PrintExecutor> executor)
165 : embeddingTemplateData(d)
166 , exec(std::move(executor))
167 {
168 if (exec == nullptr)
169 {
170 throw NullArgumentException("executor can not be null");
171 }
172 if (embeddingTemplateData.empty())
173 {
174 throw InvalidTemplateException("Embedding template MUST have data");
175 }
176 }
177
185 */
186 explicit EmbeddingTemplate(std::vector<uint8_t>&& d, PrintPosition position)
187 : embeddingTemplateData(std::move(d))
188 , exec(GlobalPrintExecutor::Get())
189 , pos(position)
190 {
191 if (embeddingTemplateData.empty())
192 {
193 throw InvalidTemplateException("Embedding template MUST have data");
194 }
195 }
196
204 */
205 explicit EmbeddingTemplate(const std::vector<uint8_t>& d, PrintPosition position)
206 : embeddingTemplateData(d)
207 , exec(GlobalPrintExecutor::Get())
208 , pos(position)
209 {
210 if (embeddingTemplateData.empty())
211 {
212 throw InvalidTemplateException("Embedding template MUST have data");
213 }
214 }
215
224 */
225 EmbeddingTemplate(std::vector<uint8_t>&& d, PrintPosition position, std::shared_ptr<PrintExecutor> executor)
226 : embeddingTemplateData(std::move(d))
227 , exec(std::move(executor))
228 , pos(position)
229 {
230 if (exec == nullptr)
231 {
232 throw NullArgumentException("executor can not be null");
233 }
234 if (embeddingTemplateData.empty())
235 {
236 throw InvalidTemplateException("Embedding template MUST have data");
237 }
238 }
239
248 */
249 EmbeddingTemplate(const std::vector<uint8_t>& d,
250 PrintPosition position,
251 std::shared_ptr<PrintExecutor> executor)
252 : embeddingTemplateData(d)
253 , exec(std::move(executor))
254 , pos(position)
255 {
256 if (exec == nullptr)
257 {
258 throw NullArgumentException("executor can not be null");
259 }
260 if (embeddingTemplateData.empty())
261 {
262 throw InvalidTemplateException("Embedding template MUST have data");
263 }
264 }
266 void WriteTo(Writer& w) const override
267 {
268 w.WriteArray("d", embeddingTemplateData);
269 }
270
271 EmbeddingTemplate(const EmbeddingTemplate&) = delete;
273 EmbeddingTemplate& operator=(const EmbeddingTemplate&) = delete;
274 EmbeddingTemplate& operator=(EmbeddingTemplate&&) = delete;
275 EmbeddingTemplate() = delete;
276 virtual ~EmbeddingTemplate() = default;
277
278 private:
279 std::shared_ptr<PrintExecutor> exec;
280 std::optional<PrintPosition> pos;
281 };
282} // namespace inno
283// NOLINTEND(cppcoreguidelines-non-private-member-variables-in-classes,misc-non-private-member-variables-in-classes,cppcoreguidelines-avoid-const-or-ref-data-members)
It is general matcher for Embedding templates.
Definition EmbeddingMatcher.h:23
virtual PrintSimilarityScore Match(const EmbeddingTemplate &probe, const EmbeddingTemplate &gallery) const =0
Calculates similarity score of probe and gallery template.
Print template in proprietary embedding format used for biometric operations.
Definition EmbeddingTemplate.h:30
EmbeddingTemplate(std::vector< uint8_t > &&d, std::shared_ptr< PrintExecutor > executor)
Create EmbeddingTemplate object.
Definition EmbeddingTemplate.h:140
PrintPosition GetEmbeddingTemplateBiometricPosition() const
It returns biometric position to which template belongs.
Definition EmbeddingTemplate.h:66
std::string GetVersion() const
Provides version information of Innovatrics proprietary algorithm used to create the embedding templa...
Definition EmbeddingTemplate.h:81
EmbeddingTemplate(const std::vector< uint8_t > &d, std::shared_ptr< PrintExecutor > executor)
Create EmbeddingTemplate object that copies data.
Definition EmbeddingTemplate.h:163
EmbeddingTemplate(std::vector< uint8_t > &&d)
Create EmbeddingTemplate object.
Definition EmbeddingTemplate.h:103
EmbeddingTemplate(const std::vector< uint8_t > &d, PrintPosition position, std::shared_ptr< PrintExecutor > executor)
Create EmbeddingTemplate object copy data.
Definition EmbeddingTemplate.h:248
PrintSimilarityScore SimilarWith(const EmbeddingTemplate &tmpl, const EmbeddingMatcher &matcher) const
It calculates similarity score between this and given EmbeddingTemplate.
Definition EmbeddingTemplate.h:43
EmbeddingTemplate(std::vector< uint8_t > &&d, PrintPosition position, std::shared_ptr< PrintExecutor > executor)
Create EmbeddingTemplate object.
Definition EmbeddingTemplate.h:224
EmbeddingTemplate(std::vector< uint8_t > &&d, PrintPosition position)
Create EmbeddingTemplate object.
Definition EmbeddingTemplate.h:185
EmbeddingTemplate(const std::vector< uint8_t > &d)
Create EmbeddingTemplate object that copies the data.
Definition EmbeddingTemplate.h:121
EmbeddingTemplate(const std::vector< uint8_t > &d, PrintPosition position)
Create EmbeddingTemplate object that copies the data.
Definition EmbeddingTemplate.h:204
bool IsEmbeddingTemplateBiometricPositionKnown() const
It checks if template contains known biometric position.
Definition EmbeddingTemplate.h:55
void WriteTo(Writer &w) const override
Write itself into writer.
Definition EmbeddingTemplate.h:265
Base exception for all enrollment-sdk runtime exceptions.
Definition EnrollmentException.h:84
Holds instance of PrintExecutor.
Definition PrintExecutor.h:1300
Null argument is not allowed.
Definition EnrollmentException.h:156
Provides interface for serialization of all classes.
Definition Writer.h:164
void WriteArray(const char *name, const std::vector< uint8_t > &value)
Serialize bytes from vector.
Definition Writer.h:233
PrintPosition
It is position of finger on hands.
Definition PrintPosition.h:29
unsigned int PrintSimilarityScore
It is similarity score between print Templates.
Definition SimilarityScore.h:28