11 ms·
Show HN: Build a DIY license plate reader with machine learning
- calebkaiser 6y agoHey HN, I’m Caleb, and I’m a maintainer of Cortex, an open source model deployment platform. Not long ago, we published this DIY license plate reader project, and I wanted to share it here for anyone who is interested in computer vision or production machine learning in general. The project is a web service that accepts images and, using three trained models, returns extracted license plate text, assuming there is a license plate in the image. Of the models used, two are pre-trained models from keras-ocr, while one is a fine tuned YOLOv3. All models are freely available. You can see a video of the project in action here: https://www.youtube.com/watch?v=gsYEZtecXlA https://www.youtube.com/watch?v=gsYEZtecXlA And read a write up by Robert Lucian, the maintainer who spearheaded this entire project, about how he built a camera system to interface with the web service using a Raspberry Pi and 5G: https://towardsdatascience.com/i-built-a-diy-license-plate-reader-with-a-raspberry-pi-and-machine-learning-7e428d3c7401 https://towardsdatascience.com/i-built-a-diy-license-plate-r...
- omgwtfbyobbq 6y agoThis looks very neat. Do you think something like a Jetson Nano would be able to handle inference locally?
- calebkaiser 6y agoThanks! The short answer is that I don't know, as it's only been run on EC2 instances, but given its current compute needs, probably not. The longer answer is that this project has a ton of room for optimization, some of which is mentioned in the repo, and with lower latency requirements + optimizations, I don't see why it wouldn't work on less powerful hardware (I've never personally worked with the Jetson Nano, so I don't want to speak with any false confidence on it specifically).
- hadeson 6y agoI guess object detection is the bottleneck of the pipeline, which highly optimized YOLOv4-tiny[0]could get to 39 FPS on Jetson Nano. Also camera decoding with Nvidia Deepstream is a lot faster than OpenCV. [0] https://github.com/pjreddie/darknet/issues/2201 https://github.com/pjreddie/darknet/issues/2201
- jmnicolas 6y agoI wonder if it would be more efficient with OpenCV?
- calebkaiser 6y agoThat's very possible. The Python interface for writing prediction APIs makes it pretty easy to switch between models, so it shouldn't be hard to test.
- bigiain 6y agoThis one uses some OpenCV: https://www.freecodecamp.org/news/remember-that-86-million-license-plate-scanner-i-replicated-heres-what-happened-next-9f3c64e8f22b/ https://www.freecodecamp.org/news/remember-that-86-million-l...
- markdown 6y ago> using a Raspberry Pi and 5G For anyone else wondering, he used a Raspberry Pi and a mobile internet connection. Any number of G's will do.
- techbio 6y ago"Do-it-yourself" seems like a not quite appropriate title for an interface that calls a webservice with pre-built vision ML.
- parasanti 6y agoI was thinking the same thing. If it was all localized to a Pi then yes, but outside services isn't really DIY so much. Maybe half DIY if such a thing.
- sokoloff 6y agoOn the other hand, I would tend to agree that this project is a "DIY Alexa" (edit to add: in the minds of most readers of Instructables website): https://www.instructables.com/id/DIY-Amazon-Alexa/ https://www.instructables.com/id/DIY-Amazon-Alexa/
- hundchenkatze 6y agoThis is another example of what the GP comment is complaining about. It's not a DIY Alexa. Alexa is the virtual assistant API. This is a DIY Amazon Echo that still relies on the Alexa service.
- sokoloff 6y agoAs an engineer and a technologist, I agree that you and GP are precisely correct. If you showed it to and asked a string of randoms off the street, I think way more than half would agree with the "DIY Alexa" label as reasonably communicative description and more useful than a longer but more precise title.
- hundchenkatze 6y agoYeah, that's a good point. It's easy to get caught up in our little tech bubble :)
- 6y ago
- jlturner 6y agoTake care to understand your local law regarding automatic license plate recognition. Use of such software and/or data collected with it may be under regulation. IANAL, but see your state statutes here if you live in the US: https://www.ncsl.org/research/telecommunications-and-information-technology/state-statutes-regulating-the-use-of-automated-license-plate-readers-alpr-or-alpr-data.aspx https://www.ncsl.org/research/telecommunications-and-informa...
- joncrane 6y agoI find it interesting that some states are trying to regulate something like this. What if you had a child read off every license plate they see and use voice recognition to record the license plates? Is it illegal in real time, but allowed if you replay your dashcam footage later?
- arcticfox 6y agoThe vast majority of those laws seem to be targeted at law enforcement. I imagine any system designed to automatically collect license plates would be included, whether it's sync or async.
- bobbean 6y agoGood luck having someone do that 24 hours a day, or during rush hour. I assume it's more about bulk collection.
- varispeed 6y agoWhat if you let the child buy drugs? Same thing. Don't let your child do illegal things and better - don't help it. If you hear your child is reciting the number plates, make sure all recording hardware in your car is off before you lecture the kid that what it does is absolutely forbidden.
- Google234 6y agoThis made me laugh
- dickfickling 6y agoThis is great! I've been meaning to build something like this for a long time. I'm always excited when I notice I've passed the same car on commutes on different days, or see a car I recognize from home in a different part of town. Automating that process and having my phone tell me e.g. "You just passed a car that you once drove past 1,000 miles away from here" is such a tempting side project. Bit big-brothery, though.
- tgot 6y agoI want this tied to a crude speed estimation algorithm, from a stationary camera. Even with ALPR retention restrictions, I could trigger a video save and send the police a video of the idiots doing 50mph through the residential neighborhood.
- ALittleLight 6y agoFor speed estimation, I wonder if the simplest thing would be two plate readers a fixed distance apart. Say they're attached to light poles N meters distant. When the reader triggers and takes a picture, it pings your server for a timestamp. It does the processing and records car X at time T provided by the timestamp. You then calculate the speed by the distance between the two meters divided by the time between the two timestamps for X. Provided that speeding cars are a problem in your neighborhood, I bet you could find the people responsible for the light poles (which likely have power associated to them) to let you install the devices, especially if you're providing the devices and servers. I don't think you'd necessarily be able to ticket the drivers though, as you're not law enforcement. Maybe you'd be able to work with local law enforcement though.
- tgot 6y agoI was thinking of using the bounding boxes across frames. Maybe I could work with a neighbor, but then things need to be tightly time-synced. Zero chance I could get light pole access. A city endorsed surveillance system? No way.
- ocdtrekkie 6y ago
- giarc 6y agoAm I missing something or in this image, is the confidence score 99.23% and has the incorrect license plate? The plates clearly have a 5 but it's predicting an S. https://camo.githubusercontent.com/5138d6bce5c840d15e533db6f300660c80eb2619/68747470733a2f2f692e696d6775722e636f6d2f746731504531452e6a7067 https://camo.githubusercontent.com/5138d6bce5c840d15e533db6f...
- hundchenkatze 6y agoNope, you are correct. Wow, both examples from that image are wrong.
- IncRnd 6y ago99.23% is not 100%. 1/130ish But, the wrong examples don't seem a good demonstration of that...
- cptskippy 6y agoIs that confidence for the value or the category. It comes after LP in the image which makes me think it's the confidence that it is a license plate, not necessarily the confidence of the reading of said license plate.
- giarc 6y agoYou might be right. The gif on github, at times, shows no plate prediction but still includes a confidence score. I would suspect that if it can't even show a prediction, it's confidence score wouldn't show either (being that it would be 0%).
- cptskippy 6y ago> I would suspect that if it can't even show a prediction, it's confidence score wouldn't show either (being that it would be 0%). Recognizing that something is a license place, and being able to read the plate are mutually exclusive things. People can identify license plates even if they can't read them, and people who don't know what a license plate is my still be able to read the numbers on them. The ML has to do two things; the first is reject anything that isn't a License Plate, the second is OCR License Plates.
- master_yoda_1 6y agocan somebody tell this joker that it is illegal and stay the fcuk away from my car.
- hundchenkatze 6y agoIt _may_ be illegal where you live, but you have to remember that people live in other places than you, with different laws.
- cptskippy 6y agoIt's probably not illegal where they live judging by their tone. Often people who don't like something will tell you it's illegal to gain your compliance relying on your ignorance. They usually cuss and make a big show of it.
- DarthGhandi 6y agoI'd be quite surprised if it was illegal anywhere. Dashcams are perfectly legal and even mandatory in some situations. Getting data from that footage is legal. I guess the uploading of images done here might be murky, but again there's millions of dashcam vids and youtube and other video sites.
- anaganisk 6y agoDashcams are illegal in few countries.
- tyingq 6y agoI wonder how much more revenue police departments are making with ANPR[1]. They can, for example, have a camera in all the cruisers, and automatically alert when a nearby car has an expired registration, inspection, etc. Or, if they have the tie-ins, registered to an owner with an open warrant or unpaid traffic citations. [1] https://en.wikipedia.org/wiki/Automatic_number-plate_recognition https://en.wikipedia.org/wiki/Automatic_number-plate_recogni...
- yuvadam 6y agoHow does this implementation perform compared to classic approaches such as OpenALPR [1] ? At the very least running local inference becomes much more expensive, and possibly provides worse results. [1] - https://github.com/openalpr/openalpr https://github.com/openalpr/openalpr
- curben 6y agoThis reminds me of an article [1] I read a few years back which utilised OpenALPR. [1]: https://www.freecodecamp.org/news/how-i-replicated-an-86-million-project-in-57-lines-of-code-277031330ee9/ https://www.freecodecamp.org/news/how-i-replicated-an-86-mil...
- CleanItUpJanny 6y agosweet, time to add this to my car and make some dough selling license plate locations to Facebook Custom Audience
- alexchamberlain 6y agoThe actual computation here shouldn't be that great, right? (especially given the RPi has a GPU on) Seems like an inconsiderate design to stream images to a cloud service, rather than process locally and stream the plates themselves.
- groby_b 6y ago"You, too, can now actively participate in the surveillance state" Yes, I get the technical appeal. I wish we all wondered less if we could, and more if we should.
- tangled 6y agoI’ve pondered the implications of running an ‘installation art’ project where a bunch of these are deployed around a city, with aggregated data visible over a web UI (assuming that this doesn’t violate any laws.) The aim would be to raise public awareness of pervasive surveillance, and perhaps catalyze changes to the law.
- pc86 6y agoRegardless of the content, I think the idea of an installation art project whose goal is to make the art project itself illegal is pretty cool.
- deleted 6y ago[deleted]
- csours 6y agoI've been watching dashcam footage lately and thinking about this. It would be very helpful for hit and runs if the dashcam had some on-board recognition that saved the last x license plates just like it saves the last x seconds of videos. Often the video footage is not good enough to get a plate because the capture settings are set lower so that more footage can be stored.
- mitchtbaum 6y agohttps://music.youtube.com/watch?v=w1mUAVPaX98&feature=share https://music.youtube.com/watch?v=w1mUAVPaX98&feature=share
- darkport 6y agoThis is great. One of my side project ideas is to build an ANPR based app and 'social network' starting with basic tracking, I.e. you've passed this car 4 times before. I'm new to the ML world so still learning vut Do you think this is feasible to run in real time using CoreML on iOS?
- ramon 6y agoI was thinking the other day about a DIY solar panel for apartments that could be part of the decoration like within plant vases or something in that fashion that would be cool and would look good and not have "space being occupied", that would be interesting.