Test Requests

Before you can proceed with development and deliver face recognition services to your customers, make sure that the FindFace Server components are working. To do so, run the test requests below, minding the sequence. To pretty-print responses, we recommend you to use jq.

Note

The request messages here are provided only for reference. To create valid requests out of the examples below, replace the token in the messages with the actual one.

Tip

To proceed with development, find more code samples (in C#, PHP, Java and Python) on our GitHub.

In this section:

How to Pretty-Print Responses

Use jq to parse JSON data in responses. To install jq, execute:

sudo apt-get install jq

List Galleries

This request returns the name of the only gallery existing at the present moment. It is the default gallery. Relevant REST API method: /galleries GET.

Request

curl -H "Authorization: Token t3WGNhZbyaE_GFyQaywYllFoR2QkHXi-" http://localhost:8000/v0/galleries | jq

Response

{
  "results": [
    "default"
  ]
}

Detect Face in Image

This request detects faces in a sample image on the Internet and returns coordinates of the rectangle around a detected face (bbox). Relevant REST API method: /detect POST.

Request

curl -H "Authorization: Token t3WGNhZbyaE_GFyQaywYllFoR2QkHXi-" -F "photo=http://static.findface.pro/sample.jpg" http://localhost:8000/v0/detect | jq

Response

{
  "faces": [
    {
      "x1": 595,
      "x2": 812,
      "y1": 127,
      "y2": 344
    }
  ],
  "orientation": 1
}

Compare Two Faces

This request compares a face in a local image and that on the Internet. Relevant REST API method: /verify POST.

Request

curl -H "Authorization: Token t3WGNhZbyaE_GFyQaywYllFoR2QkHXi-" -F "photo1=@Pictures/sample.jpg" -F "photo2=http://static.findface.pro/sample2.jpg" http://localhost:8000/v0/verify | jq

Response

{
  "results": [
    {
      "bbox1": {
        "x1": 595,
        "x2": 812,
        "y1": 127,
        "y2": 344
      },
      "bbox2": {
        "x1": 515,
        "x2": 821,
        "y1": 121,
        "y2": 427
      },
      "confidence": 0.9373794198036194,
      "verified": true
    }
  ],
  "verified": true
}

List Faces from Galleries

The following requests return the list of all faces stored in galleries, both default and custom (#1), and only custom (#2). Relevant REST API method: /faces GET.

Request #1

curl -H "Authorization: Token t3WGNhZbyaE_GFyQaywYllFoR2QkHXi-" http://localhost:8000/v0/faces | jq

Response

{
  "next_page": "/v0/faces?max_id=3827058103081960",
  "prev_page": null,
  "results": [
    {
      "friend": false,
      "galleries": [
        "default",
        "testgal"
      ],
      "id": 3827229578000564,
      "meta": "sample",
      "normalized": "http://192.168.113.88:3333/uploads//20170517/14950115538997407.jpeg",
      "person_id": 5,
      "photo": "http://192.168.113.88:3333/uploads//20170517/14950115538939695.jpeg",
      "photo_hash": "53477c4a72f52c6efc951d9c7ece42bc",
      "thumbnail": "http://192.168.113.88:3333/uploads//20170517/14950115538985784.jpeg",
      "timestamp": "2017-05-17T08:59:13.893000",
      "x1": 595,
      "x2": 812,
      "y1": 127,
      "y2": 344
    },
    {
      "friend": false,
      "galleries": [
        "default"
      ],
      "id": 3827229391220303,
      "meta": "Sam Berry",
      "normalized": "http://192.168.113.88:3333/uploads//20170517/1495011480937809.jpeg",
      "person_id": 5,
      "photo": "http://192.168.113.88:3333/uploads//20170517/14950114809306293.jpeg",
      "photo_hash": "53477c4a72f52c6efc951d9c7ece42bc",
      "thumbnail": "http://192.168.113.88:3333/uploads//20170517/149501148093593.jpeg",
      "timestamp": "2017-05-17T08:58:00.930000",
      "x1": 595,
      "x2": 812,
      "y1": 127,
      "y2": 344
    },
    {
      "age": 26.0483455657959,
      "emotions": [
        "neutral",
        "sad"
      ],
      "friend": false,
      "galleries": [
        "default"
      ],
      "gender": "female",
      "id": 3827227793957831,
      "meta": "Sam Berry",
      "normalized": "http://192.168.113.88:3333/uploads//20170517/14950108570078573.jpeg",
      "person_id": 5,
      "photo": "http://192.168.113.88:3333/uploads//20170517/14950108570022256.jpeg",
      "photo_hash": "53477c4a72f52c6efc951d9c7ece42bc",
      "thumbnail": "http://192.168.113.88:3333/uploads//20170517/14950108570066717.jpeg",
      "timestamp": "2017-05-17T08:47:37.002000",
      "x1": 595,
      "x2": 812,
      "y1": 127,
      "y2": 344
    }
  ]
}

Request #2

curl -H "Authorization: Token t3WGNhZbyaE_GFyQaywYllFoR2QkHXi-" http://localhost:8000/v0/faces/gallery/testgal | jq

Response

{
  "next_page": "/v0/faces/gallery/testgal?max_id=3827059994026334",
  "prev_page": null,
  "results": [
    {
      "friend": false,
      "galleries": [
        "default",
        "testgal"
      ],
      "id": 3827229578000564,
      "meta": "sample",
      "normalized": "http://192.168.113.88:3333/uploads//20170517/14950115538997407.jpeg",
      "person_id": 5,
      "photo": "http://192.168.113.88:3333/uploads//20170517/14950115538939695.jpeg",
      "photo_hash": "53477c4a72f52c6efc951d9c7ece42bc",
      "thumbnail": "http://192.168.113.88:3333/uploads//20170517/14950115538985784.jpeg",
      "timestamp": "2017-05-17T08:59:13.893000",
      "x1": 595,
      "x2": 812,
      "y1": 127,
      "y2": 344
    },
   {
      "galleries": [
        "default",
        "testgal"
      ],
      "id": 3827059994026334,
      "meta": "sample",
      "normalized": "http://127.0.0.1:3333/uploads//20170516/14949453101653092.jpeg",
      "photo": "http://127.0.0.1:3333/uploads//20170516/14949453101581762.jpeg",
      "photo_hash": "53477c4a72f52c6efc951d9c7ece42bc",
      "thumbnail": "http://127.0.0.1:3333/uploads//20170516/14949453101640306.jpeg",
      "timestamp": "2017-05-16T14:35:10.158000",
      "x1": 595,
      "x2": 812,
      "y1": 127,
      "y2": 344
    }
  ]
}

Recognize Gender, Age and Emotions

This request detects faces in a sample image on the internet and returns coordinates of the rectangle around a detected face (bbox) along with gender, age and emotions information. Relevant REST API method: /detect POST. API version: v1.

Note

First, you need to configure gender, age and emotions recognition.

Request

curl -H "Authorization: Token t3WGNhZbyaE_GFyQaywYllFoR2QkHXi-" -F 'photo=https://static.findface.pro/sample2.jpg' -F 'gender=true' -F 'emotions=true' -F 'age=true' http://localhost:8000/v1/detect | jq

Response

{
  "faces": [
    {
      "age": 29.057680130004883,
      "emotions": [
        "neutral",
        "happy"
      ],
      "gender": "female",
      "x1": 515,
      "x2": 821,
      "y1": 121,
      "y2": 427
    }
  ],
  "orientation": 1
}