SpoofSense Face Liveness API Documentation
  • Introduction
  • Image requirements
  • API Usage
Powered by GitBook
On this page
  • Best practices
  • Compressing Images for high performance - python

Image requirements

The API expects the input image to have certain requirements in order to accurately perform facial liveness checks.

Best practices

  • Supported image formats: png, jpg, jpeg.

  • Image size should not exceed: 10mb

  • Image should be clicked in a well-lit room, with the face shown clearly to the camera. Extreme darkness/brightness on the face might increase the BPCER.

  • The Face should be straight and not tilted.

  • Minimum Size of detected face should be 224X224 pixels.

  • Distance between eyes should be ateast 100 pixels.

  • Motion Blur might increase BPCER.

  • Any occlusions on parts of face like Glasses, Masks should be removed while performing Liveness Check.

  • The detected Face should occupy atleast 20% of the total image area.

  • Image should be clicked as a selfie (portrait mode only).

  • No image compression is highly recommended.

Compressing Images for high performance - python

Use the following snippet to reduce the size of the images before sending it to the spoofsense-api.

from PIL import Image

def compress_image(image_path, output_path, quality):
    # Open the image file.
    with Image.open(image_path) as img:
        # Save the image again with reduced quality.
        img.save(output_path, "JPEG", quality=quality)

# Path of the image to be compressed.
image_path = "path/to/your/image.jpg"

# Path where the compressed image will be saved.
output_path = "path/to/your/compressed/image.jpg"

# Quality parameter. Lower value will reduce the size more, but may decrease the quality.
# In many cases, values around 80 to 90 still provide good quality images.
quality = 90

compress_image(image_path, output_path, quality)

PreviousIntroductionNextAPI Usage

Last updated 1 month ago