Bicycle Dashcam with License Plate Recognition (ALPR)
To make the experience fit your profile, pick a username and tell us what interests you.
Example of a photo taken from the Pi mounted to my bicycle while riding.
JPEG Image - 2.21 MB - 10/09/2019 at 00:53
I was reading an article about Oak Vision Modules on Hackaday, and thought, wow, this is the PERFECT platform for my bicycle dashcam. The Oak Vision module is a Kickstarter project with camera modules, depth mapping capability using stereo vision, and a processor (Intel Movidius Myriad X) designed to accelerate machine vision in 1 package for $149US – see https://www.kickstarter.com/projects/opencv/opencv-ai-kit/
At the 3:55 mark in the marketing video, I THEN see the board mounted to a bicycle saddle, which is EXACTLY what I want to do:
I went to see what I could find about the developers, and read about them on TechCrunch: “The actual device and onboard AI were created by Luxonis, which previously created the CommuteGuardian, a sort of smart brake light for bikes that tracks objects in real time so it can warn the rider. The team couldn’t find any hardware that fit the bill so they made their own, and then collaborated with OpenCV to make the OAK series as a follow-up.”
This is pretty exciting – CommuteGuardian is the first project I’ve come across with similar goals to mine: Prevent and Deter Car-Bicycle accidents. I exchanged a few emails with Brandon Gilles, the Luxonis CEO, and he shared some background – they also checked out OpenALPR, and started work on mobile phone implementations, but decided to move to a custom board when the Myriad X processor was launched.
You can read more about CommuteGuardian here: https://luxonis.com/commuteguardian and https://discuss.luxonis.com/d/8-it-works-working-prototype-of-commute-guardian
I decided to back Luxonis’ Oak project. I’ll have to learn some new tools, but this board will be much faster than the Pi for image analysis (much faster than the 1 frame per 8 seconds I’m getting now!). The stereo vision capabilities on the Oak-D will allow for depth mapping, a capability for which I had previously been considering adding a LIDAR sensor. Looking forward to receiving my Oak-D, hopefully in December. In the interim, I’ll continue to experiment with different license plate recognition systems, read more about the tooling I can use with Oak-D, and perhaps try a different camera module on the Pi.
On a sunny mid-June Saturday, I took my bike for a ride down Yonge St to lake Ontario with my bicycle dashcam, testing my latest changes (May 18th). Over the course of a 2 hour ride, taking a photo about every 10 seconds:
I’m going to try running these photos through alternate ALPR engines, and compare results. On this run, I tested the Pi Camera V2’s various sensor modes: the streaming modes at 1920×1080 30 fps, 3280×2464 15 fps, 640×922 30 fps, 1640×922 40 fps, 1280×720 41 fps, 1280×720 60 fps, as well as the still mode at 3280×2464. Further testing is likely still required, but I continue to get the best results from the still mode – all of the successful matches were shot using still mode.
I’m getting better results than I had on previous runs as a result of tweaking the pi-camera-connect NodeJS library to:
However, the images are still not as good as I would like.
I might order the latest Pi camera with the zoom lens and see if I get better results.
In February, I saw Robert Lucian's Raspberry Pi based license plate reader project on Hackaday. His project is different, in that he wrote his own license plate recognition algorithm, which runs in the cloud - the Pi feeds the images to the cloud for processing. He had great results - 30 frames per second, with 1 second of latency. This is awesome, but I want to process on the device - I want to avoid cellular data and cloud charges. Once I get this working, I'll look at improving performance with a more capable processor, like the nVidia Jetson or the Intel Neural compute stick.
In any case, Robert was getting great images from his Pi - so I asked him how he did it. He wrote me back with a few suggestions - he is using the Pi camera in stream mode 5 at 30 fps.
I wondered if one of the issues was my Pi Camera (v1), so I ordered a version 2 camera (just weeks before the HQ camera came out!). The images I was getting still weren't great. I'm using the pi-camera-connect package, here's what I've learned so far:
I still have more tweaking to do with the Pi Camera 2. If after a few more runs, I don't get the images I need, I'll try the HQ camera or try interfacing with an action camera.
Finally, I've added GPS functionality. If you access the application with your phone while you're riding, the application will associate your phone's GPS coordinates with each capture.
I have an old Canon S90 point and shoot camera that I haven't been using. This weekend, I thought I'd try to see if I could use it for this project.. It isn't rugged, but thought it might be fine for taking this project a bit further, as it takes great photos, and if I could find one, Canon did make a rugged waterproof case for it. It also has image stabilization, which should help with getting useable photos on my bumpy ride.
I looked at how I might be able to control it, and download photos for processing. First, I looked at PTP, the protocol for downloading images from cameras. PTP allows for telling the camera to take a picture, and then download it. I tried an PTP Node library, it didn't work, and then I tried using a command line PTP control tool called gphoto2. Gphoto2 worked great for downloading photos from the command line, but wouldn't instruct the camera to take a picture - it turns out, my S90 doesn't support that feature (although its predecessor, the S80, did!).
Then I thought, I could take regular pictures on a timer, and then download them for processing. I had done this before using CHDK custom firmware for Canon cameras. CHDK allows you to do all sorts of things with your camera that it can't do out of the box, including automation and scripting. I thought I would use a pre-written script to take a photo every 10 seconds, and then download it with gphoto2. But as soon as I connect the camera with PTP/gphoto2, the script stops. So I'm back to looking for a camera, or camera module, that I can control from a Pi & can take useable photos in a high-vibration environment.
We had an early snowfall here in Toronto, and I've put my bike into storage for the winter. I have given some thought about next steps though.
First, I found a really easy way to implement a display. I came across this article about a Vancouver cyclist who tries to "beat" the packed buses on along West Broadway with a display-equipped Pix Backpack. This backpack might be the quickest way to to implement a display.
Second, I started thinking about cameras. Looking at the footage from Cycliq cycling cameras, its definitely possible to get steady footage on a bicycle. I explored modules and spec sheets for various modules from Arducam and camera-modules.com - anything "fast" enough should take a suitable shot. And a co-worker suggested just using a GoPro, but the challenge is, how do you pull the image off to process it as you're riding? Reading various action camera reviews, I came across Yi Action cameras. Although none of the libraries seem to be current, they've made SDKs available to interface with their cameras: https://github.com/YITechnology/YIOpenAPI
I've reviewed the footage on Youtube from Yi cameras mounted to bicycles - it looks pretty good. I'll probably pursue this route.
Following a suggestion from user Gerben, I looked for a way to isolate the camera from vibrations while riding.
A quick search DIY camera vibration isolator seemed to find many were building wire rope isolators:
DIY: Build Your Own Anti-Vibration Camera Drone Mount for Only $10!
DIY Wire Rope Vibration Isolator for RC CAR Camera Mount ( Part 1)
I built an isolator with some wire and plywood, and mounted it along with the Pi to my bike:
I didn't tune it, I'll have to look into how to matching the springiness of the wire by tweaking the length against the weight of the Pi. But it wasn't enough - I think a faster camera is still required. Here are some sample photos from my bike, with the Pi mounted on the isolator:
Photo isn't clear enough to make the the writing on the green sign, or the plates on that car:
Photo is clear enough to make out objects that aren't in motion - Finch Ave., Soban cafe. But not the cars in motion.
I may try to "tune" the isolator, but I think either way, I need a better camera sensor.
Become a member to follow this project and never miss any updates