WeCount Traffic Sensors

By David Crookes. Posted

It’s important for planners to understand how well a city’s streets are being used. They need to know how many vehicles are being driven past a particular point, what type are they, and how fast are they going in order to learn more about traffic flow.

Rather than have someone stand on the pavement and count manually, however, planners use technology. Some expensive solutions are limited to a narrow set of locations such as highways but, in the case of the WeCount project, an affordable solution has been found with the help of Raspberry Pi.

WeCount invites members of the public to place a sensor in their homes, peering out of the window, allowing live traffic maps of neighbourhoods to be built. Engineering and emissions expert Kris Vanherle says involving citizens results in greater support for future traffic management implementation. “Data collection also becomes more affordable for local authorities and citizens can even help interpret the data,” he adds.

In one instance, a spike in traffic was due to a temporary road block and this was reported by one of the citizens involved. WeCount is now being used in six European cities – Madrid, Barcelona, Dublin, Cardiff, Ljubljana, and Leuven – and the data collected is uploaded to the cloud so that it can be used within initiatives related to air pollution, safety, active travel, noise, and speed.

Creating the sensors

The sensors were originally built using Raspberry Pi 3B+ computers, but the production units make use of Raspberry Pi 3A+. “These already provide the required processing power and memory and we found we did not need the extra ports of its big brother after the initial development phase,” explains Dr Péter I. Pápics, a researcher at Transport & Mobility Leuven.

     A Raspberry Pi 3A+ is fitted inside each case and connected to the WiFi within each volunteer resident’s home

He says the project uses standard Python libraries combined with OpenCV for the image processing and object tracking algorithms. “We need to maintain the necessary frame rate, which is around 30fps, to capture even the fastest cars over at least a few frames,” he continues.

“So we are using the most simple background extraction and contour detection methods to find moving objects on each frame and then a tracking algorithm to identify and track them over their visibility period stretching across a set of consecutive frames.”

A Raspberry Pi operates as a wireless hotspot and it provides a simple user interface so that camera angles can be fine-tuned. “After ten minutes, the hotspot mode is automatically disabled and Raspberry Pi attempts to connect to the local WiFi,” says Péter.

“If successful, the actual traffic monitoring script is activated and various properties of the detected objects are periodically transmitted to our services where data processing, classification, and aggregation services produce the data that’s available on our website or via the public API.”

Amassing the data

The cities involved are enthusiastic. Prof Enda Hayes, from the University of the West of England in Bristol, says he was keen to include Cardiff because it has immeasurable potential for more active travel. “The city’s inhabitants are very car dependent and the city experiences a large influx of daily commuters with the majority of these journeys – some 80 percent – by car,” he says.

Kris Vanherle and colleague Giovanni Maccani work on the production of a sensor device which is housed inside an expensive casing made by TEKO

The sensor also allows for the counting of pedestrians and cyclists. “I delivered one to a volunteer who lived on a dead-end street and found out pedestrians and cyclists were using the street as an active travel rat-run to get to a local train station. He wanted to convert the street into a Low Traffic Neighbourhood.”

Kris says the data also allows researchers to observe how traffic behaves if lanes are closed on adjacent streets and it’s been used to increase compliance to speed limits. “WeCount empowers citizens and anyone who wants to join can do because the platform is open,” he says. 

From The MagPi store