12#include "enrollment/Export.h"
49 virtual void ConfigureMatchingParameters(
const ICSTemplate& probe,
51 inno_ICSVerifyMatcher_params& params) = 0;
55 virtual void OnCreated() = 0;
61 virtual void CheckCompatibility(inno_ICSVerifyMatcher_params& params) = 0;
65 Artifact(
const Artifact&) =
delete;
66 Artifact(Artifact&&) =
delete;
67 Artifact& operator=(
const Artifact&) =
delete;
68 Artifact& operator=(Artifact&& c) =
delete;
69 virtual ~Artifact() =
default;
71 friend class ICSVerifyMatcher;
77 class Artifacts :
public Artifact
88 void Add(Artifact& artifact)
90 const std::lock_guard lock(artifactsMux);
92 if (isMatchingInProgress)
97 inno_ICSVerifyMatcher_params param = {};
99 for (
auto* a : artifacts)
101 a->CheckCompatibility(param);
105 artifact.CheckCompatibility(param);
107 artifacts.emplace_back(&artifact);
111 void ConfigureMatchingParameters(
const ICSTemplate& probe,
113 inno_ICSVerifyMatcher_params& params)
final
115 const std::lock_guard lock(artifactsMux);
117 for (
auto* a : artifacts)
119 a->ConfigureMatchingParameters(probe, gallery, params);
122 isMatchingInProgress =
true;
125 void OnCreated() final
127 const std::lock_guard lock(artifactsMux);
129 for (
auto* a : artifacts)
134 isMatchingInProgress =
false;
137 void CheckCompatibility(inno_ICSVerifyMatcher_params& params)
final
139 const std::lock_guard lock(artifactsMux);
141 for (
auto* a : artifacts)
143 a->CheckCompatibility(params);
147 std::vector<Artifact*> artifacts;
148 std::mutex artifactsMux;
149 bool isMatchingInProgress =
false;
152 Artifacts() =
default;
153 Artifacts(
const Artifacts&) =
delete;
154 Artifacts(Artifacts&&) =
delete;
155 Artifacts& operator=(
const Artifacts&) =
delete;
156 Artifacts& operator=(Artifacts&& c) =
delete;
157 virtual ~Artifacts() =
default;
165 class MatchingMinutiae :
public Artifact
175 const std::scoped_lock lock(dataMux);
177 if (isMatchingInProgress)
191 const std::scoped_lock lock(dataMux);
193 if (isMatchingInProgress)
209 std::vector<std::shared_ptr<Minutia>> probe;
210 std::vector<uint16_t> matchingProbeIndices;
211 std::vector<std::shared_ptr<Minutia>> gallery;
212 std::vector<uint16_t> matchingGalleryIndices;
213 int maxMatchingMinutiae = 0;
214 mutable std::mutex dataMux;
215 bool isMatchingInProgress =
false;
217 void ConfigureMatchingParameters(
const ICSTemplate& probeTemplate,
219 inno_ICSVerifyMatcher_params& params)
final
221 const std::scoped_lock lock(dataMux);
223 if (isMatchingInProgress)
228 isMatchingInProgress =
true;
230 probe = probeTemplate.GetMinutiae();
231 gallery = galleryTemplate.GetMinutiae();
233 maxMatchingMinutiae =
static_cast<int>(std::min(probe.size(), gallery.size()));
234 matchingProbeIndices.resize(maxMatchingMinutiae);
235 matchingGalleryIndices.resize(maxMatchingMinutiae);
237 params.assocGalleryMinutiae = matchingGalleryIndices.data();
238 params.assocProbeMinutiae = matchingProbeIndices.data();
239 params.associationCount = &maxMatchingMinutiae;
242 void OnCreated() final
244 const std::scoped_lock lock(dataMux);
247 std::vector<std::shared_ptr<Minutia>> reorderedMinutiae;
250 reorderedMinutiae.reserve(maxMatchingMinutiae);
251 for (
int i = 0; i < maxMatchingMinutiae; ++i)
253 reorderedMinutiae.emplace_back(probe[matchingProbeIndices[i]]);
255 std::swap(probe, reorderedMinutiae);
257 reorderedMinutiae.clear();
258 reorderedMinutiae.reserve(maxMatchingMinutiae);
259 for (
int i = 0; i < maxMatchingMinutiae; ++i)
261 reorderedMinutiae.emplace_back(gallery[matchingGalleryIndices[i]]);
263 std::swap(gallery, reorderedMinutiae);
265 isMatchingInProgress =
false;
268 void CheckCompatibility(inno_ICSVerifyMatcher_params& params)
final
270 if (params.assocGalleryMinutiae !=
nullptr || params.associationCount !=
nullptr ||
271 params.assocProbeMinutiae !=
nullptr)
273 throw EnrollmentRuntimeException(
"matching minutiae artifact is already enabled");
276 static uint16_t c = 0;
279 params.assocGalleryMinutiae = &c;
280 params.assocProbeMinutiae = &c;
281 params.associationCount = &d;
288 class Config :
public Serializable
305 static constexpr unsigned int MaxRotation = 180;
306 if (value > MaxRotation)
327 writer.Write(
"r", maxRotation);
354 static constexpr unsigned int DefaultMaxRotation = 180;
355 unsigned int maxRotation = DefaultMaxRotation;
366 auto nullArtifact = NullArtifact();
367 return Match(probe, gallery, nullArtifact);
381 log.LogInfo(
"Matching prints probe %v and gallery %v with config %v", probe, gallery, cfg);
383 inno_ICSVerifyMatcher_params params = {};
389 params.maxRotation =
static_cast<int>(cfg.GetMaxRotation());
391 artifact.ConfigureMatchingParameters(probe, gallery, params);
393 exec->MatchICS(¶ms, slog.
GetCallbacks(), ThrowOnError{});
395 artifact.OnCreated();
397 log.LogInfo(
"Matching prints probe %v and gallery %v with score %d", probe, gallery, params.score);
418 : cfg(std::move(config))
431 : cfg(std::move(config))
433 , exec(std::move(executor))
449 , exec(std::move(executor))
466 std::shared_ptr<PrintExecutor> exec;
468 class NullArtifact final :
public Artifact
471 void ConfigureMatchingParameters(
const ICSTemplate& ,
473 inno_ICSVerifyMatcher_params& )
final
476 void OnCreated() final
479 void CheckCompatibility(inno_ICSVerifyMatcher_params& )
final
484 NullArtifact() =
default;
485 NullArtifact(
const NullArtifact&) =
delete;
486 NullArtifact(NullArtifact&&) =
delete;
487 NullArtifact& operator=(
const NullArtifact&) =
delete;
488 NullArtifact& operator=(NullArtifact&& c) =
delete;
489 virtual ~NullArtifact() =
default;
CallbackLogger is logger for binary part of libary due to C boundary.
Definition Logger.h:157
LoggerCallBacks GetCallbacks() const
Get the Callbacks object.
Definition Logger.h:166
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
Holds instance of Logger.
Definition Logger.h:275
Holds instance of PrintExecutor.
Definition PrintExecutor.h:1300
Print template in ICS format used for biometric operations.
Definition ICSTemplate.h:41
const std::vector< uint8_t > icsTemplateData
template data
Definition ICSTemplate.h:44
Interface that generalize storing of artifacts that are produced during matching.
Definition ICSVerifyMatcher.h:39
void Add(Artifact &artifact)
Add artifact to be created during matching.
Definition ICSVerifyMatcher.h:87
ICSVerifyMatcher configuration.
Definition ICSVerifyMatcher.h:288
void WriteTo(Writer &writer) const final
Function serializes configuration via provided Writer.
Definition ICSVerifyMatcher.h:324
void SetMaxRotation(unsigned int value)
Set the Max Rotation.
Definition ICSVerifyMatcher.h:302
static Config Default()
Provides default config.
Definition ICSVerifyMatcher.h:335
Config()=default
Default configuration is.
unsigned int GetMaxRotation() const
Get the Max Rotation.
Definition ICSVerifyMatcher.h:316
It enables creation of matching minutiae during matching.
Definition ICSVerifyMatcher.h:165
std::vector< std::shared_ptr< Minutia > > GetGalleryMinutiae() const
Get gallery matching minutiae.
Definition ICSVerifyMatcher.h:188
std::vector< std::shared_ptr< Minutia > > GetProbeMinutiae() const
Get probe matching minutiae.
Definition ICSVerifyMatcher.h:172
ICSVerifyMatcher is template matcher that uses Innovatrics proprietary verification algorithm.
Definition ICSVerifyMatcher.h:32
ICSVerifyMatcher()
Constructor with default Config GlobalPrintExecutor is used to execute matching.
Definition ICSVerifyMatcher.h:404
PrintSimilarityScore Match(const ICSTemplate &probe, const ICSTemplate &gallery) const final
Calculates similarity score of probe and gallery template.
Definition ICSVerifyMatcher.h:363
ICSVerifyMatcher(std::shared_ptr< PrintExecutor > executor)
Constructor with default Config.
Definition ICSVerifyMatcher.h:445
ICSVerifyMatcher(Config config, std::shared_ptr< PrintExecutor > executor)
Constructor uses Config to setup matching algorithm.
Definition ICSVerifyMatcher.h:429
PrintSimilarityScore Match(const ICSTemplate &probe, const ICSTemplate &gallery, Artifact &artifact) const
Calculates similarity score of probe and gallery template and provide artifacts.
Definition ICSVerifyMatcher.h:376
ICSVerifyMatcher(Config config)
Constructor uses Config to setup matching algorithm.
Definition ICSVerifyMatcher.h:416
Interface for library logging.
Definition Logger.h:45
Null argument is not allowed.
Definition EnrollmentException.h:156
Provides interface for serialization of all classes.
Definition Writer.h:164
unsigned int PrintSimilarityScore
It is similarity score between print Templates.
Definition SimilarityScore.h:28