Sign Up
Misc, Product

ALPR With Portainer and Kerberos

Do you have a Raspberry Pi?  Have you have been wondering how you could use your Pi with an ALPR software?  Worry no more as Plate Recognizer now supports Kerberos.io as a VMS for Raspberry Pi.

In this article, we will walk you through the steps to getting our ALPR software up and running on your Raspberry Pi.

What is Kerberos.io?

Kerberos.io is a video surveillance solution, which works with any camera and on every Linux based machine. You can deploy a fully configured video surveillance system within a few minutes on the environment you prefer: Raspberry Pi, Docker, Kubernetes cluster. Great UX and scalability is one of its key differentiators.

What is Portainer?

Portainer was built for customers to easily build, manage and maintain their Docker environments. Portainer is easy to use software that provides an intuitive interface for both software developers and IT operations. Portainer gives you a detailed overview of your Docker environments and allows you to manage your containers, images, networks and volumes.

What is Plate Recognizer?

Plate Recognizer is a sophisticated Automatic License Plate Recognition ALPR Software that uses Optical Character Recognition (OCR) and neural network algorithms to read and decode vehicle number plates for a variety of use cases.

Let’s Get Started!

Let’s dive in right now into the steps needed to set up Portainer, Kerberos and Plate Recognizer on Raspberry Pi.

#1: Install Docker & Portainer

Here is a good tutorial on installing docker and Portainer on your Raspberry Pi. By the way, Pi-Hole is also handy, but not for this project.

On the Raspberry Pi command line, run the following commands:

To Install Docker
• curl -sSL get.docker.com | sh
• sudo usermod -aG docker pi
• Log out & in again
• If the usermod doesn’t “take”, you need to add “sudo” before all the commands below

To Install Portainer:
• docker volume create portainer_data
• docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data ––restart always portainer/portainer

To check that Portainer is running:
• docker ps

To check that you can connect:
• Point your web browser to the pi’s IP address, port 9000.

You will need to create an admin user. The GUI doesn’t really give the impression that you can change the username, but you can.

I used the username “pi” so there’s one less to remember.

After login, select “Local” and then click “Connect”.

Right now, Portainer is good to go, and you can then install Plate Recognizer SDK.

Sign up here and get a Plate Recognizer API Token. You will have to request for a Free Trial of Snapshot SDK. Make sure to sign up with your corporate email address as we only grant Snapshot SDK free trials to business users.

#2: Install Plate Recognizer using Portainer GUI

Follow the steps below.

1. Create a volume:
• license

2. Create container:
• Image: platerecognizer/alpr-raspberry-pi
• Manual network port publishing:
Port 8080 => container 8080

3. Add volume:
• Container: /license
• Volume: license-local

4. Add environment variables:
• TOKEN = Replace with your API Token from Plate Recognizer
• LICENSE_KEY = Replace with your SDK License Key from Plate Recognizer.

5. Restart policy: Restart unless stopped.

#3: Check that Plate Recognizer is Working

Follow the steps below.

1. In your web browser, go to localhost:8080/info/

2. Check that Plate Recognizer ALPR is working using the Raspberry PI command line:
• curl -o /tmp/car.jpg app.platerecognizer.com/static/demo.jpg
• curl -F ‘file=@/tmp/car.jpg’ localhost:8080/alpr

You should get a JSON output such as:
{“processing_time”: 1571.571, “camera_id”: null, “filename”: “car.jpg”, “usage”: {“max_calls”: 5000, “calls”: 4503}, “results”: [{“vehicle”: {“type”: “Car”, “box”: {“ymin”: 116, “xmax”: 923, “ymax”: 659, “xmin”: 90}, “score”: 0.811}, “box”: {“ymin”: 483, “xmax”: 281, “ymax”: 581, “xmin”: 150}, “region”: {“code”: “gb”, “score”: 0.979}, “candidates”: [{“score”: 0.895, “plate”: “nhk552”}], “dscore”: 0.83, “score”: 0.895, “plate”: “nhk552”}], “timestamp”: “2020-03-15 12:29:21.591831”}

3. Want to have it human-readable? JQ is your friend and is used as follows:
• sudo apt install jq
• anpr=$(curl -s -F ‘file=@/tmp/car.jpg’ localhost:8080/alpr)
• echo $anpr | jq .results[]

#4: Install Kerberos.io

Here are the steps to install Kerberos.io on your Raspberry Pi.

1. Create a volume, for easy local access to images and videos created by Kerberos.io.
• Example name: kerberos

2. Create container:
• Use a reasonable name. If your IP-camera has a name on the network, use that.
• Or a unique identifier, example: “kerberosio-45” since my camera’s IP address ends in .45
• Image: kerberos/kerberos
• Volumes:
Container: /etc/opt/kerberosio/capture ->volume kerberos –– local
• Manual network port publishing:
89 =>80
8889 => 8889
Restart policy: Unless stopped

3. Point your web-browser to the Raspberry Pi IP Port 89
• First select language, then create user/password
• Click “Configuration” and give the container a name
• Select “IP Camera” and input the stream URL.

As the stream URL can be challenging to find, here’s a tool that worked well for me.

For my camera it is: 172.16.172.39:554/11

In case you want to use the RPI camera, then you’ll need to either set up fast mpjpeg-streamer or suchlike in the host OS, or install a container that provides an IP stream from the RPICam.

4. Select a suitable resolution, delay and frame rate.
Also note that Kerberos.io suggests that you use the same resolution and frame rate that the camera sends.

5. Click Confirm & Select, and then Update.

Since the Kerberos.io GUI is a little bit weird:
• You navigate with the small arrows in the popup window
• You MUST click “Update” for changes to be saved

6. Go to the Dashboard and check if stream is working. Be advised as it may take a long time before the stream shows up, most times minutes.

#5: Tune Kerberos.io

Now you need to “tune” Kerberos.io to give you correct trigger.  Play with detection zone, delay, FPS, etc.  Once you are happy with captured images, it is time to run them through Plate Recognizer.

The images captured are located in /var/lib/docker/volumes/
• Open a (root) shell in the Kerberos.io container, either from Portainer or using the PI docker command line.
• Edit the run.sh script (or input another name in the Motion config in Kerberos.io)
apt install nano
nano /etc/opt/kerberosio/scripts/run.sh

Here’s a simple example:
   #!/bin/bash

   start=$(date +%s%3N)
   filnavn=$(echo $1 | jq -r ‘.pathToImage’)
   alpr=$(curl -s -F ‘file=@/etc/opt/kerberosio/capture/’$filnavn” 192.168.172.51:8080/alpr)
   stopp=$(date +%s%3N)

   echo “—” >>/tmp/motion.log
   echo $(date -d @$((start/1000)) +”%Y%m%d %H:%M:%S”) $filnavn >>/tmp/motion.log
   echo “ANPR-prosessering ms: ” $(($stopp-$start)) >>/tmp/motion.log
   echo $alpr >>/tmp/motion.log

The ANPR decoded plate results are stored in /tmp/motion.log.

If you want to make them available to the host OS (operating system), then you save the file in /etc/opt/kerberosio/capture/anpr.log

Now that we have all up and running, you can play around with the decoded plates.
run.sh would be the fastest way to get something done on ANPR results. For instance, opening a gate for a known license plate.

For general use, a script monitoring the volume (locally on PI: /var/lib/docker/volumes/kerberos/_data ) using inotify or suchlike would be better.

One could also consider using a AI system/Machine Learning to determine if a vehicle is in the image before running it through ALPR, to save on the number of calls to the Plate Recognizer SDK.

Also, the ALPR results include “area of interest”, which can be used for many interesting things, including determining the vehicle direction of travel, if you set up motion on Kerberos.io to capture several pictures of the moving car.

Major Takeaway!

Individuals and businesses of all types and sizes can use Plate Recognizer, Kerberos.io and Portainer on a Raspberry Pi to cost-efficiently track vehicles for community safety, enforce parking lot policies, be informed when suspicious vehicles enter a school parking lot, and more.
We are super-excited as you can now use Kerberos.io and Portainer with our Automatic License Plate Recognition software!

Many Thanks!

We here at Plate Recognizer want to give a huge shout out and thank you to Tommy Leonhardsen!

Tommy was born in 1967 and now lives in Verdal, Norway with wife and three kids ages 16, 18 and 20.  Tommy became interested in technology after purchasing his first computer, an Amiga, when he got a full time job at the age of 18 and after using BBS back in 1989.  He is now a Sys Admin with DevOps experience and has worked at Yahoo, Microsoft, and a few smaller firms. (He even turned down a job offer from Google as he did not want to move back to Switzerland.)

Tommy is proficient in Bash, somewhat proficient in Python. His work can be found at: aweussom.github.io/

Outside of work and family, he is a musician and a freelance journalist.

About Plate Recognizer

Plate Recognizer provides accurate, fast, developer-friendly Automatic License Plate Recognition (ALPR) software that works in all environments, optimized for your location. Sign up for a Free Trial!

Contact Us

Have a question about ALPR or Parking Management Software? Contact Us

Privacy Settings
We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
Youtube
Consent to display content from Youtube
Vimeo
Consent to display content from Vimeo
Google Maps
Consent to display content from Google
Spotify
Consent to display content from Spotify
Sound Cloud
Consent to display content from Sound