Cisco Meraki MV Camera MQTT ALPR/ANPR


IFM supplies network engineering services for $NZ180+GST per hour. If you require assistance with designing or engineering a Cisco network - hire us!

Introduction

Second generation Meraki MV cameras (those ending with a "2" in their model number) have built in people detection.  The Cisco Meraki MV72 (and only the MV72) also feature vehicle detection.  These cameras can deliver the detections via a system known as MQTT (MQ Telemetry Transport or Message Queue Telemetry Protocol).  The MV cameras send their messages to something called an MQTT broker.  Clients like cameras send notifications to the MQTT broker, and then other clients connect to the MQTT broker and subscribe to those notifications and process them further in some way.

meraki-mqtt-alpr is a node.js application that subscribes or consumes the MQTT notifications from second generation Cisco Meraki MV cameras via an MQTT broker.  In the case of people detections it saves a still snapshot.  In the case of vehicle detections (from an MV72 camera) meraki-mqtt-alpr can use a cloud based image to licence plate server - either platerecognizer.com or openalpr.com.  They call these services ALPR or ANPR depending where in the world you come from.  If platerecognizer.com is used and you are based in New Zealand the number is then looked up in the New Zealand Police stolen vehicles database to see if the vehicle is stolen.

Limitations and Restrictions

  • To be able to deploy this you should have a medium skill level in using the Cisco Meraki system and scripting.  If you have never done either or are new to doing this consider getting someone to help with sufficient experience.
  • The MQTT broker and meraki-mqtt-alpr should be installed on a machine located on the same site as the cameras. They don't need to be in the same VLAN, but the Cisco Meraki cameras need to be able to send messages via IP to the machine hosting the MQTT broker.  The program uses very little resources, so a low end workstation is fine.
  • The Cisco Meraki dashboard API limits calls to the dashboard to 5 per second for the entire organisation.  meraki-mqtt-alpr uses the dashboard API to request a snapshot of whatever triggered the person or vehicle event.  Consequently meraki-mqtt-alpr wont work well in an environment where more than 5 requests are made per second for snapshots.  Note that if you have any other dashboard API integrations running they will also be counting against the limit of 5 per second. You can have brief periods where it bursts higher than this, but it can not operate at a sustained level higher than this.
  • The MQTT framework uses the Cisco Meraki MV Sense API.  Each organisation gets 10 free licences.  If you need to use more than 10 cameras with this system you'll need to buy additional MV Sense licences.
  • meraki-mqtt-alpr has been written to expect all of the cameras being monitored to be in the same Cisco Meraki Dashboard organisation and network.  If you have cameras spread across more networks you'll need to either modify the code or run additional instances of meraki-mqtt-alpr.

Preparing to get started

You need to decide on a machine to install the meraki-mqtt-alpr onto.  meraki-mqtt-alpr uses very little CPU or RAM, so it can go onto a low end workstation.  This machine needs to have a static IP address.

meraki-mqtt-alpr is a node.js program.  If you don't have node.js then you'll need to download and install it.  It's free.  I like free.  Download and install node.js.  The default configuration is fine.

You need an MQTT broker.  I like the free MQTT broker called Mosquito.  Download and install Mosquito.  The default configuration is fine.

You need to configure the cameras that you want to use with meraki-mqtt-alpr to send MQTT messages to Mosquitto.  Follow the "Configuring MQTT in the Dashboard" guide.  Mosquitto defaults to using port 1883.

You need to enable the Meraki API.  I would recommend creating a dedicated Meraki dashboard administrator account for the API access.  meraki-mqtt-alpr requires read-only access.  The account needs to be able to access and view the cameras that will be used.  Follow the "The Cisco Meraki Dashboard API" guide to enable the API and to generate an API key.  The API key is essentially a password and you should treat it in the same way you would treat a user password.

If you want to do licence plate recognition you now need to decide on a ALPR cloud provider to use.  meraki-mqtt-alpr supports platerecognizer.com and openalpr.com.  In both cases the cloud API of each relevant service is used.

openalpr.com seems to be the most famous and very popular.

platerecognizer.com is cheaper, comes with a generous allowance of free plate recognitions (so you can have a really good play at no cost), and from my use of it - substantially better at converting images of number plates to readable text.

openalpr.com lists New Zealand as a supported country but it recognises so few number plates I found it useless.  It may be better for your country.  platerecognizer.com does not list New Zealand as a supported country but it pretty much recognises every single number plate image I gave it - even really bad images or barely readable images.  I found when using openalpr.com the images need to be really good.  An image a little less than good could not be recognised.

Whichever cloud based ALPR provider you choose, go open an account with them.  For platerecognizer.com you need to generate an API token.  For openalpr.com you need to generate an API key.  Remember you will be using their cloud based product.

Deployment

Start by download meraki-mqtt-alpr.zip and extra it into a new directory.

Next you need to create an ".env" file (special note for Windows users - the filename is dot env).  This is used to store all your sensitive information.  There is a sample called template.env.  Copy "template.env" to ".env".  Open up the ".env" file and fill in the fields for the bits that are relevant to you.  A sample might look like:

# Meraki configuration
merakiAPIKey=0146************************************
orgName=ICU Ltd
networkName=ICU Car Park
# platerecognizer.com config. Only needed if you are using platerecognizer.com. plateRecognizerAPIToken=f418************************************
# openalpr.com configuration. Only needed if you are using openalpr.com. openALPRsecret=sk_0186********************

SPECIAL NOTE: Currently there is a bug in the module node-meraki-dashboard. To work around this edit the file "node_modules\node-meraki-dashboard\src\index.js" and change the "api" on line 24 from https://api.meraki.com/api/v0/ to be the URL for the shard your organisation is in (which you can see when logged into your Meraki dashboard with your web browser).  An example shard is "n85" - so you would change "api" to "n85".

Next you need to configure which options you want to use.  Edit "index.js" and search for the text "CHECKME".  Read the comment related to each option.  Most of them involve setting a flag to true or false depending on weather you want meraki-mqtt-alpr to take some action.

The last "CHECKME" is the list of cameras you want to subscribe to.  You can either list each camera you want to subscribe to, or use the last option to subscribe to all camera notifications.  If you have many cameras but are only interested in processing a few it will be more efficient to list those specific cameras.

Ready, set, go!

You are now ready to run the system. Change into the directory and execute "node index.js". You should shortly get a message saying the system is ready to start processing camera messages.  If you get an error go back then check your work and try and work through the error message.

If you have it enabled, each time meraki-mqtt-alpr gets a person detection message the image will be saved to the "people" folder.  Note this folder could grow very big, so create a scheduled task to delete its contents every now and then.

If you have it enabled, each time meraki-mqtt-alpr gets a vehicle detection message the image will be saved to the "vehicles" folder. Note this folder could grow very big, so create a scheduled task to delete its contents every now and then.  Also if you have either of platerecognizer.com or openalpr.com enabled a request is made for the licence plate to be read.  If the licence plate is readable it will be written to the console.  If you have configured lookups against the NZ Police stolen vehicle database and are using platerecognizer.com then that will also be checked and a special warning written to the console if the vehicle is listed as stolen.

Summary

meraki-mqtt-alpr provides you with a working framework to use Meraki MV cameras to process people detection events and in the case of the MV72, vehicle detection events.  The vehicle detection events use an ALPR cloud based service to convert it to a licence plate in plain text which can then be passed onto other systems for further processing.  You can extend the code to provide further processing, as demonstrated by being able to consult the NZ Police stolen vehicle database.