Skip to content

Crop Requirements

Guidelines for creating properly sized face crops for the fast-check-crops endpoint.

In plain terms

When using the crops endpoint, each face image must be 224×224 pixels and include context around the face—hair, neck, some background. The face should fill only ~30% of the crop. Too-tight crops (face fills >50%) reduce accuracy; the API may return a warning.

Overview

The fast-check-crops endpoint requires pre-cropped face images that include significant context around the face. This allows for faster processing since the server skips face detection.

Cropping Process

Original
Frame
Face
Detected
3x Face
Region
224×224
PNG
  1. Detect the face bounding box in the original frame
  2. Calculate the center of the face bounding box
  3. Expand to 3× the face size (use the larger of width/height)
  4. Create a square crop centered on the face
  5. Resize the crop to exactly 224×224 pixels
  6. Export as PNG (base64 encoded)

Critical: Include context around the face

The crop must include significant context around the face (hair, neck, some background). If the face fills more than 50% of the crop, the model's accuracy degrades significantly.

Correct vs Incorrect Crops

❌ Too Tight (Wrong)

  • Face fills >50% of crop
  • Little or no context visible
  • May trigger warning in response
  • Accuracy significantly degraded

✅ Correct

  • Face is ~30% of crop
  • Hair, neck, and background visible
  • Optimal context for detection
  • Maximum accuracy achieved

Specifications

Specification Value
Output Size 224 × 224 pixels (square)
Format PNG, base64 encoded
Face Size ~30% of crop area
Expansion Factor 3× the detected face size
Platform Library Description
JavaScript @mediapipe/tasks-vision Browser-based face detection
Python mediapipe Google's MediaPipe face detection

See the JavaScript Examples and Python Examples for complete crop implementations.