Detect objects in a photo
To detect objects in a photo, use this method:
POST /detect
The REQUEST BODY is required and contains multipart/form-data with the following parameters.
Name |
Type |
Description |
---|---|---|
|
binary |
Source image file. |
|
object |
Contains attributes that can be detected for the following object types: face, vehicle, and body. |
The attributes
field may be empty or include the face
, car
, and body
objects, each with the following set of parameters:
Name |
Type |
Description |
|
---|---|---|---|
|
object |
Contains face attributes. |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
object |
Contains vehicle attributes. |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
object |
Contains body attributes. |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
|
|
boolean |
If |
Attach a source image file and send the POST
request.
CURL example
curl -X POST "http://<findface-ip:port>/detect" \
-H "Authorization: Token <token>" \
-H "Content-Type: multipart/form-data" \
-F "photo=@sample_face.jpg" \
-F 'attributes={
"face": {
"age": true,
"beard": true,
"emotions": true,
"glasses": true,
"gender": true,
"medmask": true,
"headpose": true,
"eyes_attrs": true
},
"car": {
"description": false,
"license_plate": false,
"special_vehicle_type": false,
"category": false,
"weight_type": false,
"orientation": false
},
"body": {
"color": false,
"clothes": false,
"bags": false,
"protective_equipment": false,
"age_gender": false,
"fall": false,
"handface": false,
"phoneuse": false
}
}'
Tip
Replace sample_face.jpg
with the full path if the file is not in your current working directory.
Example: "photo=@/home/ubuntu/sample_face.jpg"
If the response is successful (OK: 200), it returns a JSON object that contains the following parameters. Example.
Name |
Type |
Description |
---|---|---|
|
integer |
EXIF orientation of the photo. |
|
object |
Contains arrays of data. Each array includes information about detected objects of a specific type (face, body, or vehicle), along with their attributes specified in the request. |
Response example
{
"orientation": 1,
"objects": {
"face": [
{
"id": "d1uvcdskd5qs72mq52h0",
"bbox": {
"left": 722,
"top": 31,
"right": 801,
"bottom": 132
},
"detection_score": 0.5006658,
"low_quality": false,
"features": {
"age": 25,
"beard": {
"name": "none",
"confidence": 0.052511778
},
"emotions": {
"name": "neutral",
"confidence": 0.9908866
},
"glasses": {
"confidence": 0.89929795,
"name": "none"
},
"gender": {
"confidence": 0.99800926,
"name": "female"
},
"medmask": {
"confidence": 0.9999994,
"name": "none"
},
"headpose_pitch": {
"name": 6.227072,
"confidence": 1
},
"headpose_yaw": {
"name": 20.798172,
"confidence": 1
},
"eyes_attrs": {
"confidence": 0.8949018,
"name": "opened"
}
}
}
],
"body": [
{
"id": "d1uvceskd5qs72mq52hg",
"bbox": {
"left": 522,
"top": 5,
"right": 933,
"bottom": 792
},
"detection_score": 0.82396024,
"low_quality": false,
"features": {}
}
]
}
}
In the response, you will receive the id
and bounding box (bbox) coordinates of the object (face
, car
, body
). Copy the id
of the required object to add the object to a record or to search for the object.