In this PoV, we have created a script that can subscribe to a Meraki MV telemetry stream through a MQTT broker and it can detect whether a person is loitering for more than a set threshold. In case the person is detected for longer than the set threshold, then a Webex notification is sent to a recipient through a Webex bot.
The following commands are executed in the terminal.
Create and activate a virtual environment for the project:
#WINDOWS:
$ py -3 -m venv [add_name_of_virtual_environment_here]
$ [add_name_of_virtual_environment_here]/Scripts/activate.bat
#MAC:
$ python3 -m venv [add_name_of_virtual_environment_here]
$ source [add_name_of_virtual_environment_here]/bin/activate
For more information about virtual environments, please click here
Access the created virutal environment folder
$ cd [add_name_of_virtual_environment_here]
Clone this repository
$ git clone [add_link_to_repository_here]
Access the folder merakimv_people_detection
$ cd merakimv_people_detection
Install the dependencies:
$ pip install -r requirements.txt
Meraki MV Camera Connection
env_var.py
file. You can find details on how to obtain the Meraki API key here.MERAKI_API_KEY= " "
env_var.py
file.NETWORK_ID = " " CAMERA_SERIAL = " "
MQTT Setup
In the Meraki dashboard, go to Cameras
> [Camera Name]
> Settings
> Sense
page.
Click to Add or Edit MQTT Brokers > New MQTT Broker and add you broker information. For testing/trial you can find public broker at here.
Add the MQTT Server settings to the env_var.py
file.
MQTT_SERVER = " " MQTT_PORT = None #Please note: integer
Cisco Webex
In order to send notifications to a Webex space, we have created a Webex Bot. Follow the following instructions to create a Webex bot and its token:
Log in to developer.webex.com
Click on your avatar and select My Webex Apps
Click Create a New App
Click Create a Bot
to start the wizard
Following the instructions of the wizard: fill in details such as the bot name, bot username and choose an icon
Click Add Bot
and you will be given access token
Copy the access token and store it safely. Please note that the API key will be shown only once for security purposes. In case you lose the key, then you have to revoke the key and regenerate a new key
For more information about Webex Bots and how to create one, please see the documentation.
env_var.py
file:BOT_ACCESS_TOKEN = " " MESSAGE_RECIPIENT = " " # email address
Threshold settings
The threshold settings can be configured in env_var.py
file. The value specified is in milliseconds. By default, the threshold is set at 60000 milliseconds, but in practice 10 minutes is more likely.
AGE_THRESHOLD = 60000 #milliseconds
Run the python script
$ python main.py
When a person is detected the a MQTT broker will send a notification to the python program. If the person stays within the reach of the camera for 5min then a webex notification is sent to the security team.
Provided under Cisco Sample Code License, for details see LICENSE
Our code of conduct is available here
See our contributing guidelines here
Please note: This script is meant for demo purposes only. All tools/ scripts in this repo are released for use "AS IS" without any warranties of any kind, including, but not limited to their installation, use, or performance. Any use of these scripts and tools is at your own risk. There is no guarantee that they have been through thorough testing in a comparable environment and we are not responsible for any damage or data loss incurred with their use.
You are responsible for reviewing and testing any scripts you run thoroughly before use in any non-testing environment.
We have created a script that can subscribe to a Meraki MV telemetry stream through a MQTT broker and it can detect whether a person is loitering for more than a set threshold. In case the person is detected for longer than the set threshold, then a Webex notification is sent to a recipient through a Webex bot.
Provide links to related white papers:
Provide a link to a related DevNet Sandbox:
Provide links to related Learning Labs or modules on DevNet:
Provide links to related solutions on DevNet Ecosystem Exchange:
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community