## 4 Materials and Methods
### Methods
#### 4.2.1 Data Collection  
Deep learning bases its analysis on data, making inferences from the data. So it is of critical importance to have suitable samples for each problem. In this research, we needed to generate our samples, which were obtained in four stages. Figure 6: The graphic diagram of the two parts required to develop this work. Figure 7: Components used to estimate the vehicle’s speed. The first stage corresponds to _sampling_, which involves going to a place with a constant flow of vehicles to obtain the most significant amount of data. The second stage is the samples _cleaning_, which seeks to consider only those vehicles whose speed was correctly measured. The third stage is the _Extraction_, where the data is extracted from the images sequences. The four stage is _Validation_, where the extracted data are corroborated to be a valid sample. These four stages result in a set of samples ready to be processed by the predictive model. This whole process is described in Algorithm 1. ```
Data: Traffic video Result: Csv File with features Sampling (Camera, Radar) \(\longrightarrow\) Samples; whileExist samplesdo  CleaningSamples \(\longrightarrow\) Clean_Samples;  Extraction_Cam_Samples \(\longrightarrow\) Features;  Validation_Features \(\longrightarrow\) Valid_Features ;  Save_features Valid_Features \(\longrightarrow\) csv_File end
```  
**Algorithm 1**Data Collection  
* Sampling: For sampling, two devices were required to extract the dataset that will later be used to train the predictive models. One of the devices is the Bushnell radar. At the same time, the other device is a video camera; both devices are described in the _Material Section_. The videos are taken at 60 frames per second, but it should be taken into account that having a low resolution may result in a loss of image quality and a smaller area than desired. While having low frames will cause loss of vehicles passing at a higher speed. On the other hand, increasing the resolution and frames per second causes the system to take longer to process the video. There is special care when positioning the camera since we do not want the experiments to be considered 2D speed calculations. Therefore, the camera was placed where vehicular traffic passes with a certain degree of inclination, without pointing the camera directly to the vehicles' side (Figure 8). Since the camera and the speed radar are devices that are not synchronized, it was necessary to implement a mechanism to associate the radar reading with the video recording. * Cleaning: The radar device and the tracking system are not linked, so it is essential to combine the speed supplied by the radar with the information received by the tracking system (video camera). For this, a visual inspection of the samples taken is required. The first step is identifying the landmarks to reference vehicle entry and exit points. Using our exit landmark as a reference, we record the second when a vehicle passes through the exit landmark. Figure 8 shows an example of how the landmarks in the images were established as reference points for vehicle entry and exit. Also shown is the inclination of the camera used for sampling. In addition, we identify the lane in which the vehicles pass to separate them in the three street lanes, we represent with zero the first lane, one the central lane, and two the last lane, with this we seek to create three datasets as divided in the work of [35]. This information obtained visually we save in a csv (comma-separated values) file, which will have the following three attributes:
* The second that the object passes through the exit point. * The vehicle's speed. * Extraction: Specific characteristics of the previously cleaned videos are necessary to perform the speed estimation. These characteristics are the basis to carry out the estimation. The characteristics extracted from the videos are described in Table 2.  
The execution of the system is simple. We need the CSV file generated earlier with the speeds and limits that we also identified in the previous step.