You are currently viewing a new version of our website. To view the old version click .
Sensors
  • Article
  • Open Access

29 November 2022

Real-Time Vehicle Classification System Using a Single Magnetometer

,
and
1
Department of Mechatronics and Automation, Faculty of Engineering, University of Szeged, Moszkvai Krt. 9, 6725 Szeged, Hungary
2
Department of Technical Informatics, Faculty of Science and Informatics, University of Szeged, Arpad Ter 2, 6720 Szeged, Hungary
*
Author to whom correspondence should be addressed.
This article belongs to the Special Issue Sensors for Autonomous Vehicles and Intelligent Transport

Abstract

Vehicle count and classification data are very important inputs for intelligent transportation systems (ITS). Magnetic sensor-based technology provides a very promising solution for the measurement of different traffic parameters. In this work, a novel, real-time vehicle detection and classification system is presented using a single magnetometer. The detection, feature extraction, and classification are performed online, so there is no need for external equipment to conduct the necessary computation. Data acquisition was performed in a real environment using a unit installed into the surface of the pavement. A very large number of samples were collected containing measurements of various vehicle classes, which were applied for the training and the validation of the proposed algorithm. To explore the capabilities of magnetometers, nine defined vehicle classes were applied, which is much higher than in relevant methods. The classification is performed using three-layer feedforward artificial neural networks (ANN). Only time-domain analysis was performed on the waveforms using multiple novel feature extraction approaches. The applied time-domain features require low computation and memory resources, which enables easier implementation and real-time operation. Various combinations of used sensor axes were also examined to reduce the size of the classifier and to increase efficiency. The effect of the detection length, which is a widely used feature, but also speed-dependent, on the proposed system was also investigated to explore the suitability of the applied feature set. The results show that the highest achieved classification efficiencies on unknown samples are 74.67% with, and 73.73% without applying the detection length in the feature set.

1. Introduction

Automatic vehicle detection technologies provide presence detection, traffic counting, speed monitoring, vehicle classification, and weigh-in-motion data. Thus, they constitute a very important part of intelligent transportation systems (ITS). Vehicle count and classification data are very important during traffic modelling, transportation planning, pavement design, traffic control, and emission/pollution estimation. Vehicle detection systems are also commonly used in parking lots and toll systems.
Vehicle detection systems can be classified into intrusive and non-intrusive technologies [1]. Intrusive detection systems are mounted directly into the pavement surface, in saw-cuts or holes in the road surface, or by tunneling under the surface, and they include inductive loops, piezoelectric detectors, and pneumatic road tubes. Non-intrusive technologies are installed above the roads or on the side of a roadway and include microwave radar, ultrasonic, passive acoustic, active and passive infrared, and video image processing (VIP)-based technologies. Some of these systems are able to monitor multiple lanes. Magnetic sensor-based units can be mounted into the pavement surface or on the side of the roads, so they can be included in both technologies.
Cameras and inductive loops are the most commonly used systems. The advantages of VIP technologies are that they are easily configurable and they can monitor multiple lanes, but their performance is affected by many factors, such as vehicle shadows, day to night transition, fog, rain, snow, etc., and their installation and maintenance are costly. Inductive loop-based systems detect vehicles when they are passing above the sensor based on their metallic content [2]. Speed measurement, vehicle classification, and heading direction estimation in these technologies can be achieved by applying two loops. Vehicle classification is usually realized using the estimated vehicle length and axle-count. Vehicle length is computed using the detection length and the measured speed [3], while the number of axles is estimated by analyzing the waveforms. Some methods were also proposed which apply only a single loop for vehicle classification [4,5]. The main disadvantages of inductive loops are that their mounting and maintenance requires lane closure, their installation requires pavement cutting, and deformations of the road surface largely affect their performance.
Magnetic sensor-based vehicle detection systems are based on the measured changes in the Earth’s magnetic field and can be used as an alternative technology to inductive loops. Similar to inductive loops, they are immune to environmental factors, such as rain, snow, or fog. The main advantages of these systems compared to loops are that they require less pavement cut, and they are less susceptible to stresses of traffic. The use of batteries can further decrease the pavement damage and the installation cost, because there is no need to install cables to the detector. These models can form wireless sensor networks (WSNs) [1,6,7]. Magnetometer-based vehicle detection systems can also effectively work when they are mounted on the side of the roads [8,9].
Another advantage of the magnetic sensor-based technology is that even a single sensor unit can effectively estimate the heading direction, which can be used for detecting vehicles driving in the wrong lane, e.g., while overtaking. This can be achieved by analyzing the measurements in the axis pointing in the direction of movement, or for more precise results, by using a two-axis sensor, where the axes are parallel with the ground [10,11,12].
Classification of vehicles using the magnetic sensor technology can be done using two sensors by measuring vehicle length and/or by processing the magnetic signature of the vehicle, which is much more detailed than an inductive loop-based signature. Counter to the inductive loops, vehicle axles cannot be detected so easily in the waveforms.
Magnetic sensors can be used fused together with other sensor types. Accelerometers mounted on the pavement surface can measure vibrations caused by vehicles passing near the sensor. The use of accelerometers alone was also reported in the literature [13], but they were mainly utilized together with magnetic sensors [14,15,16,17]. In these systems, accelerometer data are applied to identify axle locations using peak detection algorithms, while the magnetometers are used to determine vehicle arrival, departure, and speed.
Magnetometer measurements are affected by temperature drifts, which is a complicating factor in traffic monitoring systems, due to the many changes in the temperature of the pavement [1]. This effect can make parking occupancy detection very hard, since the vehicles are standing above the sensor for a long time, but with proper algorithms these systems can be effectively used for this purpose too [18,19,20].
This paper studies the online classification of vehicles into multiple classes using measurements from only a single magnetic sensor mounted into the surface of the pavement.
The rest of the paper is organized as follows. Section 2 presents related research results and the contributions of the proposed work. The measurement system and the data acquisition are presented in Section 3. The proposed classification algorithm is described in Section 4. The experimental results are discussed in Section 5, while Section 6 summarizes the results of the paper.

3. Measurement

Magnetometers are passive sensors that measure the strength of the Earth’s magnetic field at a given point. Metallic objects such as vehicles cause local distortions, which can be measured by these sensors. Vehicle presence can be determined based on these distortions. Vehicles have different magnetic fingerprints due to their different ferromagnetic composition.
Magnetic sensor-based systems, as described earlier, can be installed both in the pavement surface and on the roadside, but the distortions are much stronger when the sensors are mounted below the passing vehicles. The signals are also more uniform in the case of roadside sensors, since many different ferromagnetic parts pass near the sensors when they are mounted into the pavement [21]. Another disadvantage of roadside installation is that these units can only detect vehicles in the adjacent lane. Vehicles with high metallic content passing in the neighboring lane can cause false detections in the case of in-pavement mounting. Using a three-axis magnetometer, the axis pointing to the neighboring lane can be utilized to filter these false detections [44,46].

3.1. Measurement Unit

The used hardware is based on a Honeywell HMC5843 magnetometer, which is a small (4 mm × 4 mm × 1.3 mm), surface mount, multi-chip module designed for low field magnetic sensing in three axes. The sensor utilizes anisotropic magnetoresistive (AMR) technology and features precision in-axis sensitivity and linearity, and very low cross-axis sensitivity. The ASIC also contains an I2C serial bus interface. It can measure up to ±650 μT in 12-bit resolution, and the highest sampling frequency is 50 Hz.
The unit also contains a microcontroller, which is used to set up the sensor, to read the measurements via an I2C interface, and to forward the data via RS-485 interface to a central unit, which is a PC. The supply and the communication are realized using a cable.

3.2. Data Acquisition

A single measurement unit was installed into the pavement surface in a plastic box for data acquisition. The chosen location was between two intersections (150–200 m from both) on one of the main roads of Subotica, Serbia. The vehicles were moving with nearly constant speed when they were passing above the sensor, since they had enough time from the intersection to accelerate and reach their desired speed. The speed limit is 50 km/h, but the speed of the passing vehicles varied greatly, and many drivers even exceeded the limitation. The location was very advantageous, since it is a frequented road with various vehicle classes passing.
In-pavement mounting was chosen, since the measurement signals are more detailed and carry more information than when the sensors are mounted on the side of the roads. The unit was mounted into the middle of the outer lane, as shown in Figure 1. The sensor’s X axis pointed in the movement direction, the Y axis pointed to the neighboring lane, and Z was orthogonal with the pavement surface. The sensor unit was installed into the pavement, 5 cm beneath the surface.
Figure 1. Sensor placement for data acquisition.
The developed vehicle detection algorithm (described in Section 4) was implemented on the installed measurement unit. The applied sampling frequency was 50 Hz. The software of the device sent the measurement data and the value of the detection flag to a central unit via the RS-485 interface. Data acquisition software on the server side received and stored the measurement data. To validate the detections, and to determine the class for each recorded sample, a camera was installed beside the road. The data acquisition software saved camera images at every falling edge of the detection flag.
Data acquisition was performed during multiple months in various weather conditions, and altogether more than 30,000 samples were collected. Figure 2 shows the measurement signals on the three axes and the corresponding vehicle images when a car and a bus pass above the sensor. It can be seen in Figure 2 that the signals generated by a bus are much more complex than the disturbances caused by a passing car, i.e., it has more direction changes, local minima/maxima, zero crossings, etc.
Figure 2. Measured signals on the three sensor axes when a car (a) and a bus (b) are passing above the sensor, and the corresponding images of the vehicles (c,d).

4. Vehicle Classification Algorithm

The used vehicle classification algorithm consists of three main parts: vehicle detection algorithm, feature extraction, and classification. To perform real-time and online vehicle detection and classification, all parts should be easily implementable on the microcontroller of the used hardware.
The flow chart of the vehicle classification algorithm for one measurement cycle is shown in Figure 3.
Figure 3. The flowchart of the proposed vehicle classification algorithm.

4.1. Vehicle Detection Algorithm

Vehicle detection is a very important part of the classification process, since it should follow the environmental changes, and act the same way for different vehicles. These environmental changes cause slow variations in the offsets on the three sensor axes.
The used algorithm was designed and optimized for classification applications and was previously proposed in [44]. The basic parts of the algorithm are the following:
  • When the unit is turned on, the calibration process is run. This process uses a calibration range size, which must be slightly larger than the peak-to-peak noise level, because it should follow the slow changes in the environment. This noise level should be estimated after the installation of the unit in the current location, when no vehicles are near to the sensor. During calibration, the highest and lowest measurement values are monitored in a measurement window for all three axes. The difference between the highest and lowest values must be smaller than the calibration range size. The calibration is restarted if the difference exceeds the range size at any time in the window at any of the axes. This filters the factors which affect the magnetic field near the sensor. The size of the measurement window should be at least 1 s based on experience. If the calibration is successful, the upper and lower calibration and detection thresholds are calculated for all axes. This is done by equally stretching the range determined by the highest and lowest values to the width defined by the range sizes.
  • Vehicle presence is declared if the measurement values exceed the detection threshold at both X and Z axes.
  • The detection flag is cleared if the measurement values on both X and Z axes are between the calibration thresholds for a previously defined number of measurements. The algorithm should be suitable for detecting vehicles with trailers, so the used length should be calculated using the potential speed on the location and the possible distance between the vehicle and the trailer.
  • A recalibration is attempted always when vehicle presence is not declared. The process is the same as during calibration, but the measured highest and lowest measurements must fit into the previous calibration range. This enables the following of the environmental changes.
The overall efficiency of the detection algorithm is 94.15% [44]. The algorithm detects all vehicles passing above the sensor, and only motorcycles can cause failures if they are not passing near to the detector. False detections cause the rest of the failures. These are generated by vehicles with high metallic content passing in the neighboring lane. The detection range size is set to be as small as possible to achieve fast reaction when the vehicles are approaching the sensor. This enables the processing of the entire magnetic signature of the vehicle in the feature extraction stage. The number of false detections could be decreased with raising the thresholds, but this could also lower the detection rate of motorcycles, and important parts of the magnetic signature could also be lost. Approximately 97% of the false detections can be filtered out when the detection flag is cleared using a properly set up rule-based algorithm [46], which can further improve the efficiency of the classification process.

4.2. Feature Extraction

The inputs in the classification stage are formed by the extracted features on the time-series data. Features are extracted in the detection window, but the last measurements, which are used for clearing the detection flag, are not utilized. The chosen feature types are based on only time domain analysis because they need little computation, and they also do not require the storage of all measurements in the window. This speeds up the processing time and decreases the necessary memory. The feature values are updated after every new measurement, so they can be immediately passed to the classifier when the detection is cleared.

4.2.1. Feature Types

Feature types were chosen based on their potential ability to detect vehicle axles and overall metallic content. It is also important that the features should be immune to speed variations. Some features were previously not applied in related works for vehicle classification purposes but are very popular in other pattern recognition applications, such as human movement classification [47]. The used feature types were the following:
  • Detection length (DL): The number of measurements in the detection window.
  • Highest value (MAX) and lowest value (MIN): The highest and lowest measurement values in the detection window.
  • Place of the highest and lowest values (PlaceMax, PlaceMin): The indexes of the measurements where the MAX and MIN points were found, both divided with the detection length.
  • Range changes (RCH): The calibration thresholds define three ranges in the signal values, one above the upper threshold, one under the lower, and one between them. This feature measures how many times has the signal switched ranges.
  • Number of local maxima and minima (NumLocMax, NumLocMin): The number of local maxima in the range above the upper threshold, and the number of local minima in the range under the lower threshold. A point is considered as a local maximum (minimum) if it has local minima (maxima) before and after it, and the differences in the amplitude are higher than the peak-to-peak noise value.
  • Mean absolute value (MAV): The mean absolute amplitude value, which can be calculated as
    MAV = 1 N i = 1 N x i
    where N is the number of samples in the detection window and xi are the signal amplitudes at the given index.
  • Mean value (MV): The mean amplitude value.
  • Number of slope sign changes (NSSC): The number of direction changes, where among the three consecutive values the first or the last changes are larger than a predefined th threshold, which is the peak-to-peak noise level (2).
    NSSC = i = 2 N 1 f x i x i 1 · x i x i + 1 , f x = 1 ,   if x t h 0 ,   otherwise
  • Number of zero crossings (NZC): The number of times when the amplitude values cross the zero-amplitude level and the difference between the values with opposite signs is larger than the threshold:
    NZC = i = 1 N 1 sgn x i · x i + 1 x i x i + 1 t h ,   sgn x = 1 ,   i f x 0 0 ,   o t h e r w i s e .
  • Average waveform length (AWL): The length of the waveform over the detection window divided by the number of samples in the window:
    AWL = 1 DL i = 1 DL 1 x i + 1 x i
  • Root mean square (RMS): The calculation of the RMS can be performed as given in (5).
    RMS = 1 N i = 1 N x i 2
  • Willison amplitude (WAMP): The number of amplitude changes in the window, which are higher than the given threshold level (6).
    WAMP = i = 1 N 1 f x i x i + 1 ,   f x = 1 ,   if x t h 0 ,   otherwise

4.2.2. Extraction Modes

In related works, the raw signal values on the X, Y, and Z axes and the F magnetic field magnitude were utilized for feature computation. In this work, various novel extraction modes were tested, which can possibly increase efficiency and/or decrease the required feature number. Feature extraction is performed using raw sensor measurements and aggregated data, which are computed using the raw measurement data. The tested aggregation modes were motivated by the fact that both the strength and the direction of the magnetic field at the sensor will change when a vehicle passes by. A lower input number in the classification process can decrease the necessary computation time and the required memory space for the implementation of the classifier. The following extraction modes were applied:
  • Measurement axes (X, Y, Z): The features were computed using the raw measurement values on each axis. The calibrated offsets were subtracted from the measured values.
  • Absolute values (Xabs, Yabs, Zabs): The computed absolute values were applied on each measurement axis, which were calculated after the offsets were subtracted from the measurement values.
  • Magnitude from the origin (XYO, XZO, YZO, XYZO): Magnitude values were computed in three dimensions and in two dimensions using different combination of the axes. The magnitude of the calibration point was subtracted from computed magnitudes. These data provide information about the changes in magnitude in different planes and in 3D based on the sensor frame compared to the magnitudes given by the calibration point.
    X Y O = X 2 + Y 2 X c a l 2 + Y c a l 2
    X Z O = X 2 + Z 2 X c a l 2 + Z c a l 2
    Y Z O = Y 2 + Z 2 Y c a l 2 + Z c a l 2
    X Y Z O = X 2 + Y 2 + Z 2 X c a l 2 + Y c a l 2 + Z c a l 2
    where Xcal, Ycal, and Zcal define the calibration point, which are the middle points between the upper and lower calibration thresholds on each sensor axis.
  • Angles (XYA, XZA, YZA): The difference between the angle computed for a measurement point and the angle of the calibration point. The angles were determined for all three planes defined by the sensor axes using (11)–(13).
    X Y A = tan 1 Y / X tan 1 Y c a l / X c a l
    X Z A = tan 1 Z / X tan 1 Z c a l / X c a l
    Y Z A = tan 1 Z / Y tan 1 Z c a l / Y c a l
  • Magnitude from the calibration point (XYC, XZC, YZC, XYZC): Magnitudes were computed using the differences between the measurement points and the calibration point. The computation was also conducted for two and three dimensions, as given in (14)–(17).
    X Y C = X X c a l 2 + Y Y c a l 2
    X Z C = X X c a l 2 + Z Z c a l 2
    Y Z C = Y Y c a l 2 + Z Z c a l 2
    X Y Z C = X X c a l 2 + Y Y c a l 2 + Z Z c a l 2
Since the extraction modes based on the absolute values and the magnitudes calculated from the calibration point always provide positive values, the following feature types were not computed in these cases: MIN, PlaceMin, NumLocMin, NZC, and MAV.

4.3. Classification

The multilayer perceptron (MLP) neural network was used for classification in the proposed algorithm. Due to its high recognition efficiency and easy implementation on microcontroller-based systems, this classifier proved to be a good solution for online classification purposes compared to other well-known classifiers [47].
Artificial neural networks (ANN) are motivated by biological neural systems and used to approximate target functions. The MLP is a feedforward ANN, where neurons are organized into three or more layers (an input and an output layer with one or more hidden layers), with each layer fully connected to the next one using weighted connections. A neuron has an activation function that maps the sum of its weighted inputs to the output. Usually, ANNs are trained using the backpropagation algorithm, which uses gradient descent to tune network parameters to best fit a training set of input-output pairs.
In this work, three-layer networks were applied. The hyperparameters of the network structure can be seen in Table 3. The number of input neurons was equal to the size of the feature vector, while in the output layer a neuron was assigned to each class. To achieve easy implementation, it is important to minimize the number of neurons in the hidden layer. Various configurations were tested based on the number of hidden layer neurons to find the optimal setup. Hyperbolic tangent sigmoid transfer function was used in the hidden layer, while the neurons in the output layer were created using the linear transfer function. The output neuron with the largest output was assigned as the class of the given sample.
Table 3. Hyperparameters of the MLP structure.
The training of the MLPs was conducted offline. This procedure is time consuming since various configurations must be tested and even one training can require multiple hours, which is much more than in the case of other well-known classifiers [47]. The training time depends on various factors, e.g., the number of neurons in different layers, the number of samples, the hyperparameters used during training, the initial weights, etc. Although it is a complex and time-consuming process to find the optimal network for a given task, it does not affect its real-time operation after implementation.

5. Experimental Results

5.1. Vehicle Classes

Considering the capabilities of magnetic sensors, nine possibly separable vehicle classes were defined. The vehicle types and the number of axles for each class are shown in Table 4.
Table 4. Used vehicle classes.
Some vehicle classes (e.g., cars) passed frequently at the location. An equal number of samples (130 per class) was utilized for all classes during the training of the MLP networks to obtain better evaluation. The training of the MLPs was done using 80 (61.54%) samples, while the remaining 50 (38.46%) were used as unknown inputs for the validation of the trained classifiers. In the training process, 70% of the training data were used as training inputs and 30% as validation inputs.

5.2. Datasets

Since the classification algorithm should be implemented on the microcontroller-based system, it is important to minimize the number of inputs. The waveforms on the X and Z axes should carry most of the useful information. The Y axis can give valuable information about the position of passing vehicle, but it can also be largely affected by vehicles passing in the neighboring lane. The aggregation of the measurement data can further decrease the number of features, and possibly increase the classification efficiency. To find the optimal configuration, it was necessary to test different combinations of used axes. Using the described five feature extraction modes, altogether, 18 different combinations were defined:
  • Measurement axes:
    • X, Y, and Z;
    • X;
    • Z;
    • X and Z.
  • Absolute values:
    5.
    Xabs, Yabs, and Zabs;
    6.
    Xabs;
    7.
    Zabs;
    8.
    Xabs and Zabs.
  • Magnitudes from the origin:
    9.
    XYO, XZO, YZO, and XYZO;
    10.
    XZO;
    11.
    XYO, XZO, YZO;
    12.
    XYZO.
  • Angles:
    13.
    XYA, XZA, YZA;
    14.
    XZA.
  • Magnitude from the calibration point:
    15.
    XYC, XZC, YZC, and XYZC;
    16.
    XZC;
    17.
    XYC, XZC, YZC;
    18.
    XYZC.
The detection length feature provides vehicle length information, but it depends on the vehicle speed. Since other chosen features should be potentially immune to speed differences, it was reasonable to explore the effect of this feature on classification efficiency. This is important because not using the detection length in the feature set could enable the system to work efficiently on other locations where the potential speed of the vehicles is different. By adding this feature to all defined combinations, altogether, 36 different datasets were tested.

5.3. Performance Evaluation

To provide more valid results, five different training and validation sets were generated for all dataset types by randomly distributing the 130 samples. All five datasets for the 36 input combinations were tested with five, 10, 15, 20, 25, and 30 neurons in the hidden layer. For all setups, five sets of training were performed since the training of the neural networks largely depends on the initial weights. In the further comparison, the results with the highest efficiency on validation data from the five training sets were utilized. The training of the MLPs was realized in MATLAB environment. The hyperparameters of the training process are summarized in Table 5.
Table 5. Hyperparameters of the MLP training process.
Table 6 summarizes the required feature numbers and the average classification efficiencies on training and validation samples for each of the 36 datasets. The computation of the average efficiencies was performed using the efficiencies when the best results on unknown samples were obtained for each of the five random sets. It can be observed that the highest efficiencies can be achieved using the feature extraction mode where the magnitudes from the origin were utilized. The highest recognition rate on validation data, 74.67%, was obtained using the magnitude changes in three dimensions (XYZO) together with the DL feature. The number of features in this dataset is 15, which is also acceptable compared to other setups. Without applying the information about the length of the detection, the highest result was 73.73%, achieved using features extracted in the XZ-plane (XZO), which is a significant result taking into account the number of classes and achieved classification efficiencies in related works. The number of features in this dataset is 14. This feature set with the DL provided 74.44%, which is only 0.23% lower than with the XYZO-based extraction. This shows that the Y axis does not carry any additional information if the X and Z axes are used. The extraction mode applying the magnitudes from the calibration point requires a smaller number of features compared to the other magnitude-based mode, but the classification efficiencies are also lower. The differences are mostly higher than 3%. Recognition rates between 70% and 72% can be achieved using the features extracted from the waveforms of the measurement axes. Applying only the X or the Z axis provides very similar results, 71.33% and 71.24% without the detection length, and 72.22% and 72.36% with the DL, respectively. This shows that notable results can be achieved using even a single axis sensor, which can largely decrease the cost of the system. Utilizing the features from the two axes together even decreases the average recognition rate, although it requires double number of features. The average efficiencies are 70.13% without and 71.64% with the DL. The extraction mode utilizing the absolute values requires less features, but the recognition rates are smaller for 1–3% for the same axis combinations. Applying the changes in angles for feature computation can also provide high classification rates. Using only the signals in the XZ-plane can result in 71–72% efficiency on validation samples. The highest classification accuracies on training data can be achieved using the datasets with the highest feature numbers. In more datasets, approximately 82–84% can be reached, but the efficiencies on unknown data are smaller in these cases than when the setups with lower feature numbers are utilized. In case of the datasets which provide the best results on unknown data (above 72%), approximately 80–81% efficiency was obtained on training samples. Analyzing the effect of adding the DL feature to the feature vector, it can be stated that it does not increase the classification efficiencies significantly. The recognition rates are increased in average by 1.28% ±1.63% for training data and 0.80% ±1.37% for unknown samples. This shows that the used speed independent feature types are sufficient to extract the necessary information from the waveforms.
Table 6. Feature numbers and average recognition efficiencies (%) on training and validation data for different setups.
The average misclassification rates on the five random validation sets utilizing the XZO-based features with and without the DL feature are presented in Table 7. This extraction mode provided the highest results on unknown data. It can be observed that the motorcycles can be recognized with more than 96% in both cases. Cars are correctly classified for 90.0% of the samples with, and 87.6% without the DL feature. Most of the improperly classified samples are assigned as vans (4.8% and 6.8%). Buses can be recognized with misclassification rates of 11.2% and 13.6%. Articulated buses have lower classification rates, and the DL feature even lowers the efficiency. The recognition rates are 76.4% with and 83.2% without the DL. Most of the misclassifications occur as trucks with trailer (8.8% and 6.8%) and buses (11.6% and 5.6%). The most positive effect of the added DL feature can be noticed at vans, which are classified with the highest misclassification rates (44.8% and 52%). Further, 24.0% of the samples are classified as trucks for both datasets, and 7.6% and 8.4% as cars with trailer. The improvements between the two sets can be noticed in cars, since using the DL, the misclassification rates decrease from 17.6% to 10.4%. This result is reasonable, since both classes have two axles and do not differ significantly in metallic content. The rest of the vehicle classes, trucks, trucks with trailer, and tractor trailers, can be recognized with similar rates, around 55–60%. Trucks are mostly misclassified as vans (10.8% and 8.4%) and buses (12.4% and 18.0%), trucks with trailers as tractor trailers (16.8% and 21.6%) and articulated buses (13.2% and 11.6%), while tractor trailers as trucks with trailers (13.6% and 10.8%), buses (12.8% and 10.8%), and articulated buses (8.4% and 9.6%).
Table 7. Average misclassification rates (%) on validation data using the XZO-based features with (upper row) and without (lower row) using the detection length feature.
The required number of hidden layer neurons for achieving 97% convergence in efficiency using the mean values from the five random sets can be seen in Table 8. Analyzing the results, it can be observed that mostly 10 (58.33%) and 15 (30.56%) neurons are required for validation samples. To reach convergence on training data, more, between 15 and 25 neurons are necessary. This analysis shows that the tested range in the number of hidden layer neurons is sufficient for solving the given task.
Table 8. Required number of hidden layer neurons for reaching 97% convergence on the 36 datasets.

5.4. Implementation

The implementation of MLPs requires the storage of three parameter types: input ranges, weights, and biases. Input ranges are used for the normalization of input values, and the matrices consist of the highest and lowest values for all inputs. Two weight matrices are required, one connecting the input layer with the hidden layer, and the second connecting the hidden layer and the output layer. The dimensions of the matrices can be given using the sizes of the layers. Bias values are used in all neurons of the hidden and the output layer.
The necessary memory for different features and hidden layer neuron numbers can be seen in Figure 4. The required memory spaces are given in bytes. Since all parameter types are floating-point numbers, during computation, 4 bytes were counted for each parameter. It can be observed from Figure 4 that even with the largest examined feature numbers and hidden layer neuron numbers, which are 40 and 30, respectively, the required memory for storing the weights of the MLP is approximately 6 kB. This is much lower than the usual memory capacity of microcontrollers, which shows that the classifier is implementable on such embedded systems.
Figure 4. Memory requirements for the implementation of MLP networks.
The testing shows that after the detection is cleared, the vehicle class can be determined in 1–2 measurement cycles (20–40 ms), without affecting the other parts of the algorithm. The required time depends on the size of the network.

6. Conclusions

In this study, a novel, real-time online vehicle classification system was presented, which utilizes only a single tri-axial magnetic sensor. Data acquisition was performed during multiple months in a real environment using a unit mounted into the pavement. Vehicle detection was performed using an adaptive threshold-based algorithm, which can follow the environmental changes. A camera was also installed beside the road, and images were saved for every detection to determine the vehicle class for each sample.
Nine vehicle classes were defined, and 130 samples per class were used for the training and validation of the classifiers. The utilized features for classification were extracted in the detection windows. The chosen feature types are based on only time domain analysis and have low computation and memory requirements.
Since the classification algorithm should be implemented on the microcontroller-based system, it is important to minimize the applied feature number. Various novel feature extraction modes and used sensor axes were tested to find the optimal configuration. The effect of the detection length was also investigated, since it depends on the speed of the vehicle. Altogether, 36 different datasets were constructed and compared. The classification was performed using three-layer MLP networks.
The obtained results show that using aggregated data in the form of angles or magnitudes can even increase the classification efficiencies besides decreasing the number of inputs. The highest recognition rates on validation data were achieved using magnitudes computed from the origin in the XZ-plane, 74.67% with, and 73.73% without applying the detection length. Using only the X or the Z axis can provide 71–72%, which shows that even a single axis sensor can effectively classify vehicles into multiple classes. The length of the detection on average increases the classification efficiencies only by 1.28% ±1.63% for training data, and 0.80% ±1.37% for unknown samples, which shows that the used features can effectively extract the information from the waveforms. The necessary feature number in the best sets was 14–15, while convergence on unknown samples can be noticed with 10–15 neurons.
The testing shows that the proposed algorithm can be implemented on the microcontroller of the unit, and the vehicle class can be determined in 1–2 measurement cycles (20–40 ms) after the detection is cleared. The solution could also be effectively used in WSN applications, since the classification algorithm runs online, and there is no need to transmit measurement data to a central unit.
The future goals of this research include improving the recognition efficiency, adding more features which could discriminate different trucks and buses, and finding the features with most influence using different feature selection algorithms to reduce the required number of inputs in the classification stage. To deal with the diversity of various locations, data should be collected from further locations and applied together during the training process.

Author Contributions

Conceptualization, P.S.; methodology, P.S.; software, P.S. and A.O.; validation, P.S.; formal analysis, P.S.; investigation, P.S.; resources, P.S.; data curation, P.S.; writing—original draft preparation, P.S.; writing—review and editing, S.P. and A.O.; visualization, P.S. and A.O.; supervision, P.S.; project administration, P.S. and S.P.; funding acquisition, A.O. and P.S. All authors have read and agreed to the published version of the manuscript.

Funding

The work was supported by the National Research, Development, and Innovation Fund of Hungary through project no. 142790 under the FK_22 funding scheme.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

Not applicable.

Acknowledgments

The authors would like to thank Selma Ltd., Subotica, Serbia for the technical resources and support.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Cheung, S.; Varaiya, P. Traffic Surveillance by Wireless Sensor Networks: Final Report; University of California: Berkeley, CA, USA, 2007. [Google Scholar]
  2. Gheorghiu, R.A.; Iordache, V.; Stan, V.A. Urban traffic detectors—Comparison between inductive loop and magnetic sensors. In Proceedings of the International Conference on Electronics, Computers and Artificial Intelligence (ECAI), Pitesti, Romania, 29–30 June 2021. [Google Scholar] [CrossRef]
  3. Gajda, J.; Stencel, M. A highly selective vehicle classification utilizing dual-loop inductive detector. Metrol. Meas. Syst. 2014, 21, 473–484. [Google Scholar] [CrossRef]
  4. Meta, S.; Cinsdikici, M. Vehicle-classification algorithm based on component analysis for single-loop inductive detector. IEEE Trans. Veh. Technol. 2010, 59, 2795–2805. [Google Scholar] [CrossRef]
  5. Gajda, J.; Mielczarek, M. Automatic vehicle classification in systems with single inductive loop detector. Metrol. Meas. Syst. 2014, 21, 619–630. [Google Scholar] [CrossRef]
  6. Balid, W.; Tafish, H.; Refai, H. Intelligent vehicle counting and classification sensor for real-time traffic surveillance. IEEE Trans. Intell. Transp. Syst. 2018, 19, 1784–1794. [Google Scholar] [CrossRef]
  7. Fimbombaya, H.S.; Mvungi, N.H.; Hamisi, N.Y.; Iddi, H.U. Enhanced magnetic wireless sensor network algorithm for traffic flow monitoring in low-speed congested traffic. J. Electr. Comput. Eng. 2020, 2020, 5875398. [Google Scholar] [CrossRef]
  8. Feng, Y.; Zhang, J.A.; Cheng, B.; He, X.; Chen, J. Magnetic sensor-based multi-vehicle data association. IEEE Sens. J. 2021, 21, 24709–24719. [Google Scholar] [CrossRef]
  9. Valenti, G.; Biral, F.; Fontanelli, D. Vehicle Localisation using asphalt embedded magnetometer sensors. In Proceedings of the IEEE International Workshop on Metrology for Automotive (MetroAutomotive), Bologna, Italy, 2–3 July 2021. [Google Scholar] [CrossRef]
  10. Lan, J.; Xiang, Y.; Wang, L.; Shi, Y. Vehicle detection and classification by measuring and processing magnetic signal. Measurement 2011, 44, 174–180. [Google Scholar] [CrossRef]
  11. Wahlström, N.; Hostettler, R.; Gustafsson, F.; Birk, W. Classification of driving direction in traffic surveillance using magnetometers. IEEE Trans. Intell. Transp. Syst. 2014, 15, 1405–1418. [Google Scholar] [CrossRef]
  12. Zhu, Q.; Tong, G.; Li, B.; Yuan, X. A practicable method for ferromagnetic object moving direction identification. IEEE Trans. Magn. 2012, 48, 2340–2345. [Google Scholar] [CrossRef]
  13. Smidla, J.; Simon, G. Accelerometer-based event detector for low-power applications. Sensors 2013, 13, 13978–13997. [Google Scholar] [CrossRef] [PubMed]
  14. Hostettler, R.; Djurić, P. Vehicle tracking based on fusion of magnetometer and accelerometer sensor measurements with particle filtering. IEEE Trans. Veh. Technol. 2015, 64, 4917–4928. [Google Scholar] [CrossRef]
  15. Ma, W.; Xing, D.; McKee, A.; Bajwa, R.; Flores, C.; Fuller, B.; Varaiya, P. A wireless accelerometer-based automatic vehicle classification prototype system. IEEE Trans. Intell. Transp. Syst. 2014, 15, 104–111. [Google Scholar] [CrossRef]
  16. Kleyko, D.; Hostettler, R.; Birk, W.; Osipov, E. Comparison of machine learning techniques for vehicle classification using road side sensors. In Proceedings of the IEEE International Conference on Intelligent Transportation Systems (ITSC), Gran Canaria, Spain, 15–18 September 2015. [Google Scholar] [CrossRef]
  17. Miklusis, D.; Markevicius, V.; Navikas, D.; Cepenas, M.; Balamutas, J.; Valinevicius, A.; Zilys, M.; Cuinas, I.; Klimenta, D.; Andriukaitis, D. Research of distorted vehicle magnetic signatures recognitions, for length estimation in real traffic conditions. Sensors 2021, 21, 7872. [Google Scholar] [CrossRef]
  18. Zhang, Z.; Tao, M.; Yuan, H. A parking occupancy detection algorithm based on AMR sensor. IEEE Sens. J. 2015, 15, 1261–1269. [Google Scholar] [CrossRef]
  19. Zhu, H.; Yu, F. A vehicle parking detection method based on correlation of magnetic signals. Int. J. Distrib. Sens. Netw. 2015, 2015, 361242. [Google Scholar] [CrossRef]
  20. Zhu, H.; Yu, F. A cross-correlation technique for vehicle detections in wireless magnetic sensor network. IEEE Sens. J. 2016, 16, 4484–4494. [Google Scholar] [CrossRef]
  21. Taghvaeeyan, S.; Rajamani, R. Portable roadside sensors for vehicle counting, classification, and speed measurement. IEEE Trans. Intell. Transp. Syst. 2014, 15, 73–83. [Google Scholar] [CrossRef]
  22. Sifuentes, E.; Casas, O.; Pallas-Areny, R. Wireless magnetic sensor node for vehicle detection with optical wake-up. IEEE Sens. J. 2011, 11, 1669–1676. [Google Scholar] [CrossRef]
  23. Markevicius, V.; Navikas, D.; Zilys, M.; Andriukaitis, D.; Valinevicius, A.; Cepenas, M. Dynamic vehicle detection via the use of magnetic field sensors. Sensors 2016, 16, 78. [Google Scholar] [CrossRef]
  24. Burresi, G.; Giorgi, R. A field experience for a vehicle recognition system using magnetic sensors. In Proceedings of the Mediterranean Conference on Embedded Computing (MECO), Budva, Montenegro, 14–18 June 2015. [Google Scholar] [CrossRef]
  25. Vancin, S.; Erdem, E. Implementation of the vehicle recognition systems using wireless magnetic sensors. Sadhana 2017, 42, 841–854. [Google Scholar] [CrossRef]
  26. Yang, B.; Lei, Y. Vehicle detection and classification for low-speed congested traffic with anisotropic magnetoresistive sensor. IEEE Sens. J. 2015, 15, 1132–1138. [Google Scholar] [CrossRef]
  27. Dong, H.; Wang, X.; Zhang, C.; He, R.; Jia, L.; Qin, Y. Improved robust vehicle detection and identification based on single magnetic sensor. IEEE Access 2018, 6, 5247–5255. [Google Scholar] [CrossRef]
  28. Markevicius, V.; Navikas, D.; Idzkowski, A.; Andriukaitis, D.; Valinevicius, A.; Zilys, M. Practical methods for vehicle speed estimation using a microprocessor-embedded system with AMR sensors. Sensors 2018, 18, 2225. [Google Scholar] [CrossRef]
  29. Wang, Q.; Zheng, J.; Xu, H.; Xu, B.; Chen, R. Roadside magnetic sensor system for vehicle detection in urban environments. IEEE Trans. Intell. Transp. Syst. 2018, 19, 1365–1374. [Google Scholar] [CrossRef]
  30. Hodon, M.; Karpis, O.; Sevcik, P.; Kocianova, A. Which digital-output MEMS magnetometer meets the requirements of modern road traffic survey? Sensors 2021, 21, 266. [Google Scholar] [CrossRef] [PubMed]
  31. Spandonidis, C.; Giannopoulos, F.; Sedikos, E.; Reppas, D.; Theodoropoulos, P. Development of a MEMS-based IoV system for augmenting road traffic survey. IEEE Trans. Instrum. Meas. 2022, 71, 9510908. [Google Scholar] [CrossRef]
  32. Tafish, H.; Balid, W.; Refai, H. Cost effective vehicle classification using a single wireless magnetometer. In Proceedings of the International Wireless Communications and Mobile Computing Conference (IWCMC), Paphos, Cyprus, 5–9 September 2016. [Google Scholar] [CrossRef]
  33. Zhang, W.; Tan, G.; Ding, N.; Shang, Y.; Lin, M. Vehicle classification algorithm based on binary proximity magnetic sensors and neural network. In Proceedings of the IEEE International Conference on Intelligent Transportation Systems (ITSC), Beijing, China, 12–15 October 2008. [Google Scholar] [CrossRef]
  34. Velisavljevic, V.; Cano, E.; Dyo, V.; Allen, B. Wireless magnetic sensor network for road traffic monitoring and vehicle classification. Transp. Telecommun. 2016, 17, 274–288. [Google Scholar] [CrossRef]
  35. Wang, K.; Xiong, H.; Zhang, J.; Chen, H.; Dou, D.; Xu, C.-Z. SenseMag: Enabling low-cost traffic monitoring using non-invasive magnetic sensing. IEEE Internet Things J. 2021, 8, 16666–16679. [Google Scholar] [CrossRef]
  36. Xu, C.; Wang, Y.; Bao, X.; Li, F. Vehicle classification using an imbalanced dataset based on a single magnetic sensor. Sensors 2018, 18, 1690. [Google Scholar] [CrossRef]
  37. Zhang, X.; Huang, H. Vehicle classification based on feature selection with anisotropic magnetoresistive sensor. IEEE Sens. J. 2019, 19, 9976–9982. [Google Scholar] [CrossRef]
  38. Chen, X.; Kong, X.; Xu, M.; Sandrasegaran, K.; Zheng, J. Road vehicle detection and classification using magnetic field measurement. IEEE Access 2019, 7, 52622–52633. [Google Scholar] [CrossRef]
  39. Li, W.; Liu, Z.; Hui, Y.; Yang, L.; Chen, R.; Xiao, X. Vehicle classification and speed estimation based on a single magnetic sensor. IEEE Access 2020, 8, 126814–126824. [Google Scholar] [CrossRef]
  40. Li, H.; Dong, H.; Jia, L.; Ren, M. Vehicle classification with single multi-functional magnetic sensor and optimal MNS-based CART. Measurement 2014, 55, 142–152. [Google Scholar] [CrossRef]
  41. Feng, Y.; Mao, G.; Cheng, B.; Li, C.; Hui, Y.; Xu, Z.; Chen, J. MagMonitor: Vehicle speed estimation and vehicle classification through a magnetic sensor. IEEE Trans. Intell. Transp. Syst. 2022, 23, 1311–1322. [Google Scholar] [CrossRef]
  42. Kaewkamnerd, S.; Chinrungrueng, J.; Pongthornseri, R.; Dumnin, S. Vehicle classification based on magnetic sensor signal. In Proceedings of the International Conference on Information and Automation (ICIA), Harbin, China, 20–23 June 2010. [Google Scholar] [CrossRef]
  43. He, Y.; Du, Y.; Sun, L.; Wang, Y. Improved waveform-feature-based vehicle classification using a single-point magnetic sensor. J. Adv. Transp. 2015, 49, 663–682. [Google Scholar] [CrossRef]
  44. Sarcevic, P.; Pletl, S. Vehicle classification and false detection filtering using a single magnetic detector based intelligent sensor. In Proceedings of the International Conference on Information Society and Technology (ICIST), Kopaonik, Serbia, 9–13 March 2014. [Google Scholar]
  45. Sarcevic, P. New Methods in the Application of Inertial and Magnetic Sensors in Online Pattern Recognition Problems. Ph.D. Thesis, University of Szeged, Szeged, Hungary, 2019. [Google Scholar]
  46. Sarcevic, P.; Pletl, S. False detection filtering method for magnetic sensor-based vehicle detection systems. In Proceedings of the IEEE International Symposium on Intelligent Systems and Informatics (SISY), Subotica, Serbia, 13–15 September 2018. [Google Scholar] [CrossRef]
  47. Sarcevic, P.; Kincses, Z.; Pletl, S. Online human movement classification using wrist-worn wireless sensors. J. Ambient Intell. Humaniz. Comput. 2019, 10, 89–106. [Google Scholar] [CrossRef]
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.