Hacker News new | past | comments | ask | show | jobs | submit login

I have a rail line right under my apartment, so I built a small computer vision app running on a Rasperry Pi which records each train passing, and tries to stitch an image of it.

It has a frontend at https://trains.jo-m.ch/.

Edit: it's currently raining and the rain drops are disturbing the images a bit.




Have you considered getting a line scan camera for sharper and higher resolution images? I took some train scans with one: https://daniel.lawrence.lu/photos/

Incidentally I also built some tech for it: https://github.com/dllu/nectar but I need to update the readme...


Thanks for sharing, those photographs are very clear and sharp (especially this one: https://pics.dllu.net/file/dllu-pics/boston-pcc.jpg) it seems to tickle my brain.


I have three of those actually:

https://daniel.lawrence.lu/photos/pcc

Technically, the photo could be twice the resolution, since the length of the line scan sensor is 4096. It consists of two lines, RGRGRG and GBGBGB. By interpolating the red and blue channels, it would be possible to get images 4096 pixels tall. The challenge is that the two green channels apparently have quite different sensitivity and also each pixel has some variation in sensitivity, which also seems to drift with temperature and settings, so it's quite annoying to calibrate everything properly haha.


This reminds me of Wes Anderson movies for some reason.


I'm a big fan of Wes Anderson's aesthetics and would love to shoot that funicular train from Grand Budapest Hotel (which actually exists --- the Buda Hill funicular) using my line scan camera.


His style is to shoot his subjects straight-on. Most other movies have the camera at an angle.


Wow, the pictures look amazing! Yes, the look of line scan images were an inspiration for this project. But of course, I also tried to keep BOM costs down and so ended up with a RP4 + RPi Camera.


The RPi HQ camera is a nice step up from the regular RPi camera while being not too expensive too. Incidentally, I also have a project using that [0] but unfortunately no trains where I live.

[0] https://daniel.lawrence.lu/blog/y2022m01d27/


Have you tried the opposite direction? Sitting on the train with the line feed and taking a picture of outside? Like say, a panorama view of the entire run-length of the line, distorted in proportion to the trains turns and accelerations.


I love how the line scan camera’s horizontal background makes it look like the trains are moving impossibly fast. Not only are the images sharp & high res, it has a great aesthetic and implies you were tracking an action shot.


I remember seeing your photographs on Wikimedia Commons and wondering how you did them - now I know! I always assumed that you just used a very quick shutter with an f-stop of zero :)


I have a huge backlog of photos that I need to contribute to Wikimedia Commons! I'll get around to doing it eventually, hopefully before 2045.


Do it sooner than 2038 and you get the privilege of 32-bit timestamps on the metadata :)


I know he told us how already, but that would have left the background sharp, rather than always the same.


Woah the resolution! You can see the earpods on a person behind the tinted windows of Shinkansen.


How do you get the x scaling right? You have to measure the speed of the train somehow?


When the train is moving at a constant speed, you can just scale the image manually to make it just right. If it's moving at a non-constant speed, you can apply a spline or similar to remove the distortion.


Your blog is a gem, thanks for sharing!


Tip: some more interesting ones (including failed ones) show up if you filter for shortest.

https://trains.jo-m.ch/#/trains/350

https://trains.jo-m.ch/#/trains/3224

https://trains.jo-m.ch/#/trains/4045

Etc


I think the first one is a firefighter train. There is one (the same?) that lives near me.


This is such a cool project! I live right next to a busy road and for a long time have wanted to do something like this that would count the vehicles passing. I've always been curious how many cars pass on a given day and I feel like the hardest part now adays would be getting the right camera angle so if cars are occupying all 3 lanes they aren't counted incorrectly. From there I just need to detect cars as they pass and count them.

It's really cool to see it used like this! The resulting images are really neat as well!


There was a post yesterday about counting traffic on a pi, you might want to check it out: https://nathanrooy.github.io/posts/2019-02-06/raspberry-pi-d...


Thank you for this! It's great!


Given the type of trains that are passing (it seems no IC/IR), along with their precise timing and direction, I'm sure it is easy to figure out where exactly you are living.


Especially in Switzerland where the trains actually go on time :P But anyway does it really matter? It'll still be hard to identify the actual apartment.

Most online webcams are easier to identify


Given an approximate location, even I could do that. You just look at the camera angle.


But the camera image here is heavily processed. Getting an angle out of that looks difficult.


Wonder if we can get a nice photo of an HN reader?


Please don't actually do this without permission. It's bloody terrifying when 4chan does it.


Yes.


No interest in trains, but your website is great - simple, visual and effective.


I wonder if there's open data or an open API for the schedule or location information. That way, you could include information on which train is which.


Yes, the APIs are there, with minute accurate real time data. Would just have to do it ;)


Made me think of Kartrak (an early optical barcode-like system for tracking rolling stock): https://www.youtube.com/watch?v=5K8UpMNYIPo


This is close to what I've always wanted to build; a camera watching the road next to me that records the speed of the vehicle traveling by. I should have everything needed from a simple camera setup, but I've not bothered actually doing it.

Since you have speed, I should dig into this.


I wanted that with noise levels. I'm so very tired of hearing illegally modified exhausts. It seems like an I2S mic would give calibrated levels.


Same here, I have a Pi 3 but I want to have this outside in the balcony, the question that always stops me is how to power it and what camera do I meed?


My plan was to stick the Pi inside, and power both it and the camera with Power over Ethernet (external-rated PoE cameras are a dime-a-dozen on Alibaba and friends).

I even got so far as to get it working with Zoneminder to dump out the clips that had motion, but didn't get further.



I actually have done something similar to this, since I had pretty clear view of the road infront and had my old android phone laying around,

Used to yolov5 to detect vehicles and deepsort to track them, also got a rough estimate for the speed of the pass

heres the two part blog i wrote about it

https://dharisd.github.io/posts/vehicle-monitor/

https://dharisd.github.io/posts/vehicle-monitor-part-two/


Could you show average speed vs car manufacturer? Or vs car type (compact, European luxury, minivan, truck). I've always wondered if this is correlated.


Would be interest; perhaps the red ones ARE faster.


The short ones are fastest.


I live on an airport - Id really like to do this.


https://skybot.cam/ (see also https://github.com/IQTLabs/SkyScan) and might be of interest to you?


Do you mean by an airport?

Or do you litteratur love in or on an airport?


Awesome. Congratulations from a fellow Swiss (and panorama photo dabbler).


And yet again I forgot it’s not the Chinese TLD.

By the way I have a quick expansion for most TLDs and for the Swiss .ch “cheese” sounds rather more apt and easier than the real one in my head :)


This is cool. How do you calculate the speed of the train?

I'm assuming you are measuring how far a certain feature of the train takes to get from one point of the frame to the other. Similar to how police catch people speeding by measuring how long road markings take to pass in a given frame.


Sounds interesting id love to know how you do it. Is the speed calculated based on the noise of the wheels going over a track join? Then you can work out the length/speed based on the time it takes etc. Are the train types/images random or calculated some how?


There is a parameter which tells the program how many pixels there are per meter. From this you can compute the length after stitching. Using framerate, you can compute the speed in the same way.


I love this so much. Amazing use of creativity and tech chops. A++ would trainspot again.


Really cool. They look like model trains! :-)


Yeah! I've never seen trains so clean and modern looking in my life. They look like they came out of a futuristic toy set.


They're swiss trains, I guess we have enough wealth to make sure that our trains are clean. The interior is also almost always clean, except early morning on weekends (drunk people).

From time to time I see a train with graffiti on it, but usually they remove such things very fast.


That's Europe for you. Usable train infra is actually a thing.


It somewhat works but let's not exaggerate how well it works.


Maybe West Europe. Definitely not here in the east.


There are visitors from the east sometimes ;)

https://trains.jo-m.ch/#/trains/2483


Wow that's very cool. The resulting super flat images of the trains is really interesting -- like taking a photo from immense distance


When you say "right under my apartment", where exactly do you mean? Because I also have a train line going underground very near my apartment but it's not directly under. Could I capture such images? And I'm on the 4th floor.


I got confused at first too. What he means is "somewhere outside on the ground level while my apt is not on the ground level, there are trains passing by which I can see from my apt". You need line of sight.

This is not mysterious tech deriving images from sound traveling through the floor. You will be out of luck with your underground subway.


A fun fact is that there is a monorail station built in the middle of a residential building, so it might also be literal.

https://en.m.wikipedia.org/wiki/Liziba_station


If you have the schedule and the sound I'm sure you could make a cam with translucent ground. You should be able to figure out where it is, which model and how long it is. Who knows, maybe the orchestra of break sounds (it has many) is unique enough to spot which it is exactly.


Nice job! I would be really happy if I ever finished my own hobby projects this well.


Sharing this with SBB

I hope they notice (also makes me want to guess the location). I am in Zurich and I hope I don't find this spot


Reminds me of the 90's Lego computer game "Lego Loco"


I'm glad there's at least one other person in the world who remembers that game.


Some cool tech there too - client side sqlite db over wasm, neat! :)


Very neat. What are those power cars (triebkopf)? I thought sbb was only using proper locomotives (cabs at both ends) and EMUs (kiss, twindexx, …).



This is really cool! Thanks for creating and sharing!


Taking trainspotting to a new level, congratulations


This is so cool!


Curious to know how you manage to concentrate during waking hours on work and how you sleep peacefully?


There's a lot of trains in Switzerland so there's a lot of apartments by tracks. For the most part, the apartments are just built well.

Plus, the trains and tracks are very well maintained, so they create a lot less noise than you may be used to.


Very cool, how does the stitching work?


Wow this is cool as hell!!


I think this might be my favorite. Wonderful idea and execution!


How accurate is the speed and length measurement?


Very nice! Pleasantly surprised to see the SBB logo <3


A hybrid between area and line scan - block scan camera?


What’s up with the duplicated cars at the top?


The camera is pointing at the car. The train is moving past the car. The images of the whole train are made by stitching together lots of photos, all containing the bit of the train in front of the car as it moves past it.


From what I can see, they're not actually duplicated, I would suggest taking a closer look at the windows. But I do agree that it's quite hard to see the difference.

The trains look very clean from the outside. I do wonder how loud is it, to live so near the tracks.


They are also very clean from the inside :).

I also live right next to a train line in CH (that has exactly the same kind of rolling stock passing by as the ones captured by jo-m). These are modern commuter trains (no cargo and long distance trains), and are a lot less loud than you'd expect. A somewhat busy street nearby would be an order of magnitude more annoying.


This is really impressive. Very nice work


Cool project - thanks for sharing!


This is incredible. Congrats.


This is awesome. Really nice!


these pics look great. like some big model trail set catalog.


This is really sick!


This is so cool!!


This is amazing


Amazing photos


that is very neat, thanks for sharing!


So RAD !


That's amazing. Very cool.


wow that is so cool!


this is so cool :D


Cool! :D




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: