If you’re looking for a fun Raspberry Pi project to get on board with, you may want to grab a ticket and hop on over to Jo M’s GitHub page to see this amazing trainspotting creation. Affectionally dubbed Trainbot, the system is designed to watch trains as they pass by and create full-length images of the trains. These images are stored in a database that users can view online with real-time updates.
Jo was kind enough to explain in great detail how the setup processes image input. It doesn’t take much hardware to operate the project as it primarily consists of a Raspberry Pi with a camera module v3 (the Global Shutter Camera would be a great option) and there's no need for tools such as OpenCV to process the image input as all of the image processing takes place on the processor.
According to Jo, once the Pi tracks a train and creates the image (of every carriage!) , it then uploads the picture along with additional information — including how long the train is, which direction it’s going, and how fast it’s traveling — via FTP. Users can access this data from any device with a web browser by going to https://trains.jo-m.ch. Here you can see all of the recently tracked trains and even click on individual trains to get a closer look.
Jo explains that while they’re using a Raspberry Pi camera v3 module, you should be able to duplicate this project using any compatible camera, such as a video4linux compatible USB camera. Jo confirmed that this project was designed and tested with a Raspberry Pi 4 B — you could probably get away with a Raspberry Pi 3 B+, but this has not been tested.
Because it doesn’t use anything too intense like OpenCV for processing, the software side is fairly easy to set up. All of the code is available over at GitHub, which also includes instructions for using V4l to process the image input as well as libcamera library functions to operate the camera module. For a closer look at this Raspberry Pi project, check out the project page over at GitHub, and visit the official website, Onlytrains, to see it in action.