Total.js Platform
Total.js Platform

Total.js Platform news and tutorials

Using AI for Traffic Analysis and Smart Parking Monitoring

Using AI for Traffic Analysis and Parking Lot Monitoring

In this article, I will show you how we used artificial intelligence to process image data and turn it into solutions for smart cities. In our projects, we use it to analyze road traffic, track vehicle movement at intersections, and automatically evaluate parking lot occupancy.

By combining AI models, camera systems, and the Total.js IoT platform, we transform image data into actionable information. We then process, evaluate, and display this information in our systems.

In the following article, I will introduce two solutions that we developed and deployed in production – road traffic analysis at urban intersections and parking space occupancy monitoring.

Road Traffic Analysis at Intersections

For the first solution, we focused on automatically monitoring road traffic intensity at urban intersections. We use camera systems that provide us with images from multiple directions at individual intersections.

Our goal is to identify passing vehicles, distinguish their categories, and record their movement through predefined sections of the roads.

Image Processing Using NVIDIA Jetson AGX

For image processing, we used NVIDIA Jetson AGX devices, which provide the computing power needed to analyze multiple camera streams simultaneously.

One Jetson AGX device handles approximately five urban intersections in our setup, representing roughly 18 camera inputs. We connect to the individual cameras through RTSP streams, from which we obtain image data for further processing.

We use NVIDIA DeepStream to process the video streams. For each device, we created configuration files that define the camera inputs and configure their simultaneous processing. This allows us to analyze images from multiple intersections and different directions using a single device.

In this way, we centralized image processing from multiple locations on one computing device, while the cameras themselves serve as the source of the video streams.

Vehicle Identification and Classification Using AI

We use the YOLO11s model to recognize vehicles. The model analyzes image data from camera streams, identifies individual objects, and then classifies them into the appropriate categories:

  • Passenger cars
  • Buses
  • Motorcycles
  • Trucks

Vehicle detection alone, however, is not enough. For traffic analysis, we also need to know where a vehicle passed and when it crossed the monitored section.

Tracking Vehicle Movement Using Virtual Lines

For each camera, we define virtual lines that represent monitored points on the road. We adjust their placement to match the specific camera view and intersection layout.

When a detected vehicle crosses one of the defined lines, the system records the corresponding event.

To track crossings over these lines, we created our own libraries in the C programming language. They process detections and evaluate events as vehicles pass through the monitored areas.

We then send the resulting events via Redis to Total.js Flow, where we process them further.

Illustration of vehicle movement tracking

Event Processing in Total.js Flow

After receiving messages via Redis, we process them in the Total.js Flow environment. For this purpose, we prepared custom components for parsing the received messages and processing individual events.

We then send the resulting data to dedicated endpoints in our IoT platform. The data is stored, evaluated, and displayed through dashboards.

The result is an overview of traffic intensity at individual intersections, including a breakdown of vehicles by category.

Total.js Flow:

Total.js Flow

Total.js IoT device details:

Total.js IoT device details

Total.js IoT device overview:

Total.js IoT device overview

Total.js Dashboard:

Total.js Dashboard

AI-Powered Parking Lot Occupancy Monitoring

For the second solution, we created an automated parking space occupancy monitoring system based on image data from cameras.

Unlike intersection analysis, where we track vehicle movement within video streams, for parking lots we regularly evaluate individual images from the cameras. In this case, all processing is handled by Total.js Flow.

Capturing and Preparing Image Data

At regular intervals, we load the current image from the camera. In our solution, we chose an interval of 60 seconds.

Before detection itself, we need to select only the part of the image that is relevant to us. For this purpose, we use image masking.

In Total.js Flow, we apply a polygon-defined mask to the captured image. It specifies the exact area we want to analyze – in this case, the parking space area.

We ignore the remaining parts of the image during further processing. This allows the AI to focus on the relevant area and prevents the detection from being unnecessarily affected by the surrounding environment.

Masking

Vehicle Detection and Occupancy Evaluation

For image processing, we prepared a custom Python service that uses the OpenCV, NumPy, and Ultralytics libraries. It enables us to perform multiple operations on image data.

For example, the service allows us to:

  • Apply a mask to a defined image area.
  • Search for and detect objects using an AI model.
  • Crop selected areas based on the coordinates of detected objects.
  • Draw detection results directly onto the image.
  • Draw defined lines and polygons.

During detection itself, we specify which object classes we want to search for in the image. The AI then identifies the relevant objects and returns their categories, coordinates, and detection confidence.

We can also visualize the results directly in the image, which makes it easy to check the accuracy of the recognition.

Masking + detection result

Evaluating Data and Displaying Available Parking Spaces

After detection is complete, we send the data obtained from Total.js Flow to a dedicated endpoint in our IoT platform. In the next step, we use Data Views, which are virtual devices that allow us to process and aggregate the received data.

We use them to evaluate the total number of vehicles in the monitored parking lot, and then use the resulting value in downstream systems.

One of the outputs is a set of information boards displaying the current parking lot occupancy, or the number of available parking spaces.

Displaying available parking spaces

Connecting Artificial Intelligence and IoT

Both solutions showed us how artificial intelligence, image processing, and an IoT platform can be combined into one functional system. For road traffic analysis, we use the computing power of NVIDIA Jetson AGX devices and NVIDIA DeepStream to process multiple camera streams. For parking lot monitoring, we regularly capture images and analyze them directly in Total.js Flow.

In both cases, Total.js Flow is an important part of the solution, handling the processing of the collected data and connecting it with the IoT platform.

This allows us to transform image data into structured information that we can store, analyze, display, and provide to other systems.

While developing these solutions, we verified that existing camera infrastructure can be used for much more than visual surveillance alone. Cameras can become a source of data for automated traffic analysis, parking management, and other smart city applications.