ALPR (ANPR, CPR, LPR or LAPI)
What is ALPR ?
ALPR stands for Automatic License Plate Recognition. Depending on where you are in the world this may also be called Automatic Number Plate Recognition or Car Plate Recognition or just License Plate Recognition.
ALPR is the process by which computers can recognise license plates. This can be useful in many scenarios for example:
- Automatically opening gates/ doors for authorised vehicles
- Alerting on unrecognised vehicles parking in your driveway
- Alerting on unrecognised vehicles parking in reserved spots
- Traffic monitoring and recognition
How does it work?
ALPR involves a number of procedural processing steps. These are:
- Extract specified region of the frame
- Convert to gray scale
- Perform edge detection based on automatic or manual thresholding
- Generate list of objects (blobs) with minimum dimensions
- Extract rectangular blobs (that fit aspect ratio limits) from the gray scale image
- Apply OTSU Thresholding to the extracted blobs
- Generate list of objects (blobs) from the extracted blob
- Iterate through blobs if minimum number found
- Remove blobs with dimensions outside of 20% from average of extracted
- Create a new image from the extracted blobs (vertical to ensure character and not word extraction from OCR)
- Pass this new image to OCR (we use google's open source Tesseract engine)
- Parse the results of OCR
As you can see ALPR involves a fair amount of processing! If you are interested in the source code then take a look at the ANPR.cs file in the ispy source repository.
ALPR working on a live feed with overlay
Setting it Up
To setup ALPR, install the free numberplate recognition plugin click to add or edit a camera (that's pointing at a car license plate!) and then select the Alerts tab. Change the alert type drop-down to "Numberplates" and click the "..." button. You will see the configuration screen above. In the text area enter a comma separated list of license plates that you want to allow (not trigger an alert for).
The overlay option tells iSpy to display onscreen the detected license plate string.
The Required Accuracy setting controls how much of the detected string must match a license plate to trigger an alert. OCR (Optical Character Recognition) isn't perfect and can frequently detect an O as an 0 or a 4 as an A for example.
Specify an Area
The next step is to choose an area to look for license plates in. If your camera
isn't running this functionality will be disabled - enable your camera and open
up the configuration screen again. Click and drag out an area on the image to
monitor for license plates.
Troubleshooting
- No plate detected: Try selecting a specific area in the frame to monitor. Try using the manual thresholding option. At the moment iSpy only works with alphanumeric plates and may have problems with reversed plates (white on black for example) - although this is untested (let us know!). Also OCR requires a good resolution to be accurate. Use a high quality camera and / or move the camera closer to the license plate you want to detect. Commercial license plate cameras use resolutions of several megapixels - so it's unlikely you will get good results from a 320 x 240 webcam! If you can't easily read the license plate on the screen it's unlikely iSpy will be able to either.
Also, ensure that you have specified a motion detector type - iSpy will only look for license plates when it is detecting movement (to save CPU power).