Face detection

With Uploadcare Face detection operation, you can detect faces in your images for automatic cropping or blurring those out. Face detection is available in group photos, including photos with small faces.

/:uuid/detect_faces/

The detect_faces operation returns the coordinates of faces found in an input image. The output is similar to the json operation. The output is a JSON with the additional list of faces that holds the coordinates of faces that were detected.

Data for each of the found faces are put into separate lists that look like this:

[x, y, x_size, y_size]json

Further, lists within faces contain:

  • x, y — coordinates of the upper-left corner of an area where a face was found.
  • x_size, y_size — dimensions of that area.

Note, detect_faces is not divided from a file UUID by the /-/ separator. Hence, it can not be piped to other operations.

Example

Run a face-check for the following image on our CDN:

Compound image with three faces

Put detect_faces into the image URL, separating it with the forward slash / from the UUID:

Get the following faces list in the response JSON:

"faces": [
  [45, 142, 207, 207],
  [460, 113, 238, 238],
  [892, 43, 265, 265]
]json

detect_faces uses an algorithm that better detects the fronts of faces rather than facial profiles. Also, covering important face features with different objects leads to a decline in detection accuracy.

Technically, the operation detects faces using Haar Cascades. That approach deals with machine learning processes that rely on classifiers holding cascades of features specific to faces, eyes, etc.