
License Plate Detection Without Machine Learning - symisc_devel
https://sod.pixlab.io/articles/license-plate-detection.html
======
king_magic
Been there, done that. Put that car at an angle and see how well that works.
Or maybe add rain. Or bright sunshine. Or make it dark.

Spoiler alert: these kinds of image processing Rube Goldberg machines fall
apart real quick with real world conditions.

> The intent of this article is to sensibilize the reader that a machine
> learning approach in not always the best or first solution to solve some
> object detection problems.

The danger of this article is people end up wasting time & budget with brittle
approaches.

(Though to be fair the danger of the deep learning/ML route is people can end
up wasting just as much time when they don’t have an adequate amount of
training data.)

~~~
neetdeth
There’s a pretty vast gulf between 70s era threshold, edge detect, morphology
type methods and deep learning.

Robust feature detectors, voting methods, etc. can fill that gap for object
detection and pose estimation. Also simpler machine learning models for
classification like SVMs.

It increasingly feels like the slice of computer vision techniques I learned
in the early 2000s is receding in relevance. But at the same time, there ought
to be a more modern grab bag of robust tools to build engineered solutions.

In the end any algorithm is only as good as the dataset it’s
developed/validated against. Ad-hoc methods may fail in bright sunshine, but
so too would a neural network if that condition never arises in its training
set.

~~~
trentlott
The future of computing is here!

After tiring of convoluted web 3.0 frameworks and Babel-esque dependency
structures, programmers have finally fashioned a black box they cannot
understand which relieves the anxiety of knowing they should.

~~~
king_magic
Do you know how _your_ brain recognizes objects in images? Not superficially,
but truly understand how it works at a deep fundamental level?

I'll wait.

Until then, when it comes to the state of the art in things like reading
license plates, it's the old algorithmic approaches (like described in the
article) that result in convoluted, brittle, easily broken approaches - far
closer to the "convoluted web 3.0 frameworks and Babel-esque dependency
structures" you seem to despise.

DL may not be fundamentally understandable (yet), but it works a hell of a lot
better than stringing together image processing algorithms.

------
l33tman
I successfully designed a commercial LPR system using non-ML methods that
handles all those kind of weird real-world cases you get that are never
mentioned in papers about LPR and OCR.

Check out some of the hard cases here: [https://waysight.com/lpr-
technology/#examples](https://waysight.com/lpr-technology/#examples)

I couldn't use neural networks at the time, because 1) it had to run in a
single core 200 MHz ARM at 20 fps, and 2) it took too long to "debug" the NNs
(often you want to improve performance and the failure cases seem fine to you)

So the resulting performance of this system was and is state of the art in
that in practice it captures everything correctly, so there is no point
wasting cycles on an NN solution.

On the other hand, starting from scratch, an NN solution can allow you to
advance quickly with little domain knowledge.

I would like to repeat a word of caution other posters mentioned as well - it
takes years to collect the training data required for successful commercial
LPR, both for NN and non-NN methods (as you need regression tests even if you
don't need it for training), to get plates from all seasons and weathers and
vehicle conditions.

Interestingly, now almost 10 years later, when I look at more modern deep NNs
and analysing their initial stages with modern tools I see a lot of similarity
to my original "standard" algorithms. In essence, the code I wrote did the
same thing a modern convolutional deep NN would learn to do.

In particular, see this recent analysis of how (some) convnets learn:

[https://www.lyrn.ai/2019/02/14/bagnet-imagenet-with-a-
simple...](https://www.lyrn.ai/2019/02/14/bagnet-imagenet-with-a-simple-bof-
model/)

Which, as it turns out, is really similar to how 80's and 90's style classic
OCR algorithms work!

~~~
dsfyu404ed
I noticed bent license plates aren't in the list of example "hard cases".

Are those not an issue or does the tech just fail so hard on those it's not
even worth trying?

Every other older vehicle where I live has a front plate that's got a
horizontal bend in it from when you park with the front end in a snow bank so
while not a majority case it's not exactly an edge case either.

~~~
chrismeller
When you mentioned pickups I immediately pictured bent and mangled plates from
hitching up trailers. Not being from any sort of region that would have snow
banks, let alone ones tall enough to get to the bumper of a truck... why is
that bending license plates?

~~~
tazard
Often to get off the road, people pull up and drive right into the snow bank.
After it's been plowed and it settles, it can get quite hard.

~~~
chrismeller
Wouldn’t that harm the bumper the plate is on at some point? I mean if it’s
hard enough to bend the plate it seems the same as me just bumping into the
concrete wall in front of my parking space every day when I get home and I
would never do that and think it’s ok...

~~~
dsfyu404ed
Eventually, maybe, depends how hard you hit stuff and the bumper in question.
Depending on the vehicle age and owner there might just not be any fucks
around to give (with work vehicles being driven by people making less than
$20/hr this is almost guaranteed). Snow doesn't tend to be very damaging
because you can't really build a straight up wall with it and the outer layers
generally conform to the bumper so it's more like a soft push on all the
available surface area. It's just that if the license plate doesn't have
anything substantial backing it up it will bend.

~~~
moate
There's also a significant materials difference between a bumper (either
plastic or metal) and the thin piece of metal a license plate is made out of.

I would imagine there's probably some mental disconnect about how damaging ice
_could_ be because "hey, it's just frozen water, it's not like it's concrete
or something"

------
czr
> _The intent of this article is to sensibilize [sic] the reader that a
> machine learning approach in not always the best or first solution to solve
> some object detection problems_

This is a good lesson to teach people! But I don't think that this page does
so successfully. By far and away the biggest issue is that they are __only
demonstrating on a single image __. You can get almost any method to work on a
single image, especially when you 're interactively designing the method to
work on that specific image. If you want a method that works in unforeseen
conditions, you need to think carefully about your assumptions...

* Threshold on 0.5–will that work at night? What if you're driving into the sun and the image is overexposed?

* Dilating canny edges and finding connected components–what if the car is white with black trim, and the dilation merges the license plate CC with another one? What if the car is further away, and the dilation factor merges the entire car into one big blob?

* Filtering the blobs by ratio–what if the car is at an angle (turning, or starting up a hill), so the ratio is off? What if they have bumper stickers that are the same shape, and fool the filter?

While you can make a reasonable license plate detector with traditional
methods (see, for example,
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.455...](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.455.2440&rep=rep1&type=pdf)),
the advantage of using ML methods is that, if done correctly, they actually
have a chance of working in most the situations you encounter (including the
assumption-violating ones above), rather than just the ones you can think of
while making the system. That lesson is probably just as important as the
"don't jump straight to ML" one.

~~~
AstralStorm
A chance, which is completely unpredictable. Classical methods have
predictable failure modes which can be covered and fixed.

How do you fix an ML model that fails to cover a weird special case?

Ultimately, you will need to validate the model, whether parametric as the old
algorithms, or not, as in ML.

~~~
spaced-out
>How do you fix an ML model that fails to cover a weird special case?

You bring examples of those special cases into the dataset.

------
laingc
These sorts of posts are just so ridiculously off base.

People are absolutely desperate to show that ML isn’t the answer to
everything, which nobody in ML claims it is. But it is the very clear answer
to some things, and problems like license plate detection fall so
unambiguously into that category that, quite frankly, if you think otherwise
you’ve really disqualified yourself from the set of people who ought to be
asked about these things.

In my team, we don’t use deep learning for every problem. We don’t even use
machine learning for every problem. I’m a Mathematician, and frankly I’m just
not that immature. The fact is, ML is a great solution to a lot of problems,
and Deep Learning is a particularly good solution to an ever-increasing
category of problems.

If you can’t tell the difference between such cases, then you should probably
not conclude that everyone is doing it wrong, and instead conclude that you
have more to learn.

~~~
supermatt
On the contrary, people are absolutely desperate to show that ML isn't the
ONLY answer to some things.

This article shows how by following a number of logical steps (and explaining
how the algorithms work), you can achieve numberplate recognition.

These techniques have been used for DECADES. They work on machines your ML
model likely wont fit on. In some cases they are faster. In some cases they
are slower. In some cases they are more accurate, and in some cases they are
not.

If you think ML is the magic bullet to any task you've really disqualified
yourself from the set of people who ought to be asked about these things.

~~~
laingc
> which nobody in ML claims it is.

> We don’t even use machine learning for every problem.

Since your comment is in obvious bad faith, this is the only response you’ll
get from me.

~~~
supermatt
you were claiming that number plate recognition is a ML task and if we don’t
agree with you we don’t know what we are talking about. seems like you are the
one commenting in bad faith. if you reread, you will see i used your own
words, which may have confused you into thinking mine was the bad faith
comment. good day.

------
squarefoot
I used OpenCV about 15 years back to read football pools tickets. It
eventually worked but my (admittedly atrocious) code was slow and clunky: a
soup of mixed C and C++ whose sources I luckily lost:) What made the process
even slower with then available hardware was the necessary deskewing if one
put the ticket not perfectly aligned with the camera, which is almost always
the case. Not having worked with OpenCV since then, my question is that todays
newer versions and available low cost hardware (namely *PI like boards) could
allow a similar but more complex process in almost realtime and reading whole
digits instead of bullets. That is, an user puts a piece of paper under the
camera, the software recognizes what it is by looking at common patterns it
has with other similar documents, giving it proper orientation when needed,
then it reads text and numeric information applying OCR code, then according
to that information, fills/updates one or more fields in this or that
database. Doable? Caveats?

~~~
johnnycab
>my question is that todays newer versions and available low cost hardware
(namely *PI like boards) could allow a similar but more complex process in
almost realtime and reading whole digits instead of bullets. That is, an user
puts a piece of paper under the camera, the software recognizes what it is by
looking at common patterns it has with other similar documents, giving it
proper orientation when needed, then it reads text and numeric information
applying OCR code, then according to that information, fills/updates one or
more fields in this or that database. Doable? Caveats?

It is certainly do-able and has already been implemented by banks for image
based clearance/processing of cheques[1] and fraud detection. The caveats in
this case would include a large set of training data and a supervised model
for handwritten examples.

[1][https://www.pyimagesearch.com/2017/07/24/bank-check-ocr-
with...](https://www.pyimagesearch.com/2017/07/24/bank-check-ocr-with-opencv-
and-python-part-i/)

------
Hydraulix989
I’ve tried many of the same techniques myself for doing OCR. It’s a very
brittle pipeline. You’ll need ML to do the job well. The state-of-the-art is
Jaderberg’s Text Spotting in the Wild.

~~~
Beefin
What do you think of this implementation:

[https://github.com/mathDR/reading-text-in-the-
wild/blob/mast...](https://github.com/mathDR/reading-text-in-the-
wild/blob/master/README.md)

------
itissid
I worked on a project on Optical inspection of PCBs on assembly lines in early
2004 and it was all image processing. Not a peep about ML in those days.

------
notus
Seems like its going to have a hard time in adverse conditions

------
villgax
Having a signpost with the same aspect ratio, let's forget the failure rates
for skewed angles & lighting issues will also make this fail. ML approach
which takes context is the way to do this but it will only improve in the
future with performance.

This is almost sounding like ASM vs Python.

------
zachguo
It's essentially an approach based on heuristics. It can be brittle and cannot
deal with ambiguity well, and that's where ML shines. It's not uncommon that
people combine heuristics with ML in real world, since rule-based models are
fast and cheap.

------
alexcnwy
This approach fails e.g. The morphological operations you need for an infrared
night time image with washed out white is different than what you need to
detect the plate in the day time etc.

------
pragmaticlurker
this is dead old problem that doesn't work in bad light / perspective
conditions

