Enrollment
28.2.0
Theme:
Default
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
IdentificationEmbeddingExtractor.h
Go to the documentation of this file.
1
9
10
#pragma once
11
12
#include "enrollment/Export.h"
13
#include "
enrollment/Logger/FormattingLogger.h
"
14
#include "
enrollment/Print/EmbeddingExtractor.h
"
15
#include "
enrollment/Print/ExtractedPrintEmbedding.h
"
16
#include "
enrollment/Serialization/Writer.h
"
17
#include <vector>
18
19
namespace
inno
20
{
21
class
Logger;
22
28
*/
29
class
IdentificationEmbeddingExtractor
:
public
EmbeddingExtractor
30
{
31
public
:
41
*/
42
[[nodiscard]] std::shared_ptr<ExtractedPrintEmbedding>
Extract
(
const
std::shared_ptr<Print>& print)
const
final
43
{
44
if
(print ==
nullptr
)
45
{
46
throw
NullArgumentException
(
"Print can not be null"
);
47
}
48
49
log.LogInfo(
"Print embedding extraction for %v ..."
, print);
50
51
auto
rawImage = print->image->AsRawImage();
52
53
std::vector<uint8_t> tmplData;
54
auto
tmplAllocator = +[](
void
* container,
size_t
length) -> uint8_t*
55
{
56
// It is "safe" cast because we forward pointer to vector created in "user cpp space"
57
// (the space where this header is compiled) and the "own cpp space" (out compiled shared library)
58
// wil provide it back for us to the same "user cpp space". We have all spaces under control.
59
// It is used to do not have unecessary copy data from "own cpp space" into "user cpp space".
60
std::vector<uint8_t>& vec = *
static_cast<
std::vector<uint8_t>*
>
(container);
61
vec.resize(length);
62
return
vec.data();
63
};
64
65
exec->IFingerCreateEmbedding(module.get(),
66
rawImage.Data().data(),
67
rawImage.type,
68
rawImage.width,
69
rawImage.height,
70
static_cast<
int
>
(
static_cast<
unsigned
int
>
(rawImage.dpi)),
71
tmplAllocator,
72
&tmplData,
73
ThrowOnError{});
74
75
auto
extractedPrintEmbedding = std::make_shared<ExtractedPrintEmbedding>(std::move(tmplData), print, exec);
76
77
log.LogInfo(
"Print embedding extraction result %v"
, extractedPrintEmbedding);
78
79
return
extractedPrintEmbedding;
80
}
81
87
*/
88
IdentificationEmbeddingExtractor
()
89
: log(
GlobalLogger
::Get())
90
, exec(
GlobalPrintExecutor
::Get())
91
, module(Initialize())
92
{
93
}
94
101
*/
102
explicit
IdentificationEmbeddingExtractor
(std::shared_ptr<PrintExecutor> executor)
103
: log(
GlobalLogger
::Get())
104
, exec(std::move(executor))
105
, module(Initialize())
106
{
107
if
(exec ==
nullptr
)
108
{
109
throw
NullArgumentException
(
"executor can not be null"
);
110
}
111
}
112
IdentificationEmbeddingExtractor
(
const
IdentificationEmbeddingExtractor
&) =
delete
;
113
IdentificationEmbeddingExtractor
(
IdentificationEmbeddingExtractor
&&) =
delete
;
114
IdentificationEmbeddingExtractor
& operator=(
const
IdentificationEmbeddingExtractor
&) =
delete
;
115
IdentificationEmbeddingExtractor
& operator=(
IdentificationEmbeddingExtractor
&&) =
delete
;
116
virtual
~IdentificationEmbeddingExtractor
() =
default
;
117
118
private
:
125
std::unique_ptr<void, inno_Deleter>
Initialize
()
126
{
127
if
(exec ==
nullptr
)
128
{
129
throw
NullArgumentException
(
"executor can not be null"
);
130
}
131
132
inno_Deleter moduleDeleter =
nullptr
;
133
auto
* mod = exec->IFingerCreateIdentificationModule(&moduleDeleter, ThrowOnError{});
134
std::unique_ptr<void, inno_Deleter> identificationModule(mod, moduleDeleter);
135
136
return
identificationModule;
137
}
138
139
FormattingLogger log;
140
std::shared_ptr<PrintExecutor> exec;
141
std::unique_ptr<void, inno_Deleter> module;
142
};
143
}
// namespace inno
EmbeddingExtractor.h
ExtractedPrintEmbedding.h
FormattingLogger.h
Writer.h
GlobalLogger
Holds instance of Logger.
Definition
Logger.h:275
GlobalPrintExecutor
Holds instance of PrintExecutor.
Definition
PrintExecutor.h:1300
IdentificationEmbeddingExtractor
EmbeddingExtractor creates Innovatrics proprietary embedding print template.
Definition
IdentificationEmbeddingExtractor.h:29
IdentificationEmbeddingExtractor::IdentificationEmbeddingExtractor
IdentificationEmbeddingExtractor(std::shared_ptr< PrintExecutor > executor)
Constructs new IdentificationEmbeddingExtractor.
Definition
IdentificationEmbeddingExtractor.h:101
IdentificationEmbeddingExtractor::Extract
std::shared_ptr< ExtractedPrintEmbedding > Extract(const std::shared_ptr< Print > &print) const final
Function creates embedding template for given Print.
Definition
IdentificationEmbeddingExtractor.h:41
IdentificationEmbeddingExtractor::IdentificationEmbeddingExtractor
IdentificationEmbeddingExtractor()
Constructs new IdentificationEmbeddingExtractor.
Definition
IdentificationEmbeddingExtractor.h:87
Logger
Interface for library logging.
Definition
Logger.h:45
NullArgumentException
Null argument is not allowed.
Definition
EnrollmentException.h:156
Initialize
static void Initialize(const InitializerConfig &config)
Initialize SDK from InitializerConfig (license, models path, and thread counts).
Definition
Initializer.h:114
Print
IdentificationEmbeddingExtractor.h
Generated by
1.17.0