DIY Photography

Your one stop shop for everything photo-video

  • News
  • Inspiration
  • Reviews
  • Tutorials
  • DIY
  • Gear
Search

Submit A Story

This Raspberry Pi project stitches together images of passing trains

May 12, 2023 by John Aldred 3 Comments

  • Share
  • Tweet
  • Flipboard
  • WhatsApp

This is quite a fascinating concept. Based around a Raspberry Pi, it takes photographs – lots of photographs – of trains passing through a station and then stitches them together to create a single long composite of the entire locomotive. It works on a similar principle to slit-scan photography, which is often used for capturing fast-moving subjects passing a fixed point – like horses finishing a race.

Slit-scan photography in the digital age typically shoots a stream of 1-pixel wide vertical slices. This is required if you’re trying to the capture speed between multiple moving objects, such as in a horse race. But in this project by “jo-m“, the “slits” are a little wider, which means fewer images are required in order to composite the final result together. But for applications such as this, it’s all that’s needed.

The project is called Trainbot, and it lives looking at a single piece of track from jo-m’s apartment, he writes. Running on a Raspberry Pi, a computer vision app spots when there’s a train in the view and records images of it as it moves past the fixed view of the track. It then stitches the photo segments together in order to try and create a super long panoramic image of the entire train. It even uploads them to the web on a website he’s nicknamed Onlytrains.

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.

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.

The images from jo-m’s creation are quite intriguing with the repeated background pattern from each “slit” of the images. The width of the slits is variable based on the speed of the train. Slower-moving trains have a narrower slit while faster trains have a wider one. This allows jo-m to not only calculate the length of the train but also its speed.

It’s a pretty niche project, although I’m sure there are many other applications that this concept could be applied to. If you want to have a go at making your own, head over to GitHub where jo-m has posted all of the code for you to check out under an MIT license. The author has a fairly lengthy to-do list on the project page, so perhaps there’s something there you might be able to help with.

To see jo-m’s complete archive of train photos so far, which seems to get new trains added every 5-10 minutes or so, be sure to head over to his “Onlytrains” website.

[via Hackster.io]

FIND THIS INTERESTING? SHARE IT WITH YOUR FRIENDS!

  • Share
  • Tweet
  • Flipboard
  • WhatsApp

Related posts:

Strike four: Huawei caught passing DSLR images as smartphone camera photos again You really can’t hear trains until they’re almost right on top of you Default ThumbnailThe Best DIY Project Of Them All – Your Project Nvidia trains AI to remove noise and watermarks by looking only at corrupted photos

Filed Under: DIY Tagged With: computer vision, DIY, Raspberry Pi, slit-scan, trains

John Aldred: from diyphotography.net

About John Aldred

John Aldred is a photographer with over 20 years of experience in the portrait and commercial worlds. He is based in Scotland and has been an early adopter - and occasional beta tester - of almost every digital imaging technology in that time. As well as his creative visual work, John uses 3D printing, electronics and programming to create his own photography and filmmaking tools and consults for a number of brands across the industry.

« TikToker hides tiny camera on suitcase to see what happens at the airport
Florida photographer offers gender affirming portraits to trans community »

Submit A Story

Get our FREE Lighting Book

DIYP lighting book cover

* download requires newsletter signup
DIYPhotography

Recent Comments

Free Resources

Advanced lighting book

Recent Posts

  • Here’s a bullet time video booth you can build yourself
  • Ricoh has discontinued the HD PENTAX-DA 21mm F3.2AL Limited silver lens
  • This “stellar flower” unravels the twilight’s evolution in 360 degrees
  • Strobes vs Continuous LEDs – Which is right for you?
  • Wave goodbye to Apple’s My Photo Stream next month

Udi Tirosh: from diyphotography.netUdi Tirosh is an entrepreneur, photography inventor, journalist, educator, and writer based in Israel. With over 25 years of experience in the photo-video industry, Udi has built and sold several photography-related brands. Udi has a double degree in mass media communications and computer science.

Alex Baker: from diyphotography.netAlex Baker is a portrait and lifestyle driven photographer based in Valencia, Spain. She works on a range of projects from commercial to fine art and has had work featured in publications such as The Daily Mail, Conde Nast Traveller and El Mundo, and has exhibited work across Europe

David Williams: from diyphotography.netDave Williams is an accomplished travel photographer, writer, and best-selling author from the UK. He is also a photography educator and published Aurora expert. Dave has traveled extensively in recent years, capturing stunning images from around the world in a modified van. His work has been featured in various publications and he has worked with notable brands such as Skoda, EE, Boeing, Huawei, Microsoft, BMW, Conde Nast, Electronic Arts, Discovery, BBC, The Guardian, ESPN, NBC, and many others.

John Aldred: from diyphotography.netJohn Aldred is a photographer with over 20 years of experience in the portrait and commercial worlds. He is based in Scotland and has been an early adopter - and occasional beta tester - of almost every digital imaging technology in that time. As well as his creative visual work, John uses 3D printing, electronics and programming to create his own photography and filmmaking tools and consults for a number of brands across the industry.

Dunja Djudjic: from diyphotography.netDunja Djudjic is a multi-talented artist based in Novi Sad, Serbia. With 15 years of experience as a photographer, she specializes in capturing the beauty of nature, travel, and fine art. In addition to her photography, Dunja also expresses her creativity through writing, embroidery, and jewelry making.

Copyright © DIYPhotography 2006 - 2023 | About | Contact | Advertise | Write for DIYP | Full Disclosure | Privacy Policy