Facial recognition
Overview
Face SDK allows you to perform the following operations of comparing biometric face templates:
Verification (1:1) — comparison of two face templates for belonging to the same person (comparison of two faces).
Identification (1:N) — comparison of one biometric face template with other face templates (search for a face in a face database).
The result of recognition is an assessment of the similarity between the compared templates.
Processing blocks
- FACE_TEMPLATE_EXTRACTOR extracts a biometric face template from an image.
- VERIFICATION_MODULE compares two face templates to check their similarity.
- MATCHER_MODULE searches for similar faces in a database.
Classes for working with face recognition modules
- ContextTemplate stores a biometric face template in binary format. Used for comparison and search in recognition modules.
- DynamicTemplateIndex stores a collection of biometric templates for quick search in MATCHER_MODULE. Supports adding and deleting templates without re-creating the index.
Modifications and versions of face recognition processing blocks
The FACE_TEMPLATE_EXTRACTOR
processing block modification determines the template generation speed and recognition accuracy. The higher the speed, the lower the accuracy.
Modification series:
- 30-1000 - standard modifications, suitable for PCs.
- 30m-1000m - optimized for mobile processors, work faster, but with less accuracy compared to the standard series.
- 30-1000
- 30m-1000m
Modification | Version | Template size (bytes) | Template creation (ms) PC* | Template creation (ms) Mobile** |
---|---|---|---|---|
30 | 1 | 280 | 19 | 50 |
50 | 1 | 288 | 31 | 92 |
100 | 1 | 280 | 68 | 212 |
1000 | 1 | 296 | 611 | 2200 |
Modification | Version | Template size (bytes) | Template creation (ms) PC* | Template creation (ms) Mobile** |
---|---|---|---|---|
30m | 1 | 280 | 14 | 30 |
50m | 1 | 288 | 25 | 53 |
100m | 1 | 280 | 55 | 102 |
1000m | 1 | 296 | 543 | 1100 |
* – Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz.
** – MediaTek Helio G95.
The default modification is "1000"
.
For VERIFICATION_MODULE
and MATCHER_MODULE
processing blocks, the modification and version determine the type of template that these modules will work with.
Description of ContextTemplate and DynamicTemplateIndex
ContextTemplate
Creating a ContextTemplate
An instance of ContextTemplate can be created in several ways:
- Obtained after running the
FACE_TEMPLATE_EXTRACTOR
module. - Call the
service.loadContextTemplate
method. This method allows you to load a ContextTemplate object from a binary data stream.
ContextTemplate methods
- C++
- Python
- Flutter
- C#
- Java
- Kotlin
// Getting the name of a template modification
std::string getMethodName() const;
// Template size
size_t size() const;
// Saving to a binary data stream
void save(std::ostream &binary_stream) const;
# Getting the name of a template modification
def get_method_name(self) -> str:
# Template size
def size(self) -> int:
# Saving to a byte array
def save(self, binary_stream: BytesIO):
// Getting the name of a template modification
String getMethodName();
// Template size
int size();
// Saving to a byte array
Uint8List save();
// Deleting a template
void dispose();
// Getting the name of a template modification
String getMethodName();
// Template size
long size();
// Saving to a binary data stream
void save(Stream binary_stream)
// Getting the name of a template modification
String getMethodName();
// Template size
int size();
// Saving to a binary data stream
void save(OutputStream binary_stream)
// Deleting a template
void dispose();
// Getting the name of a template modification
fun getMethodName(): String?
// Template size
fun size(): int?
// Saving to a binary data stream
fun save(binary_stream: OutputStream!)
// Deleting a template
fun dispose();
DynamicTemplateIndex
Creating a DynamicTemplateIndex
To create a DynamicTemplateIndex
instance, use the service.createDynamicTemplateIndex
method. The method accepts a Context container with the following parameters:
max_license_count
(type: long) - The maximum number of templates that the index can contain. Cannot exceed the limit specified in the license. The default value is 100.capacity
(type: long) - Reserves space for templates in the index. The default value is max_license_count.async
(type: bool) - If true is specified, enables asynchronous mode for adding and removing templates. This allows these operations to be performed in parallel. The mode is in beta.model_version
(type: string) - The modification and version of the model, for example, "1000_1". This parameter determines which modification of theFACE_TEMPLATE_EXTRACTOR
module the index will work with.
DynamicTemplateIndex methods
- C++
- Python
- Flutter
- C#
- Java
- Kotlin
// Getting the name of a template method in a database
std::string getMethodName() const;
// Number of templates in the database
size_t size() const;
// Current capacity of the database
size_t capacity() const;
// Getting UUID of a template by index in the database
std::string getUUID(size_t index) const;
// Getting a template by UUID
pbio::ContextTemplate::Ptr at(const std::string& uuid) const;
// Getting a template by index in the database
pbio::ContextTemplate::Ptr at(int64_t index) const;
// Adding a template to the database
void add(pbio::Template::Ptr templ, const std::string& uuid);
void add(const std::vector<pbio::Template::Ptr>& templates, const std::vector<std::string>& uuids);
void add(pbio::ContextTemplate::Ptr templ, const std::string& uuid);
void add(const std::vector<pbio::ContextTemplate::Ptr>& templates, const std::vector<std::string>& uuids);
// Removing a template from the database by UUID
void remove(const std::string& uuid);
void remove(const std::vector<std::string>& uuids);
// Merging template databases
// otherIndex becomes invalid
void concat(DynamicTemplateIndex::Ptr otherIndex);
# Getting the name of a template method in a database
def get_method_name(self) -> str:
# Number of templates in the database
def size(self) -> int:
# Current capacity of the database
def capacity(self) -> int:
# Getting UUID of a template by index in the database
def get_uuid(self, i: int) -> str:
# Getting a template by UUID
def at(self, uuid: str) -> ContextTemplate:
# Getting a template by index
def get(self, index: int) -> ContextTemplate:
# Adding a template to the database
def add(self, template: ContextTemplate, uuid: str) -> None:
def add(self, template: Template, uuid: str) -> None:
def add(self, templates: Union[List[Template], List[ContextTemplate]], uuids: List[str]) -> None:
# Removing a template from the database
def remove(self, uuid: str) -> None:
def remove(self, uuids: List[str]) -> None:
# Merging template databases
# other_index becomes invalid
def concat(self, other_index: "DynamicTemplateIndex") -> None:
/// Getting the name of a template method in a database
String getMethodName();
/// Number of templates in the database
int size();
/// Current capacity of the database
int capacity();
/// Getting UUID of a template by index in the database
String getUUID(int index);
/// Getting a template by UUID
ContextTemplate at(String uuid);
/// Getting a template by index
ContextTemplate get(int index);
/// Adding a template to the database
void addContextTemplate(ContextTemplate template, String uuid);
void addContextTemplates(List<ContextTemplate> templates, List<String> uuids);
void addRecognizerTemplate(Template template, String uuid);
void addRecognizerTemplates(List<Template> templates, List<String> uuids);
/// Removing a template from the database
void removeByUuid(String uuid);
void removeByUuids(List<String> uuids);
/// Merging template databases
/// otherIndex becomes invalid
void concat(DynamicTemplateIndex otherIndex);
/// Deleting the template database
void dispose();
// Getting the name of a template method in a database
String getMethodName();
// Number of templates in the database
long size();
// Current capacity of the database
long capacity();
// Getting UUID of a template by index in the database
string GetUUID(int i);
// Getting a template by UUID
ContextTemplate At(string uuid);
// Getting a template by index
ContextTemplate Get(int i);
// Adding a template to the database
void Add(ContextTemplate templ, string uuid);
void Add(List<ContextTemplate> templates, List<string> uuids);
void Add(Template templ, string uuid);
void Add(List<Template> templates, List<string> uuids);
// Removing a template from the database
void Remove(string uuid);
void Remove(List<string> uuids);
// Merging template databases
void Concat(DynamicTemplateIndex other_index);
// Getting the name of a template method in a database
String getMethodName();
// Number of templates in the database
int size();
// Current capacity of the database
long capacity();
// Getting UUID of a template by index in the database
String getUUID(final long i);
// Getting a template by UUID
ContextTemplate at(final String uuid);
// Getting a template by index
ContextTemplate get(final long i);
// Adding a template to the database
void addContextTemplate(final ContextTemplate templ, final String uuid);
void addContextTemplate(final Vector<ContextTemplate> templates, final Vector<String> uuids);
void addTemplate(final Template templ, final String uuid);
void addTemplate(final Vector<Template> templates, final Vector<String> uuids);
// Removing a template from the database
void remove(final String uuid);
void remove(final Vector<String> uuids);
// Merging template databases
// otherIndex becomes invalid
void concat(final DynamicTemplateIndex otherIndex);
// Deleting the template database
void dispose()
// Getting the name of a template method in a database
fun getMethodName(): String?
// Number of templates in the database
fun size(): int?
// Current capacity of the database
fun capacity(): Long
// Getting UUID of a template by index in the database
fun getUUID(i: Long): String!
// Getting a template by UUID
fun at(uuid: String!) ContextTemplate!
// Getting a template by index
fun get(i: Long): ContextTemplate!
// Adding a template to the database
fun addContextTemplate(templ: ContextTemplate!, uuid: String!)
fun addContextTemplate(templates: Vector<ContextTemplate!>!, uuids: Vector<String!>!)
fun addTemplate(templ: Template!, uuid: String!)
fun addTemplate(templates: Vector<Template!>!, uuids: Vector<String!>!)
// Removing a template from the database
fun remove(uuid: String!)
fun remove(uuids: Vector<String!>!)
// Merge template databases
// otherIndex becomes invalid
fun concat(otherIndex: DynamicTemplateIndex!)
// Deleting the template database
fun dispose()
Specification of facial recognition processing blocks
List of configurable parameters of processing blocks
Face template extractor
- The input container Context must contain a binary image and an array of objects obtained after the operation of the face detection and fitter processing blocks:
Click to expand the Context input container specification
{
"image" : {
"format": "NDARRAY",
"blob": "data pointer",
"dtype": "uint8_t",
"shape": [height, width, channels]
},
"objects": [{
"id": {"type": "long", "minimum": 0},
"class": "face",
"confidence": {"double", "minimum": 0, "maximum": 1},
"bbox": [x1, y2, x2, y2]
"keypoints": {
"left_eye_brow_left": {"proj" : [x, y]},
"left_eye_brow_up": {"proj" : [x, y]},
"left_eye_brow_right": {"proj" : [x, y]},
"right_eye_brow_left": {"proj" : [x, y]},
"right_eye_brow_up": {"proj" : [x, y]},
"right_eye_brow_right": {"proj" : [x, y]},
"left_eye_left": {"proj" : [x, y]},
"left_eye": {"proj" : [x, y]},
"left_eye_right": {"proj" : [x, y]},
"right_eye_left": {"proj" : [x, y]},
"right_eye": {"proj" : [x, y]},
"right_eye_right": {"proj" : [x, y]},
"left_ear_bottom": {"proj" : [x, y]},
"nose_left": {"proj" : [x, y]},
"nose": {"proj" : [x, y]},
"nose_right": {"proj" : [x, y]},
"right_ear_bottom": {"proj" : [x, y]},
"mouth_left": {"proj" : [x, y]},
"mouth": {"proj" : [x, y]},
"mouth_right": {"proj" : [x, y]},
"chin": {"proj" : [x, y]},
"points": ["proj": [x, y]]
}
}]
}
- After executing the evaluation processing block, the
"face_template"
field in each object of the"objects"
array will contain the biometric template in the"template"
field and a unique identifier in the"uuid"
field. The template is stored in the ContextTemplate class object. The issueduuid
can be used to work with DynamicTemplateIndex or replaced with your own identifier.
Click to expand the Context output container specification
[{
"keypoints": {},
"face_template": {
"template": {"ContextTemplate"},
"uuid": {"string"}
}
}]
Verification module
- The Context input container must contain two biometric templates written in the
"template1"
and"template2"
fields. The template type must correspond to the modification of the processing block.
Click to expand the Context input container specification
{
"template1" : {
"template": {"ContextTemplate"}
},
"template2" : {
"template": {"ContextTemplate"}
}
}
- After calling the verification processing block, the result will be placed in
"result"
.
Click to expand the Context output container specification
{
"template2": {},
"result": {
"distance": {"double", "minimum": 0},
"score": {"double", "minimum": 0, "maximum": 1},
"far": {"double", "minimum": 0, "maximum": 1},
"frr": {"double", "minimum": 0, "maximum": 1},
}
}
Matcher module
- The input container Context must contain an object of the DynamicTemplateIndex class in the
"template_index"
field and a set of the required biometric templates placed in another object of the DynamicTemplateIndex class in the"queries"
field, or one template in the form of an object of the ContextTemplate class.
Click to expand the Context input container specification
{
"queries": {"DynamicTemplateIndex"},
"template_index": {"DynamicTemplateIndex"}
}
OR
{
"queries": {"ContextTemplate"},
"template_index": {"DynamicTemplateIndex"}
}
- After calling the verification processing block, the result will be placed in the
"results"
array.
Click to expand the Context output container specification
{
"template_index": {"DynamicTemplateIndex"}
"result": [{
"index": {"long", "minimum": 0}
"uuid": {"string"}
"distance": {"double", "minimum": 0},
"score": {"double", "minimum": 0, "maximum": 1},
"far": {"double", "minimum": 0, "maximum": 1},
"frr": {"double", "minimum": 0, "maximum": 1},
}]
}
Recognition results
- distance – distance between the compared template vectors. The lower the value, the higher the confidence in correct recognition.
- far – probability of false positives, when the system takes images of different people for images of the same person.
- frr – probability of false negatives, when the system takes two images of the same person for images of different people.
- score – degree of similarity of faces from 0 (0%) to 1 (100%). A high degree of similarity means that two biometric templates belong to the same person.
- index - position of the found template within the
DynamicTemplateIndex
object. (only forMATCHER_MODULE
) - uuid - unique template identifier passed when adding to
DynamicTemplateIndex
. (only forMATCHER_MODULE
)
Examples of working with face recognition processing blocks
Extracting face templates
To get a face template from an image, do the following:
- Create a configuration Context container and specify the
"unit_type"
values for"FACE_TEMPLATE_EXTRACTOR"
and the"modification"
and"version"
of the modification you are interested in.
An example of creating a processing block can be found here
List of configurable parameters of processing blocks
Pass the Context container obtained after running the face detection and fitter processing blocks.
Call the face template extraction processing block.
- C++
- Python
- Flutter
- C#
- Java
- Kotlin
auto configCtx = service->createContext();
configCtx["unit_type"] = "FACE_TEMPLATE_EXTRACTOR";
configCtx["modification"] = "{modification}";
pbio::ProcessingBlock blockFaceExtractor = service->createProcessingBlock(configCtx);
//------------------
// creating a processing block and a Context container with a binary image
//------------------
faceDetector(ioData)
faceFitter(ioData)
blockFaceExtractor(ioData);
configCtx = {"unit_type": "FACE_TEMPLATE_EXTRACTOR", "modification": "{modification}" }
blockFaceExtractor = service.create_processing_block(configCtx)
#------------------
# creating a processing block and a Context container with a binary image
#------------------
faceDetector(ioData)
faceFitter(ioData)
blockFaceExtractor(ioData)
ProcessingBlock blockFaceExtractor = service.createProcessingBlock({"unit_type": "FACE_TEMPLATE_EXTRACTOR", "modification": "{modification}"});
//------------------
// creating a processing block and a Context container with a binary image
//------------------
faceDetector.process(ioData);
faceFitter.process(ioData);
blockFaceExtractor.process(ioData);
Dictionary<object, object> configCtx = new();
configCtx["unit_type"] = "FACE_TEMPLATE_EXTRACTOR";
configCtx["modification"] = "{modification}";
ProcessingBlock blockFaceExtractor = service.CreateProcessingBlock(configCtx);
//------------------
// creating a processing block and a Context container with a binary image
//------------------
faceDetector.Invoke(ioData);
faceFitter.Invoke(ioData);
blockFaceExtractor.Invoke(ioData);
Context configCtx = service.createContext();
configCtx.get("unit_type").setString("FACE_TEMPLATE_EXTRACTOR");
configCtx.get("modification").setString("{modification}");
ProcessingBlock blockFaceExtractor = service.createProcessingBlock(configCtx);
//------------------
// creating a processing block and a Context container with a binary image
//------------------
faceDetector.process(ioData);
faceFitter.process(ioData);
blockFaceExtractor.process(ioData);
val configCtx = service.createContext()
configCtx["unit_type"].string = "FACE_TEMPLATE_EXTRACTOR"
configCtx["modification"].string = "{modification}"
val blockFaceExtractor = service.createProcessingBlock(configCtx)
//------------------
// creating a processing block and a Context container with a binary image
//------------------
faceDetector.process(ioData)
faceFitter.process(ioData)
blockFaceExtractor.process(ioData)
Saving a face template
To save a face template to a file, follow these steps:
Get the ContextTemplate object from the data.
Open the binary file for writing.
Save the template to a file using the
save()
method.
- C++
- Python
- Flutter
- C#
- Java
- Kotlin
pbio::ContextTemplate::Ptr face_template = ioData["objects"][0]["face_template"]["template"].getContextTemplate();
std::ofstream out("template.bin", std::ios::binary);
face_template->save(out);
face_template = ioData["objects"][0]["face_template"]["template"]
with open("template.bin", "wb") as file:
face_template.save(file)
ContextTemplate faceTemplate = ioData["objects"][0]["face_template"]["template"].get_value();
File out = File("template.bin");
await out.writeAsBytes(faceTemplate.save());
ContextTemplate faceTemplate = ioData["objects"][0]["face_template"]["template"].GetContextTemplate();
using Stream fileStream = new FileStream("template.bin", FileMode.Create, FileAccess.Write);
faceTemplate.save(fileStream);
ContextTemplate faceTemplate = ioData.get("objects").get(0).get("face_template").get("template").getContextTemplate();
try (FileOutputStream stream = new FileOutputStream("template.bin"))
{
faceTemplate.save(stream);
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
val faceTemplate = ioData["objects"][0]["face_template"]["template"].contextTemplate
try {
val stream = FileOutputStream("template.bin")
faceTemplate.save(stream)
} catch (ioe: IOException) {
ioe.printStackTrace()
}
Loading a face template
To load a face template from a file, follow these steps:
Open the file to read the binary data.
Load the template using
loadContextTemplate()
.
- C++
- Python
- Flutter
- C#
- Java
- Kotlin
std::ifstream input("template.bin", std::ios::binary);
pbio::ContextTemplate::Ptr face_template = service->loadContextTemplate(input);
with open("template.bin", "rb") as file:
face_template = service.load_context_template(file)
File input = File("template.bin");
Uint8List templateBytes = await input.readAsBytes();
ContextTemplate faceTemplate = service.loadContextTemplate(templateBytes);
});
using Stream fileStream = new FileStream("template.bin", FileMode.Open, FileAccess.Read);
ContextTemplate faceTemplate = service.loadContextTemplate(fileStream);
try (FileInputStream stream = new FileInputStream("template.bin"))
{
ContextTemplate faceTemplate = service.loadContextTemplate(stream);
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
try {
val stream = FileInputStream("template.bin")
val faceTemplate = service.loadContextTemplate(stream)
} catch (ioe: IOException) {
ioe.printStackTrace()
}
Face verification
Create a configuration Context container and specify the
"unit_type"
values for"VERIFICATION_MODULE"
and"modification"
and"version"
of the modification you are interested in.Generate a Context container and add biometric templates to the
"template1"
and"template2"
fields:.
- You can add the contents of the
"face_template"
field obtained when calling the"FACE_TEMPLATE_EXTRACTOR"
module to the "template1" and "template2" fields - Or create a new Context container and add an object of the ContextTemplate class to it.
- Call the verification processing block.
- C++
- Python
- Flutter
- C#
- Java
- Kotlin
pbio::Context verificationConfig = service->createContext();
verificationConfig["unit_type"] = "VERIFICATION_MODULE";
verificationConfig["modification"] = "{modification}";
pbio::ProcessingBlock verificationModule = service->createProcessingBlock(verificationConfig);
pbio::Context verificationData = service->createContext();
verificationData["template1"] = ioData["objects"][0]["face_template"];
verificationData["template2"]["template"] = face_template;
verificationModule(verificationData);
configCtx = {"unit_type": "VERIFICATION_MODULE", "modification": "{modification}"}
verificationModule = service.create_processing_block(configCtx)
verificationData = service.create_context({})
verificationData["template1"] = ioData["objects"][0]["face_template"]
verificationData["template2"]["template"] = face_template
verificationModule(verificationData)
ProcessingBlock verificationModule = service.createProcessingBlock({"unit_type": "VERIFICATION_MODULE", "modification": "{modification}"});
Context verificationData = service.createContext({"template1": {}, "template2": {}});
verificationData["template1"].placeValues(ioData["objects"][0]["face_template"])
verificationData["template2"]["template"].placeValues(faceTemplate)
verificationData = verificationModule.process(verificationData);
Dictionary<object, object> verificationConfig = new();
verificationConfig["unit_type"] = "VERIFICATION_MODULE";
verificationConfig["modification"] = "{modification}";
ProcessingBlock verificationModule = service.CreateProcessingBlock(verificationConfig);
Context verificationData = service.CreateContext(null);
verificationData["template1"] = ioData["objects"][0]["face_template"];
verificationData["template2"]["template"].SetContextTemplate(faceTemplate);
verificationModule.Invoke(verificationData);
Context verificationConfig = service.createContext();
verificationConfig.get("unit_type").setString("VERIFICATION_MODULE");
verificationConfig.get("modification").setString("{modification}");
ProcessingBlock verificationModule = service.createProcessingBlock(verificationConfig);
Context verificationData = service.createContext();
verificationData.get("template1").setContext(ioData.get("objects").get(0).get("face_template"));
verificationData.get("template2").get("template").setContextTemplate(faceTemplate);
verificationModule.process(verificationData);
val verificationConfig = service.createContext()
verificationConfig["unit_type"].string = "VERIFICATION_MODULE"
verificationConfig["modification"].string = "{modification}"
val verificationModule = service.createProcessingBlock(verificationConfig)
val verificationData = service.createContext()
verificationData["template1"].setContext(ioData["objects"][0]["face_template"])
verificationData["template2"]["template"].contextTemplate = faceTemplate;
verificationModule.process(verificationData)
Generating DynamicTemplateIndex
To generate DynamicTemplateIndex
, follow these steps:
Generate a container-Context and specify the fields "model_version" and "max_license_count" and pass this container to the
createDynamicTemplateIndex
methodAdd templates to the index using the
add()
method, passing ContextTemplate and uuid
- C++
- Python
- Flutter
- C#
- Java
- Kotlin
pbio::Context indexConfig = service->createContext();
indexConfig["model_version"] = "{modification}_1";
indexConfig["max_license_count"] = 1000;
pbio::DynamicTemplateIndex::Ptr template_index = service->createDynamicTemplateIndex(indexConfig);
for (const pbio::Context& object : ioData["objects"])
{
template_index->add(object["face_template"]["template"].getContextTemplate(), "<uuid>");
}
index_config = service.create_context({
"capacity": 1000,
"model_version": "{modification}_1",
"async": False,
"max_license_count": 1000
})
template_index = service.create_dynamic_template_index(index_config)
for object in ioData["objects"]:
template_index.add(object["face_template"]["template"].get_value(), "<uuid>")
Context indexConfig = service.createContext({
"capacity": 1000,
"model_version": "{modification}_1",
"async": false,
"max_license_count": 1000
});
DynamicTemplateIndex templateIndex = service.createDynamicTemplateIndex(indexConfig);
for (int i = 0; i < ioData["objects"].len(); i++){
templateIndex.add(ioData["objects"][i]["face_template"]["template"].get_value(), "<uuid>");
}
Context indexConfig = service.CreateContext
(
new()
{
{ "capacity", 1000 },
{ "model_version", "{modification}_1" },
{ "async", false },
{ "max_license_count", 1000 }
}
);
DynamicTemplateIndex templateIndex = service.createDynamicTemplateIndex(indexConfig);
for (int i = 0; i < (int)ioData["objects"].Length(); i++)
{
templateIndex.Add(ioData["objects"][i]["face_template"]["template"].GetContextTemplate());
}
Context indexConfig = service.createContext();
indexConfig.get("capacity").setLong(1000);
indexConfig.get("model_version").setString("{modification}_1");
indexConfig.get("async").setBool(false);
indexConfig.get("max_license_count").setLong(1000);
DynamicTemplateIndex templateIndex = service.createDynamicTemplateIndex(indexConfig);
Context objects = ioData.get("objects");
for (int i = 0; i < objects.size(); i++)
{
templateIndex.add(objects.get(i).get("face_template").get("template").getContextTemplate(), "<uuid>");
}
val indexConfig = service.createContext()
indexConfig["capacity"].long = 1000
indexConfig["model_version"].string = "{modification}_1"
indexConfig["async"].bool = false
indexConfig["max_license_count"].long = 1000
val templateIndex = service.createDynamicTemplateIndex(indexConfig)
val templatesData = service.createContext()
val objects = ioData["objects"]
for (i in 0 until objects.size()) {
templateIndex.add(objects[i]["face_template"]["template"].contextTemplate, "<uuid>")
}
The uuid
passed must be unique
Search for persons in the database
Create a configuration Context container and specify the
"unit_type"
values for"MATCHER_MODULE"
and"modification"
and"version"
of the modification you are interested in.Form an input Context container according to the specification for
"MATCHER_MODULE"
.Call the processing block to search the database.
- C++
- Python
- Flutter
- C#
- Java
- Kotlin
pbio::Context matcherConfig = service->createContext();
matcherConfig["unit_type"] = "MATCHER_MODULE";
matcherConfig["modification"] = "{modification}";
pbio::ProcessingBlock matcherModule = service->createProcessingBlock(matcherConfig);
// Forming the input Context container for matcherModule
pbio::Context matcherData = service->createContext();
matcherData["template_index"] = template_index;
matcherData["queries"] = ioData["objects"][0]["face_template"]["template"];
matcherModule(matcherData);
matcher_module = service.create_processing_block({"unit_type": "MATCHER_MODULE", "modification": "{modification}"})
matcher_data = service.create_context({})
matcher_data["template_index"] = template_index
matcher_data["queries"] = ioData["objects"][0]["face_template"]["template"]
matcher_module(matcher_data)
matcherModule = service.createProcessingBlock({"unit_type": "MATCHER_MODULE", "modification": "{modification}"});
// Forming the input Context container for matcherModule
Context matcherData = service.createContext({"template_index": {}, "queries": []});
matcherData["template_index"] = templateIndex;
matcherData["queries"] = ioData["objects"][0]["face_template"]["template"];
matcherModule.process(matcherData);
Dictionary<object, object> matcherConfig = new();
matcherConfig["unit_type"] = "MATCHER_MODULE";
matcherConfig["modification"] = "{modification}";
ProcessingBlock matcherModule = service.CreateProcessingBlock(matcherConfig);
// Creating the input Context container for matcherModule
Context matcherData = service.CreateContext(new Dictionary<object, object>{
{ "template_index", templateIndex},
{ "queries", ioData["objects"][0]["face_template"]["template"] },
});
matcherModule.Invoke(matcherData);
Context matcherConfig = service.createContext();
matcherConfig.get("unit_type").setString("MATCHER_MODULE");
matcherConfig.get("modification").setString("{modification}");
ProcessingBlock matcherModule = service.createProcessingBlock(matcherConfig);
// Forming the input Context container for matcherModule
Context matcherData = service.createContext();
matcherData.get("template_index").setDynamicTemplateIndex(templateIndex);
matcherData.get("queries").setContextTemplate(ioData.get("objects").get(0).get("face_template").get("template").getContextTemplate());
matcherModule.process(matcherData);
val matcherConfig = service.createContext()
matcherConfig["unit_type"].string = "MATCHER_MODULE"
matcherConfig["modification"].string ="{modification}"
val matcherModule = service.createProcessingBlock(matcherConfig)
// Forming the input Context container for matcherModule
val matcherData = service.createContext()
matcherData["template_index"].dynamicTemplateIndex = templateIndex
matcherData["queries"] = ioData["objects"][0]["face_template"]["template"]
matcherModule.process(matcherData)