• New Hardware

    Richard Audette08/14/2020 at 00:56 0 comments

    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:

    Luxonis OAK-D vision module prototype as seen in their Kickstarter video

    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.

  • More Field Testing

    Richard Audette06/24/2020 at 01:38 0 comments

    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:

    • Reviewing the photos with my own eyes, I can make out about 45 images with readable plates (not every image was usable or had a car in the photo)
    • Of these 45, OpenALPR can make out about 10
    OpenALPR picked out this dry cleaning sign as license plate 2 H0UR

    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.

    Dashcam Successfully Recognizes License Plate

    I’m getting better results than I had on previous runs as a result of tweaking the pi-camera-connect NodeJS library to:

    • use a 5 second capture delay, which allows exposure time, gain, and white balance to be determined
    • set the exposure mode to sports, which reduces motion blur by preferentially increasing gain rather than exposure time

    However, the images are still not as good as I would like.

    Rolling shutter issues are apparent in some photos taken by the Pi Camera V2 while in motion

    The Plate Recognizer service has an excellent article on Camera Setup for ALPR. It highlights many of the challenges I’m seeing with my setup:

    • Angle, lighting
    • 8 MP is suggested for highway or street monitoring – the Pi Camera is sufficient in this regard
    • Zoom – I think this is a challenge in my setup – I liked the idea of getting everything around me, but I think I have to reduce the area I capture to get a view of the plate with more detail. Perhaps focus to my “7 o’clock” rather than capture everything behind me.
    • At 30 mph (~45 km/hr), which probably covers most bike riding in traffic, they suggest at least 3 to 5 frames at 15-25 frames per second.

    I might order the latest Pi camera with the zoom lens and see if I get better results.

    Reviewing the data from my ride, there’s also an issue with my code that pulls the GPS coordinates from the phone, which I didn’t see when testing at home. I figure this is either the phone locking while I ride, and not running the javascript – I’ll try using the NoSleep.js library before my next test run.

  • Camera upgraded, More experimentation, GPS + Help from afield

    Richard Audette05/18/2020 at 22:16 0 comments

    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:

    • The best documentation I've seen for the Pi camera can be found at https://picamera.readthedocs.io/en/release-1.13/
    • Some of the modes are capable of higher frames per second, but results may be poor.  Start with 30 fps
    • In stream mode, streamCamera.startCapture() must be called 2-3 seconds before streamCamera.takeImage()
    • There are a number of parameters not exposed by the pi-camera-connect package, but ultimately, this package is just a front end for raspistill and raspivid.  All the settings can be tweaked in the source.  Specifically, increase the --timeout delay for still images.  I also want to experiment with the --exposure sports setting.

    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.

  • An idea... that was fruitless

    Richard Audette02/17/2020 at 21:07 0 comments

    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.

  • Winter Hibernation

    Richard Audette11/23/2019 at 22:50 0 comments

    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. 

  • Added a DIY Camera Vibration Isolator

    Richard Audette10/14/2019 at 13:39 0 comments

    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.


    Although there are no plates in this picture, you can see that you can't make out the street name.

    I may try to "tune" the isolator, but I think either way, I need a better camera sensor.