Jonathan M created Trainbot with a Raspberry Pi Camera. It watches a stretch of train track outside his home, detects trains, and stitches together images of them.
Everyone else at Pi Towers said their favourite thing about the project is the Wes Anderson-esque aesthetic of the screen recording above. My favourite thing is that the tab for the train watching website says “Onlytrains”, because I am easily amused.
Image patch matching means that the image you see is made up of small patches, each of which has been processed individually in order to create a single final composite image. RANSAC stands for RANdom SAmple Consensus, and that’s the machine learning method Jonathan uses to make sure no “outlier” images make it into the final cut. It is trained to select only those patches which show separate bits of the train for the final image, dismissing any overlaps.
Simpler than it sounds
If this all seems too complicated, Jonathan insists it is easier to run than it sounds:
“The computer vision used in Trainbot is fairly naïve and simple. There is no camera calibration, image stabilization, undistortion, perspective mapping, or “real” object tracking. This allows us to stay away from complex dependencies like OpenCV, and keeps the computational requirements low.”jo-m on GitHub
Wall-to-wall Raspberry Pi
As well as having a Raspberry Pi camera for eyes, Trainbot’s software runs on a Raspberry Pi 4B. Images and data are uploaded to a web server via FTP so you can watch the trains passing by Jonathan’s home.
Trainbot needs a little more training to make sure it works properly in snow and bad weather. That RANSAC algorithm has a tough time discerning which snow-covered part of a train it is looking at. It seems to do perfectly fine during light flurries if the image above is anything to go by.
Thanks for sharing this visual snippet from your daily life with the rest of the world, Jonathan. Also, congratulations on coining the greatest name for a trainspotting website ever.