11

Continuing from this thread:

What are good algorithms for vehicle license plate detection?

I've developed my image manipulation techniques to emphasise the license plate as much as possible, and overall I'm happy with it, here are two samples.

alt text

alt text

Now comes the most difficult part, actually detecting the license plate. I know there are a few edge detection methods, but my maths is quite poor so I'm unable to translate some of the complex formulas into code.

My idea so far is to loop through every pixel within the image (for loop based on img width & height) From this compare each pixel against a list of colours, from this an algorithm is checked to see if the colors keep differentiating between the license plate white, and the black of the text. If this happens to be true these pixels are built into a new bitmap within memory, then an OCR scan is performed once this pattern has stopped being detected.

I'd appreciate some input on this as it might be a flawed idea, too slow or intensive.

Thanks

Community
  • 1
  • 1
Ash
  • 3,494
  • 12
  • 35
  • 42
  • 3
    Are you gonna give me a traffic ticket when I drive by one of your machines? – DOK Jan 18 '11 at 17:35
  • hah, nah this is just a uni project, luckily I get to choose the images I test :) – Ash Jan 18 '11 at 19:37

3 Answers3

5

Your method of "see if the colors keep differentiating between the license plate white, and the black of the text" is basically searching for areas where the pixel intensity changes from black to white and vice-versa many times. Edge detection can accomplish essentially the same thing. However, implementing your own methods is still a good idea because you will learn a lot in the process. Heck, why not do both and compare the output of your method with that of some ready-made edge detection algorithm?

At some point you will want to have a binary image, say with black pixels corresponding to the "not-a-character" label, and white pixels corresponding to the "is-a-character" label. Perhaps the simplest way to do that is to use a thresholding function. But that will only work well if the characters have already been emphasized in some way.

As someone mentioned in your other thread, you can do that using the black hat operator, which results in something like this:

image after black hat operation

If you threshold the image above with, say, Otsu's method (which automatically determines a global threshold level), you get this:

alt text

There are several ways to clean that image. For instance, you can find the connected components and throw away those that are too small, too big, too wide or too tall to be a character:

alt text

Since the characters in your image are relatively large and fully connected this method works well.

Next, you could filter the remaining components based on the properties of the neighbors until you have the desired number of components (= number of characters). If you want to recognize the character, you could then calculate features for each character and input them to a classifier, which usually is built with supervised learning.

All the steps above are just one way to do it, of course.

By the way, I generated the images above using OpenCV + Python, which is a great combination for computer vision.

carnieri
  • 1,353
  • 6
  • 11
  • Thanks for your reply, really appreciate it. OpenCV does look amazing, but I'd rather take something away from this rather than call a couple of library functions heh. You've given me some confidence to really go for it. Simply inverting my image also produces very nice results so I might go off that once I've finished these image manipulation methods :). – Ash Jan 19 '11 at 00:06
3

Colour, as much as looks good, will present quite some challenges with shading and light conditions. Depends really how much you want to make it robust but real world cases have to deal with such issues.

I have done research on road footage (see my profile page and look here for sample) and have found that the real-world road footage is extremely noisy in terms of light conditions and your colours can change from Brown to White for a yellow back-number-plate.

Most algorithms use line detection and try to find a box with an aspect ratio within an acceptable range.

I suggest you do a literature review on the subject but this was achieved back in 1993 (if I remember correctly) so there will be thousands of articles.

This is quite a scientific domain so just an algorithm will not solve it and you will needs numerous pre/post processing steps.

In brief, my suggestion is to use Hough transform to find lines and then try to look for rectangles that could create acceptable aspect ratio.

Harris feature detection could provide important edges but if the car is light-coloured this will not work.

Aliostad
  • 80,612
  • 21
  • 160
  • 208
  • Cheers for the reply, I still might give my method described above a go, as I can't really find any pseudo code regarding Hough transform method. Anyway thanks! – Ash Jan 18 '11 at 20:20
  • You do not have to go for implementing hough yourself - use OpenCV, although I once did that for an assignment. I think if you need to do serious Computer Vision, you have to think about using OpenCV, it is very very easy to use and implements Hough, and a lot of other useful stuff and is so quick. – Aliostad Jan 18 '11 at 20:28
  • Yeah I wanted to stay away from using libraries but guess I don't have much choice. – Ash Jan 18 '11 at 20:35
  • Sorry to bug you, but do you think my method described is pointless to implement? Just that the application will use images that I've selected personally, and won't be coming from video feed. – Ash Jan 18 '11 at 20:46
  • Sorry for late reply. By all means investigate that route although I think the success will be limited. It will at least familiarise you even more with the challenges of computer vision. Back in 2004-5 I was looking for algorithms to do clever image processing stuff. The more I did the more I realised I need more than just an algorithm and that was the reason I enrolled for a part-time course in DSIP in 2006 which I managed to finished in 2008. This sort of stuff really requires very scientific tools which you can only find in C++ libraries. – Aliostad Jan 18 '11 at 23:36
  • Thanks again, yeah I totally understand what your saying, I never was aiming for it to be perfect. It this was for a commercial system or something I would even consider my idea. I'll update the thread once I've made some progress. – Ash Jan 19 '11 at 00:08
1

If you have a lot of samples, you could try to check face detection method developed by Paul Viola and Michael Jones. It's good for face detection, maybe it'll do fine with license plate detection (especially if combined with some other method)

  • I dont get why this was downvoted, basically Tomasz is right, there is a nice article for a system which is implemented using viola and jones object detection [Real-Time License Plate Recognition on Embedded DSP-Platform](http://www.icg.tu-graz.ac.at/publications/pdf/arth_-_real-time_license_plate_recognition_ecw07.pdf). Example in opencv [here](http://docs.opencv.org/trunk/doc/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html) – Mantas Jun 05 '14 at 05:56