Skip to main content
Skip table of contents

Create an analytics case

Creating an analytics case with the type «Face recognition».

The analytics tool automatically localizes human faces in a video stream and identifies the person based on a reference model (photo) in the existing databases (analytics resources). This analytics can be applied in various use cases where there is a need to establish the identity of a «visitor/guest» and respond to such events.

Events:

Face identified - the image obtained from the camera's video stream has similarity with the reference image added in the analytics resources

Face not identified - The image obtained from the camera's video stream does not have similarity with the reference image added in the analytics resources

POST/api/v1/analytic-case

Headers

Authorization

Bearer token

Accept

application/json

X-Client

ios-cctv|android-cctv|thick-legal|web

X-UUID

unique device id

Body

json

JSON
{
    "title": "Face recognition",
    "type": "face",
    "cameras": [
        {
            "id": 10,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 26,
                    "analytic_groups": [
                        2,
                        1
                    ]
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.153125,
                        "y": 0.31666666666666665
                    },
                    {
                        "x": 0.3421875,
                        "y": 0.7361111111111112
                    },
                    {
                        "x": 0.86875,
                        "y": 0.6472222222222223
                    },
                    {
                        "x": 0.78125,
                        "y": 0.125
                    }
                ],
                "threshold": 90
            }
        },
        {
            "id": 7,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 26,
                    "analytic_groups": [
                        2,
                        1
                    ]
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.134375,
                        "y": 0.25277777777777777
                    },
                    {
                        "x": 0.4359375,
                        "y": 0.8694444444444445
                    },
                    {
                        "x": 0.8953125,
                        "y": 0.6611111111111111
                    },
                    {
                        "x": 0.7453125,
                        "y": 0.1361111111111111
                    }
                ],
                "threshold": 30
            }
        }
    ]
}

titlerequired

string

Analytics case name

typerequired

string

For this type of case, the value «face» should always be sent

camerasrequired

array

Array of camera objects specifying the event, reaction, and analytics resource groups

cameras.*.idrequired

array

Camera ID

cameras.*.scriptsrequired

array

Array of event and reaction IDs

cameras.*.scripts.*.idrequired

int

Event and reaction ID, see Creating an event and reaction

cameras.*.scripts.*.analytic_groupsrequired

array

Array of analytics resource group IDs

cameras.*.scripts.*.analytic_groups.*required

int

Analytics resource group ID, see Create a resource group

cameras.*.metarequired

array

Meta information

cameras.*.meta.figurerequired

array

Dedicated area of the camera to be processed by the analytics. It is passed as an array of coordinates (line bending points) in relative values from 0 to 1. The number of points can be from three to n. The last coordinate should not be passed; the area will be closed with the initial coordinate

cameras.*.meta.thresholdrequired

int

Minimum percentage for a face to be considered recognized

Response

201

Returns the analytics case

JSON
{
    "id": 53,
    "title": "Face recognition",
    "type": "face",
    "type_pretty": "Face recognition",
    "status": "active",
    "cameras": [
        {
            "id": 10,
            "group_id": 2,
            "status": "active",
            "type": "media_server_v2",
            "start_at": "",
            "created_at": "2022-12-16 10:25:55",
            "billing_id": null,
            "pretty_name": "Camera 1",
            "pretty_text": "Cameras",
            "short_address": "Cameras",
            "full_address": "Cameras",
            "lat": null,
            "lng": null,
            "azimuth": null,
            "streams": [
                {
                    "id": 19,
                    "type": "high",
                    "camera_id": 10,
                    "is_preview_from_server": true,
                    "is_archive_from_server": null,
                    "status": "active",
                    "has_sound": false,
                    "width": null,
                    "height": null
                },
                {
                    "id": 20,
                    "type": "low",
                    "camera_id": 10,
                    "is_preview_from_server": true,
                    "is_archive_from_server": null,
                    "status": "active",
                    "has_sound": false,
                    "width": null,
                    "height": null
                }
            ],
            "has_sound": false,
            "archive_ranges": [],
            "archive_recording_timetable": null,
            "is_archive_recording": false,
            "archive_recording_type": "fulltime",
            "can_change_archive_timetable": false,
            "scripts": [
                {
                    "id": 26,
                    "title": "Set a label",
                    "schedule": [],
                    "timetable": {
                        "days": [
                            {
                                "to": "23:59:00+05:00",
                                "from": "00:00:00+05:00",
                                "type": "same_every_day",
                                "breaks": []
                            }
                        ],
                        "intervals": []
                    },
                    "status": "active",
                    "created_at": "2022-12-21 12:51:35",
                    "updated_at": "2022-12-21 12:51:35",
                    "users": [
                        {
                            "id": 5,
                            "login": "user",
                            "name": "user",
                            "parent_id": null,
                            "created_at": "2022-12-06 20:20:58",
                            "updated_at": "2022-12-21 12:57:40",
                            "access_token_id": null,
                            "can_update_password": true
                        }
                    ],
                    "event": {
                        "id": 4,
                        "name": "recognized-face",
                        "description": "Face identified",
                        "color": "#07D4F0",
                        "analytic_type": "face"
                    },
                    "analytic_groups": [
                        {
                            "id": 1,
                            "name": "Faces",
                            "type": "face_resource",
                            "type_pretty": "Faces",
                            "uuid": "92fa40e4-5dbe-47e2-b690-ee0ae4636d90",
                            "created_at": "2022-12-21 12:57:14",
                            "updated_at": "2022-12-21 12:57:14"
                        },
                        {
                            "id": 2,
                            "name": "Face 2",
                            "type": "face_resource",
                            "type_pretty": "Face",
                            "uuid": "9d3e5d3c-973a-482f-b0bc-988c698af9e0",
                            "created_at": "2022-12-21 12:57:32",
                            "updated_at": "2022-12-21 12:57:32"
                        }
                    ],
                    "extra": null
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.153125,
                        "y": 0.31666666666666665
                    },
                    {
                        "x": 0.3421875,
                        "y": 0.7361111111111112
                    },
                    {
                        "x": 0.86875,
                        "y": 0.6472222222222223
                    },
                    {
                        "x": 0.78125,
                        "y": 0.125
                    }
                ],
                "threshold": 90
            },
            "analytic_case_camera_status": "active",
            "analytic_case_camera_status_pretty": "Camera active",
            "analytic_case_camera_user_status": null,
            "analytic_case_camera_user_status_pretty": null,
            "event": null,
            "is_bridge": false,
            "is_favorite": false,
            "user_status": "active",
            "name": "Camera 1"
        },
        {
            "id": 7,
            "group_id": 2,
            "status": "inactive",
            "type": "media_server_v2",
            "start_at": "",
            "created_at": "2022-12-16 10:25:54",
            "billing_id": null,
            "pretty_name": "Camera 2",
            "pretty_text": "Cameras",
            "short_address": "Cameras",
            "full_address": "Cameras",
            "lat": null,
            "lng": null,
            "azimuth": null,
            "streams": [
                {
                    "id": 13,
                    "type": "high",
                    "camera_id": 7,
                    "is_preview_from_server": true,
                    "is_archive_from_server": null,
                    "status": "active",
                    "has_sound": false,
                    "width": null,
                    "height": null
                },
                {
                    "id": 14,
                    "type": "low",
                    "camera_id": 7,
                    "is_preview_from_server": true,
                    "is_archive_from_server": null,
                    "status": "active",
                    "has_sound": false,
                    "width": null,
                    "height": null
                }
            ],
            "has_sound": false,
            "archive_ranges": [],
            "archive_recording_timetable": null,
            "is_archive_recording": false,
            "archive_recording_type": "fulltime",
            "can_change_archive_timetable": false,
            "scripts": [
                {
                    "id": 26,
                    "title": "Set a label",
                    "schedule": [],
                    "timetable": {
                        "days": [
                            {
                                "to": "23:59:00+05:00",
                                "from": "00:00:00+05:00",
                                "type": "same_every_day",
                                "breaks": []
                            }
                        ],
                        "intervals": []
                    },
                    "status": "active",
                    "created_at": "2022-12-21 12:51:35",
                    "updated_at": "2022-12-21 12:51:35",
                    "users": [
                        {
                            "id": 5,
                            "login": "user",
                            "name": "user",
                            "parent_id": null,
                            "created_at": "2022-12-06 20:20:58",
                            "updated_at": "2022-12-21 12:57:40",
                            "access_token_id": null,
                            "can_update_password": true
                        }
                    ],
                    "event": {
                        "id": 4,
                        "name": "recognized-face",
                        "description": "Face identified",
                        "color": "#07D4F0",
                        "analytic_type": "face"
                    },
                    "analytic_groups": [
                        {
                            "id": 1,
                            "name": "Faces",
                            "type": "face_resource",
                            "type_pretty": "Faces",
                            "uuid": "92fa40e4-5dbe-47e2-b690-ee0ae4636d90",
                            "created_at": "2022-12-21 12:57:14",
                            "updated_at": "2022-12-21 12:57:14"
                        },
                        {
                            "id": 2,
                            "name": "Faces 2",
                            "type": "face_resource",
                            "type_pretty": "Faces",
                            "uuid": "9d3e5d3c-973a-482f-b0bc-988c698af9e0",
                            "created_at": "2022-12-21 12:57:32",
                            "updated_at": "2022-12-21 12:57:32"
                        }
                    ],
                    "extra": null
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.134375,
                        "y": 0.25277777777777777
                    },
                    {
                        "x": 0.4359375,
                        "y": 0.8694444444444445
                    },
                    {
                        "x": 0.8953125,
                        "y": 0.6611111111111111
                    },
                    {
                        "x": 0.7453125,
                        "y": 0.1361111111111111
                    }
                ],
                "threshold": 30
            },
            "analytic_case_camera_status": "active",
            "analytic_case_camera_status_pretty": "Camera active",
            "analytic_case_camera_user_status": null,
            "analytic_case_camera_user_status_pretty": null,
            "event": null,
            "is_bridge": false,
            "is_favorite": false,
            "user_status": "active",
            "name": "Camera 2"
        }
    ],
    "created_at": "2022-12-21 12:57:51",
    "updated_at": "2022-12-21 12:57:51",
    "analytic_files": [
        {
            "id": 1,
            "name": "8cd2c62afc562e34baf410f60fb5c389.jpeg",
            "type": "face_resource",
            "type_pretty": "Faces",
            "uuid": null,
            "body": "",
            "url": "http://127.0.0.1:8080/storage/analytic-files/2022/12/21/kmdNICDeShIrlzLxYsbJnOrSKybLFUGqqJGd1V9i.jpg",
            "created_at": "2022-12-21 12:52:04",
            "updated_at": "2022-12-21 12:52:04"
        },
        {
            "id": 2,
            "name": "6-sep-2017-beauty-salons-where-are-best-face-peeli-op.jpeg",
            "type": "face_resource",
            "type_pretty": "Faces",
            "uuid": null,
            "body": "",
            "url": "http://127.0.0.1:8080/storage/analytic-files/2022/12/21/oCF24atlYCsztS00pQdF6VErPyF9KFgVRTGxqfp0.jpg",
            "created_at": "2022-12-21 12:52:04",
            "updated_at": "2022-12-21 12:52:04"
        },
        {
            "id": 3,
            "name": "8cd2c62afc562e34baf410f60fb5c389.jpeg",
            "type": "face_resource",
            "type_pretty": "Faces",
            "uuid": null,
            "body": "",
            "url": "http://127.0.0.1:8080/storage/analytic-files/2022/12/21/kTyAPEk53tLRQbYBeeiCMOIgEI82uSa382wqdqju.jpg",
            "created_at": "2022-12-21 12:57:30",
            "updated_at": "2022-12-21 12:57:30"
        },
        {
            "id": 4,
            "name": "6-sep-2017-beauty-salons-where-are-best-face-peeli-op.jpeg",
            "type": "face_resource",
            "type_pretty": "Faces",
            "uuid": null,
            "body": "",
            "url": "http://127.0.0.1:8080/storage/analytic-files/2022/12/21/x6EMx699hPaTTfs0Qcud1ytzhZBZcT7AfuIz0soT.jpg",
            "created_at": "2022-12-21 12:57:30",
            "updated_at": "2022-12-21 12:57:30"
        }
    ],
    "color": "#E5642E",
    "available_events": [],
    "is_fails_exists": false
}
401

Authorization token not provided or invalid, see Obtaining a token

402

License limit exceeded for the selected analytics case

422

Returns a JSON object with an error, see Validation

JSON
{
    "message": "There won't be any informative message here",
    "errors": {
        "any_key": [
            "Here the error cause will be described"
        ]
    }
}

Example

JSON
curl -k --location --request POST 'https://vms.local/api/v1/analytic-case' \
--header 'Authorization:Bearer token' \
--header 'Accept:application/json' \
--header 'X-Client:ios-cctv|android-cctv|thick-legal|web' \
--header 'X-UUID:unique device id' \
--header 'Content-Type: application/json \
--data-raw '{
    "title": "Face recognition",
    "type": "face",
    "cameras": [
        {
            "id": 10,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 26,
                    "analytic_groups": [
                        2,
                        1
                    ]
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.153125,
                        "y": 0.31666666666666665
                    },
                    {
                        "x": 0.3421875,
                        "y": 0.7361111111111112
                    },
                    {
                        "x": 0.86875,
                        "y": 0.6472222222222223
                    },
                    {
                        "x": 0.78125,
                        "y": 0.125
                    }
                ],
                "threshold": 90
            }
        },
        {
            "id": 7,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 26,
                    "analytic_groups": [
                        2,
                        1
                    ]
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.134375,
                        "y": 0.25277777777777777
                    },
                    {
                        "x": 0.4359375,
                        "y": 0.8694444444444445
                    },
                    {
                        "x": 0.8953125,
                        "y": 0.6611111111111111
                    },
                    {
                        "x": 0.7453125,
                        "y": 0.1361111111111111
                    }
                ],
                "threshold": 30
            }
        }
    ]
}'
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.