Coupling strips of train images into images of trains
April 28, 2023 3:46 PM   Subscribe

 
ETA: the post quotes from the developer's post on hacker news.
posted by Chef Flamboyardee at 3:47 PM on April 28, 2023 [1 favorite]


I love this project! I wish it had identifiers for the trains themselves, where they're going. I don't think there's enough marks available to identify them that way but it's a Swiss train, you can pretty reliably figure it out just from the schedule.

The whole Hacker News discussion is a delight (for once). My favorite is the custom radio FM station for someone's 93 year old mother in law who can't use computer user interfaces but knows how to turn on her radio. Pirate radio for the retirement home!
posted by Nelson at 3:57 PM on April 28, 2023 [6 favorites]


This is the internet I signed up for.
posted by gwint at 4:41 PM on April 28, 2023 [3 favorites]


God I wish I had the ability to do this sort of thing without turning it into a year-and-a-half nightmare.
posted by aramaic at 5:11 PM on April 28, 2023 [1 favorite]


Rail companies do this for freight trains. They're called "defect detectors", and some of them are visual. It takes quite the machine vision setup to be able to take high-quality images of fast-moving trains, and unfortunately it shows in some of the images posted. Just the lighting in itself might be too much to do "the right way", especially if you're going to be shining it in through passenger trains' windows. It would start with something like this 😁.

I have a soft spot for 1D scanning imagery, which is what this essentially is, both because my wife is currently busy building the state-of-the-art 15 years from now, but also because it produces trippy images such as these in sports applications.
posted by tigrrrlily at 5:14 PM on April 28, 2023 [2 favorites]


tgrrrlily, Pi camera is now available with global-shutter for single-read of the full frame, rather than scanned read of column after column of CCD elements. [1]

1: https://hackaday.com/2023/03/09/new-raspberry-pi-camera-with-global-shutter/
posted by k3ninho at 1:11 AM on April 29, 2023 [1 favorite]


Years ago when I used to ride the train into NYC frequently, I got a similar idea, but it was to put a camera out the window and try to make a giant panorama of the trip into the city. Back then I would have probably had to make my own image processing software to do it, but I bet now I could just stick ten thousand images into photoshop and have it do it for me.
posted by I-Write-Essays at 5:37 AM on April 29, 2023


I've been wanting the ability to collect car speed and frequency data on my street. I had been thinking a cell phone camera app would be the solution but now I am curious about this whole "raspberry pi" thing. Any advice where to start looking?
posted by rebent at 6:25 AM on April 29, 2023


There's nothing magic about a Raspberry Pi, it's just a low cost computer. If I were starting this project I'd begin with a PC running Linux and any ordinary USB webcam that was good at high speed capture. The hard part is entirely in the image processing software. If that all worked it would probably work on an RPi too, assuming you could find one to buy (there's been a massive shortage for a year+ now.)
posted by Nelson at 6:30 AM on April 29, 2023


This is a major breakthrough for independently monitoring the transportation of hazardous materials on the cheap. I’ve talked to a lot of people who wanted a system like this for identifying oil trains.
posted by Headfullofair at 8:24 AM on April 29, 2023 [2 favorites]


Normally, with 1D scanning of a stationary scene, you know the scanning speed so you know what linear resolution your image should have in the scanning direction (you know your pixel aspect ratio, basically). In the sports example I gave above, however, you know the readout frequency but the subject is moving, so you can't automatically get a properly-proportioned 2D image. What you get on the horizontal axis is time, but luckily, timing data is what you happen to be interested in. The fact that the picture looks almost like a regular 2D image (just perhaps stretched a little bit) is just icing for the spectators.

With trains, you do not know the velocity of your subject, so you would not be able to automatically provide a 2D-looking image of the train without further context. However, that context is provided by using an ordinary 2D camera and getting several scanned lines at nearly the same moment. Stitching software can then look for matching areas and use them as stitch points, as smartphones do when making a panorama image. This process takes care of the aspect ratio problem, as with higher-speed trains the usable vertical slice of each captured image just gets wider and wider until, theoretically, with a fast enough train you fail to find commonality between subsequent images and the process fails.
posted by tigrrrlily at 1:56 PM on April 29, 2023


Looks like Western blots to me.
posted by praemunire at 3:31 PM on April 29, 2023


There's nothing magic about a Raspberry Pi, it's just a low cost computer.

Well, it was a low-cost computer...

Since the pandemic and the ensuing supply chain disruption / semiconductor shortage, RPis are selling for about 5x-7x MSRP, depending on model. The Pi "Zeros" which were supposed to be $5 cheap-and-cheerful boards for stuff like digital signage and homebrew IoT / sensor applications are now $35+, and an RPi4 8GB model will set you back $175.

TBH, if you do not absolutely need a Raspberry Pi for compatibility with the whole ecosystem of "hats" and other stuff that has evolved around it (including the Pi branded cameras), you are often much better off buying surplus small-form-factor thin client workstations. You can get one that's about as powerful as a RPi 4 for $50-60, and it's already in a case.

The problem for a project like this is you'd have to use a webcam-style USB camera, rather than the low-level CSI bus that the official RPi cameras use (it's basically the same connector/bus that cellphones use to interface with their built-in cameras, except the Pi puts it on a somewhat larger ribbon cable instead of the microscopic connectors phones use). But if you could get away with a USB camera you have a much broader, and cheaper, variety of hardware to choose from.

I love the RPis, but it's unfortunate in a way that they became the default platform for cool DIY computing projects in the last few years. Or rather, it's unfortunate that other platforms with the same sort of hardware—including, specifically, mobile phones—are so bloody difficult to put a 'real' operating system and run your own code on. There are probably thousands of phones as powerful as Raspberry Pi going into landfills every day, and many with awfully nice cameras and optics, just because the manufacturers don't want the hassle or warranty claims they believe that will result if people can access the hardware like a real computer.
posted by Kadin2048 at 8:41 PM on April 29, 2023 [3 favorites]


Absolutely agreed. I've got a couple single-use phones around the house. One runs Bug Ben Bonger, which rings out the quarter hour, the other lets me help my family small business when they are out of town.

I've probably got at least 10 functioning but old devices in a bin under my bed. I wish I could use them.

What is a " small-form-factor thin client workstation"?
posted by rebent at 8:22 AM on April 30, 2023


"Thin client" workstations are inexpensive computers designed to exclusively run network applications, often without allowing the user to actually store any data locally. Basically modern-day dumb terminals. They're very common in banks and some other industries, and at least in recent years tend to be built around the same "System on Chip" (SoC) designs that the RPis use (although typically x86 instead of ARM).

If you search "thin client" on eBay you'll see a lot of them. This is one example. (It's an HP T520, for when that link dies.) For $25 you get a 1.65GHz dual-core processor that's in the same ballpark as a Pi3B+, 4GB RAM, 16GB eMMC storage, USB 3, two serial ports, and—no joke—a parallel port.

It's probably not quite as low-power as an RPi, and it's physically larger and harder to embed if you're putting it on a drone or something, but for a media PC or some of the other projects that people like to use RPis for, I'd say it's not a bad replacement. There are even models that are smaller, and some that have VESA mounting points so you can attach it to the back of your TV.

The one thing you don't get is GPIOs and other low-level I/O (I2C, SPI); for that you'd need to add some sort of breakout board (or figure out how to bit-bang that parallel port, maybe?). But still, it's a decent amount of computing power for less than the price of a steak dinner, or what the RPi was supposed to sell for originally.
posted by Kadin2048 at 12:48 AM on May 1, 2023


Trainsspotted
posted by kirkaracha at 9:11 AM on May 1, 2023


Honestly, this might be fairly easily handled by a $10 ESP32-CAM. An I2C sensor could handle identifying when a train starts and finishes passing, and you could very easily automate uploading to a cloud service for processing.

For anything that doesn’t necessitate a keyboard and screen, microcontrollers have more than surpassed the RPi/microcomputer ecosystem in terms of functionality.
posted by Molten Berle at 11:39 PM on May 4, 2023 [1 favorite]


« Older Not SLB (Single Link Beaverton)   |   …a 20-minute question from a soon-to-be emeritus... Newer »


This thread has been archived and is closed to new comments