The Face Detection API allows you to detect faces within an image. It analyzes the provided image and returns information about the detected faces, including their coordinates, landmarks, and detection scores.

Verifik has a guide on what Search services are and how to use them; we invite you to read it: Search Guide.

collection_id

For the service to work correctly, a parameter called collection_id must be provided. This parameter is obtained when creating a new collection with the name "code." Here is an example of a collection creation response:

{
  "data": {
    "_id": "65175da13e81e4fabc12345",
    "deleted": false,
    "name": "Test2",
    "description": "Test Collection",
    "client": "65175da13e81e4fabc12345",
    "code": "dac2c81b-96a6-4f19-ab54-d1a72d55b64b", //Parametro a enviar en collection_id
    "updatedAt": "2023-09-29T23:28:33.894Z",
    "createdAt": "2023-09-29T23:28:33.894Z",
    "__v": 0
  }
}

Implementation

Request

import axios from 'axios';

const options = {
  method: 'POST',
  url: '<https://api.verifik.co/v2/face-recognition/detect>',
  params: {
  },
  headers: {
    Accept: 'application/json',
    Authorization: 'jwt <tu_token>'
  },
  data: {
    image: 'base64_encoded_string',
    min_score: 0.7,
    max_results: 10,
    search_mode: 'FAST/ACCURATE choose one',
    collection_id: 'OPTIONAL_COLLECTION_ID_TO_RESTRICT_SEARCH'
  }
};

try {
 notFou const { data } = await axios.request(options);
  console.log(data);
} catch (error) {
  console.error(error);
}

Response 200 - (Successful response)

{
  "id": "pgui5",
  "data": [
    {
      "box": {
        "top": 169,
        "left": 698,
        "right": 1214,
        "bottom": 845
      },
      "persons": [],
      "landmarks": {
        "nose": [
          961,
          550
        ],
        "left_eye": [
          836,
          422
        ],
        "right_eye": [
          1080,
          425
        ],
        "left_mouth": [
          865,
          679
        ],
        "right_mouth": [
          1049,
          683
        ]
      },
      "thumbnail": "Base 64 image",
      "detection_score": 0.8
    }
  ],
  "signature": {
    "message": "Certified by Verifik.co",
    "dateTime": "September 29, 2023 9:10 PM"
  }
}