Skip to main content
Skip table of contents

Create an analytics case. Visitor counting

Creating an analytics case with the type "Visitor counting".

This analytics case involves the automatic localization and accurate counting of people passing through a specific area or passage over a certain period of time. It can be used in various scenarios where there is a need to count overall traffic and analyze the visitor patterns of an object/location based on months, days of the week, hours, and minutes.

Event: Detection of people crossing a specified line on the observed object, recognition of their gender and age for further display on the Analytics infographic page.

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": "Visitor counting",
    "type": "visitor_counting",
    "cameras": [
        {
            "id": 7,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 22
                }
            ],
            "meta": {
                "line": [
                    {
                        "x": 0.0859375,
                        "y": 0.24722222222222223
                    },
                    {
                        "x": 0.415625,
                        "y": 0.8416666666666667
                    },
                    {
                        "x": 0.94375,
                        "y": 0.5722222222222222
                    },
                    {
                        "x": 0.7390625,
                        "y": 0.09444444444444444
                    }
                ],
                "figure": [
                    {
                        "x": 0.0859375,
                        "y": 0.24722222222222223
                    },
                    {
                        "x": 0.415625,
                        "y": 0.8416666666666667
                    },
                    {
                        "x": 0.94375,
                        "y": 0.5722222222222222
                    },
                    {
                        "x": 0.7390625,
                        "y": 0.09444444444444444
                    }
                ]
            }
        },
        {
            "id": 10,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 22
                }
            ],
            "meta": {
                "line": [
                    {
                        "x": 0.14375,
                        "y": 0.4166666666666667
                    },
                    {
                        "x": 0.3875,
                        "y": 0.925
                    },
                    {
                        "x": 0.90625,
                        "y": 0.6166666666666667
                    },
                    {
                        "x": 0.778125,
                        "y": 0.29444444444444445
                    }
                ],
                "figure": [
                    {
                        "x": 0.14375,
                        "y": 0.4166666666666667
                    },
                    {
                        "x": 0.3875,
                        "y": 0.925
                    },
                    {
                        "x": 0.90625,
                        "y": 0.6166666666666667
                    },
                    {
                        "x": 0.778125,
                        "y": 0.29444444444444445
                    }
                ]
            }
        }
    ]
}

titlerequired

string

Analytics case name

typerequired

string

For this type of case, you should always send the visitor_counting value

camerasrequired

array

Array of camera objects with specified events and reactions

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.*.meta.linerequired

array

Line that triggers the selected analytics when crossed. It is an array of relative coordinates (start and end points of the line) consisting of 2 points ranging from 0 to 1

cameras.*.meta.figurerequired

array

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

Response

201

Returns an analytics case

JSON
{
    "id": 45,
    "title": "Visitor counting",
    "type": "visitor_counting",
    "type_pretty": "Visitor counting",
    "status": "active",
    "cameras": [
        {
            "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 1",
            "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": 22,
                    "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:46:00",
                    "updated_at": "2022-12-21 12:46:00",
                    "users": [],
                    "event": {
                        "id": 8,
                        "name": "visitor_counting",
                        "description": "Visitor detection",
                        "color": "#8B3EBA",
                        "analytic_type": "visitor_counting"
                    },
                    "extra": null
                }
            ],
            "meta": {
                "line": [
                    {
                        "x": 0.0859375,
                        "y": 0.24722222222222223
                    },
                    {
                        "x": 0.415625,
                        "y": 0.8416666666666667
                    },
                    {
                        "x": 0.94375,
                        "y": 0.5722222222222222
                    },
                    {
                        "x": 0.7390625,
                        "y": 0.09444444444444444
                    }
                ],
                "figure": [
                    {
                        "x": 0.0859375,
                        "y": 0.24722222222222223
                    },
                    {
                        "x": 0.415625,
                        "y": 0.8416666666666667
                    },
                    {
                        "x": 0.94375,
                        "y": 0.5722222222222222
                    },
                    {
                        "x": 0.7390625,
                        "y": 0.09444444444444444
                    }
                ]
            },
            "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": 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 2",
            "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": 22,
                    "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:46:00",
                    "updated_at": "2022-12-21 12:46:00",
                    "users": [],
                    "event": {
                        "id": 8,
                        "name": "visitor_counting",
                        "description": "Visitor detection",
                        "color": "#8B3EBA",
                        "analytic_type": "visitor_counting"
                    },
                    "extra": null
                }
            ],
            "meta": {
                "line": [
                    {
                        "x": 0.14375,
                        "y": 0.4166666666666667
                    },
                    {
                        "x": 0.3875,
                        "y": 0.925
                    },
                    {
                        "x": 0.90625,
                        "y": 0.6166666666666667
                    },
                    {
                        "x": 0.778125,
                        "y": 0.29444444444444445
                    }
                ],
                "figure": [
                    {
                        "x": 0.14375,
                        "y": 0.4166666666666667
                    },
                    {
                        "x": 0.3875,
                        "y": 0.925
                    },
                    {
                        "x": 0.90625,
                        "y": 0.6166666666666667
                    },
                    {
                        "x": 0.778125,
                        "y": 0.29444444444444445
                    }
                ]
            },
            "analytic_case_camera_status": "inactive",
            "analytic_case_camera_status_pretty": "Camera inactive",
            "analytic_case_camera_user_status": "failed_to_create",
            "analytic_case_camera_user_status_pretty": "Creation error",
            "event": null,
            "is_bridge": false,
            "is_favorite": false,
            "user_status": "active",
            "name": "Camera 2"
        }
    ],
    "created_at": "2022-12-21 12:46:24",
    "updated_at": "2022-12-21 12:46:24",
    "color": "#C76DFF",
    "available_events": [],
    "is_fails_exists": true,
    "errors": [
        "Error creating camera Camera 2."
    ]
}
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": "Visitor counting",
    "type": "visitor_counting",
    "cameras": [
        {
            "id": 7,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 22
                }
            ],
            "meta": {
                "line": [
                    {
                        "x": 0.0859375,
                        "y": 0.24722222222222223
                    },
                    {
                        "x": 0.415625,
                        "y": 0.8416666666666667
                    },
                    {
                        "x": 0.94375,
                        "y": 0.5722222222222222
                    },
                    {
                        "x": 0.7390625,
                        "y": 0.09444444444444444
                    }
                ],
                "figure": [
                    {
                        "x": 0.0859375,
                        "y": 0.24722222222222223
                    },
                    {
                        "x": 0.415625,
                        "y": 0.8416666666666667
                    },
                    {
                        "x": 0.94375,
                        "y": 0.5722222222222222
                    },
                    {
                        "x": 0.7390625,
                        "y": 0.09444444444444444
                    }
                ]
            }
        },
        {
            "id": 10,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 22
                }
            ],
            "meta": {
                "line": [
                    {
                        "x": 0.14375,
                        "y": 0.4166666666666667
                    },
                    {
                        "x": 0.3875,
                        "y": 0.925
                    },
                    {
                        "x": 0.90625,
                        "y": 0.6166666666666667
                    },
                    {
                        "x": 0.778125,
                        "y": 0.29444444444444445
                    }
                ],
                "figure": [
                    {
                        "x": 0.14375,
                        "y": 0.4166666666666667
                    },
                    {
                        "x": 0.3875,
                        "y": 0.925
                    },
                    {
                        "x": 0.90625,
                        "y": 0.6166666666666667
                    },
                    {
                        "x": 0.778125,
                        "y": 0.29444444444444445
                    }
                ]
            }
        }
    ]
}'
JavaScript errors detected

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

If this problem persists, please contact our support.