Building a license plate reader from scratch with deep learning
nanonets.com
nanonets.com
Imagine, "Bake Cookies From Scratch," and step one is remove the Pillsbury cookie dough from the freezer...
If you wish to make an apple pie from scratch, you must first invent the universe.
To be fair, the web service (for which this article appears to be inbound marketing) is optional and presented as an alternative to building anything at all.
One thing often missed in license plate reading is that the tech is really well solved now using an open source stack.
There is always room for improvement so I welcome new technological approaches like this.
However when thinking about license plate data, the real trouble is in what you do with the data, how you handle duplication, and create rules and interface to make the collection useful.
-- OpenCV for de-obliqueing angled images
-- Character separation from background;
-- OCR around individual characters via Convnet Classifier
I tried this with decent results, but I wonder what state of the art open-source is?
Instead, I’d look at vehicle type identification. There is at least one startup selling an API that determines make / model info that when combined with license plate you would very likely find unique data.
As is so often the case, it seems like it'd be easier to move ourselves to the machine, by including the state information in the code. If a code can only belong to one state, this problem just can't arise.
No, they don't.
> a standard California plate is 2AAA222, while a New Mexico plate is AAA222.
And the New Mexico AAA222 pattern is currently shared with Arkansas, Indiana, Iowa, one of the optional Michigan designs, Mississippi, one of the Montana designs, some Nebraska plates, North Carolina, the Northern Mariana Islands, Oklahoma, Puerto Rico, South Carolina, Vermont, and the US Virgin Islands.
To be fair, only NC, OK, and PR share NMs use of a dash between the alpha and numeric portion.
> No, they don't.
Yes, they do. I described an example of it, and you agreed. I didn't say they don't feature overlap.
This is an a DIY Article on building a license plate detector using attention OCR.
We deep dive in with this article on how you can automate your data entry work with the help of deep learning based OCR. It speaks about attention mechanisms, spatial transformer networks and how they are applied for any text recognition task.
https://news.ycombinator.com/show
(Not trying to scold or anything, but seems like this would fit well with that convention.)
> Show HN is for something you've made that other people can play with. HN users can try it out, give you feedback, and ask questions in the thread.
The easy ubiquity of LPR is essentially the death knell of privacy of movement. We'd have to move to encrypted transponders that only respond to queries with the right codes, but of course the police would still be able to know where you were whenever they liked. Rolling QR code digital number plates would work. But it won't happen.
I like the "Rolling QR code digital number plates" concept; are you aware of rolling QR codes used elsewhere?
Other digital transponders, either for tolling or just your devices broadcasting their Wifi/Bluetooth addresses, certainly cause problems but they are within your scope to control.
It would be interesting to see if you could design an adversarial LPR jammer, that would not look to a cop like a licence plate.
When I wrote 'rolling code' I was being a bit off the cuff.
A PKI based system might be something like: {nonce,E(rego_pub,(nonce,car ID, date, hour)),S(car_priv,(nonce,car ID, date, hour))}, where rego_pub is the public key of the local authority, car_priv is the private key of the car, E is encrypt, S is sign.
This is already quite complicated, requires central PKI etc. And unfortunately QR codes themselves are not a great fit, because you need to be close to read them, but you could have a variant designed for shorter strings.
Another possibility might be to use a (prefix, TOTP code). With a fixed prefix indexed on car model/year (which is already visible from looking at it), the set of all TOTP codes from that fleet at that time could easily be searched by the registration authority to identify which vehicle it was. So, e.g., all blue Toyota Camry 2018s would have prefix 'P9J' and then a 10 minute changing code, like 'Y3KE'.
So if a cop needs to look up a car the LPR reads P9JY3KE. The local terminal says it should be a blue Camry, and then sends the string to the validator, which computes the TOTP for all vehicles in the class (like, 2000 in a group) and see if any of them match. If none match, pull them over.
There are a few problems with this still, e.g. replay attacks. But possibly solved by using IFF techniques, i.e. the police car can send a signed query forcing the named plate to show more digits of the TOTP code.
Criminals just steal the plates off another vehicle (of the same model/color if they are smarter), so maybe they can just steal the whole digital licence plate computer module? Unless the smart licence plate is part of the vehicle security system, on the car bus, it is still going to happen.
--- The whole IOV (Internet of Vehicles), V2V (Vehicle to Vehicle) space is going to have to deal with these problems, and there is no shortage of protocols but I don't think it is remotely solved. Lots of companies pushing 5G approaches for this, but I wonder if transponders like for aircraft (ADS-B) or ships (AIS) won't be a simpler (and much cheaper) way, even if they are still using mm wave radios.
https://github.com/openalpr/openalpr
basically:
alpr imagefile
will recognize a plate. It just as simple in python.Ring/security cameras are fine but being able to pinpoint a handful of plates to the wee hours of the morning would allow theft issues to be handled pretty easily when cross referenced with camera tech.
Ex. Right now you get a description like "Older white 4 door" or "White Nissan Sentra"
Bounce that against plates from that time and you've got a good match to work off of, especially if the owner matches descriptions from cameras.
I've been writing my own home surveillance camera network video recorder software, so I've thought about plugging in something like this, but I don't think it's really necessary. The one time I might use it is if there's a car that was likely involved in a burglary, I might scan the previous few weeks to find previous times they were in-frame. Then I might see their scoping the place out, potentially revealing more about themselves. It's too labor-intensive to look through that many motion events by hand.
[1] My understanding is this requires some care. You have to select the right kind of camera, place/aim/zoom it carefully, and tune it for license plate recognition, particularly at night. I think the cameras typically come tuned for slow-moving, not-very-reflective-to-IR objects. License plates on a moving car are the opposite, so you want to say decrease the aperture and increase the shutter speed from the default, position it carefully as I said, maybe tweak some other settings, and test it.
So be prepared for the requests from divorce attorneys and police. Better to just have video to make it more difficult.
I doubt LPR will be the primary utility of this kind of tech.
You're right. LPR isn't going to be the primary utility, but it's very possible that this will be one of the first areas to benefit from this tech at scale.
Ditto for similar big systems like EZPass are expensive. Some read transactions cost the government as much as $2.
It’s a market where the price is going to plummet as it becomes a service delivered thing. You’ll pull into a grocery store parking lot and generate an alarm to have a clerk get your groceries ready, and when you park it will tell him where to go. You’re also going to have a lot more tolls.
Haven’t seen these yet, but Target has a pretty cool system that is app based. Easy to see how they could hook in cars.
Success as defined by non-educated (and some from the social studies) people everywhere.
With the rise of this kind of tech and its prevalence, I think the privacy-focused among us should start pushing to outlaw the use of this tech and eliminate the need for external identification on vehicles.
The parking garage I use every weekday reads my plate, and opens the gate as I have a subscription. Same thing happens when I want to leave. Is that immoral?
It's less about the technology about license-plate reading and more about what people do with the data afterwards.
I would restructure the argument as " I cannot think of a usage for storing the data of a license-plate reader for purpose of selling it which is not immoral." or something like that.
As someone who cares very much about probably I think this is a point that cannot be stressed enough. It is mostly about storage. Storing things is the major danger. Of course there are use cases too, and I would feel uncomfortable with the police tracking every car on the 5 freeway, but tracking requires storage.
Honestly I think your parking garage example is a great use. I can think of others. A notification of your friend or family member pulling into your driveway. Have your house do things like turn on the lights or give you a notification. It could be a good way to do parking meters. I'm sure people could think of more. Technology always has two sides to the coin, it's always a balance of using it only for ethical things. But that requires nuance.
Edit: a cool way to use these might be like we use passwords. Your license plate is a password (or let's say username). OCR is used to identify the plate, then it hashes it, checks the hash with that in the database and bingo, door opens. I think that's a level of privacy most of us are comfortable with. There's no retention of the license plate, no good way to identify who's it is, and if the database is hacked the attacker doesn't get your plate.
Hmm, so would it open for me if I used a photo of your number plate near or over my own plate?
Highway Weigh Stations are ostensibly there to ensure safe commercial vehicle operations. The system I worked on had a number of different sensors. A mile or so before the weigh station, there was a weight-in-motion (WIM) scale embedded in the highway; this part of the system measures (somewhat coarsely) the weight of the vehicle and counts the number of axles it has. Around there, there's also an ALPR and a USDOT reader[2]. Using the weight, ALPR, and USDOT information, a decision is made as to whether the vehicle is required to check in at the weigh station (which is indicated using a road-side sign). There's no fine yet or anything, vehicles are just flagged for further inspection based on:
- measured weight vs GVWR
- company history / safety rating
- a few other factors that I don't recall off the top of my head
There's a few more ALPR cameras sprinkled throughout the weigh station itself, and another one on the highway past the station. These ones are used to track the motion of the vehicle through the system. For example, if a truck has been flagged to stop, and it instead skips the station and keeps on going, the system knows right away that they've bypassed and can send out an enforcement officer. Alternatively, if the plate is seen at the (more accurate static) scale at the station, the system automatically correlates the weight and the plate, and if it's within range, the driver can sometimes leave without even having to interact with any enforcement officers.
[1] Note that it specifically ignored non-commercial traffic unless there was something really weird going on. Categorically was not keeping persistent records of all traffic.
[2] Funny enough, there's no significant regulations specifying the exact font/size/placement for USDOT information, so a reliable USDOT camera is significantly harder to make than a reliable ALPR.
> How hard would it be to remove those bits that ignored non-commercial traffic?
Code-wise? It'd be really easy to add an INSERT that stuffs extra data into another table. But as far as "removing the bits that ignore non-commercial traffic", none of the non-commercial traffic would be in the datasets provided by the various federal agencies (whose acronyms I forget).
Performance-wise? The whole thing is a giant mass of Oracle PL/SQL that can barely keep up with the commercial traffic. If we tried processing all non-commercial traffic through the scoring algorithms etc, the whole house of cards would fall down :D
I once had a problem with my car in a big carpark. I asked the security guard for help and he wanted my license plate number. He typed it into the computer and the camera found my car and panned and zoomed onto it. Amazing! Much easier than trying to explain the location. So there's your non-immoral example and you can stop worrying.
As for privacy. So what? Where are people going in public that's such a secret? If you want to do something secretly, do it in private. If it involves using the public streets, then accept that it's public.
It really doesn't take much of an imagination to come up with dozens of examples, so I'll just give a couple: gay bars, abortion clinics
It really doesn't take much of an imagination to come up with places people might not want others to know they go to.
STD clinics, abortion clinics, AA/NA meetings and gay bars would be some low hanging fruit if you really can't think of any on your own.
> If it involves using the public streets, then accept that it's public.
"If you didn't want your violent ex husband to track you down, you shouldn't have used public streets to get to the shelter"
Nobody seems to mind that Google Streetview shows cars. My sister visited her mother in another city at the time they drove past so now there's a permanent record that she was there at that time to anyone who knows what her car looks like. Is that a problem too?
Quantity has a quality all of it's own.
If you can legally be fired for having police show up at work, then you're at risk of being fired for any reason and that itself is a problem. Solve that problem with employment protection laws like many countries already have.
How can you travel to any secret place without passing public areas?
The conflation of privacy and secrecy is an issue that deserves addressing: When you walk into a public restroom stall, it's not really a secret what you're going to do in there. But you still close the door, don't you?
What I'm doing or where I'm going may not be a secret, but that doesn't mean I want the details logged and sold by some data broker.
If you're not trying to log the movements of the public, the usage is likely moral.