All Collections
FLOW - real-time monitoring
Use-case tutorials - How-to Series
Traffic jam detection - How-to series in FLOW Insights
Traffic jam detection - How-to series in FLOW Insights

Learn how to detect traffic congestion and get a wide range of metrics for deeper understanding of this phenomenon.

DataFromSky avatar
Written by DataFromSky
Updated over a week ago

Traffic Jams cost a lot of money. Traffic congestion costs Europe about 1% of its Gross Domestic Product (GDP) every year.* This value is even bigger at 3,5% for some Latin American countries.** Many stakeholders are looking to tackle this phenomenon but in order to do that we first need to understand it. FLOW is a universal detector that can use any IP camera to measure parameters that are necessary for examining traffic jams such as vehicle counts and category distribution, level of service, congestion length, stationary time, delay time, or vehicle speed. You can also use FLOW´s real-time data for adaptive traffic control which can reduce traffic congestion in junctions with traffic lights. In this article, we will show you how to detect traffic jams with various methods with a focus on the level of service measurement method. We will also show you how to get many other useful data types for detecting and examining traffic congestions.

If you are new to FLOW - read this article or watch our webinar to get familiar with the basics. Links to more FLOW-specific guides can be found below.

What will you learn from this article?

1. How to detect traffic jams with the level of service

2. How to measure the length of traffic congestion

3. What other types of traffic jam data are available with FLOW

Don't have FLOW Insights yet? Download it here for free!


First, we drag and drop a category filter to the canvas. We double-click it to open its menu and we tick boxes to select the following categories: car, light, heavy, and bus. We do not include motorcycles as counting them reduces the accuracy of the level of service due to them being able to go through traffic congestion with ease.

Level of Service

The best way to measure the traffic flow is to use the level of the service (LOS for short) group operator. There are many ways you can define the level of service but the definition we use is based on the passage times - meaning we use the time it takes a car to get from the start to an end of a road section to establish it. In our level of service operator, there are 6 levels and for each, you can assign the threshold which is the maximum passage time. The level of service is calculated as an average passage time from the pool of input trajectories.

In our example, we filter this pool of trajectories in 2 ways. We filter them based on categories and spatial properties of the trajectory. To filter the trajectories to only get the ones that have passed through the whole section and count only the trajectory parts in the area we want to monitor, we need to create a movement spatial filter. To define the movement we need to create 2 gates - one at the start and one at the end of the road section and then we need to connect them. Afterward, we drag the movement over to the canvas and connect it to the category filter.

More about the LOS can be found in the upcoming article dedicated to this group operator. You should adjust your passage times in the LOS element to accurately represent the length of the monitored area and the speeds inside of it. You can refer to guides such as this one*** to tell you what speeds fit to which level of service. You can calculate the speeds of the vehicles based on the length of the monitored section and the passage times or georegister your footage to get the speed data directly. You can also color-code the individual LOS levels inside a value widget.

To get the data from the level of service element we need to add a value widget. On the widget we select the “level of service” attribute and under time mode we choose time block - previous and set it to 1-minute blocks which makes the data more representative giving a bigger picture than a “now” time mode would. You can use the level of service value as input for adaptive traffic control. To communicate the data to the traffic controller you can use the open API to add a variety of data sinks.

Measuring the length of traffic congestion

One of the many ways we can measure traffic congestion length in FLOW is to use zones in conjunction with the expression widget. We will create a simple example with a couple of zones and scripting custom calculations in the expression widget. Based on the number of cars present in the zones, we can estimate the length of the traffic congestion. This simple script uses a simple concept - if a road segment (zone) fills up with a specified number of cars the script will detect it as congested. Depending on whether the zones are congested or not - the traffic congestion length is then calculated. So for example, if you have 2 zones that total up to 50 meters in length and your car limit is 12 cars per zone. If there are 15 cars in the first zone and 8 cars in the second zone then- the traffic jam length will be estimated to be 25 meters. In this case, by the first zone, we mean the zone farthest down the road. If both zones would be below 12 cars it would be 0 meters and if both zones would have at least 12 cars then it would be 50 meters.

The script for this example would like this:

var z1 = $1"ZONE 2 - Value";
var z2 = $2"ZONE 1 - Value";
var zoneLength = 50;
var minVehicles = 12;

function congestionLength() {
if (z2 >= minVehicles) { return zoneLength; }
else if (z1 >= minVehicles) { return zoneLength / 2.0; }
else { return 0.0; }

Make sure that you have the zones in the correct order. The first zone in the script should be the one with the highest number and the one the cars pass through first. The scripts evaluate the thresholds in order, checking whether the condition is met. If it is not, it moves to the next road segment and the next one which makes the congestion detected smaller and smaller.

Getting additional traffic jam data

As mentioned in the introduction, FLOW can give you many more useful data types for examining traffic jams. You can get a raw number of cars passing through a road section, car categories, or the vehicle speeds that you can get if you georegister the footage. You could also measure passage time directly without converting it to the level of service or use expression scripting to calculate the delay cars incurred due to the congestion. All these metrics can be filtered in time with the individual widget's settings. You can select from a variety of time modes: now, time blocks - current and previous, floating time windows, or whole history. With speeds, level of service, and passage times it is best to use 1-minute time blocks for representative and current data. To communicate all the results of the analytics that we have set up we can add various sinks. API data sinks together with I/O interfaces allow easy integration of FLOW with other systems.


Now you know how to set up traffic jam detectors and what factors to consider when doing so. This knowledge can be used to inform drivers about congestion ahead to decrease their speed or redirect them by overhead traffic message boards to a less busy route. Why not integrate FLOW with traffic lights control, so that the traffic lights cycle adapts to increase the green-light duration for specific directions as required? Contact us to learn more!

FLOW is the ideal solution for real-time traffic monitoring and it's available on a variety of devices. We offer 2 IoT edge processing devices. The TrafficCamera can be used on simpler scenes such as straight two-way roads. Then there is the TrafficEmbedded for detection on more complex intersections with a single camera or multiple simpler scenes with up to 6 cameras. Lastly, we offer a centralized solution the TrafficEnterprise that can work with an unlimited number of cameras based on the processing power of the server. FLOW works with any IP camera. With FLOW you can get a range of traffic congestion metrics such as level of service, speeds or traffic flow counts to help you understand them better but you can also measure traffic violations like wrong-way driving or stop sign running at the same time.

We hope that you have enjoyed this guide.

To browse more articles about FLOW click here.

Do you have any questions? Do not hesitate to contact us here.

• Do you have more questions? Contact us!

• Follow us on Linkedin.

• Learn more about FLOW.

• Check out our Webinars.

• Visit our homepage to view products and news.

Thank you for your interest! Have a great day!

Let the traffic flow - with FLOW!


Did this answer your question?