Passing Vehicle Road Occupancy Detection Using the Magnetic Sensor Array

The increasing presence of vehicles on roads necessitates intelligent traffic management solutions in areas where video cameras cannot be utilized. Currently, there are limited choices for depersonalized vehicle reidentification systems. This paper introduces a system that later will be used for vehicle reidentification. The system uses anisotropic magnetoresistive sensors and is based on the hypothesis that each vehicle leaves unique magnetic signatures which can be used for comparison and matching. Vehicle location on the road perpendicular to sensor array detection methodology is presented in this work. An array of magnetic sensors is installed in asphalt across the vehicle’s driving direction. The system continuously measures Earth’s natural magnetic field and detects distortions when vehicles pass an array of a sensors and then logs magnetic signatures. Useful parameters from raw sensor axes are calculated– modules and derivatives. Applying signal-to-noise ratio calculation for module derivatives between ambient noise and signal gives important features for neural network input. Different types of neural network architectures and output result interpretation techniques are investigated. Further, after evaluating network output it is possible to label sensor nodes that are directly beneath the vehicle. Experiment results show that implemented algorithm is highly sufficient for valid sensors under the vehicle selection. Correct sensor selection is important for further re-identification algorithms.


I. INTRODUCTION
Road vehicles are an integral part of our daily lives. The need for Intelligent transportation systems (ITS) is constantly increasing. Intelligent traffic light control, special transport priority, accident prevention, and smart parking are extensively researched fields [1], [2], [3], [4]. For the ITS system to function correctly accurate sensor information is vital. Various sensing technologies can be used, such as video cameras, inductive loop detectors, radars, infrared sensors, piezoelectric sensors, and magnetic sensors. Traffic analysis is important for the smooth, safe, and economical operation The associate editor coordinating the review of this manuscript and approving it for publication was Wuliang Yin . of traffic. Traffic stream parameters provide important information regarding traffic flow which helps detect variations. Flow is influenced by a driver, vehicle, road condition, and weather. Traffic flow parameterization includes vehicle speed, length, occupancy time, and vehicle class evaluation. Re-identification can be defined as the same specific vehicle repeatedly matching to itself.
Over the past 20 years, the biggest improvements for vehicle reidentification were made in video processing fields. Mainly video camera-based re-identification can be classified based on a vehicle license plate and specific vehicle features [5], [6], [7], [8]. However, reidentification using video cameras suffers from some drawbacks -periodic maintenance is needed, image quality has a high dependence on weather conditions, high computational resources, and high cost. General data protection regulation (GPDR) is also important because in some cases sensitive informationvehicle license plate, driver's and passenger's faces might be used for illegal purposes. Other systems like RFID [9] and GPS [10] require additional hardware installation and are more suitable for public and commercial transport. A novel solution is to use magnetic sensors for vehicle re-identification which are inexpensive, not raise any privacy issues. In recent years, magnetic sensing techniques have shown promise for vehicle re-identification in ITS systems, due to their low cost, low power consumption, and potential resistance to environmental interference. By using the magnetic field signature of a vehicle, it is possible to track its movement and re-identify it at different points along a roadway.

II. RELATED WORK
Magnetic sensors emerge as a promising technology for vehicle reidentification. Hot topics in the research field for vehicle presence, speed, length detection, [11], [12], [13] classification to distinctive categories [14] use magnetic sensors. Considering the cost of installation, it is possible to use a single anisotropic magnetoresistive sensor [15]. The authors propose a method for categorical classification (sedan, van, truck, bus) using feature vectors from features extracted from the magnetic signature of a passing vehicle. Features consist of Mel Frequency Cepstral Coefficients (MFCC) and energy. Accuracy from 60 % to 93 % is possible to reach.
Fewer attempts are made for the same vehicle reidentification problem. Using existing inductive loop detectors (ILD) infrastructure authors at [16] performed the same vehicle matching on the freeway. 31%-45% of incoming traffic was matched in a downstream detector. Using neural networks and collected ILD signatures [17] created features for re-identification based on statistical distance measures -Euclidean, Correlation and Lebesgue. Some researchers combine ILD with other sensing techniques -for example, RFID [18] Inductive loop detector registered signature is not very informative so sensors registering Earth magnetic field distortion are used. Authors at [19] investigated the possibility to estimate vehicle location using a magnetic sensor array. The array consisted only of two sensors, but mathematics can be applied to a larger array. A passing vehicle travels parallel to the sensor array -it can be considered as a magnetic dipole and generate an ideal dipole magnetic signature. Overall accuracy is not mentioned, but it is stated that using a magnetic sensor array it is possible to detect vehicle location.
Problems occur if vehicle location estimation happens perpendicular sensor array. For re-identification using magnetic sensors single sensor or sensor array might be used.
Authors at [20] evaluated a custom vehicle re-identification system consisting of wireless magnetometers, access points, and a camera for ground truth reference. Sensor correlation is a popular measure for vehicle similarity evaluation. Section of 226 m road upstream and downstream vehicle signatures were recorded at [21]. Cross-matching vehicle signatures obtained by different nodes using a cross correlation coefficient identification algorithm achieved high accuracy of 94-96 %. This type of experiment should be defined as a classification problem and not re-identification because only defined categories are studied. Vehicle re-identification attempt can be found in [22]. Signatures from 25 different cars were collected. Signatures were preprocessed to remove speed influence. Using Euclidean distance and dynamic time warping (DTW) methods signatures were compared. Authors emphasize that lateral vehicle position is very important for re-identification performance and adding more sensors closer to each other might improve accuracy.
An array of magnetic sensors which is shorter than a vehicle was employed to register signatures and using DTW and machine learning techniques (k-NN, LMD, Gaussian classifier) lateral vehicle position estimation and re-identification were performed [23]. Results look very promising, however, the authors used the same signatures for training and evaluation, the database size was small, distribution unequal, and all vehicles were from a similar category in a controlled environment. There are no experiments on how algorithms would perform under new unseen data.
Reviewed methods for reidentification are summarized in Table 1. Some key points so far can be defined: • current vehicle re-identification is based on video data, however, cameras suffer from weather influence, need periodic maintenance, do not comply with the privacy policy.
• the available research on magnetic sensors studies vehicle parametrization, but there are only a few specific studies about vehicle re-identification using magnetic sensors.
• each vehicle generates a complex magnetic signature that depends on the vehicle passing trajectory.
Since the sensor array needs whole road width coverage it needs to be wider than a vehicle. Vehicles do not always travel at the same trajectory in the road lane, so every time registered signatures will fluctuate. To address this issue vehicle location in the lane needs to be known. Some research exists for vehicle trajectory estimation again mostly based on video cameras [24], [25], combining inside vehicle sensor data [26], or based on statistical methods [27]. Authors at [28] managed to estimate vehicle trajectory using an accelerometer and magnetometer combination placed on the side of the road. Simulation results looked promising, but actual real-life tests concluded that it is not feasible for real-time applications.
Since sensors are installed at roadside passing passenger vehicles magnetic signature looks like an ideal magnetic dipole. It is possible to estimate vehicle speed and trajectory with a big uncertainty. As seen from available research currently there are only a few trials for systems that can anonymously repeatedly match VOLUME 11, 2023   passing vehicles. A hypothesis exists that it is possible to perform re-identification for specific passing vehicles based only on a magnetic signature. Since the road is wider than vehicles and vehicle drive patterns will be different every time for correct re-identification only sensors which are directly under the vehicle are useful for data analysis. After determining which sensors are under the vehicle, collected signatures later can be used for vehicle reidentification.
In this paper, we propose a magnetic sensor array system and method for vehicle location on road estimation. This system later will be used for vehicle re-identification purposes.
In the third section sensor array and central hub for high sample rate, and data logging are described. In the fourth section algorithm for data preprocessing and valid sensors selection is presented. Two vehicle record comparison for reidentification is beyond the scope of this paper and will be presented in future works.

III. EXPERIMENTAL SETUP
A special system was developed for real-world traffic surveillance. The system sensors array consists of 13 LIS3MDL tri-axis anisotropic magnetoresistive sensors equally spaced at 20 cm distance sampled with individual microcontrollers and connected using FD-CAN bus. Individual sensor nodes are placed inside an aluminum frame and epoxy is used for insulation. The sensor sampling frequency is 1 kHz, and since each sensor samples the x, y, and z axes, 2 bytes of data are collected every 1 ms, resulting in a significant amount of data that needs to be managed. Since the maximum achievable data rate using the classic CAN 2.0 protocol is 1 Mbps is too slow for this application CAN-FD was selected. The transmission baud rate was set to 3 Mbps to achieve a longer distance. Practical experiments showed that at 4 Mbps 25 m is the maximum distance, and at 3 Mbps 40 m is the maximum distance. To simplify data transmission and enable sampling at precisely exact time system structure consists of individual nodes for every sensor and central hub as shown in figure 1.
Individual sensor nodes send data to a hub and the collected vehicle signature is transmitted to the server using Ethernet. Hubs can be chained in parallel using a primary hub and secondary hub so even more nodes can be connected. The primary hub activates the video camera after deciding that vehicle is present in a detection zone. The camera has an internal license plate recognition module so getting ground truth data becomes easier for recorded vehicles. Hub microcontroller runs a real-time operating system (RTOS). The program structure is shown in Figure 2. All data for magnetic sensor processing is held in structure. Raw magnetic data is preprocessed using an adaptive threshold algorithm [29] to remove earth magnetic offset and temperature influence. Every sensor has its own individual structure. Raw data values read from the CAN bus are put into the corresponding structure as a new value. Once all of the sensor's new values are acknowledged, the corresponding offsets are subtracted. Upon power-up, the offset values are updated using the current measured values. Later offsets are continuously updated in detrend function. This function calculates the sensor module All sensor module amplitudes are checked against a defined threshold. If any sensor amplitude surpasses the threshold internal counters and flags are reset and timeout counters start. New values are periodically updated and checked if amplitude drops below the threshold for all sensors. If the timeout is reached it is treated as an anomaly, offset values are updated using current cycle values, and a reset flag is asserted for other blocks to know that magnetic data is corrupted. All other times when amplitudes are below the threshold offsets are updated using a moving average with a 20-point time window to smooth data.
Car_detect function block takes input arguments detrended sensor values and resets flag. This block outputs two flags for the next blocks: Direction flag to decide if a vehicle is going  forward or backward and Car_valid to signal that vehicle is currently present in the detection area. If the reset flag is asserted all internal variables are reset. Function constantly monitors two predefined sensors from all structures called ''speed sensors'' which are in the middle of the array. If any sensor amplitude goes beyond the predefined threshold, then a timeout for hysteresis is started (Figure 3).
During this time both sensors' amplitudes need to become higher than the second threshold. If both sensors successfully pass hysteresis, then the detection algorithm is started and the Car_valid flag is asserted. In the same cycle car, the direction decision logic is started. Both ''speed sensors'' continuously sum module values. After 20 cycles (ms) these sums are compared and one with higher corresponds to which direction the vehicle appeared. Car_valid signal is asserted until both sensors module amplitudes drop below the first threshold and fixed additional time passes for signature tail recording.
The collector function also takes input detrended magnetic sensor values and status flags. While the Car_valid flag is set to false function is continuously updating prebuffer. Prebuffer is fixed for 100 records for every sensor. Buffer is circular and then Car_valid flag is asserted prebuffer is copied to the first data segment from latest records to newest. The collector constantly appends data records while the Car_valid flag is set. After the Car_valid flag is set to false or the maximum recording length is reached transmit flag is set to true and the data structure is sent to the server using a TCP connection. If during data collection Detrend function issued a reset signal because of a detected anomaly all collected data is discarded.
The sensor unit and vehicle axle relation are shown in Figure 4 below. Twelve sensors are equally spaced at a 20 cm distance. Thirteen sensor is used for direction detection and speed estimation is parallel to a middle sensor at the same distance. The sensor is buried in asphalt at a depth of 8 cm across the road.
The usual passenger vehicle width is up to 2 meters. Since the sensor array length is 2.20 m any sensor combination can be beneath the vehicle. Vehicle tire width can be from 15.5 cm to 30.5 cm, so wheels may go directly over the sensing element. From [30], [31] it is noticed that wheels greatly distort the registered signature. For vehicle reidentification purposes, only sensors that are between wheels give useful information. Sensors that are outside wheels usually register a vehicle as an ideal magnetic dipole, so it doesn't give useful information for reidentification.
Modern passenger vehicle tires have come to long development and have a complex structure. Tires can be divided into two categories radial and diagonal. Currently, most tires used are radial type, because of benefits-improved driving comfort, little heat generated, and lower fuel consumption. Diagonal-type tires were standard before radial tires were introduced. The tire consists of three main layers tread, casing, and tire bead. These layers are subdivided into smaller groups. The tire tread layer has strong steel cords to provide rigidity. Instead of steel polyester or nylon can be used. Mainly diagonal tires can have carcass layers made from nylon cord. These tires are still popular off-road because they are lighter than radials [32].
Since most tires have steel components inside, they distort Earth's magnetic field as a simple magnetic dipole. In Figure 5 radial summer tire 205 55 R16 without rim is rolled over four magnetic sensors spaced equally in a square box with distances of 20 cm between them and magnetic distortion is registered. Registered tire magnetic signal amplitude is quite large -50 µT in some cases it might be equal to or surpass the overall vehicle magnetic signature. It is important for vehicle parameters (speed, length) calculation applications and also for re-identification applications because vehicle signatures distort useful signatures if the vehicle wheel passes directly over the sensor.
In this paper method for elimination of signatures that are directly affected by the wheel is presented. The main goal is to VOLUME 11, 2023 50987 Authorized licensed use limited to the terms of the applicable license agreement with IEEE. Restrictions apply. select signatures from sensors under the vehicle undistorted by wheels and suspension elements.

IV. VEHICLE OCCUPANCY DETECTION METHOD
Using a magnetic sensor array vehicle magnetic signatures can be recorded. Example of recorded vehicle picture and magnetic signature modules in Figure 6. Signal module amplitudes for sensors 2,3,10,11 are a few times larger than the average maximum. Also, some signatures have low amplitudes and the shape is not informative -sensors 1-12. Sensor 1 also was near the wheel. It is noticeable that wheel and tire influence mainly appears as a sharp peak in amplitude for 1 or two sensors. If there is no influence, then overlapping signature values look consistent. Based on this information it is possible to develop an algorithm for discarding sensors that are registering wheel-distorted signatures.
Useful sensors which are directly under the vehicle are selected considering constraints applied by sensors that are in contact with the wheel. If a wheel doesn't distort the magnetic signature, then the center of the vehicle and length is approximated.
In the best-case scenario if two same-model vehicles pass the sensor array in the same trajectory same sensor sequence will be selected for both records. If a vehicle is towing a trailer, the trailer's magnetic signature will distort Earth's magnetic field similar to the vehicle. In the trailer largest distortion occurs near the wheels, with unique distortion under a trailer, and smaller distortion in the outside area.

A. FEATURE CALCULATION
The method for sensing the vehicle on top of the sensor was developed using a derivative of the module. First for all registered modules M n,t , n ∈ [1, .., 12] derivatives D n (t) = M n (t) are calculated. Derivatives give vital information about signature ascents and descents. For sensors that are in contact with the wheel derivative will be higher compared to the nominal, and for outlier sensors, the derivative will be at noise levels. After calculating derivatives signal to noise ratios (SNR) for every sensor are calculated with reference ambient noise using the formula: where D n,t is sensor module derivative, N t ambient Gaussian noise. Calculated ratios are scaled by amplitude and so, it results in 12-element vectors ranging from 0 to 1. Several distinctive pattern possibilities of calculated normalized SNR are possible: both car wheels can be identified, a single wheel can be identified, and the wheel doesn't distort signatures ( figure 7). Usually, the wheel doesn't appear in the signature if the tire doesn't have steel elements, and is demagnetized during driving, car body frame signature has a higher amplitude than a tire. Using SNR patterns, it is possible to decide which sensors are directly under the vehicle.
Shapes can vary slightly so it is difficult to make a correct decision using hard-coded rules. Trials to define specific thresholds failed quickly. Sensor selection definition can be tailored to a single car model mainly if a different vehicle appears sensor selection becomes unpredictable. The better way is to use machine learning techniques to solve this problem as a regression problem or as a classification problem. If a regression algorithm is used, then input values are mapped to output values. Using classification all available categories are defined and input values are translated into the corresponding category. The usage of defined categories removes uncertainty if gaps between valid sensors should occur. However, using regression output values ranging from 0 to 1, an additional threshold needs to be applied. Rounding values at the point of 0.5 show promising results, however, gaps occur, and not the full range is covered.

B. MACHINE LEARNING FOR REGRESSION PROBLEM
500 records of passing vehicles were labeled with valid sensors to use according to SNR. These records were used for fitting problem solving -a set of numeric inputs mapped to a set of numeric outputs. Various types of neural networks exists -feedforward, recurrent, radial basis function, modular [32]. Two-layer feed-forward network with 12 inputs, 12 outputs, and one hidden layer with 12 nodes was tested.
Different activation functions were considered. For visualization of network behavior, all inputs were set to 1. It is expected for a network to produce output as an inverted parabola which is centered at sensor number 6. A few examples of outputs for networks using different activation functions for the hidden layer and output layer are shown in Figure 8. VOLUME 11, 2023 Visualizing network behavior using different activation functions shows that the output function has a higher influence than hidden layer activation. Using softmax in the output layer gives only a single peak, sometimes a smaller amplitude than 0.5. The Softsign function in the output layer pushes all output values close to 1. The sigmoid output function pattern reassembles the sinus function. Softplus output activation function pattern varies from sinus to inverted parabola patterns depending on the hidden layer function. Scaled exponential linear unit and linear unit (selu and elu) functions were best fit for parabola after real data test selu for hidden layer and softplus for output layer were selected. The network structure is shown in Figure 9. For training 70% of samples were selected and for testing 30%. The network is trained using 350 observations using the Adam optimizer.
Since network output values vary from 0 to 1 they are rounded, and values equal to 1 are considered valid sensors. If the predicted value is below 0.5 gaps in sequence may occur as shown in Figure 10. To overcome this issue rounded values are processed into a sequence. The first and last valid sensors are found and the range is selected accordingly. In this way, gaps are filled.
An example of network validation performance is shown in Figure 10. One vertical stripe corresponds to one passing car sensor selection evaluation. Sensor numbers are in vertical axes. Yellow squares indicate sensors selected by the algorithm. If in selected sensor sequence occur discarded sensor is treated as a gap and promoted to the approved sensor.
A recursive neural network (RNN) was trained using the same training dataset and compared to ANN. The RNN can easily map sequences to sequences whenever the alignment between the inputs and outputs is known ahead of time [33]. Identically RNN with 12 input layers, 12 output layers, and 12 hidden layers was trained. This network structure is more complex compared to a simple neural network, however, major performance improvements were not noticed.

C. MACHINE LEARNING FOR CLASSIFICATION PROBLEM
Another approach is to use ANN feed-forward network configured for classification problems. In this case, the SNR sequence is a direct input to a network, but an output corresponds not to valid sensor numbers, but to the coded category. A list of available sensor combinations is created. It has different valid sensors count -from 3 to 7 and different locations. Each list entry is interpreted as a coded category. For network training, valid sensor targets first are encoded to a category and then trained. To get the prediction result, the predicted output category also is decoded as a valid sensor sequence according to the table. The benefit of this method is that all available variants are defined, so there are no gaps and uncertainty in prediction. Network training and usage structure are in Figure 11.
Network configuration consists of 12 input nodes, 100 hidden nodes with sigmoid activation function, 26 output neurons with softmax activation function, and 41 output for the corresponding category. The network is trained using scaled conjugate gradient backpropagation.

D. METHOD FOR ACCURACY EVALUATION
Ussually machine learning model performance is evaluated using metrics: accuracy, precision, recall, F1-score, ROC, AUC [34]. Selected valid sensors are important for later research -re-identification. Algorithms for sensor selection are not perfect, so errors occur. Training data for algorithms are prepared intuitively -different observers might include/discard different edge sensors. To measure how good the network is in choosing the correct sensors there is no need for 100 % true positive detection. It is assumed that the deviation of 1 sensor to either side is acceptable. Evaluation is made as follows -labeled reference and the predicted result are multiplied together (logical AND operation). This multiplication result is summed: Two sums difference (s2 -s1) gives how many sensors are chosen incorrectly. Percentages of using different algorithms with the same training data for each case are given in Table 1. Different observation datasets were used for network comparison. Training and testing datasets don't overlap.
Observation datasets were random and included various vehicle types and travel directories. Values in the table indicated the percentage of cars for which assigned sensors were valid while selecting either side 0-2 sensors. The network predicts sensors as observer labeled means 0 sensors are missed, 1 missed sensor means algorithm selected 1 sensor more compared to observer, 2 and more means overall algorithm selected sensors might be shifted. Recursive neural network performance was worst. Traditional ANN in both modes' performance was similar, however, ANN classification tends to have more missed sensors compared to ANN regression.

V. FUTURE WORK
In the future work, the collected signatures and insights from this research gives a valuable foundation for further advancements in vehicle re-identification using magnetic sensors. As identified in this research, the accuracy of re-identification heavily relies on correctly identifying and utilizing sensors that are directly under the vehicle and have no contact with the tires. Therefore, developed algorithm can accurately predict and select these valid sensors is of paramount importance. Future work aims to develop a complete and robust vehi-cle re-identification system that leverages the strengths of magnetic sensing technology while addressing practical challenges, such as sensor selection, environmental variations, and scalability. Magnetic sensing for vehicle reidentification have potential for widespread adoption in intelligent transportation systems.

VI. CONCLUSION
Currently, only a few attempts exist for vehicle re-identification using magnetic sensors. To have highquality signals for analysis vehicle's position on the road must be known. Signatures which are registered not directly under the vehicle might be not informative, and sensors that have close contact with tires can distort the magnetic signal.
A high data rate magnetic signature sampling system was developed and tested in real-time conditions. An algorithm for valid sensor selection was developed and presented. After evaluating the sensor selection method with different vehicles some conclusions can be drawn: • The same vehicle model leaves the same SNR pattern. • Two distinct patterns exist when wheels can be easily separated and then wheels don't appear in the signature.
• Hard-coded rules for valid sensor selection can become too complicated so the machine learning method is preferable.
• There is no need for 100% observer labeled and algorithm-predicted values to match.
• Using an advanced algorithm, it might be possible to distinguish two each other passing vehicles in the same lane.
• Overall accuracy achieved with the ANN regression algorithm is calculated using averages for different data subsets and calculating mean while taking into account only 0 or 1 missed sensor. Calculated accuracy is 94 % which is suitable for good sensor separation.
• The regression method performed 3 % better compared to the classification method.
• For future works signatures collected by this system will be used to develop a method for same-vehicle reidentification. VOLUME  . After study, his working activities has been associated to a Researcher and an Assistant Professor within power electronics and power converter systems with the Department of Mechatronics and Electronics, FEE-UNIZA, where he was an Associate Professor, in 2013. Since 2017, he has been the Head of the Department of Mechatronics and Electronics, FEE-UNIZA, and he received the tittle of a Professor, in 2021. He is the author of more than 130 articles, more than 20 inventions, and five books. His research interests include power electronic systems, switched mode power supplies, resonant converters, power semiconductor devices, wireless power transfer, power density, efficiency optimization, thermal management, thermal modeling, lifetime optimization, e-mobility, alternative transport systems, and the modern concepts of power electronic systems for intelligent grids.