Descriptor matching

Face descriptor matching

It is possible to match a pair (or more) previously extracted descriptors to find out their similarity. With this information, it is possible to implement face search and other analysis applications.

It is possible to match a pair of descriptors with each other or a single descriptor with a descriptor batch.

A simple rule to help you decide which storage to opt for:

  1. when searching among less than a hundred descriptors use separate descriptor object;

  2. when searching among bigger number of descriptors use a batch.

Module contains a face descriptor estimator

See `face descriptor`_.

class lunavl.sdk.faceengine.descriptors.FaceDescriptor(coreEstimation, garbageScore=0.0)[source]

Descriptor

garbageScore

garbage score

Type

float

asBytes

Get descriptor as bytes.

Returns:

Return type

bytes

asDict()[source]

Convert to dict

Returns

Dict with keys “descriptor” and “score”

Return type

Dict[str, Union[float, bytes]]

asVector

Convert descriptor to list of ints :returns: list of ints.

Return type

List[int]

model

Get model of descriptor :returns: model version

Return type

int

rawDescriptor

Get raw descriptors :returns: bytes with metadata

Return type

bytes

class lunavl.sdk.faceengine.descriptors.FaceDescriptorBatch(coreEstimation, scores=None)[source]

Face descriptor batch.

scores

list of garbage scores

Type

List[float]

append(descriptor)[source]

Add descriptor to end of batch.

Parameters

descriptor – descriptor

Return type

None

asDict()[source]

Get batch in json like object.

Returns

list of descriptors dict

Return type

List[Dict[~KT, ~VT]]

class lunavl.sdk.faceengine.descriptors.FaceDescriptorFactory(faceEngine)[source]

Face Descriptor factory.

_faceEngine

faceEngine

Type

VLFaceEngine

generateDescriptor()[source]

Generate core descriptor

Returns

core descriptor

Return type

IDescriptorPtr

generateDescriptorsBatch(size)[source]

Generate core descriptors batch.

Parameters

size – batch size

Returns

batch

Return type

IDescriptorBatchPtr

Module realize face descriptor match.

see face descriptors matching.

class lunavl.sdk.faceengine.matcher.FaceMatcher(coreMatcher, descriptorFactory)[source]

Base estimator class. Class is a container for core estimations. Mostly estimate attributes can be get through a corresponding properties.

_coreMatcher

core matcher

Type

IDescriptorMatcherPtr

descriptorFactory

face descriptor factory

Type

FaceDescriptorFactory

match(reference, candidates)[source]

Match face descriptor vs face descriptors.

Returns

List of matching results if match by several descriptors otherwise one MatchingResult.

Return type

Union[MatchingResult, List[MatchingResult]]

class lunavl.sdk.faceengine.matcher.MatchingResult(distance, similarity)[source]

Structure for storing matching results.

distance

L2 distance between descriptors

Type

float

similarity

descriptor similarity [0..1]

Type

float