Raspberry Pi License Plate Recognition

license-plate-thumbRecently I stumbled upon an interesting open source framework called OpenALPR (Automated License Plate Recognition). This seemed very interesting for trying out on the Raspberry PI. The OpenALPR framework has a couple of dependencies that you have to download and compile first.

Check out the instructions on the OpenALPR framework GitHub repository: https://github.com/openalpr/openalpr/wiki/Compilation-instructions-(Ubuntu-Linux)

You need these libraries:

OpenCV – http://opencv.org/
Leptonica – http://www.leptonica.org/
Tesseract OCR – https://code.google.com/p/tesseract-ocr/
OpenALPR – https://github.com/openalpr/openalpr

After compiling everything, which took quite a while, I created a simple Python script that takes a photo from a webcam and processes it using the OpenALPR. The Python script processes and presents the license plate recognition results.

You can check the script at my GitHub repository: https://github.com/lukagabric/PyALPR

Video of the Python script in use:

The webcam takes images of size 640×480. This is the image that was taken and used for automated license plate recognition in this video:

alpr-capture

 

Recognition takes quite a while, about 10-13 seconds. I’ve been testing this with 7 plates and the recognition results are very good. All plates have successfully been recognized.

If you liked this blog post I’d appreciate if you followed me on Twitter

Related Post

Remember to share...Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInEmail this to someone

45 thoughts on “Raspberry Pi License Plate Recognition

  1. Most interesting
    It would be great if it would work quicker. I would like to use it to open some security gates when cars arrive.

    Kind regards

  2. Or you could simply use the PI to capture the images, send them to a fast computer for processing then send a success or failure response.

  3. Or, just use as many RPi’s as you need. For example, two per lane on a road would handle a vehicle every 6 seconds.

  4. Nice work! may i ask, what method did you use to install openalpr in the pi? which one of the three methods? (the easiest, easier or hardest)

  5. Hello Luca,

    I tryed your script on Raspberry and have got this problem:

    Traceback (most recent call last):
    File “PyALPR.py”, line 64, in
    plate_reader.read_plate()
    File “PyALPR.py”, line 40, in read_plate
    alpr_json, alpr_error = self.alpr_json_results()
    File “PyALPR.py”, line 25, in alpr_json_results
    self.webcam_subprocess().communicate()
    File “PyALPR.py”, line 17, in webcam_subprocess
    return subprocess.Popen(self.webcam_command_args, stdout=subprocess.PIPE)
    File “/usr/lib/python2.7/subprocess.py”, line 710, in __init__
    errread, errwrite)
    File “/usr/lib/python2.7/subprocess.py”, line 1335, in _execute_child
    raise child_exception
    OSError: [Errno 2] No such file or directory

    I wonder, if you’d help me =)

    Best regards,
    Maryna

    1. Hey Maryna,
      Did you successfully compile OpenALPR on the Raspberry Pi? Which method did you use(Easiest, Easy or Harder)?
      Thanks

  6. i got it working but it doesn’t give any result!
    + this script needs a small modification is:

    add shell=False in :
    subprocess.Popen(self.alpr_command_args, stdout=subprocess.PIPE, shell=False)
    and
    subprocess.Popen(self.webcam_command_args, stdout=subprocess.PIPE, shell=False)

    but i got no result : when i delete “–quiet” from “fswebcam” command i get everything working with the webcam , the image is written in “image-name.jpg” and thats all nothing else.

    there is no other script to make it work in streaming ? means real time analyse of the license plate from the RPI webcam?

  7. Hi
    I installed and compiled as per the instructions on the post above. The test script runs through and I get a result of ” No JSON object could be decoded”
    Any thoughts on this please?

  8. 7 seconds on a RPi 2 for one image

    and 6 seconds before error on a image file not found

    and 9 seconds for 3 images

    So, 6 seconds for loading and only 1 second per image ???

  9. to get it to run faster use the alpr daemon, it runs on a video stream and it can manage around 4-5 pics a sec depending on the image size.

    1. i was try your guide but still get error could you please help me
      when i try to use your python script seems JSON error

      Unknown file type
      No JSON object could be decoded

      thanks

  10. Will Open ALPR work with Raspbian OS or do you need to install a different flavor of Linux on your Pi for it to work?

  11. while trying to work with usb camera on running the python script provided here i get the error
    Unknown file type
    *** Error in `alpr’: corrupted double-linked list: 0x0222e1f0 ***
    No JSON object could be decoded
    any help is much appreciated. thank you

  12. Hi,
    I think this is an interesting project. I wanna know if I could take the licence plates from a video (a web-cam streaming online). So I could look for the licence plates on a data base (from internet) and know if the car has reported as stolen or something like that.
    Maybe the police have the same system but an expensive solution ($$$…) and more faster.

  13. I actually need help cornering construction of a camera based surveillance system using Raspberry pi I need the circuit diagrams I have all the hardware requirements already I just need help on how do make it work together please I would really appreciate any help you can render thanks

  14. Can you provide some more sample plates? I am able to get decent results within Mathematica on Raspberry Pi by loading the picture into a variable called image and then running

    bImage = LocalAdaptiveBinarize[image, 20, {0.75, .05}];

    Select[TextRecognize[bImage, “Line”, {“Text”, “Strength”},
    RecognitionPrior -> “SparseText”], #[[2]] > .7 &][[All, 1]]

    I can probably get even better results but I’d like to test against multiple plates rather than customize too extensively against the one.

  15. i was try your guide but still get error could you please help me
    when i try to use your python script seems JSON error

    Unknown file type
    No JSON object could be decoded

    thanks

Leave a Reply

Your email address will not be published. Required fields are marked *