Playground biometrics demo BioID home page

Face Recognition Method Search

Performs a one-to-many comparison of the uploaded face images with stored biometric templates in order to find matching persons in the database.

This method creates biometric feature vectors for all of the provided face images. To perform the comparisons, all biometric templates to compare are then fetched from the database (their digital signature is verified and they may get decrypted) according to the specified list of tags.

As the process of fetching (verification and decryption) of the biometric face templates from the database is more time-consuming than the actual comparison with the calculated feature vectors, we support bulk processing of multiple input images here. This speeds up the average comparison time a lot.

Anyway, the method has a timeout (a backend response read timeout), that may abort the call after 10 minutes.

Service method definition

The Search API is defined as a unary RPC:

rpc Search (FaceSearchRequest) returns (FaceSearchResponse);

message FaceSearchRequest {
    repeated ImageData images = 1;
    repeated string tags = 2;
    bool top_matches = 3;
}

message FaceSearchResponse { 
    JobStatus status = 1;
    repeated JobError errors = 2;
    repeated ImageProperties image_properties = 3;
    repeated SearchResult result = 4;

    message SearchResult {
        repeated TemplateMatchResult matches = 1;
    }

    message TemplateMatchResult {
        int64 classId = 1;
        double score = 2;
    }
}

Request

The FaceSearchRequest message has the fields as follows:

images
A list of one or more ImageData messages containing the facial images of the persons to search for. Each image has to contain exactly a single face, otherwise the call is aborted immediately to avoid unnecessary template fetches.
tags
List of tags that need to be assigned to the biometric templates to search. Only templates that have all of these tags applied are considered in the search. If no tag is specified, all available templates are searched.
top_matches
By default only a list of identified classes is returned. Optionally, a list of the top 10 best matches can be delivered, if this property is set to true.

The maximum API request size is 50 MB. This is the only limitation for the number of input images.

Request Headers

This API requires a valid JWT in the Authorization request header and accepts an optional reference number.

Authorization Required Bearer authentication. Please refer to BWS API Authentication for a description of how to provide a valid JWT here.
Reference-Number Optional, client specific reference number, which will be added to the BWS bookkeeping as well as to the response header. You typically use this reference to link the resulting BWS bookkeeping entries with your logs.

Response

On success the API returns a FaceSearchResponse message:

status
The status of the BWS job that processed the request. Please note that errors may have occurred, even if the job was completed successfully.
errors
A list of errors that might have occurred while the request has been processed.
image_properties
The calculated image properties for each of the provided images in the given order.
result
For each input image a SearchResult is created and returned in the order of the provided input images. A SearchResult again is a sorted list (by score) of TemplateMatchResult messages containing the identified classes or the best matches, depending on the top_matches flag in the request.
classId
Class ID of the person the matched template belongs to.
score
The calculated similarity score for this class in the range between 0.0 and 1.0. The higher the score, the more likely the template matches the calculated feature vector.
Remarks

Please note, that this method might be a long running task, as all biometric templates need to be fetched from the database, its digital signature need to be verified and the template may need to be decrypted before it can be compared with the calculated face feature vectors. Therefore using bulk processing (sending more than one image simultaneously) and restriction to user-groups (by using tags) can speed up this method immense.

BWS Errors

Possibly some errors might have been reported:

FaceNotFound
No suitable face was found in at least one of the provided images.
MultipleFacesFound
More than one face has been found in at least one of the provided images.
DifferentFeatureVersions
Internal: A mixup of different face feature vector versions was encountered.

gRPC Errors

Beside of the success return status code OK (0), this call might also return one of the following gRPC error status codes to indicate an error:

Cancelled (1)
Client application cancelled the request.
Unknown (2)
Server experienced some unexpected behaviour.
InvalidArgument (3)
Client specified an invalid argument:
  • The service cannot decode one of the provided input images, e.g. because the format cannot be detected or the image is too big.
DeadlineExceeded (4)
Deadline expired before operation could complete.
Internal (13)
Internal errors indicate that critical system invariants have been violated. If you encounter one of these errors, it means something is severely wrong. These errors can occur due to an invalid service configuration, a misconfigured client, or an unexpected exception.
Unavailable (14)
The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.
Unauthenticated (16)
The request does not have valid authentication credentials for the operation.

HTTP Errors

This method might also return an HTTP error (504) in case ...:

Response Headers/Trailers

All successful BWS gRPC calls return a response header and a response trailer containing additional information about the request:

Response Header
jobid The Job-ID (a GUID) that has been assigned to this BWS call.
bws-version The version of the BWS gRPC service.
reference-number An optional reference number as provided in the request header.
date The timestamp when the request has been received at the server.
... Other headers that might have been added by the server (NGINX, Kestrel, ...) that was handling the request.
Response Trailer
response-time-ms The timespan in milliseconds the request spent at the BWS service.
... Other trailers, like exception trailers, which are added by the gRPC framework in case an RPC exception occurred.