0

Measuring traffic flow remotely
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Measuring traffic flow remotely

by mojo on Mon Jan 24, 2011 1:59 pm

We don't collect enough traffic flow data in the UK to be useful. You sometimes get warnings of congestion on major roads but never for main roads in town etc. The sensors to measure traffic flow in those areas simply do not exist, so we should make some.

The idea is to build a sensor that can measure how fast traffic is moving and how many cars per minute pass. This info will then be made available on the web (twitter, some kind of dedicated site) and made available for use in sat-navs and the like. Integration with Google Maps is obviously a good start. The question is how to build such a sensor.

It has to be able to operate remotely, e.g. from a window overlooking the road. An embedded solution would be best to keep costs and energy consumption down, similar to the Tweet-a-Watt. I was thinking along the lines of using a web camera and some image processing but there has to be an easier way.

My best idea so far is to use a PIR sensor. They normally have a lens that covers a wide area but if you remove that it might be possible to tune it to see cars passing by. Other ideas... Laser range finder maybe? You can get ones that work though glass. Some kind of simple radar perhaps? You can even get camera modules with serial output and if working with IR it might be possible to simply watch for changes at a specific pixel. It does not need to be 100% accurate, just tell you if traffic is flowing, slow or queued up.

mojo
 
Posts: 136
Joined: Mon Jan 21, 2008 5:04 pm

Re: Measuring traffic flow remotely

by stinkbutt on Mon Jan 24, 2011 2:37 pm

My brother works in the field of traffic data analysis, so I'll recommend you use their sensors, which are strips you lay out on the road. Cars go over them, and that tells you when a car's passed. At least, it tells you when a pair of wheels have passed, you divide that number by two and you get the number of cars that have passed. The amount of time between the two pairs of wheels passing should also tell you the speed at which the car is traveling - You'd just need to estimate the wheelbase.

I don't know exactly how they implement it, but I'd guess they use large FSRs, possibly split into three or four sections so you can differentiate between the different lanes. If you're polling fast enough you should be able to tell the difference between the front & then back wheels of a car passing and the back wheels of one car & the front wheels of another, particularly if they exert different amounts of pressure on the FSR.

Oh, and if you put two of them, right next to each other, (say, spaced by only 3 or 4 feet or so,) you get another way to discriminate between cars, as you'll never see two cars on top of them at the same time, no matter how badly the trailing car is tailgating.
Red M&M, Blue M&M: They all wind up the same color

stinkbutt
 
Posts: 593
Joined: Wed Feb 17, 2010 2:40 am

Re: Measuring traffic flow remotely

by mojo on Mon Jan 24, 2011 4:14 pm

The problem with on-road sensors is that you can't just install them, you would need permission from the local authority. The goal is to come up with something that can measure passively from a distance, so that the user can have the sensor on their property next to the road itself.

I was also thinking of some kind of audio analysis but it might be tricky to deal with slow moving traffic. Automatic level setting will be a challenge too.

mojo
 
Posts: 136
Joined: Mon Jan 21, 2008 5:04 pm

Re: Measuring traffic flow remotely

by stinkbutt on Mon Jan 24, 2011 4:33 pm

mojo wrote:The problem with on-road sensors is that you can't just install them, you would need permission from the local authority. The goal is to come up with something that can measure passively from a distance, so that the user can have the sensor on their property next to the road itself.

I was also thinking of some kind of audio analysis but it might be tricky to deal with slow moving traffic. Automatic level setting will be a challenge too.


Unless you're putting the sensor on private property, you're going to need permission from the locality anyway, unless you're inclined to put a device with blinking lights up in a high-traffic area, but that usually doesn't work out too well for the coyote.
Red M&M, Blue M&M: They all wind up the same color

stinkbutt
 
Posts: 593
Joined: Wed Feb 17, 2010 2:40 am

Re: Measuring traffic flow remotely

by mojo on Mon Jan 24, 2011 7:13 pm

You misunderstand I think. The idea is that anyone who is interested can set the system up in their own home and monitor traffic flow outside. Similar to the way anyone can set up a weather station and upload the data to sites like Weather Underground.

Japanese cities have more sensors and the local government gathers much more data. Plus they use data from cell phones to estimate traffic flow. It works really well.

mojo
 
Posts: 136
Joined: Mon Jan 21, 2008 5:04 pm

Re: Measuring traffic flow remotely

by stinkbutt on Mon Jan 24, 2011 7:35 pm

In that case there are a suite of ultrasonic range sensors that might serve your needs:

http://www.acroname.com/robotics/info/a ... sharp.html
Red M&M, Blue M&M: They all wind up the same color

stinkbutt
 
Posts: 593
Joined: Wed Feb 17, 2010 2:40 am

Re: Measuring traffic flow remotely

by zener on Mon Jan 24, 2011 7:49 pm

I would think machine vision with a camera would be the way to go. Don't know how hard it would be to program though. I don't think PIR will work and ultrasonic has issues also.
Last edited by zener on Tue Jan 25, 2011 12:39 am, edited 1 time in total.

zener
 
Posts: 4558
Joined: Sat Feb 21, 2009 2:38 am

Re: Measuring traffic flow remotely

by franklin97355 on Mon Jan 24, 2011 9:49 pm

Stinkbutt, those are IR sensors you linked to. I'm for video since everything else has distance limits that may not be possible from private property.

franklin97355
 
Posts: 21488
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Measuring traffic flow remotely

by dda on Mon Jan 24, 2011 10:44 pm

I've had success using processing and a webcam to quantify movement based on the code from here: http://www.learningprocessing.com/examp ... ple-16-13/

Video with processing is a little problematic, depending on which platform you are on. For me I've got it working after installing winvdig v1.01 (not the most recent release) or by using the GSVideo library instead of the processing.video library though the former method was more stable.
dda
 
Posts: 6
Joined: Mon Jan 24, 2011 10:36 pm

Re: Measuring traffic flow remotely

by stinkbutt on Tue Jan 25, 2011 1:17 am

franklin97355 wrote:Stinkbutt, those are IR sensors you linked to. I'm for video since everything else has distance limits that may not be possible from private property.


Tomayto tomahto. It's a sensor, it reports movement, first-order approximation is any movement = 1 car, no movement = 0 cars, and the duration of movement can be proportional to it's velocity, (plus or minus a fair amount of error.)

That's the first level of data-logging. I'd get that working first, and then worry about adding more sophisticated sensors and datalogging. In fact, I might not ever remove that first-order system. It might provide an excellent complement to the next sensor I add, or help in calibration, if nothing else.
Red M&M, Blue M&M: They all wind up the same color

stinkbutt
 
Posts: 593
Joined: Wed Feb 17, 2010 2:40 am

Re: Measuring traffic flow remotely

by mojo on Tue Jan 25, 2011 1:10 pm

dda wrote:I've had success using processing and a webcam to quantify movement based on the code from here: http://www.learningprocessing.com/examp ... ple-16-13/

Video with processing is a little problematic, depending on which platform you are on. For me I've got it working after installing winvdig v1.01 (not the most recent release) or by using the GSVideo library instead of the processing.video library though the former method was more stable.


Thanks, that is an excellent link you provided. I was looking at Intel's image processing libraries but Processing looks a lot easier. I have a Sheevaplug I might try it out on. Certainly a webcam based system would be versatile and easy to update, plus you get all the networking stuff for free as well. By the time you have added sensors and ethernet to an embedded system or Arduino it would most likely be a similar order of magnitude in cost too.

Another advantage of using a webcam is that it could be dual purpose. Monitoring both lanes at once, plus maybe the availability of car parking spaces. Unfortunately image processing is not something I know much about but this might be a good time to learn. It looks like the tools are finally getting mature enough to work with.

mojo
 
Posts: 136
Joined: Mon Jan 21, 2008 5:04 pm

Re: Measuring traffic flow remotely

by Ramjet1 on Wed Jan 26, 2011 5:17 pm

Fiscal makes a wireless IP camera that has a built in server so it can push. The configuration allows you to set a motion alarm and then decide what to do when it trips. You could likely hack this easily to do what you want. They even have narrow angle lens options and ir illumination which might be helpful to your project.
Last edited by Ramjet1 on Wed Jan 26, 2011 5:20 pm, edited 1 time in total.
Ramjet1
 
Posts: 70
Joined: Sun Jan 23, 2011 10:52 am

Re: Measuring traffic flow remotely

by Ramjet1 on Wed Jan 26, 2011 5:19 pm

I hate my IPad. Ok, I said it. Steve Jobs, come and get me - gimme a unix term anyday. This thing just Changes what you type. The camera brand I was talking about in the previous post was FOSCAM.
Ramjet1
 
Posts: 70
Joined: Sun Jan 23, 2011 10:52 am

Re: Measuring traffic flow remotely

by mojo on Wed Jan 26, 2011 7:06 pm

Some kind of hackable device would be nice. I was wondering if an AVR could do it given some very clever programming. You can get camera modules with an SPI interface on eBay, often paired with a colour LCD screen as if they come from a mobile phone. The demo app just copies the image from the camera to the LCD but manages to hit 30FPS at some unknown load on the AVR.

Since we are only talking about some really basic motion detection from a fixed camera an AVR might be able to do it. I would put it facing the road square on so that the cars only move horizontally and then just pick one single scanline to work with. Maybe convert the camera to IR, just to simplify the processing. Cars must have their lights on at night of course.

Another advantage of this method is that calibration is easy because you can see exactly what the webcam can see on the LCD. If simple PIRs were used it might be tricky to aim the device at the road so that it counted reliably.

mojo
 
Posts: 136
Joined: Mon Jan 21, 2008 5:04 pm

Please be positive and constructive with your questions and comments.