11

(Marcin) #1
FORGE

ACCURACY IMPROVEMENT
If your camera is unavoidably placed at an awkward angle, don’t worry! You can calibrate
the software to warp the image (a bit like keystone adjustment on a projector) so that the car
appears as close to straight-on as possible before being scanned for number-plates.
There’s loads of information about how to do this on OpenALPR’s website:
hsmag.cc/GKEwaX.

Firstly, OpenALPR installs a file on your system which
might point you in the right direction. To view this file,
type this command:


sudo nano /usr/share/openalpr/runtime_data/
cameras.yaml

If you don’t find what you’re after in there,
iSpyConnect have a pretty big Camera Connection
Database at: hsmag.cc/nRgTLB, so take a look,
click on the manufacturer of your camera, and try the
various options in VLC until you find the one that works
best for you.
Once that’s working and you have constructed the
URL of your camera’s network stream, this needs to
be input into the config file for the OpenALPR daemon.
First, open up the defaults file like this:


sudo nano /usr/share/openalpr/config/alprd.
defaults.conf

Select and copy the contents of that file, then open
the empty config file to paste it in ready to be adjusted:


sudo nano /etc/openalpr/alprd.conf

Find the section entitled ‘Example stream config:’.
Here, you can list camera streams and paste the full
URL on a line starting ‘stream = ‘. This file also allows
you to specify the country code of the plates you’ll be
looking at, so in my case, as my car has a British plate,
I’ve set this to ‘country = gb’. Once you’ve made those


changes, press CTRL+X, followed by Y, and ENTER to
save and exit.
As you’ll see from the daemon config file, you can
build a pretty big system monitoring several camera
streams across multiple sites, if you want. However,
you’d certainly need something bigger and more
powerful than a humble Raspberry Pi for that, although
the basic concepts all remain the same.
Once you’ve set your configuration for the daemon,
run the following command to restart it using
those settings:


sudo service openalpr-daemon restart

Above
Test out your on-
premises ANPR
solution by taking
a still photo of
your car, and then
running it through the
OpenALPR software
at your Raspberry
Pi’s command line

HARVESTING THE BEANSTALK
The OpenALPR daemon will now be monitoring
your camera and placing any results into a queuing
system called Beanstalk, and we’ll be using a Python
script to read the results out of that queue and act
upon them.
The Python script that you’ll install later uses
the beanstalkc library to read the Beanstalk queue,
so install the pip tool and then use it to install
beanstalkc and PyYAML with these three lines
of code:
sudo apt-get install python-pip
pip install PyYAML
pip install beanstalkc

The requests library is used to make the POST
request to talk to IFTTT, and can be installed like this:
sudo apt-get install python-requests

BIG DATA MEETS LITTLE DATA
The Python script makes use of a small database
in which data such as your car number-plate and its
current ‘home or away’ status is stored. To keep
resource usage to an absolute minimum, we’ll use
SQLite for this, which can be installed with the
following command:
sudo apt-get install sqlite3

To create a database called ‘anpr.db’, type this:
sqlite3 anpr.db

We can now create a table in which to store our
data, like so:

The OpenALPR daemon
will now be monitoring
your camera and placing
any results into a queuing
system called Beanstalk


Free download pdf