[AI] Face Recognition

1. Face detecting
Find faces in photographs then return the location (pixel coordinatates) of any faces.

URL: https://ai.rta.vn/api-v1/face/detect-face

Request:

  • photos[]: photos that need to detect faces

Response: List of face’s location that found in photos:

  • x,y: coordinatates of the top-left pixel
  • width: distance from the the top-left to the top-right pixel
  • height: distance from the the top-left to the bottom-left pixel
  • photo_name: name of the photo that the detected face belongs to
{
    "data": [
        {
            "x": "222",
            "y": "165",
            "width": 258,
            "height": 258,
            "photo_name": "bella_whoopi.jpg"
        },
        {
            "x": "692",
            "y": "156",
            "width": 372,
            "height": 371,
            "photo_name": "bella_whoopi.jpg"
        },
        {
            "x": "593",
            "y": "908",
            "width": 149,
            "height": 149,
            "photo_name": "IMG_20190620_175705.jpg"
        }
    ]
}

Sample:

curl -X POST https://ai.rta.vn/api-v1/face/detect-face \
-F ‘photos[]=@/Users/phuongnguyen/Downloads/bella_whoopi.jpg’ \
-F ‘photos[]=@/Users/phuongnguyen/Downloads/IMG_20190620_175705.jpg’

2. Face training
Give a new unknown face to system, name it and assign data.
Rename a known face or update assigned data.

URL: https://ai.rta.vn/api-v1/face/train-face

Request:

  • photos[]: photos to train new face (all photos must have contain face of only one person) (skip this to only rename face/update data)
  • name: name of face
  • data: data of face (should be in extendable format, like JSON)

Response:

  • The known face (system recognize it)

    • uuid: unique id of the face
    • name: updated name of face
    • data: updated data of face
    {
        "data": {
            "id": 9,
            "uuid": "GQoarULXmynL355tGQpQbeUuf60sc0xgbea012kWv1TQshC0VjHPMmh9yRNQ1KuiC7fMvSUhpEAyXfIUIAv8LPqBr4gArussyiVARlrji2WxJmfwKQUX8otB8OLbsx5n",
            "name": "Ngan Nguyen",
            "data": "\"{\\n  \\\"name\\\": \\\"ngannguyen\\\",\\n  \\\"rta_username\\\": \\\"rta_ngannguyen\\\"\\n}\"",
            "created_at": 1561028127,
            "updated_at": 1561028127,
            "created_by": null,
            "updated_by": null
        },
        "message": "This face looks like [Ngan Nguyen]. Set forceTrain=1 to force to train."
    }
    
  • The new face (system does not recognize it)

    • uuid: auto-generated unique id of new face
    • name: new name of face
    • data: extendable data of face
       {
        "data": {
            "id": 10,
            "uuid": "6V3bPA59np8GlZcUtejiFDdnSlQ5XreRb3MjC70cjzTyeVrpxMCG4b6ulVb0KtD1WdLgQKOV1Nnzzapi9BvyMJErehcBSLajzBRyAfeZW03iHNODsoygiXMLSk0GBfnH",
            "name": "Nelson Mandela",
            "data": "\"{\\n  \\\"name\\\": \\\"nelson\\\",\\n  \\\"rta_username\\\": \\\"rta_nelson\\\"\\n}\"",
            "created_at": 1561090525,
            "updated_at": 1561090525,
            "created_by": null,
            "updated_by": null
        },
        "message": ""
    }
    

Sample:

curl -X POST https://ai.rta.vn/api-v1/face/train-face
-F ‘data={“name”: “nelson”,“rta_username”: “rta_nelson”}’
-F ‘photos[]=@Nelson-Mandela.jpg’
-F ‘name=Nelson Mandela’

3. Face recognition
Recognize faces in photographs then return name and data (assigned to face by 2. Face training) of each known face.

URL: https://ai.rta.vn/api-v1/face/recognize-face?tolerance=0.54
(tolerance is optional)

Request:

  • photos[]: photos that need to recognize faces

Response: List of known face and their data:

  • uuid: unique id of the face
  • name: name of face
  • data: extendable data of face
  • distance: how much the found face in photo look like the known face in database (smaller is better)
  • photo_name: name of the photo that the known face belongs to
{
    "data": [
        {
            "id": 8,
            "uuid": "uy4ovdpQ4Bc47Av5X468ApRZoGKzi1VtruZ9d4AJJkX6xWKP0rcIkdnAgLCck7BJW3btMPcRbzCHe1FUSSvjVelRMZAVQSwnOiTL42gjmvCPcNbR1vWRXbKK4klkeJie",
            "name": "mark zuckerberg",
            "data": "\"{\\n  \\\"name\\\": \\\"mark zuckerberg\\\",\\n  \\\"rta_username\\\": \\\"mark zuckerberg\\\"\\n}\"",
            "created_at": 1561027733,
            "updated_at": 1561027733,
            "created_by": null,
            "updated_by": null,
            "distance": "0.5099239753769768",
            "photo_name": "Mark Zuckerberg.jpg"
        },
        {
            "id": 9,
            "uuid": "GQoarULXmynL355tGQpQbeUuf60sc0xgbea012kWv1TQshC0VjHPMmh9yRNQ1KuiC7fMvSUhpEAyXfIUIAv8LPqBr4gArussyiVARlrji2WxJmfwKQUX8otB8OLbsx5n",
            "name": "Ngan Nguyen",
            "data": "\"{\\n  \\\"name\\\": \\\"ngannguyen\\\",\\n  \\\"rta_username\\\": \\\"rta_ngannguyen\\\"\\n}\"",
            "created_at": 1561028127,
            "updated_at": 1561028127,
            "created_by": null,
            "updated_by": null,
            "distance": "0.35517317260609277",
            "photo_name": "IMG_20190620_175705.jpg"
        }
    ]
}

Sample:

curl -X POST https://ai.rta.vn/api-v1/face/recognize-face \
-F ‘photos[]=@/Users/phuongnguyen/Downloads/bella_whoopi.jpg’ \
-F ‘photos[]=@/Users/phuongnguyen/Downloads/Mark Zuckerberg.jpg’