Open ALPR scripts

2,022 views
Skip to first unread message

load...@yahoo.com

unread,
Jan 16, 2016, 8:14:44 AM1/16/16
to OpenALPR
Hello

I'm working on a project and after looong time made my Open ALPR to work on my Raspberry Pi v1 model B + USB Webcam

It can process images perfectly.

I'm new to working in Raspberry Pi so I don't know much.

My next steps would be that OpenALPR reads a plate and that I somehow connect it to a database.and that it goes through already saved records or saves new ( This is my part ) and shows results.

Now my issue is how do I even start a script like this one?
It would be a python script but I have no idea how to load one.
I've been through OpenALPR documentation but just got really confused :(
Any help is welcome.

Thanks

Matt

unread,
Jan 16, 2016, 11:44:11 AM1/16/16
to OpenALPR
Here's a good example for running OpenALPR in Python:

Python has libraries for just about any database you'd want to use. 
Message has been deleted

load...@yahoo.com

unread,
Jan 17, 2016, 3:48:02 AM1/17/16
to OpenALPR
Hello again

Got an issue now.

alpr webcam works and I have used "us" plates as it was in this script.
Now when I run this scrip it gives me this error :/

Timis Daniel

unread,
Jan 18, 2016, 4:22:04 AM1/18/16
to OpenALPR
Think I can help you with this.
Basically Alpr is writing the results to the Beanstalk message queue or the alpr lib is returning the results encoded in Json format.

I got around this by importing a Json library I use to decode the results.

Try this guide: http://www.tutorialspoint.com/json/json_python_example.htm you can start from here.

I did something like

import demjson
...
job = beanstalk.reserve()
jobb = job.body
result = demjson.decode(jobb)

plate = d['results'][0]['plate']

uuid = d['uuid']

if you are using the daemon you can check out the data structure of the result here :

hope this helps in any way.

load...@yahoo.com

unread,
Jan 19, 2016, 1:16:32 PM1/19/16
to OpenALPR
Thanks for replying

Installed 2.2.4 version but still same error.

Also no idea how to work around daemon :/

Tried some simple scripts that would just read the plate and show the code but no success.

load...@yahoo.com

unread,
Jan 25, 2016, 11:48:30 AM1/25/16
to OpenALPR
Finally made some scripts to work but this "test" scrip gives me this error: http://i.imgur.com/2wfjSTv.png?1

Script:
from openalpr import Alpr
from argparse import ArgumentParser

parser = ArgumentParser(description='OpenALPR Python Test Program')

parser.add_argument("-c", "--country", dest="country", action="store", default="us",
                  help="License plate Country" )

parser.add_argument("--config", dest="config", action="store", default="/etc/openalpr/openalpr.conf",
                  help="Path to openalpr.conf config file" )

parser.add_argument("--runtime_data", dest="runtime_data", action="store", default="/usr/share/openalpr/runtime_data",
                  help="Path to OpenALPR runtime_data directory" )

parser.add_argument('plate_image', help='License plate image file')

options = parser.parse_args()

alpr = None
try:
    alpr = Alpr(options.country, options.config, options.runtime_data)

    if not alpr.is_loaded():
        print("Error loading OpenALPR")
    else:
        print("Using OpenALPR " + alpr.get_version())

        alpr.set_top_n(7)
        alpr.set_default_region("wa")
        alpr.set_detect_region(False)
        jpeg_bytes = open(options.plate_image, "rb").read()
        results = alpr.recognize_array(jpeg_bytes)

        # Uncomment to see the full results structure
        # import pprint
        # pprint.pprint(results)

        print("Image size: %dx%d" %(results['img_width'], results['img_height']))
        print("Processing Time: %f" % results['processing_time_ms'])

        i = 0
        for plate in results['results']:
            i += 1
            print("Plate #%d" % i)
            print("   %12s %12s" % ("Plate", "Confidence"))
            for candidate in plate['candidates']:
                prefix = "-"
                if candidate['matches_template']:
                    prefix = "*"

                print("  %s %12s%12f" % (prefix, candidate['plate'], candidate['confidence']))



finally:
    if alpr:
        alpr.unload()

Timis Daniel

unread,
Jan 26, 2016, 3:45:00 AM1/26/16
to OpenALPR
think you need to specify the extension of the image

load...@yahoo.com

unread,
Jan 26, 2016, 11:09:44 PM1/26/16
to OpenALPR
I'm not a programmer but. I went through whole script and checked from where it is supposed to take out settings and it should work :/
I honestly have no idea.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages