# Machine Learning-Driven Calibration of Traffic Models Based on a Real-Time Video Analysis
## 1 Introduction
### Capturing Intelligent Transport System Data to Develop Machine Learning Applications  
A dataset for training and testing ML models can be obtained from the ITS sensor system (PTS) and the SMTF, which is part of the VTS. One increasingly popular method for collecting traffic flow data from specific highway sections in PTS is the use of wireless sensor networks (WSNs) due to their flexibility, scalability, and cost-effectiveness, as highlighted in [71; 72; 73; 74; 75; 76]. WSNs allow data collection on parameters recorded by sensors from each vehicle connected to the communication network, providing more detailed information about the analyzed route section than analyzing traffic video streams [77]. These richer data can help address a broader range of ITS problems through ML. Despite the benefits of using WSNs, video recording systems, especially those based on autonomous aerial vehicles, are becoming more prevalent [78; 79] thanks to advancements in ML methods for processing video streams [80] and the proliferation of city cameras. This trend enables the creation of extensive and affordable systems for collecting transport network data to build and calibrate simulation models [81; 82; 83]. Video systems allow data collection from all vehicles without specialized sensors or communication modules. On the other hand, integrating a large number of vehicles into a WSN can present challenges. However, it is essential to note that a fixed dataset is required to address various challenges in constructing SMTF for specific route sections, conducting computational experiments, and pre-training ML models for integration into the VTS [84; 85; 86]. This dataset cannot always be directly obtained from video streams, and deploying WSNs may be hindered by the lack of vehicles equipped with transceiver systems and sensors. The amount of actual data obtained from the PTS may be limited in representing various traffic flow phenomena and the amount of data. Obtaining it may also be complicated by technical limitations. Receiving data from the VTS will only be effective for developing an ML application if the generated data are comparable to the data from the PTS. Suppose the statistical characteristics of the simulated data do not match the statistical characteristics of the real data. In that case, the ML model trained on the simulated data may not perform effectively in real conditions. When developing an ML application for a vehicle-to-infrastructure (V2I) system, we encountered a similar problem of lack of statistical proximity between VTS and PTS data. It required us to develop an approach to reducing this discrepancy in datasets, which is the topic of this paper. In our previous work [27], we showcased an application of ML in ITSs focusing on specific traffic flow data, based on which the location of the \"connected car\" was determined to generate a dedicated radio channel, tuning the phased antenna array radiation pattern. The approach involved generating synthetic data to train the ML algorithm within the V2I system, leveraging the SUMO simulation model and the Longley-Rice propagation model [87]. The primary objective was to reduce delays in the V2I network, including minimizing network connection time. By creating a method for generating diverse motion scenarios, the algorithm's ability to generalize for antenna radiation tuning was enhanced. The ML algorithm, trained on the synthetic dataset, exhibited a 94% accuracy in determining the optimal main lobe position crucial for establishing and sustaining a dependable connection between the V2I infrastructure and vehicles. However, when tested on real data extracted through intelligent processing of video streams from the simulated area, the accuracy dropped by over 40% compared to synthetic data. This discrepancy highlighted a significant deviation between the characteristics distribution generated by the simulation model and actual traffic flow data.