[Douglas] hometown Goshen, Indiana takes the state’s motto ‘The Crossroads of America’ seriously, at least when it comes to trains. The city is the meeting point of three heavily frequented railroad tracks that cross near the center of town, resulting in a car-traffic nightmare. When everybody agrees that a situation is bad, it is time to quantify exactly how bad it is. [Douglas] stepped up for this task and delivered.
He describes himself as cheap, and the gear he used to analyze the railroad traffic at a crossing visible from his home certainly fits the bill: a decades-old webcam, a scratched telephoto lens and a laptop with a damaged hinge.
With the hardware in place, the next step was to write the software to count and time passing trains. Doing this in stable conditions with reasonable equipment would pose no problem to any modern image processing library, but challenged with variable lighting and poor image quality, [Douglas] needed another solution.
Instead of looking for actual trains, [Douglas] decided to watch the crossing signals. His program crops the webcam image and then compares the average brightness of the left and right halves to detect blinking. This rudimentary solution is robust enough to handle low light conditions as well as morning glare and passing cars.
The rest is verifying the data, making it fit for processing, and then combining it with publicly available data on car traffic at the affected intersections to estimate impact. The next council meeting will find [Douglas] well prepared. Traffic issues are a great field for citizen science as shown in Stuttgart earlier. If the idea of bolting old lenses to webcams intrigues you, we got you covered as well.
31 thoughts on “Trainspotting With Junk, For Science”
Ugh, trains. In the town I live in, we have problems with trains carrying coal uncovered through town.
funny, i read the headline and thought “it cant be as bad as Elkhart” clicked on the like and its Elkhart.
You from around here? If so, you know how bad it really is. And, sorry for your luck. Lol.
Mishawaka / South Bend are a little better, but yeah, Elkhart/Goshen is horrible.
Never thought I’d see our area in a post on here except for MRRF related stuff though.
‘Never thought I’d see our area in a post on here except for MRRF related stuff though.’
And only, what, a tad less than 5 months until the next MRRF…. (Don’t judge. MRRF is about the most fun I get in a year… Yeah, I know, sad.)
Decades old webcam.
What/make model please…
This exactly. A pre-1998 webcam? Really??
Well, 15 or 16 years old. Close enough. Old enough I’m surprised it doesn’t run in steam. So I missed guesstimated a bit. Sorry about that. My bad.
Logitech. Windows says it’s a ‘QuikcamPro 4000’, which I got in 2002 or 2003. 640 x 480, which it will do, and 30fps, which it won’t Locks up every half hour to an hour at that frame rate, no matter what machine I plug it into. I’m running it at 15fps. Got it from my ‘well, it sort-a works so I’ll hang onto it and find something to use it for someday’ pile. Come to think of it, that’s the same pile where the lens and the laptop came from. :P
i like the idea of looking for the alternating flashing lights to get a reliable detection. nice hack!
Thanks! To be honest, nothing else worked in ALL conditions, night, day, bright sunlight, and the worst, partly cloudy days where the suns on it one second and it’s in shadow the next. The darn webcam won’t adjust anymore, when it’s put in ‘auto everything’ mode it jumps to ‘it’s too damn dark and I need to brighten it up a bunch’. Which helps not at all.
The idea is good, but in some areas you have the damn things sometimes suddenly go off without a train actually passing in my experience.
Hope you don’t have that problem there.
Clever way to count the number of times and length the train gates are down!
Where I am we have relatively few at-grade crossings, and the ones we do have are almost all commuter trains which take just a minute or two to pass, I take for granted waiting for trains to pass. Doug’s data says that the crossing he observes has a train pass every 15-20 minutes on average, with some pretty significant waits, possibly impacting emergency services as well as being a nuisance.
Seems like he’s also concerned w/ the noise level increasing in nearby residential areas as a result of a structures in an overpass reflecting the train sounds and horns. I’d be looking at a way to record that now and get some hard numbers before the construction is completed so you can argue for limits that must be adhered to post construction.
Maybe someone closer to the tracks would be willing to host a recording/listening device on their property and WiFi as a way to record data? Would be a good place to use a few cheap audio parts and an ESP8266–I did something similar to count duration and frequency of hammering noise in our office building awhile back when our company was running some destructive lifecycle tests and I wanted to give the mechanical guys some grief over the noise pollution generated.
Old webcam – check, various alternative lenses – check, old laptop – check, skills to get a working system – doubtful but there are ways around that, so – a project! It won’t be useful like the one in the article but it ought to be fun.
What I really don’t understand though is the fact that there are plenty of road bridges in satellite pictures of Goshen, but they are only over rivers, not railroad tracks.
We’ve noticed that too. Weird, huh? I place it in the ‘what the hell were they thinking’ category, bu I’m not sure the city officials I’m dealing with would agree.
Thank you, I thought it was a bit clever myself, but my wife tells me I’m wrong a lot about that sort of thing. Lol.
You’re idea for measuring the noise is a great one. I’m going to have to see about doing that. But I really am cheap. Being on disability’ll do that to a guy. Maybe I have something I could use on that ‘Stuff the wife is wrong about and I need to keep’ pile. I’ll go take a look…
Not sure how that last message wound up on it’s own, but it was in response to ethanboston’s message above.
Clever hack, comparing the two lights.
Unfortunately we’ve gone through this where I live — small town, 5 crossings, many delays — and it turns out the city is helpless because train traffic is the sole province of the FRA https://en.wikipedia.org/wiki/Federal_Railroad_Administration. There’s absolutely nothing anyone local can do to change their behavior and attitude, which is “screw you, trains win”.
Very valid point. I always say if your dealing with the city you have your work cut out for you. If your dealing with the city AND the state, it’s almost impossible to get anything done. If your dealing with the city, the state AND the railroad, it’s pretty hopeless.
A couple of days ago we had a train stop dead on the tracks, blocking that line that turns to the south and there is no way around until the new overpass is done, for two hours. The reason? The railroad said it needed a crew change and it took that long to get another crew there. Those guys wont pull it forward an inch to unblock a crossing when stuff like that happens. Not. One. Inch.
There are state laws about blocking crossings more than a set amount of time, and the sheriff’s department has been giving the railroad tickets for doing so. All it does is piss the railroad off more.
I would like to add something to this: This project has caused a bit of a stir here in this town, with everyone coming down into one of two camps. One is the ‘more trains means the economy is booming and that’s great’, which is true, while the other is the ‘all these trains suck’ camp. I’m a member of both camps, and I’m also the only one in town, apparently, who like FACTS, cold hard data, to back up what I’m talking about. The part of the response I like the best is when a student at a local school informed me that some of the students are using my data for their data science class to practice making up some some data visualizations. Love it!
Oh, better not neglect this: Thanks for the write up, Christian! Heck of a nice job! :D
Perhaps a silly question, but have you thought about monitoring the railroad ATCS signals over the air and logging that data along side your visual data?
I realize you said you prefer doing things on the cheap, and perhaps a software defined radio setup may not qualify, but seems like it would be a nice wealth of data to add in. The trains themselves broadcast their IDs, location, and speed data. You can likely also pickup the switch track commands from dispatch.
Not a silly question at all! Never even thought about it.
I do have a SDR dongle. I usually have it running SDRSharp with the scanner addon, listening to police and fire. I will definitely look into your suggestion. Thank You!
This is looking very interesting. Been digging into it and the railroad has one of the transmitter stations 500 feet from my house!
Drawback is I’d have to run another machine 24/7. There is no way that old laptop will do both at once. So there is that…
Dude, good job.
As a software guy, you either have brass balls or are a bit bonkers for using a windoze platform for a system that must run for more than a few hours. May we respectfully suggest Linux?
‘have brass balls or are a bit bonkers’
The two are not mutually exclusive. :P
‘May we respectfully suggest Linux?’
um, uh, point taken. (he says, shrugging his shoulders and staring at his shoes.)
Great build details.
Well, the laptop finally decided it had enough. May it rest in peace.
This project, or at least the data collection part of it is done, at least for now. Maybe I’ll try to find another machine to run it on one of these day, and run it for another month later in the winter. The web site will stay up, and all the data is still available there. And I still intend to crunch the numbers and get some more looks at the data from different views.
Over all, I have to say it was worth the trouble, and I’ve certainly given this city something to think about, and hard numbers to back it up. So it was well worth it.
Douglas! I used to live in Goshen back in 1999-2002. I moved back to South Texas because fam and the WINTERS…Grrrrr! I used to live on 7th Street by the tracks and it sucked! Love the hack!
Yeah, our winter weather sucks sometimes, alright. But it is what it is, right?
WTG on moving away from our winters. We talk about moving south, but that’s all it is so far. Talk.
The train program is back up again, and my son is ‘posed to be bringing me his spare laptop, so it should stay up from then on. I’m also working on adding a new page to the website that will display what’s going on in near real time. :)
Please be kind and respectful to help make the comments section excellent. (Comment Policy)