Book a free call

How Computer Vision Measures Real-Time Traffic Flow

Computer vision turns road cameras into live traffic counts, speeds and queue lengths. Here is how the pipeline works and what it takes to run one.

Hertiv engineering teamReviewed by a senior engineer
7 min read
How Computer Vision Measures Real-Time Traffic Flow
On this page

Short answer

Real-time traffic flow analysis uses computer vision to watch road cameras and turn video into live numbers: how many vehicles pass, how fast they move, how long queues grow and where congestion forms. A camera feed runs through detection and tracking models, and the results feed signal controllers, dashboards and incident alerts within seconds.

What is real-time traffic flow analysis?

Real-time traffic flow analysis is the use of computer vision to measure how vehicles move through a road network as it happens, using camera feeds rather than road sensors buried in the asphalt. It turns each video frame into counts, speeds and queue lengths that a traffic team can act on within seconds.

The basic unit is the vehicle passing a point. Cameras mounted on poles, gantries or buildings watch a stretch of road, and software counts each vehicle, notes its type and lane, and tracks it until it leaves the frame. That stream of positions becomes flow rate, average speed and density for each lane and direction.

Unlike inductive loops or radar, cameras see the whole scene at once. One camera can cover several lanes, spot a stopped vehicle, and tell a bus from a lorry, which is why cities use vision where they need detail rather than a single number. The idea is close to what computer vision is, applied to a road instead of a room.

What does a traffic flow system measure?

A traffic flow system reports a small set of numbers for each lane or road section, updated every few seconds. Each number answers a different question, from how busy the road is to how long drivers are waiting.

MetricWhat it meansWhy it matters
Flow rateVehicles per hour past a pointShows demand and whether the road is near capacity
Average speedMean speed across a sectionFalls when congestion builds
DensityVehicles per kilometre of laneHigh density means slow, stop-start traffic
Queue lengthVehicles waiting at a signal or blockageDrives signal timing
HeadwayTime gap between vehiclesShort gaps mean the road is near capacity
OccupancyShare of time a detection zone is coveredA simple proxy for congestion

Flow and speed together tell the story. A road can carry many vehicles at high speed, or few vehicles at low speed, and both look quiet in a single number. The pair shows whether traffic is free-flowing, busy but moving, or jammed, which is the same logic used in vehicle detection on roads.

How does computer vision read a road?

The pipeline has four stages. First, the camera captures video, usually at 10 to 30 frames per second, and the image is cleaned up for glare, rain or low light. Second, a detection model finds vehicles in each frame and draws a box around each one, with a type such as car, bus or lorry.

Third, a tracker links the boxes across frames so the same vehicle keeps one identity as it moves through the scene. Fourth, the system applies counting rules: a virtual line across the road counts each vehicle that crosses it, and a zone measures how long vehicles spend inside it, which gives speed and delay.

Most teams use ready-made detection models trained on road scenes, such as YOLO or similar detectors, and fine-tune them on their own cameras. The model choice matters less than the camera position: a high, clear view with little overlap between vehicles gives far better counts than a low camera at a busy junction. The build steps are covered in how to implement computer vision.

How do teams turn video into traffic numbers?

Turning a camera feed into trusted traffic numbers takes a set of steps, each of which can be checked on its own. The usual sequence is:

  1. Pick the measurement points. Choose where counts and speeds are needed, such as junction approaches, mid-block sections and exit lanes.
  2. Mount and aim the cameras. Fix each camera high enough to see all lanes, and record its position and field of view.
  3. Calibrate the scene. Mark the counting lines and zones on the image, and set the real-world distances used for speed.
  4. Train or tune the detector. Check detection on local footage, including night, rain and rush hour, before trusting the counts.
  5. Run tracking and counting. Link detections across frames and apply the counting rules for each lane and direction.
  6. Validate against a manual count. Compare one hour of camera counts with a hand count, and fix gaps above a few percent.
  7. Feed the results onward. Send the numbers to signal controllers, dashboards or incident alerts every few seconds.

Where is traffic flow analysis used?

The most common use is signal timing. When a controller knows the queue on each approach, it can give more green time to the busiest approach and less to an empty one, which cuts waiting time across the junction.

Cities also use it to spot incidents. A sudden drop in speed with a rising queue usually means a breakdown or a crash, and an alert can reach a control room minutes before the first phone call. Planners use the same data over months to decide where to add a lane, change a junction or retime a corridor.

Road operators use live flow data to set variable speed limits and open hard shoulders, and to warn drivers through signs and apps. The same counts feed air quality models, since slow, stop-start traffic produces more exhaust than free-flowing traffic at the same volume. Self-driving systems read the same road in a different way, as described in computer vision in autonomous vehicles.

Example (hypothetical): a city retimes one junction

Example (hypothetical): a city traffic team studies a four-way junction that carries 2,400 vehicles in the morning peak hour, from 07:00 to 08:00. Cameras count 480 vehicles in the first 15 minutes, 560 in the second, 640 in the third and 720 in the fourth, which adds up to 2,400.

The counts show the north approach carries the most traffic, so the team extends its green time from 30 to 42 seconds in each 90-second cycle. Average delay per vehicle falls from 45 to 28 seconds, a saving of 17 seconds each. Across 2,400 vehicles that is 40,800 seconds, or about 11 hours of waiting removed in a single peak hour.

The team keeps the new timing for two weeks and checks the counts each morning. The delay saving holds, and queues on the other three approaches grow by only a few seconds each, so the change stays.

What are the common mistakes?

The most common mistakes in traffic flow analysis are trusting counts that were never validated, placing cameras where vehicles hide each other, and treating one quiet hour as proof the system works.

  • Skipping validation. A detector that counts 95% of vehicles in daylight may count far fewer at night or in rain, so check every condition.
  • Mounting cameras too low. A low camera sees the nearest lane and hides the rest, which undercounts the road.
  • Counting across a junction. Vehicles turning, stopping and overlapping inside a junction are hard to track, so count on straight sections.
  • Ignoring the bus and lorry split. A road full of buses moves fewer vehicles per hour than a road full of cars, so record vehicle types.
  • Trusting speed from one camera. Speed needs a known distance, so use two points or a calibrated zone, not a single view.

What limits real-time traffic flow analysis?

Weather and light are the main limits. Heavy rain, fog, glare and darkness all cut detection accuracy, and a camera blinded by a low sun can miss a whole lane. Teams deal with this by using cameras with good low-light performance, cleaning lenses on a schedule, and flagging periods where counts are unreliable.

Privacy is a second limit. Cameras that read plates or faces raise legal questions, so most traffic systems blur plates, store no video longer than needed, and publish only aggregate numbers. Cost is a third limit: cameras, network links and processing add up, which is why teams start with the busiest junctions and expand from there.

Occlusion is the hardest technical limit. When a lorry hides the cars behind it, no detector can count what it cannot see. High cameras, overlapping views from two angles, and short gaps between measurement points all help, but some undercounting at the busiest times is normal. A partner for computer vision development can help set up the cameras and the pipeline so the counts stay honest.

Key takeaways

  • Traffic flow analysis turns camera video into live counts, speeds and queue lengths
  • Flow and speed together show whether a road is free, busy or jammed
  • Count on straight sections with high cameras, and validate against a hand count
  • Live flow data drives signal timing, incident alerts and variable speed limits
  • Rain, glare and occlusion cut accuracy, so flag unreliable periods rather than trusting them

Frequently asked questions

How accurate is camera-based traffic counting?

A well-placed camera system usually counts 90 to 98 percent of vehicles in daylight, and less at night or in heavy rain. Accuracy is checked by comparing camera counts with a manual count for the same hour, and teams fix camera position or detector settings when the gap is more than a few percent.

Do traffic cameras read number plates?

Some systems do, but most traffic flow systems do not need plates. They count vehicles and measure speed from anonymous boxes, and plates are blurred or never stored. Plate reading is a separate function used for enforcement or tolling, with its own legal basis.

How fast is real-time traffic data?

Most systems update counts and speeds every few seconds, and signal controllers can react within one cycle, usually 60 to 120 seconds. Incident alerts reach a control room in under a minute when a speed drop and queue rise are detected together.

What is the difference between flow and density?

Flow is how many vehicles pass a point in an hour, while density is how many vehicles occupy a stretch of road at one moment. A road can have high flow with low density when vehicles move fast, or low flow with high density when traffic is jammed.

Can one camera cover a whole junction?

One camera can cover several lanes, but a whole junction usually needs two or more cameras, since turning vehicles overlap and hide each other. Teams place cameras on each approach and count on the straight sections before the junction, not inside it.

Is camera-based counting better than road sensors?

Cameras give more detail, such as vehicle type, lane and queue length, while loops and radar give reliable counts in bad weather. Many cities use both: loops for a robust baseline count and cameras where detail matters, such as junctions and incident spots.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning a computer vision system for roads or cities? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Computer Vision service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call