Our customers love the freedom of connecting any camera type and running A.I. analytics of their choice without the need to manage local computing challenges. Another aspect customers love is the freedom to integrate the data into their workflow.
Today, we are adding to our existing portfolio of output options such as live Esri dashboard, SMS, Slack, and MS Teams notifications with our Analytics API.
In this article, we’re excited to share our recently released version.
The analytics API exposes read-only endpoints to authorized users, allowing customers to automatically retrieve Unleash live AI. generated analytics data and custom integrations with the Unleash live ecosystem.
This technical article provides a simple user case to get you started. If you want to learn more about how the Analytics API can be integrated into your business workflow, get in touch; we’d love to show you.
Back to the technical. This article is also available as a notebook here if you would prefer to test the API in real-time!
To start with, our analytics API documentation can be found at developer.unleashlive.com.
Code examples are provided in both BASH (using curl) and in Python 3 with the urllib3 library, which comes standard with most web environments (such as Google Compute and AWS Lambda).
Authentication is performed by providing an ‘x-api-key’ header with your request.
You’ll also need an API key to get started — for this example, we can use a test key:
s9DgN7EXDw3hST32dquq44GICMeINPBxASgC3OKb
To test that your setup is working correctly, you can perform a quick version check with curl:
curl -X GET -H "x-api-key: <API-KEY>"
https://api.unleashlive.com/v1/analytics/version
Which should return a version number if successful:
"0.0.1"
You can find a list of all of your devices within your Unleash live account under “Device Management” — for this article, we’ll be using some pre-configured test devices.
The device IDs are as follows:
['Wb109bb2283c0129', 'W9e2acb15068fc53', 'T9x8e76wtrc88n8m', 'Tjh6lkj37g85d763']
Of which ‘T9x8e76wtrc88n8m’ and ‘Tjh6lkj37g85d763’ contain data, between the 24th and 30th of August, 2020, Australian Eastern Standard Time (AEST), or 1598190900 and 1598795700 in Unix time.
While all devices with API access are returned, this is no guarantee that analytics data is available for each device, so it is recommended that you ensure analytics are being generated in your account before attempting to access them with the Analytics API.
We can assemble our first real API request with a working API key and know which devices we want to analyze.
Data for a specific device and time period can be requested with the following endpoint:
GET/analytics/{deviceId}/{unixUTCTimeStampFrom}/{unixUTCTimeStampTo}/{pageNumber}
The main request is pretty self-explanatory — deviceId is the device we found earlier, unixUTCTimeStampFrom and unixUTCTimeStampTo identify a period of time to return data from, and pageNumber, which should be 1 for the initial request.
For our data — deviceId T9x8e76wtrc88n8m, unix times from 1598190900 to 1598795700 and with page number 1, we get something like this: The main request is pretty self-explanatory — deviceId is the device we found earlier, unixUTCTimeStampFrom and unixUTCTimeStampTo identify a period of time to return data from, and pageNumber, which should be 1 for the initial request.
For our data — deviceId T9x8e76wtrc88n8m, unix times from 1598190900 to 1598795700 and with page number 1, we get something like this:
Which is a lot of data. The Analytics API is currently on a per-detection basis, allowing customers to do their own aggregations or transforms on the data.
The returns return three items — “keys”, a list of keys for the main data list, “total_num_pages”, the total number of pages for the requested time period and “data”, which is a list of lists containing each AI generated analytic data points.
Importantly, total_num_pages for this request is 4 — so we should do the request again, substituting pageNumber for 2, 3, and 4 to build up the rest of the data table.
Now that we have all our data in one convenient location, we can graph something.
Let’s start by finding out what data we have — using something like df[‘class_name’].unique() from Pandas, we find out that we have the following data points:
['this_frame_persons_count', 'num_individuals', 'group_pixel_size', 'number_of_persons_in_group', 'total_count', 'number_of_groups']
This data comes from our Social Distancing model — total_count gives us the total number of people within each video.
Displaying this with a Pandas graph gives a graph like the following, showing the number of people during daylight hours in a public space:
Graph showing the count of people per day
We can already make out some easy trends — the middle of the day on August 29th and 30th were the busiest days by far, which makes sense as they occurred on a weekend.
Next time, we’ll look at combining data from multiple devices and using the full capabilities of this particular AI App to measure social distancing.
The Unleash live Analytics API allows you to extract and work with AI-generated data in your chosen business tool or application.
Q: What are the main benefits of using Unleash live's zone application?
A: The main benefits include the ability to focus data capture on areas of interest, excluding irrelevant areas to increase accuracy and receiving zone-specific alerts for improved response times and situational awareness.
Q: How does Unleash live help in measuring pedestrian and vehicle movement?
A: Unleash live allows users to create virtual zones to accurately capture data on pedestrian and vehicle movement. By setting up Polygon and Bi-directional zones, users can target specific areas and scenarios for precise data collection.
Q: Can Unleash live's system be integrated with existing city cameras?
A: Yes, Unleash live can leverage existing city cameras for data capture, eliminating the need for new hardware deployment. This makes it easy to integrate into current infrastructure and start gathering insights quickly.
Q: How does the bi-directional count feature work?
A: The bi-directional count feature helps understand in-and-out scenarios, such as toll gates, doors, or pathways. It counts the number of people or vehicles crossing a designated line in either direction.
Q: What kind of alerts can be set up with Unleash live's zone application?
A: Users can set up zone-specific alerts to notify them of specific events within designated areas. Alerts can be integrated with APIs, e-mail, and SMS for real-time updates on predetermined anomalies.
Visit unleashlive.com to learn more, or contact one of our specialist team members to learn how your business can take advantage of live-streaming video and AI analytics.