<figure><img src="image_1.png" /></figure>

HAL
open science

# Mobile Application Utilizing YOLOv8 for Real-Time Urban Traffic Data Collection

Ayoub Charef, Zahi Jarir, Mohamed Quafafou

<figure><img src="image_2.png" /></figure>

## To cite this version:

Ayoub Charef, Zahi Jarir, Mohamed Quafafou. Mobile Application Utilizing YOLOv8 for Real-Time Urban Traffic Data Collection. E3S Web of Conferences 3rd International Conference on Energy and Green Computing (ICEGC), Nov 2024, Meknes, Morocco. pp.00077, 10.1051/e3sconf/202560100077. hal-05380492

HAL Id: hal-05380492

https://amu.hal.science/hal-05380492v1

Submitted on 24 Nov 2025

HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d'enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

<figure><img src="image_3.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Mobile Application Utilizing YOLOv8 for Real-Time Urban Traffic Data Collection

Ayoub CHAREF<fnref n="1" />,<fnref n="2" />*, Zahi JARIR<fnref n="2" />, and Mohamed QUAFAFOU<fnref n="3" />

**Abstract.** This paper presents a pioneering mobile application specifically designed to revolutionize the collection of urban traffic data. The application is engineered on the robust YOLOv8 platform for mobile devices, leveraging smartphone cameras to provide real-time observations of traffic conditions and vehicle counts with a notable accuracy of 93%. The development environment includes Java Android, enhancing the app with cutting-edge functionalities such as YOLOv8 for precise vehicle type detection and Deep Sort for effective vehicle counting. Despite achieving high accuracy, the application encounters difficulties in accurately detecting motorcycles, which are often hidden behind larger vehicles. This research not only demonstrates the effectiveness of a sophisticated tool for traffic data analysis but also emphasizes the essential need for continuous improvements to tackle practical challenges encountered in urban settings. The findings signify a major progression in urban mobility research and advocate for advanced traffic management and planning strategies.

## 1 Introduction

Urban traffic data collection is crucial for effectively managing and enhancing urban transportation systems. This process employs a variety of technologies including GPS sensors, cameras, video analytics, Floating Car Data (FCD), Automatic Traffic Counter and Classifier (ATCC) systems, surveys, and Bluetooth and Wi-Fi sensors. GPS sensors offer real-time data on travel speeds and routes, aiding in the analysis of traffic flow and congestion patterns. Cameras and video analytics provide visual assessments of traffic conditions, helping to count vehicles and analyse movement patterns, which supports traffic management and infrastructure planning. FCD collects data from numerous GPS-equipped vehicles to generate a representative sample of traffic flow, useful for large-scale traffic assessments [1, 2]. ATCC systems utilize sensors and cameras to gather detailed data on vehicle counts, types, and speeds at specific locations, which is valuable for pinpoint traffic studies. Surveys gather subjective data directly from drivers and passengers about their travel habits and preferences, enriching the quantitative data from other sources. Meanwhile, Bluetooth and Wi-Fi sensors detect the presence of devices in vehicles, offering another layer of traffic

<footnote n="1">¹LAMIGEP, EMSI Moroccan School of Engineering Marrakesh Morocco</footnote>

<footnote n="2">²Laboratory of Computer Systems Engineering (LISI) Department of Computer Science Faculty of Science Cadi Ayyad University Marrakech Morocco</footnote>

<footnote n="3">³Department of Computer Science University of Aix-Marseille Marseille France</footnote>

<footnote>* Corresponding author: ayoub.charef@ced.uca.ma</footnote>
movement data at a relatively low cost. Each of these methods has unique strengths and potential drawbacks, such as the need for extensive infrastructure with ATCC systems or the reliance on voluntary participation with FCD. The choice of method often depends on the specific requirements of the traffic study, including the type of data needed, budget constraints, and the required accuracy and reliability of the data.

By integrating these diverse data collection methods, urban planners can achieve a comprehensive view of traffic dynamics, which is essential for devising effective traffic management strategies, reducing congestion, improving road safety, and guiding infrastructure development. This integrated approach ensures that urban traffic systems are not only monitored but also continuously improved, promoting better mobility and quality of life in urban environments [3].

Our paper is structured into distinct sections, each serving a specific purpose in presenting our research. Beginning with the "Related Work" (Section 1), we provide a comprehensive review of existing literature and research relevant to our study, establishing a foundation for our own work. Moving forward, in Section 2, "Methodology," we detail our approach to conducting the study, including the design of experiments, data collection methods, and any algorithms or frameworks utilized. This section will delve into the intricacies of our research design, providing transparency and reproducibility to our methodology. Subsequently, Section 3, "Application Interface," will elucidate the development and functionality of any software, tools, or interfaces developed as part of our research, showcasing the practical implementation of our findings. In Section 4, "Results and Discussion," we present the findings of our study, accompanied by a thorough analysis and interpretation of the data collected. This section aims to offer insights into the implications and significance of our results within the context of our research objectives. Finally, Section 5, "Conclusion," synthesizes our key findings, discusses their broader implications, and outlines potential avenues for future research and application. By structuring our paper in this manner, we aim to provide a clear and coherent framework for presenting our research, facilitating understanding and engagement with our finding.

## 2 Related Works

Urban environments offer various methods for collecting traffic data, each with unique advantages and limitations. Video surveillance systems use cameras to gather information, aiding in traffic flow monitoring and incident identification. In contrast, infrared sensors detect vehicle-emitted heat to count traffic at specific points. Bluetooth sensors estimate traffic flow and travel times by capturing Bluetooth signals from vehicles, while magnetic sensors measure vehicle counts and speeds by detecting disturbances in the Earth's magnetic field. Crowdsourcing through mobile apps also contributes by allowing users to report traffic conditions, enhancing our understanding of urban traffic dynamics [4]. A notable study [5] introduces a dynamic traffic efficiency model that uses mobile crowdsensing to collect vehicular data without traditional roadside sensors, emphasizing cost-effectiveness and real-time data acquisition. Another research [6] explores GPS technology's capability to provide precise temporal and spatial vehicle data, introducing algorithms for outlier management and data clustering. Furthermore, diverse algorithms for detecting transportation modes from GPS data are evaluated in study [7], revealing their effectiveness through error rates and hit ratios. Concurrently, studies [8, 9] demonstrate how GPS and deep learning can be combined for real-time traffic analysis and prediction. Another approach [10] utilizes GPS data from bike-sharing systems to assess urban cyclist safety, showcasing GPS technology's broader
applicative potential. Despite its widespread use, GPS technology faces challenges like signal accuracy in dense urban areas and the high costs of infrastructure deployment.

Additionally, crowdsourced data, while innovative, raises concerns about its reliability and accuracy due to potential data quality variations and misinformation risks [11]. Concerns also exist regarding the proprietary nature of Google Maps data and its implications for research accessibility and data ownership [12]. Studies continue to harness Bluetooth [13] and Wi-Fi signals to improve traffic monitoring efficiency and accuracy. Additionally, advancements in video analytics are seen in research [14], focusing on automated vehicle counting and traffic pattern analysis using various computational techniques and multi-camera systems. However, the reliance on recorded video poses challenges for real-time traffic management due to potential data delays.

However, the GPS technology is commonly employed for gathering urban traffic data, yet it faces numerous challenges, especially in dense cityscapes where tall buildings and tunnels obstruct satellite signals, leading to inaccuracies in vehicle positioning and speed estimates. Such interference, alongside the substantial costs associated with deploying and maintaining GPS infrastructure, places a significant strain on transportation budgets. Similarly, while crowdsourced data and platforms like Google Maps have transformed traffic data collection, their reliability remains questionable. The variable quality of user-submitted data, which may include inaccuracies and deliberate misinformation, can skew traffic analysis. Furthermore, the use of recorded videos for traffic monitoring introduces additional complexities. Not only do these recordings fail to offer real-time data, potentially hindering prompt traffic management decisions, but the process of analysing these videos can also be cumbersome. Traditional methods require extensive manual effort, whereas automated techniques, though faster, can still suffer from issues related to lighting, camera angles, and obscured views of vehicles, impacting their overall effectiveness.

# 3 Methodology

In Our methodology, we use a blend of Java and C++ programming language to link OpenCV and YOLOv8. This is aimed at the development of an application for capturing real-time data from roadways using cameras. The main technology we use for the solution is YOLOv8, a means for recognizing vehicles e.g. cars and motorcycles. Additionally, we integrate Deep SORT for precise object tracking that in its turn ensures the accuracy and reliability of the process of data collection. Through this methodology, we make use of the latest technologies to produce a productive and effective product that can be operated in the real-time traffic environment providing vital insights [15].

## 3.1 Vehicle detection

The figure 1 in vehicle detection methodology is represented as a real-time process especially suited for mobile execution. This sequence starts with a video input that is subjected to pre-processing, a step that may include changing the size, normalization, and other optimizations to the data that are necessary for efficient processing on a mobile device with limited computational resources. One of the aspects worth mentioning is that the figure and text wrap functionalities ensure the content can be read clearly on various devices. After pre-processing, the video data is handed over the DNN model YOLO V8 (You Only Look Once, version 8) that is a highly optimized deep neural network model, which is famous for having two important attributes - speed and accuracy in object detection tasks, thereby, it is very well suitable for real-time applications on mobile platforms. The vehicle detection achieved using the YOLO V8 model involves two fully parallel actions: object tracking and classification. Tracking is one of the responsibilities that the system accomplishes alone that
is, the system checks and the vehicles are followed from frame to frame. These vehicle
sequences need to be input to a process that offers a continuous flow of the desired traffic
information for the immediate actions of traffic management. And the results of this data
directly lead to these actions executed by traffic-management modules. On the other hand,
classification takes a closer look at the types of vehicles, which among other things is a key
feature for the recognition of cars, trucks, motorcycles, and alike in mobile environments [9].
The end of the function is vehicle counting on which the vehicles are counted in real-time,
mirroring the continuous input from the tracking and classification stages. The term real-time
hint at the fact that the counting dynamically changes when new vehicles enter or leave the
frame [16, 17]. Finally, the outcome of the real-time vehicle detection and counting system
is a CSV file. The report will capture the numerical data, and, thus, will be suitable for
immediate analysis of the gathered results or it could be integrated into a real-time traffic
monitoring system. The use of the CSV format entails that the approach of data storage used
is "universal", thus, it can be used in conduction different experiments along with the
networked applications routinely used for traffic analysis, congestion management, or urban
planning, particularly in the realm of mobile and real-time applications.

<figure><img src="image_4.png" /><figcaption>**Fig. 1.** Real-Time Vehicle Detection and Tracking Framework for Mobile Applications.</figcaption></figure>

## 3.2 Vehicle tracking

<figure><img src="image_5.png" /><figcaption>**Fig. 2.** Integrated Object Detection and Multi-Object Tracking System Using YOLOv8 and Deep SORT.</figcaption></figure>
Such a system as shown in figure 2 is a complicated multi-object tracking system that starts with an input video sequence. First, the sequence is processed by YOLOv8 (You Only Look Once, version 8) [18], an object classification model designed for real-time applications. YOLOv8 distinguishes between the sequential frames of the video and displays in the "Difference Detector" block, hence it can warn the object is moving. It helps to find the object by calculating the difference from one frame to the next. Once detection, the system employs a Kalman filter [19] to estimate the future position of each found object. The Kalman predict block indicates the utilization of a Kalman filter, a standard predictive method in tracking algorithms that predicts the positions of moving objects based on their current state and the retained track over time. The multi object tracking is performed by Deep SORT [20] (Simple Online and Realtime Tracking with a Deep Association Metric). This tracking method introduces Mahalanobis [21] distance as the distance metric and a deep appearance descriptor to effectively associating objects that are detected across the frames. The Mahalanobis distance is a measure used to ascertain the degree of similarity between the detected object and existing tracks while considering the variability of each feature, which finally leads to the system being able to match objects even when they move unpredictably or are occluded altogether accurately. Furthermore, Deep SORT harnesses a deep learning-based appearance descriptor to extract features from the detected objects [22], which really helps the tracker to operate properly despite the fact that some objects are positioned in close proximity to others or have similar motion patterns. The Hungarian assignment algorithm, which is visually marked on the figure, serves as an optimization tool for the assignment of detections to existing tracks, so as to minimize the overall cost of a wrong match being done within the best way possible.

## 4 Application Interface

<figure><img src="image_6.png" /><figcaption>**Fig.3.** Real-Time Traffic Analysis Mobile Interface with Live Detection and Classification.</figcaption></figure>

The figure 3 illustrates the GUI (Graphical User Interface) related to the real-time traffic monitoring system. On the right, we can control the detectors. The Non-Maximum Suppression (NMS) and detection Threshold sliders are the tools to tune the object detection threshold and detection factor settings, respectively, for false positives reduction and detection sensitivity control. Under the settings sliders, the "START" button denotes the beginning of the tracking stage, accompanied by a timer supposed to keep the time of the tracking session. The interface's main part displays a live video feed of the streets where cars
are being detected in real time. This is a well-lit day scene where cars and maybe a bicycle are the only moving objects against an environment consisting partly of buildings and trees and grass. On the lower end of the screen, a separate section is allotted for the tabular information where the traffic is categorized and the direction for each movement is specified (Bus, Car, Bike and L->R for left to right, R->L for right to left) with a common total for each category. This immediate traffic data is of paramount importance for traffic analysis and management.

## 5 Results and discussion

In the Results and Discussion section, the data output obtained from the real-time traffic monitoring application is going to be discussed. The application has been made very carefully to capture and sort out the types of vehicles that pass through a certain checkpoint. The efficiency of the system is expressed through each vehicle being identified by its classification, getting a record of the traffic line in which, it was detected, and the direction of its movement while the vehicle moves along. This kind of data collection is really the necessary component of the evaluation of the detector's performance and also, it is the source of useful information about the most common traffic patterns and movement of cars over the specified period. Furthermore, a closer look at this data gives us the possibility to explore the success of the currently installed solution in the different traffic conditions and subsequently to talk about new upgrades and observations that pop out from the data.

<table><caption>**Table 2.** Timestamped Traffic Detection Log by Vehicle Type, Line, and Direction.</caption><tr><td>Time</td><td>10:36:10</td><td>10:36:20</td><td>10:36:30</td><td>10:36:40</td><td>10:36:50</td><td>10:37:10</td><td>10:37:20</td><td>10:37:30</td></tr><tr><td>Vehicle</td><td>car</td><td>car</td><td>motorcycle</td><td>motorcycle</td><td>car</td><td>car</td><td>car</td><td>motorcycle</td></tr><tr><td>Line</td><td>1</td><td>2</td><td>1</td><td>1</td><td>2</td><td>2</td><td>2</td><td>1</td></tr><tr><td>Direction</td><td>R-&gt;L</td><td>R-&gt;L</td><td>R-&gt;L</td><td>R-&gt;L</td><td>R-&gt;L</td><td>R-&gt;L</td><td>R-&gt;L</td><td>R-&gt;L</td></tr></table>

<figure><img src="image_7.png" /><figcaption>**Fig.4.** Comparative Analysis of Vehicle Detection: Automated App vs. Manual Counting Across Four Test Videos.</figcaption></figure>

The Table 1 consists of a timely sequence of vehicle detection logs from a traffic monitoring system. Each line records a single detection event. The columns give timestamps for ten-second intervals with the initial time being 10:36:10 and the final time being 10:37:30. For every timestamp, the vehicle type is recognized as a 'car', 'motorcycle', or 'bus'. The 'Line' column, which is situated beside the vehicle type, displays the line number from which the
vehicle was detected, thereby advertising the fact that the tracking system might be in the
process of monitoring traffic in several lines or lanes. Through this, the 'Direction' column,
in particular, indicates that the movements of all the cars are uniformly from right to left (R-
>L) in this particular series of observations. It is a sign of the data that cars are the majority
of the detections, and at the last slot, a bus be detected after cyclic motorcycle detections.

The figure 4 depicts a comparison of vehicle detection over four different video tests by bringing the totals obtained through the application into confrontation with the manual counting methods. Every chart displays individual bars, each of which stands for a car, a bus, and a motorbike, captured by the video. The full lines represent the number of cars, buses, and motorcycles individually known by the machine, and the dashed lines stand for the number they have figured out based on the computer vision approach. Via the graphical display of the picture, it is clear that two bars appear across the line for every type of vehicle, and thus both the automatic and manual methods can be easily compared visually. These graphical characters were introduced to us to help in the process of the applications. These are the chart titles and the legend which offers further details on what is represented by each color on the chart. I also need to express my thanks to technology which comes in the right time and in a right manner. I hope you receive this information in the right way and that it will assist you in this venture.

6 Conclusion

In conclusion, the comprehensive evaluation presented in this paper validates the
efficacy of our mobile application for real-time vehicle detection and classification. Through
a meticulous process of manual testing, we have demonstrated the commendable accuracy of
our application's vehicle counting and vehicle type detection capabilities. The empirical
evidence gathered from the tests shows that our app achieved a remarkable accuracy rate of
93% in vehicle counting, aligning closely with manual counts derived from video recordings.
This high degree of precision underscores the reliability of the application as a viable tool for
traffic monitoring and management. It not only serves as a testament to the robustness of the
underlying algorithms but also confirms the application's potential utility in various practical
scenarios, such as urban planning, traffic congestion management, and road safety analysis.
The success of the application can be attributed to the integration of advanced detection and
tracking algorithms, efficient real-time processing, and a user-friendly interface that
collectively contribute to its overall performance.

However, the pursuit of perfection in such systems is ongoing. Future work will focus
on further reducing the margin of error, enhancing the application's adaptability to diverse
environmental conditions, and expanding its detection capabilities to include a broader range
of vehicle types.

As we continue to refine the application, we anticipate not only an improvement in accuracy
but also an expansion in the application's functionality and scope. Our ultimate goal remains
to deliver an exceptional tool that can seamlessly integrate into smart city frameworks and
contribute significantly to the advancement of intelligent transportation systems.

References

1. Kusimo, K.O., Okafor, F.O.: COMPARATIVE ANALYSIS OF MECHANICAL AND MANUAL MODES OF TRAFFIC SURVEY FOR TRAFFIC LOAD DETERMINATION. Nigerian Journal of Technology. 35, 226–233 (2016). https://doi.org/10.4314/NJT.V35I2.1
2. Liao, C.-F.: Investigating inductive loop signature technology for statewide vehicle classification counts. (2018)

3. Charef, A., Jarir, Z., Quafafou, M.: Optimizing Traffic Flow and Pedestrian Safety: The Role of Crosswalk Distance in Roundabout Design. 2024 International Conference on Global Aeronautical Engineering and Satellite Technology (GAST). 1–6 (2024). https://doi.org/10.1109/GAST60528.2024.10520741

4. Charef, A., Jarir, Z., Quafafou, M.: Assessing the driving behaviour of motorcyclists to improve road safety. JUCS - Journal of Universal Computer Science 30(5): 617-644. 30, 617-644 (2024). https://doi.org/10.3897/JUCS.108550

5. Ali, A., Ayub, N., Shiraz, M., Ullah, N., Gani, A., Qureshi, M.A.: Traffic Efficiency Models for Urban Traffic Management Using Mobile Crowd Sensing: A Survey. Sustainability 2021, Vol. 13, Page 13068. 13, 13068 (2021). https://doi.org/10.3390/SU132313068

6. Abbruzzo, A., Ferrante, M., De Cantis, S.: A pre-processing and network analysis of GPS tracking data. https://doi.org/10.1080/17421772.2020.1769170. 16, 217-240 (2020). https://doi.org/10.1080/17421772.2020.1769170

7. Feng, T., Timmermans, H.J.P.: Comparison of advanced imputation algorithms for detection of transportation mode and activity episode using GPS data. http://dx.doi.org/10.1080/03081060.2015.1127540. 39, 180-194 (2016). https://doi.org/10.1080/03081060.2015.1127540

8. Méneroux, Y., Le Guilcher, A., Saint Pierre, G., Ghasemi Hamed, M., Mustière, S., Orfila, O.: Traffic signal detection from in-vehicle GPS speed profiles using functional data analysis and machine learning. Int J Data Sci Anal. 10, 101-119 (2020). https://doi.org/10.1007/S41060-019-00197-X/METRICS

9. Charef, A., Jarir, Z., Quafafou, M.: Impact of Motorcycle Placement on Travel Time and Traffic Dynamics at Urban Intersections. 2024 4th International Conference on Innovative Research in Applied Science, Engineering and Technology, IRASET 2024. (2024). https://doi.org/10.1109/IRASET60544.2024.10549511

10. Pogodzinska, S., Kiec, M., D'Agostino, C.: Bicycle Traffic Volume Estimation Based on GPS Data. Transportation Research Procedia. 45, 874-881 (2020). https://doi.org/10.1016/J.TRPRO.2020.02.081

11. Tafidis, P., Teixeira, J., Bahmankhah, B., Macedo, E., Coelho, M.C., Bandeira, J.: Exploring crowdsourcing information to predict traffic-related impacts. Conference Proceedings - 2017 17th IEEE International Conference on Environment and Electrical Engineering and 2017 1st IEEE Industrial and Commercial Power Systems Europe, EEEIC / I and CPS Europe 2017. (2017). https://doi.org/10.1109/EEEIC.2017.7977595

12. Semwal, D., Patil, S., Galhotra, S., Arora, A., Unny, N.: STAR: Real-time spatio-temporal analysis and prediction of traffic insights using social media. ACM International Conference Proceeding Series. 20-March-2015, (2015). https://doi.org/10.1145/2778865.2778872

13. Tayeb, F., Chihaoui, H., Filali, F.: Bluetooth-Based Vehicle Counting: Bridging the Gap to Ground-Truth With Machine Learning. (2023). https://doi.org/10.1109/ACCESS.2023.3287981

14. Peppa, M. V., Bell, D., Komar, T., Xiao, W.: URBAN TRAFFIC FLOW ANALYSIS BASED ON DEEP LEARNING CAR DETECTION FROM CCTV IMAGE SERIES. The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences. XLII-4, 499-506 (2018). https://doi.org/10.5194/ISPRS-ARCHIVES-XLII-4-499-2018
15. Charef, A., Jarir, Z., Quafafou, M.: Real-Time Multi-class Helmet Violation Detection Using YOLOv8 with License Plate Recognition. 263–273 (2024). https://doi.org/10.1007/978-3-031-68675-7_26

16. A. Charef, Z. Jarir, and M. Quafafou, “Enhancing Road Safety: Automated Traffic Violation Detection and Counting System Using YOLO Algorithm,” 2024 Mediterranean Smart Cities Conference (MSCC), pp. 1–6, May 2024, doi: 10.1109/MSCC62288.2024.10697076.

17. Charef, A., Jarir, Z., Quafafou, M.: The Impact of Motorcycle Positioning on Start-Up Lost Time: The Empirical Case Study of Signalized Intersections in Marrakech using VISSIM. Engineering, Technology & Applied Science Research. 14, 14313–14318 (2024). https://doi.org/10.48084/ETASR.7141

18. Terven, J., Córdova-Esparza, D.-M., Romero-González, J.-A.: A Comprehensive Review of YOLO Architectures in Computer Vision: From YOLOv1 to YOLOv8 and YOLO-NAS. Machine Learning and Knowledge Extraction 2023, Vol. 5, Pages 1680-1716. 5, 1680–1716 (2023). https://doi.org/10.3390/MAKE5040083

19. Welch, G.F.: Kalman Filter. Computer Vision. 1–3 (2021). https://doi.org/10.1007/978-3-030-03243-2_716-1

20. Yang, F., Zhang, X., Liu, B.: Video object tracking based on YOLOv7 and DeepSORT. (2022)

21. GJ McLachlan: Mahalanobis Distance, https://www.ias.ac.in/article/fulltext/reso/004/06/0020-0026

22. Charef, A., Jarir, Z., Quafafou, M.: Enhancing Road Safety: Automated Traffic Violation Detection and Counting System Using YOLO Algorithm. 2024 Mediterranean Smart Cities Conference (MSCC). 1–6 (2024). https://doi.org/10.1109/MSCC62288.2024.10697076