Enrollment 28.2.0
Loading...
Searching...
No Matches
EmbeddingVerifyMatcher.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "enrollment/Export.h"
19#include <array>
20#include <memory>
21#include <mutex>
22#include <vector>
23
24namespace inno
25{
26 class Logger;
33 */
34 class EmbeddingVerifyMatcher : public EmbeddingMatcher
35 {
36 public:
48 */
49 [[nodiscard]] PrintSimilarityScore Match(const EmbeddingTemplate& probe,
50 const EmbeddingTemplate& gallery) const final
51 {
52 log.LogInfo("Matching embeddings probe %v and gallery %v", probe, gallery);
53 const CallbackLogger slog(log.GetLogger());
54
55 const float score = exec->MatchEmbedding(module.get(),
56 probe.embeddingTemplateData.data(),
57 static_cast<unsigned int>(probe.embeddingTemplateData.size()),
58 gallery.embeddingTemplateData.data(),
59 static_cast<unsigned int>(gallery.embeddingTemplateData.size()),
60 slog.GetCallbacks(),
61 ThrowOnError{});
62
63 log.LogInfo("Matching embeddings probe %v and gallery %v with score %f", probe, gallery, score);
64 return static_cast<PrintSimilarityScore>(score);
65 }
66
71 */
73 : log(GlobalLogger::Get())
74 , exec(GlobalPrintExecutor::Get())
75 , module(Initialize())
76 {
77 }
78
84 */
85 explicit EmbeddingVerifyMatcher(std::shared_ptr<PrintExecutor> executor)
86 : log(GlobalLogger::Get())
87 , exec(std::move(executor))
88 , module(Initialize())
89 {
90 if (exec == nullptr)
91 {
92 throw NullArgumentException("executor can not be null");
93 }
94 }
95
98 EmbeddingVerifyMatcher& operator=(const EmbeddingVerifyMatcher&) = delete;
100 virtual ~EmbeddingVerifyMatcher() = default;
101
102 private:
109 std::unique_ptr<void, inno_Deleter> Initialize()
110 {
111 if (exec == nullptr)
112 {
113 throw NullArgumentException("executor can not be null");
114 }
115
116 inno_Deleter moduleDeleter = nullptr;
117 auto* mod = exec->IFingerCreateMatchingModule(&moduleDeleter, ThrowOnError{});
118 std::unique_ptr<void, inno_Deleter> matcherModule(mod, moduleDeleter);
119
120 return matcherModule;
121 }
122
123 FormattingLogger log;
124 std::shared_ptr<PrintExecutor> exec;
125 std::unique_ptr<void, inno_Deleter> module;
126 };
127} // namespace inno
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
Print template in proprietary embedding format used for biometric operations.
Definition EmbeddingTemplate.h:30
EmbeddingVerifyMatcher is template matcher that uses Innovatrics proprietary verification algorithm.
Definition EmbeddingVerifyMatcher.h:34
PrintSimilarityScore Match(const EmbeddingTemplate &probe, const EmbeddingTemplate &gallery) const final
Calculates similarity score of probe and gallery template.
Definition EmbeddingVerifyMatcher.h:48
EmbeddingVerifyMatcher(std::shared_ptr< PrintExecutor > executor)
Constructor with custom executor .
Definition EmbeddingVerifyMatcher.h:84
EmbeddingVerifyMatcher()
Constructor with default logger, executor and matcher module GlobalPrintExecutor is used to execute m...
Definition EmbeddingVerifyMatcher.h:71
Holds instance of Logger.
Definition Logger.h:275
Holds instance of PrintExecutor.
Definition PrintExecutor.h:1300
Interface for library logging.
Definition Logger.h:45
Null argument is not allowed.
Definition EnrollmentException.h:156
static void Initialize(const InitializerConfig &config)
Initialize SDK from InitializerConfig (license, models path, and thread counts).
Definition Initializer.h:114
unsigned int PrintSimilarityScore
It is similarity score between print Templates.
Definition SimilarityScore.h:28