In part 3 the hardware and software were all working and attached temporarily to the bike. So now it was time to have a quick test ride up and down the street.
Having shot some trial footage, I realised immediately that I needed to change the angle to point the camera down more. Once that was done by shoving a piece of foam in between the saddlebag and Pi (at the top) it became usable.
The 4.2″ screen is a decent size and is easy to see while riding. You can clearly see what’s behind you, but the resolution on the video (shot half an hour before sunset on a cloudy December day) was not good enough to resolve a car number plate. So useless as evidence, but a huge success as a rear-view mirror. I’ll need to try in better light conditions before reworking it with a better camera. I suspect that either these unofficial cameras aren’t really very good, or they’re a bit delicate and don’t like being hacked around, which maybe messes up their focus? I don’t know which it is.
I will also need to find something a bit better than a ‘lump of foam’ to hold the Pi Zero W and camera at the right angle.
View from the Camera
Here’s the initial footage from ‘maiden’ ride of new dashcam (after adding foam). It’s not particularly good video, but it gives you an idea of what the camera recorded in poor light.
At this point, I decided that the bike dashcam project is worth pursuing and installing ‘properly’.
- The software works
- The hardware works perfectly as rear-view mirror
- As yet untested out on the road in ‘normal’ conditions, so not sure if the Zerocam camera is quite up to it for dashcam ‘evidence’
So What’s Left to do?
- Put the software on Github as a backup and so it can be shared
- Make a proper handlebar mount for the screen
- Make a proper ‘shim’ to hold the camera at the correct angle
- Install the wires and cables properly and as ‘invisibly as possible’, but still be able to access and remove the saddlebag
- Go for a proper, real-world road test
I ordered some reusable cable ties to help with the wiring.
Files are now on Github
I’ve put the Python and bash scripts up on Github here
Zero W is a Good Choice
It turns out that a Zero W is a good choice for this application as you are able to process and download files from it afterwards.
You can’t view .h264 files easily in most software, so it helps to wrap it in an mp4 container. This can be done easily and fairly quickly on the Pi, using gpac’s MP4Box. I wrote a blog about this a while back, but the essence of it is below…
sudo apt-get update
sudo apt-get install gpac
MP4Box -add filename.h264 filename.mp4
Then download the .mp4 via sftp (I use Filezilla on my mac) and you’ll be able to view it.
You can also view the raw .h264 files directly on the Pi using omxplayer if you have a screen attached
Design and Make a Shim and Screen Mount
The shim was straightforward. I cut a rectangle of 2mm colourless acrylic and bent it using heat from my reflow torch. The bend was slightly diagonal and was squashed more on one side than the other to introduce a slight twist. This was because I wanted to the camera to be angled slightly down and slightly to the right. A bit of velcro and a cable tie finished the job.
Didn’t get much else done today due to a hectic day on other things. But I did have a great session in the workshop in the evening making a proper bracket to mount the screen on the bike. It took 2 iterations, first time I learnt a lot and second time got it completely right. It’s a complex bend and you have to be careful not to stress the material too much. Perspex (acrylic) probably isn’t the best material for this (it’s a bit brittle), but it’s what I have. It was also a very entertaining 3d puzzle for me to design and work out how to heat bend the flat material into the required 3d shape while still looking nice.
I made it in two parts…
The diameter of the handlebar is 25mm and the M3 threaded holes we’re making to attach the screen need to be 19mm apart. I found a piece of dowel with 25mm diameter and used this to help form the right shape of curved bend in the simpler piece…
Next I tapped M3 threads into the two holes for the screen mounting side. See how to do that here. Once that was done, I set the vice jaws exactly 19mm apart and heated the two places that needed to be bent. Heat was applied liberally on both sides. Once hot enough, the 19mm wide Perspex was kept flat and pressed into the vice bending both sides simultaneously and symmetrically. Once approximately right it was allowed to cool and then each side was individually heated and adjusted. After a couple of tweaks it fitted the screen perfectly. An M3 bolt was then threaded through both holes to keep them the correct distance apart while forming the rest of this piece.
Then the second, more complex piece was formed around the dowel with lots of heat and patience…
After that, I tried doing the 90 degree bends on the simpler piece first. The thinking here was that if I messed it up it would be easier to remake that piece. I used a pair of flat pliers and just grabbed and twisted once the Perspex was hot. It was quite straightforward.
Having safely learnt the technique on the other piece, I did the same for the more complex side…
Then there was a little heating and tweaking to make the holes line up a bit better. After that the mount was bolted to the screen with a pair of nylon bolts…
And then the whole thing was mounted on the handlebars (I used locking nuts on the bracket)…
I’m really very pleased with the final outcome. That’s one of the reasons for so many photos, but the other reason is that if I ever need to make another, I’ll have all the steps in the process documented (which is one reason that I blog).
Just a teeny piece of rubber band between the bracket and handlebar was needed to give it something to grip on to prevent it twisting around.
Install Wires and Cables Properly and ‘Invisibly’
After that I used reusable cable ties and some black insulating tape to route the power and video cables as securely and ‘invisibly’ as possible round the bike frame. Where leads were too long, they were coiled around unobstrusive areas of the frame. The idea here is that the wiring should not detract from the aesthetic of the bike. Also if it’s not easily visible, nobody’s attention will be drawn to it either.
All that remains now is the road test, which will be in the next part.