Skip to main content
Skip table of contents

Create an analytics case. Motion detection

Creating an analytics case with the type «Motion detection».

Tool for automatic motion detection in a designated area of the video stream. This business case can be applied in various scenarios where there is a need to monitor the movement of objects in specific areas/territories, with mandatory notifications upon event detection.

Event: Motion detection start - detecting the beginning of object movement in the defined detection zone of the camera.

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": "Motion detection",
    "type": "motion-detect",
    "cameras": [
        {
            "id": 8,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 17
                },
                {
                    "id": 18
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.78828125,
                        "y": 0.06078947368421053
                    },
                    {
                        "x": 0.80078125,
                        "y": 0.16578947368421054
                    },
                    {
                        "x": 0.97265625,
                        "y": 0.11328947368421054
                    },
                    {
                        "x": 0.94921875,
                        "y": 0.019342105263157897
                    }
                ]
            }
        },
        {
            "id": 2,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 18
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.78828125,
                        "y": 0.06078947368421053
                    },
                    {
                        "x": 0.80078125,
                        "y": 0.16578947368421054
                    },
                    {
                        "x": 0.97265625,
                        "y": 0.11328947368421054
                    },
                    {
                        "x": 0.94921875,
                        "y": 0.019342105263157897
                    }
                ]
            }
        },
        {
            "id": 3,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 17
                },
                {
                    "id": 18
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.78828125,
                        "y": 0.06078947368421053
                    },
                    {
                        "x": 0.80078125,
                        "y": 0.16578947368421054
                    },
                    {
                        "x": 0.97265625,
                        "y": 0.11328947368421054
                    },
                    {
                        "x": 0.94921875,
                        "y": 0.019342105263157897
                    }
                ]
            }
        }
    ]
}

titlerequired

string

Analytics case name

typerequired

string

For this type of case, the value "motion-detect" must always be sent

camerasrequired

array

Array of camera objects specifying the event and reaction

cameras.*.idrequired

array

Camera ID

cameras.*.scriptsrequired

array

Array of event and reaction IDs

cameras.*.scripts.*.idrequired

int

Event and reaction IDs, see Creating an event and reaction

cameras.*.meta.figurerequired

array

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

Response

201

Returns the analytics case

JSON
{
    "id": 41,
    "title": "Motion detection",
    "type": "motion-detect",
    "type_pretty": "Motion detection",
    "status": "active",
    "cameras": [
        {
            "id": 8,
            "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": 15,
                    "type": "high",
                    "camera_id": 8,
                    "is_preview_from_server": true,
                    "is_archive_from_server": null,
                    "status": "active",
                    "has_sound": false,
                    "width": null,
                    "height": null
                },
                {
                    "id": 16,
                    "type": "low",
                    "camera_id": 8,
                    "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": 17,
                    "title": "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": "2021-12-27 12:32:46",
                    "updated_at": "2021-12-27 12:32:46",
                    "users": [],
                    "event": {
                        "id": 2,
                        "name": "motion-detect",
                        "description": "Motion detection",
                        "color": "#5AD057",
                        "analytic_type": "motion-detect"
                    },
                    "extra": null
                },
                {
                    "id": 18,
                    "title": "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": "2021-12-27 12:36:20",
                    "updated_at": "2021-12-27 12:36:20",
                    "users": [],
                    "event": {
                        "id": 2,
                        "name": "motion-detect",
                        "description": "Motion detection",
                        "color": "#5AD057",
                        "analytic_type": "motion-detect"
                    },
                    "extra": null
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.78828125,
                        "y": 0.06078947368421053
                    },
                    {
                        "x": 0.80078125,
                        "y": 0.16578947368421054
                    },
                    {
                        "x": 0.97265625,
                        "y": 0.11328947368421054
                    },
                    {
                        "x": 0.94921875,
                        "y": 0.019342105263157897
                    }
                ]
            },
            "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 1"
        },
        {
            "id": 2,
            "group_id": 2,
            "status": "inactive",
            "type": "media_server_v2",
            "start_at": "",
            "created_at": "2022-12-06 20:20:50",
            "billing_id": null,
            "pretty_name": "Camera 2",
            "pretty_text": "Cameras",
            "short_address": "Cameras",
            "full_address": "Cameras",
            "lat": null,
            "lng": null,
            "azimuth": null,
            "streams": [
                {
                    "id": 3,
                    "type": "high",
                    "camera_id": 2,
                    "is_preview_from_server": true,
                    "is_archive_from_server": null,
                    "status": "active",
                    "has_sound": false,
                    "width": null,
                    "height": null
                },
                {
                    "id": 4,
                    "type": "low",
                    "camera_id": 2,
                    "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": 18,
                    "title": "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": "2021-12-27 12:36:20",
                    "updated_at": "2021-12-27 12:36:20",
                    "users": [],
                    "event": {
                        "id": 2,
                        "name": "motion-detect",
                        "description": "Motion detection",
                        "color": "#5AD057",
                        "analytic_type": "motion-detect"
                    },
                    "extra": null
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.78828125,
                        "y": 0.06078947368421053
                    },
                    {
                        "x": 0.80078125,
                        "y": 0.16578947368421054
                    },
                    {
                        "x": 0.97265625,
                        "y": 0.11328947368421054
                    },
                    {
                        "x": 0.94921875,
                        "y": 0.019342105263157897
                    }
                ]
            },
            "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"
        },
        {
            "id": 3,
            "group_id": 5,
            "status": "inactive",
            "type": "media_server_v2",
            "start_at": "",
            "created_at": "2022-12-06 20:20:50",
            "billing_id": null,
            "pretty_name": "Camera 1",
            "pretty_text": "Cameras",
            "short_address": "Cameras",
            "full_address": "Cameras",
            "lat": null,
            "lng": null,
            "azimuth": null,
            "streams": [
                {
                    "id": 5,
                    "type": "high",
                    "camera_id": 3,
                    "is_preview_from_server": true,
                    "is_archive_from_server": null,
                    "status": "active",
                    "has_sound": false,
                    "width": null,
                    "height": null
                },
                {
                    "id": 6,
                    "type": "low",
                    "camera_id": 3,
                    "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": 17,
                    "title": "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": "2021-12-27 12:32:46",
                    "updated_at": "2021-12-27 12:32:46",
                    "users": [],
                    "event": {
                        "id": 2,
                        "name": "motion-detect",
                        "description": "Motion detection",
                        "color": "#5AD057",
                        "analytic_type": "motion-detect"
                    },
                    "extra": null
                },
                {
                    "id": 18,
                    "title": "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": "2021-12-27 12:36:20",
                    "updated_at": "2021-12-27 12:36:20",
                    "users": [],
                    "event": {
                        "id": 2,
                        "name": "motion-detect",
                        "description": "Motion detection",
                        "color": "#5AD057",
                        "analytic_type": "motion-detect"
                    },
                    "extra": null
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.78828125,
                        "y": 0.06078947368421053
                    },
                    {
                        "x": 0.80078125,
                        "y": 0.16578947368421054
                    },
                    {
                        "x": 0.97265625,
                        "y": 0.11328947368421054
                    },
                    {
                        "x": 0.94921875,
                        "y": 0.019342105263157897
                    }
                ]
            },
            "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"
        }
    ],
    "created_at": "2022-12-21 12:38:38",
    "updated_at": "2022-12-21 12:38:38",
    "color": "#2CA329",
    "available_events": [],
    "is_fails_exists": true,
    "errors": [
        "Error creating camera Camera 3."
    ]
}
401

Authorization token is missing or invalid, see Obtaining a token

402

The license limit for the selected analytics case has been exceeded

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": "Motion detection",
    "type": "motion-detect",
    "cameras": [
        {
            "id": 8,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 17
                },
                {
                    "id": 18
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.78828125,
                        "y": 0.06078947368421053
                    },
                    {
                        "x": 0.80078125,
                        "y": 0.16578947368421054
                    },
                    {
                        "x": 0.97265625,
                        "y": 0.11328947368421054
                    },
                    {
                        "x": 0.94921875,
                        "y": 0.019342105263157897
                    }
                ]
            }
        },
        {
            "id": 2,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 18
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.78828125,
                        "y": 0.06078947368421053
                    },
                    {
                        "x": 0.80078125,
                        "y": 0.16578947368421054
                    },
                    {
                        "x": 0.97265625,
                        "y": 0.11328947368421054
                    },
                    {
                        "x": 0.94921875,
                        "y": 0.019342105263157897
                    }
                ]
            }
        },
        {
            "id": 3,
            "analytic_case_camera_user_status": null,
            "scripts": [
                {
                    "id": 17
                },
                {
                    "id": 18
                }
            ],
            "meta": {
                "figure": [
                    {
                        "x": 0.78828125,
                        "y": 0.06078947368421053
                    },
                    {
                        "x": 0.80078125,
                        "y": 0.16578947368421054
                    },
                    {
                        "x": 0.97265625,
                        "y": 0.11328947368421054
                    },
                    {
                        "x": 0.94921875,
                        "y": 0.019342105263157897
                    }
                ]
            }
        }
    ]
}'
JavaScript errors detected

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

If this problem persists, please contact our support.