Bicycle Dashcam Part 2: Camera upgrade + GPS

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.​

Source: https://github.com/raudette/plates
Bicycle Dashcam Part 1

iOS Safari’s WebSockets implementation doesn’t work with self signed certs

I’m building a Node application hosted on a Raspberry Pi, that will not be connected to the internet. A user will interface with the application through the browser on their phone. The application calls the browser for its GPS coordinates using the HTML Geolocation API.

In iOS, the HTML Geolocation API only works for HTTPS sites. I found an excellent post on Stackoverflow for creating a self signed cert that works in most browsers. I created the cert, added it to my desktop and phone. HTTPS worked great.

I first tried the Node ws websocket library, and the Node application would call out to the browser to fetch GPS coordinates when it needed them.

The application worked great in Firefox and Chrome, but it would not work in the iOS browser. If I dropped to HTTP (vs HTTPS) and WS (vs WSS), it worked fine. For some reason, the iOS browser accepted the cert for HTTPS, but not WSS. Unfortunately, I needed HTTPS to use Geolocation.

I couldn’t get it to work. I ended up moving my application to Socket.IO, which has a fallback method to HTTPS polling if a websocket connection cannot be established. This worked for my scenario. If you need a websocket like capability and have to use self signed certificates on iOS, try Socket.IO.