Liveness

While being able to identify a person by performing a search on an image is great, it is not always sufficient as someone could simply use a printed picture of a person to fool the system.

In use cases such as Access Control, Know Your Customer, Customer Onboarding, we also need to check if the image provided to the system is live, i.e. is an actual live person, and not a paper/screen showing their photo.

To facilitate this, we have the liveness API.

To ensure fraudsters cannot use high-resolution print outs, masks or video playbacks to spoof face recognition systems, liveness image has a higher requirement on image:

Liveness image requirement:

  • There should only be one main face on the image. It should be fully visible within a frame and fully open without any occlusions. No crop is allowed. Small faces in the background are not taken into account.

  • The minimum size of a face box that can be processed is 224x224 pixels.

  • The padding between the face box and the image's borders should be at least 25 pixels.

  • The distance between the pupils on the face should be at least 80 pixels.

  • The out-of-plane rotation angle (face pitch and yaw) should be no more than ±30 degrees.

  • Fish-eye lenses and sunglass images are not supported.

As usual, we start by creating a request:

from opencv.fr.liveness.schemas import LivenessRequest, DeviceType
from pathlib import Path

image_base_path = Path("sample_images")
image_path = image_base_path / "orkhan-real.jpg"

liveness_request = LivenessRequest(image_path, DeviceType.IOS)

And then we get the response:

response = sdk.liveness.check_liveness(liveness_request)
print(response.score)

The image passed in the request should be a high quality image, sufficiently close to the camera.

The returned score represents how confident the system is that this is a real image vs a printed/screen one.