Bicycle Dashcam Mark I

I love my bike – it is a workhorse I can park anywhere, a mid-1990s hybrid. After years of limited maintenance, in the past year, I’ve had to replace a tire, cassette, all the cables, pads, grips, and shifters. I’ve also just upgraded my headlight and taillight – the improvements that have been made in bicycle lighting over the last 15 years have been incredible.

I’m using my bike more this year – my downtown office recently moved to a building with badge access indoor bicycle parking and showers, with towel service, for cyclists – what a cool perk. So, I’ve been biking to work for the first time since I started at this company in 2006, 17 km down Yonge St in Toronto, about twice a week since June.

My rides have been great. Drivers along my route leave a lot of space. But it’s hard to assess risk. The City of Toronto keeps detailed data on cyclists killed or seriously injured. There have been 11 KSIs on my route since 2008. But how do I compare that against, say, the risk of the 30 km drive to my Mississauga office? I’ve been rear-ended 3 times since 2010 commuting by car to Mississauga, but all have been at low speeds, only resulting in damage to my car – the consequences of getting hit on my bike are far more severe.

I was trying to think about what I could do beyond riding cautiously and ensuring I am visible. And, I have to say, a part of me is just always on the lookout for small, fun projects.

Envision a bicycle dashcam

Bicycle dashcams have been done before, by Cycliq and others. But I envision something difference, a bicycle dashcam that could:

  • Recognize the license plates of the cars around you. From a picture, it would look at the plates on all the cars, and then associate a plate number with the picture
  • Record the speed of the cars around you
  • Record the proximity of the cars around you
  • A driver readable display, ie: “Driver ABCD1234, your current speed is 45”. Like a mobile Toronto Watch Your Speed program sign. Would a driver allow a cyclist more space if they were aware their actions are being logged?
  • Log this data on a remote server
  • Share this data, with a group. Perhaps associate “near miss” data from many cyclists, and identify troublesome areas, or troublesome cars.

Introducing my Bicycle Dashcam, Mark I

Bicycle Dashcam Mark 1
Bicycle Dashcam Mark I

My Mark I dashcam consists of a Raspberry Pi 3 with a Pi Camera (v1.3), a battery pack, running a small Node application which takes pictures, tries to recognize license plates with OpenALPR, controlled through a phone friendly web interface.

Bicycle Dashcam Dashboard
Bicycle Dashcam Dashboard

Testing and Results So Far

On the Pi 3, it takes between 8 and 800 ms to capture a photo with the Pi Camera, and another 7-8 seconds to run the OpenALPR license plate recognition process. I haven’t looked into optimizing this, but I would be curious to see how fast this could get by adding a processor optimized for these tasks, like an Intel Neural Compute Stick.

I’ve taken my prototype on a few drives, and a 5 minute bicycle ride. I don’t know why I even tried using a Lego frame to mount the dashcam to my bike – it only held together for a few minutes of riding, and completely fell apart – I’ll have to come up with something better for bicycle testing.

In the car, over a 30 minute drive (~120 photos) in traffic, about 15 license plates are identified. OpenALPR works exceptionally well – it can pick out the plate numbers even when it would be hard for a human to do so from the same photo. The limiting factor is the Pi Camera. At a stop, the pictures are fine, and OpenALPR will recognize the plates.

Pi Camera image quality sufficient for OpenALPR when stopped
Pi Camera image quality sufficient for OpenALPR when stopped

However, as soon as the car is in motion, the image is washed out.

Photo from Pi Dashcam while car is moving.
Just a blur. Photo from Pi Dashcam while car is moving.

I have spent some time tweaking the photos taken by the Pi camera, trying out different modes. So far, I haven’t been able to get great results.

As I look to take this further, I’ll look at other Pi camera options, run further tests on my bicycle, perhaps move the project to a mobile phone app, as my phone’s camera is significantly better than the Pi’s. Also, I may explore inexpensive LED matrix screens for the driver readable display.

Source code: https://github.com/raudette/plates

What seemed like a silly idea

Throughout University, we had these Engineering Design courses, where we would go through a defined process to design something.

In my second year, my team submitted “A System for Maintaining Driver Alertness <link to pdf>“.

A System for Maintaining Driver Alertness
A System for Maintaining Driver Alertness

I’m not sure where we got the idea, and the solution we proposed was gimmicky, even at the time, but the exercise was more about design process – my team did fine. Imagine my surprise, when I was browsing for something else recently on AliExpress (and on Amazon), that some company builds and sells a device similar to our proposed design.

Commercial Driver Alertness Device
Commercial Driver Alertness Device – As Seen on Amazon

As automakers have added lane following systems and basic autopilots to their cars over the last ten years, they’ve also invested in systems that ensure drivers remain alert to supervise these systems and are ready to take over. Tesla’s systems have sensors to ensure hands remain on the steering wheel, Cadillac’s Supercruise has a camera that ensures the driver’s eyes are focused on the road ahead. What seemed like a silly idea is now a little industry…

RC Sailboat Version 2

Six years ago, I built a wifi-controlled pop bottle sailboat. Smartphone control wasn’t great, so I turned my decommissioned weather station into a remote control.

RC Pop Bottle Sailboat, V2
RC Pop Bottle Sailboat, V2

My re-used weather station project board is a homemade Arduino board, with an APC220 transceiver radio. I added two rotary potentiometers for rudder and sail control. I removed the Raspberry Pi in the boat, and connected another APC220 transceiver to the Arduino Uno that controlled the sail and rudder servos.

We drove to Downsview Park and launched the boat.

RC Sailboat Launch
RC Sailboat Launch

Control still wasn’t great:

  • Controlling the sail and the rudder is fine, but with the boat just floating on the pop bottles, the rudder has very little effect. Our boat design itself needs improvement – I think this is currently the greatest issue.
  • My transmitter and receiver code could use some optimization – as I was troubleshooting at home, my code limited updates, and was only sampling every second – controls seemed “laggy”.
  • I’m using very inexpensive TowerPro MG995 servos, which many advise against using. They were fine for playing around with interfacing, but they are slow, they seem to have a hard time holding their position, as well as not consistently reaching their programmed position.
RC Boat Halfway Across The Pond
RC Boat Halfway Across The Pond

I did write my phone number on the boat in case the boat got stuck in the middle, and someone else eventually found it. In the end, it wasn’t required. We just played with the controls as the wind carried it to the other side – probably about 100 m.

Downsview Park Test Run
Downsview Park Test Run

Maybe some time over the next 6 years, I’ll optimize the RC code, install better servos, and improve the boat design by adding a keel.

finally a reason and time to play with an esp8266 wifi capable microcontroller

Ever since I read about the ESP8266 in Make magazine in 2015, I’ve been wanting to build something with it. I picked up a Sparkfun ESP8266 Thing Dev board at Creatron, probably a year ago, and let it gather dust.

Enter 35 degree weather. I have a window air conditioner, that I install in a metal sleeve built into our wall. For some reason, the sleeve is sloped such that water flows INSIDE. When the A/C runs on humid days, the water it collects from dehumidifying can leak inside, creating an unpredictable annoying mess that has to be cleaned up.

I could pickup a commercial leak sensor, but that’s not fun, the mobile app is probably not very good, it probably sends more information than needed to its cloud service, will never receive updates, and it seems like we’re always reading about IoT device vulnerabilities.

So, I bought a water sensor ($2.20!) in June, connected it to the dev board, and started to write a client in the Arduino environment for the ESP8266, and the server in Node.js. Then summer happened. Today, it’s August, its only 24 degrees outside, the A/C is off, and I’m done! The client reads the sensor every 10 seconds, and calls the server with a standard web service call, which will check the sensor reading, and send an alert by email if a water leak is detected.

ESP 8266 Water Sensor
ESP 8266 Water Sensor

The code is simple, but I had challenges getting the ESP8266 to HTTP POST a JSON payload. It seemed every example I found used different libraries or versions than the ones I had installed. I eventually got it working.

In the end, we didn’t have any leaks this summer in any case, and I don’t expect to make use of this project. If you’re interested in checking it out, you can download the code here: https://www.hotelexistence.ca/projects/watersensor.zip

Playing with tools instead of getting stuff done and other useless pursuits

This website is running WordPress on an Amazon EC2 instance.

If I were looking to keep a blog, this is not how I would do things, I’d just use a service.  The micro EC2 instance is slow, I have ensure Linux is patched, WordPress is patched, etc…  But playing around with the server is as much fun as writing the blog.

Here are a few changes to the site recently:

  • I run the EFF Privacy Badger on my browser at home, and I couldn’t believe how many trackers were running on my self hosted site, because I don’t track, and I don’t have ads.  I dropped the Youtube videos, that got rid of many (I just link to Youtube now instead of embedding).  I can’t remember what else I did, but now I’m just down to Google Fonts, used by the template.
  • The site now defaults to HTTPS.  With default settings, Qualys rates the default Ubuntu 18.04 LTS Apache HTTPS setup on this site as an A.  Its funny how many important companies struggle to get this right on their sites, given how easy this is.
  • Recently update the site to Ubuntu 18.04 LTS – the latest version of WordPress didn’t like the version of PHP on the previous LTS version I had been running (not sure what that was).  This is the third VM on which this site has been hosted.
  • I hadn’t been resizing photos and the site got REALLY slow.  I’ve resized the largest ones – it’s not painfully slow anymore.  I may eventually move the image hosting to S3, but keep the server/DB on EC2 – I expect the site would run faster without increasing costs.

Update October 5th, 2019:

  • Google Lighthouse ranks the site load speed at 100
  • Finally got the fonts loading locally with the OMGF WordPress plugin. The site no longer has any external trackers!

Microsoft revokes digital media. Again.

In 2010, I joked “I don’t think any child born in 2010 will get the chance to hear the music of their parent’s youth”, as DRM encumbered media would be unplayable.

Even in 2010, we’d seen Microsoft’s “PlaysForSure” music (launched 2004, RIP 2008) not play on Microsoft Zune (launched 2006, RIP 2015).

Today, Microsoft announced that it is revoking the ability to read books purchased on its book store. It is refunding its customers.

I didn’t foresee the rise of streaming music services – I think this model is better, as there is no illusion of a purchase.

Fixing ink blobs on epson xp-830 prints

Black ink blobs dropped randomly on pages

My Epson XP-830 started dropping black ink globs on my prints, which would smudge and wreck photos. As I had recently installed $150 worth of ink, I didn’t want to just go out and get a new printer. I also liked the compact format of this printer, and wouldn’t just buy the same one, as this was starting to look like a doorstop after its 2nd set of cartridges. I wasn’t concerned about breaking the printer at this point, because I was ready to throw it out.

I managed to resolve the issue – I’ve decided to write about what I did, and perhaps some will find this article and I’ll save a few printers from an early trip to the landfill. I expect this will work for any Epson XP printer.

First, I ordered a print head cleaning kit from Amazon (kit, Amazon link). In hindsight, I don’t actually think this was an issue with my print heads, but I did a number of things all at once, so I don’t know exactly which step resolved my issue. I recommend watching their video before ordering the kit.

The first step was getting the print head out of its right-side dock. Go to the menu, click maintenance, and then click Ink Cartridge Replacement.

Click proceed.

At this point, the print head will have moved to its change cartridge position. Disconnect the power.

I used card stock and paper towels to clean all of the ink I saw in the areas identified by red arrows

At this point, I took out the cartridges, and I wrapped them in plastic wrap, following the guidance of the Print Head Hospital.

I did clean the heads, as instructed in the Print Head Hospital video, but I think what really made the difference for the black ink globs was the following: using cheap papertowels and cardstock, I cleaned up all the ink in the areas highlighted by arrows in the above image. I cleaned under the print head by cutting a ~1″ piece of cardstock, wrapping it with a paper towel, and running it underneath the assembly as shown at the 3:40 mark in the Print Head Hospital video, and repeated until the paper towel would come out clean.

I plugged the printer back in, re-installed the cartridges, ran the regular print head cleaning cycle 3 times (until the test page came out fine), and am now getting perfect prints.

Good luck – hope this helps.

The Pigeon Tunnel

My manager has been on secondment to another team for the past 8 months. He stepped into a recent team meeting, where we were re-visiting challenges with our release process, and re-starting an initiative that had been displaced by other priorities.

As he stepped out, he joked (I paraphrase): “Good to see nothing has changed while I’ve been away”

In the next couple months, my manager will return to this team, back to where he started, back to re-visit familiar challenges.

This reminded me of the following introduction to John le Carre’s The Pigeon Tunnel, a collection of stories the author’s time in MI6 and of his unreliable father:
“There is scarcely a book of mine that didn’t have The Pigeon Tunnel at some time or another as its working title. Its origin is easily explained. I was in my mid-teens when my father decided to take me on one of his gambling sprees to Monte Carlo. Close by the old casino stood the sporting club, and at its base lay a stretch of lawn and a shooting range looking out to sea. Under the lawn ran small, parallel tunnels that emerged in a row at the sea’s edge. Into them were inserted live pigeons that had been hatched and trapped on the casino roof. Their job was to flutter their way along the pitch-dark tunnel until they emerged in the Mediterranean sky as targets for well-lunched sporting gentlemen who were standing or lying in wait with their shotguns. Pigeons who were missed or merely winged then did what pigeons do. They returned to the place of their birth on the casino roof, where the same traps awaited them.

Quite why this image has haunted me for so long is something the reader is perhaps better able to judge than I am.”

There seem to be challenges that 8 months don’t progress. Is this exercise futile, like the Monte Carlo pigeons? Are these tough problems we avoid, or constraints we work in?

Or, perhaps its why we’re here – these things are tough, and that’s why we’ve got a very skilled team consistently delivering within this environment. In this environment, over the past 8 months, we’ve completely refreshed our application’s UI, moved to Angular framework, re-branded, and delivered it to > 100,000 customers. Our release process may not be as efficient as we like, there are problems we had a year ago that we haven’t resolved, we may defer initiatives, but it’s all about playing the best hand possible with the cards we have been dealt: we are not standing still.

Code like it’s 1981

In my primary school years, I’d read my Dad’s “Compute!” magazines. Recently, I discovered they’ve been published on Archive.org https://archive.org/details/compute-magazine , and I browsed through a few issues.

I came across this ad in a 1981 issue:

Ad for SORT, an EPROM with a sorting algorithm for Apple and Commodore PET owners.
SORT algorithm on EPROM for Apple and Commodore Pet

It’s a sorting algorithm, written in assembler, distributed on an EPROM chip, mounted on a circuit board, that you’d plug into your Commodore PET or Apple II computer and call from your BASIC program.

I few things I find interesting about this ad:

  • How big was the market in 1981, for people who were writing BASIC programs, couldn’t write a sorting algorithm, and would pay $55 per seat for one?
  • If someone were looking to sell their program that they built, they’d have to bundle in this SORT product
  • At some point, sorting libraries were built-in

I actually found documentation for this product online:
http://mikenaberezny.com/wp-content/uploads/2013/10/sort-installation.pdf
http://mikenaberezny.com/wp-content/uploads/2013/10/sort-user-instructions.pdf
http://mikenaberezny.com/wp-content/uploads/2013/10/sort-review-compute-dec-1981.pdf

Ask not if our product uses Apache Struts, but…

When it was revealed that the massive Equifax breach in 2017 was attributed to their failure to patch a component in their system known as ‘Apache Struts’, everyone was reaching out to their development teams and asking: “Do we use Apache Struts? Is it patched?”

And I found it interesting. In my opinion, the wrong question was being asked.

What they should be asking us (and what we should be doing) is:

  • Do we know what libraries our application is using?
  • Do we have a process for checking if security vulnerabilities have been disclosed in the libraries we use?
  • Are all the libraries we using currently supported?
  • Are we using current, patched versions?

There has been an interesting news story recently about how a specific company was a target of a cyber-attack through a library it used. A malicious actor planted a back door in a library it was known to use – some good assessments of the incident have been posted on Ars Technica and Linux Weekly News.
https://arstechnica.com/information-technology/2018/11/hacker-backdoors-widely-used-open-source-software-to-steal-bitcoin/
https://lwn.net/Articles/773121/

Most development teams don’t have the capacity to audit the source code of all the libraries they use. Further, it would seem that in this instance, the malicious code would have passed a cursory review. At this point, our best defense is to be aware of this possibility when assessing a library, ensure that it has an active community and is well supported prior to incorporating it. Once a library has been incorporated, ensure we track its development for updates.