API
FPT.AI Reader - Face Search
Input requirements
Image format must be jpg or jpeg
Size of the input image must not surpass 5 MB with minimum resolution around 640x480 to ensure accuracy rate
Face must take up at least ¼ of the total image area.
Qualified image sample
Unqualified images
- Low-quality images or images with the face covered
API Information
Create user on the system (to add index images)
Request Url
POST https://api.fpt.ai/dmp/facesearch/v2/create
Request Headers
Parameter | Requirement | Default | Description |
---|---|---|---|
api_key | Yes | your api_key (from console.fpt.ai) |
Request Body
FormData contains the collection name and user information (id, name)
Parameter | Requirement | Description |
---|---|---|
collection | yes | each collection will be indexed and searched separately |
id | yes | user id must be unique |
name | yes |
Sample Request
curl --location --request POST 'https://api.fpt.ai/dmp/facesearch/v2/create' \\
\--header 'api_key: xxxxxxxxxxxxxxxx' \\
\--form 'collection=test2' \\
\--form 'id=1234' \\
\--form 'name=Nam'
Response
JSON
{
"data": "User created/updated",
"code": "200"
}
Response Code
Code | meaning |
---|---|
200 | User created/updated |
Sample Response: Success
{
"data": "User created/updated",
"code": "200"
}
Index user images
Request Url
POST https://api.fpt.ai/dmp/facesearch/v2/add
Request Headers
Parameter | Requirement | Default | Description |
---|---|---|---|
api_key | Yes | your api_key (from console.fpt.ai) |
Request Body
FormData contains the collection name, user id, and face image
Parameter | Requirement | Description |
---|---|---|
collection | yes | each collection will be indexed and searched separately |
id | yes | user id created |
file | yes | face detected |
Sample Request
curl --location --request POST 'https://api.fpt.ai/dmp/facesearch/v2/add' \\
\--header 'api_key: xxxxxxxxxxxxxxxx' \\
\--form 'file=\@/path/to/photo.jpg' \\
\--form 'collection=test2' \\
\--form 'id=1234'
Response
JSON
{
"data": "Add photo success",
"code": "200"
}
Response Code
Code | meaning |
---|---|
200 | Image index successs |
400 | Wrong format / Multiple faces / No face detected |
406 | Face covered with mask, hat, or sunglasses |
410 | Photo is id card |
Sample Response: Success
{
"data": "Add photo success",
"code": "200"
}
Sample Response: Error
{
"data": "No face detected",
"code": "400"
}
{
"data": "Photo is id card",
"code": "410"
}
Facesearch
Request Url
POST https://api.fpt.ai/dmp/facesearch/v2/search
Request Headers
Parameter | Requirement | Default | Description |
---|---|---|---|
api_key | Yes | your api_key (from console.fpt.ai) |
Request Body
FormData contains the collection name, and the face image to be searched
Parameter | Requirement | Description |
---|---|---|
collection | yes | each collection will be indexed and searched separately |
file | yes | face detected |
threshold | no | The default threshold for identification of 2 similar faces is 0.85 |
Sample Request
curl --location --request POST 'https://api.fpt.ai/dmp/facesearch/v2/search' \\
\--header 'api_key: xxxxxxxxxxxxxxxx' \\
\--form 'file=\@/path/to/search_photo.jpg' \\
\--form 'collection=test2' \\
\--form 'threshold=0.9'
Response
JSON
{
"data": {
"id": "1234",
"name": "Nam",
"similarity": 0.9999998807907104
},
"code": "200"
}
Response Code
Code | meaning |
---|---|
200 | Image index successs |
400 | Wrong format / Multiple faces / No face detected |
404 | Not found |
406 | Face covered with mask, hat, or sunglasses |
410 | Photo is id card |
Sample Response: Success
{
"data": {
"id": "1234",
"name": "Nam",
"similarity": 0.9999998807907104
},
"code": "200"
}
Sample Response: Error
{
"data": "No face detected",
"code": "400"
}
{
"data": "Photo is id card",
"code": "410"
}
{
"data": "Not found",
"code": "404"
}