Skip to content

Detect Faces ​

Detects every face in an image and optionally returns its embedding — the vector representation used for face comparison and search.

Endpoint ​

http
POST /v1/detect_faces_sync
Content-Type: application/json
json
{
  "image": {
    "id": "7db00808-0416-45cf-a5cb-3b6dfbd7bb74",
    "base64": "",
    "label": "portrait",
    "metadata": "{}"
  },
  "return_embedding": true
}

Parameters:

ParamTypeRequiredDefaultDescription
imageImageDataYes—Image containing the face to detect.
return_embeddingboolNofalseWhether to return the face embedding vector.

ImageData ​

ParamTypeRequiredDefaultDescription
idstringNo—ID of the image returned by Upload Image.
base64stringNo—Base64-encoded text of the image data.
labelstringNo—Label of the image, as described in Usage Recommendations.
metadatastring_jsonNo—Key/value JSON string. Example: {"id":"<ID>","type":1}

The type key inside metadata marks the comparison context:

FieldTypeDescription
1intMatching ID vs ID
2intMatching ID vs Selfie
3intMatching Selfie vs Selfie

Sample Request ​

bash
curl -X POST \
  '<BASE_URL>/v1/detect_faces_sync' \
  -H 'Authorization: ATV <ACCESS_ID>:<SIGNATURE>' \
  -H 'X-TV-Timestamp: <TIMESTAMP>' \
  -H 'Content-Type: application/json' \
  -d '{
    "image": {
      "id": "7db00808-0416-45cf-a5cb-3b6dfbd7bb74"
    }
  }'

Response ​

json
{
  "data": {
    "request_id": "f77bf948-fce3-48f3-b61c-396e4cd9a89b",
    "status": "success",
    "image": {
      "id": "e5e32ef1-296e-4385-8f23-9eb7e6512800",
      "transformed_image_id": "",
      "faces": [
        {
          "id": "2cc3a440-3390-407a-914c-66a63e6eda33",
          "bounding_box": {
            "top": 402,
            "right": 257,
            "bottom": 568,
            "left": 123,
            "angle": 0
          },
          "embedding": [0.09560582041740417, -0.15577684342861176, -0.009643876925110817]
        }
      ]
    }
  },
  "errors": []
}
FieldTypeDescription
data.request_idstringRequest ID; quote it to CAKE Support when checking logs.
data.statusstringsuccess or failure.
data.image.idstringID of the analysed image.
data.image.transformed_image_idstringID of the transformed image, present only when the image was transformed.
data.image.facesFace[]Faces found in the image, largest first.

Face ​

FieldTypeDescription
idstringID of the face within the image.
bounding_boxBoundingBoxPosition of the face in the image.
embeddingfloat[]Embedding vector for the face. Returned only when return_embedding is true.

BoundingBox ​

FieldTypeDescription
topintThe top edge of the box.
rightintThe right edge of the box.
bottomintThe bottom edge of the box.
leftintThe left edge of the box.
angleintThe angle at which the box is rotated.

Faces are sorted largest first. When the input has multiple faces, use the first result.

WARNING

A face embedding is biometric data. Store it under the same controls as the source image, keep it out of logs and analytics pipelines, and delete it when the customer relationship ends.

Errors ​

CodeMessage
2001002Unexpected error occurred while processing the external request.
2001010Access ID not found.
401100You are not authorized to perform the action.
4001000Input parameter violates a constraint.
5001000Some unexpected error occurs while processing the request.
CodeDescription
access_denied_exceptionYou are not authorized to perform the action.
invalid_parameter_exceptionInput parameter violates a constraint.
request_time_too_skewedThe X-TV-Timestamp header is expired, need a newer one.
image_not_found_exceptionThe image ID is not found in DB.
request_not_found_exceptionThe request ID is not found when polling result by id.
rate_limit_exceptionThe number of requests exceeded your throughput limit.
internal_server_errorSome unexpected error occurs while processing the request.

Next Steps ​

Developers