ALPR stands for automatic license plate recognition. The process typically consists of:
- Identifying potential license plate candidates from an image.
- Ranking the potential plate candidates and selecting the most likely one.
- Identifying alphanumeric characters and converting them to text.
The hardest part of this process is reliably acquiring the plate candidate image with variables such as:
- Lighting conditions.
- Camera angle.
- Image noise
- Variations in the type of plates.
- Distance to plate; and consequently, the size of the plate in the image
In this article, I'll be going through a gist that works for a few images. I'll cover the literature review in a followup article.
Please note that this implementation has been developed and tested with very few samples; overfitting will probably reduce it's effectiveness.
- Load an image using opencv and python (Line 33)
- Run mean shift segmentation (I haven't evaluated the effectiveness of this) and save the image.
- Use the segmented image as the camera image.
- Convert the camera image (defaults as a numpy array) into OpenCV Mat and an IPL image (CV2 can work with numpy arrays. Plain old cv requires an IPL or Mat object).
- Convert the camera image into grayscale.
- Conduct thresholding on the image (Line 76). This means that pixels that are above the threshold become white and below black. This process is also called binarization.
- Create a mask that will be used for blob extraction that covers the entire image; setting all the pixels to 1 means that the mask will be applied everywhere.
- Invert the binarized image. License plates are mostly white with a few characters in black. Inversion means that the plate becomes mostly black with a few white character strokes (Line 94).
- Blob detection parameters. We don't want very small or very large blobs.
- Do the actual blob detection (Line 115).
- Iterate over the grayscale image adding an RGB color << this is a bug
- Mark potential blobs as black in a white image (Line 131).
- Another threshold step << This is probably unnecessary.
- Dilation and erosion to clean up the image << probably unnecessary.
- Find contours over the black images.
- For each contour, try and estimate it's overall shape. triangle? rectangle? n-gon (Line 196)? after eliminating very small and very large contours.
- Draw a bounding box.
- Calculate an estimate of the aspect ratio. Plates have a W/H ratio of 1 to 5
- Off the cuff heuristic. Largest rectangle that has an acceptable aspect ratio and is a rectangle is probably a plate. This is not always true. You might much a window or a large rectangular object...
- For the selected plate candidate, draw a bounding rect
Here are the results:
|
Segmented image |
|
Thresholded image |
|
Grayscale conversion |
|
Blobs on a white image |
|
Effects of erosion on an image |
|
Effects of dilation on an image |
|
Plate candidates - from contours |
|
Min area box over plate candidate |
|
Bounding box over plate candidate |
And here are more images from a few more tests in picassa:
How did you install cvblob in python?
ReplyDeletedid u know how to insall it ?
DeleteRespect and that i have a keen offer you: What Renovations Increase The Value Of A Home entire home renovations
ReplyDelete