Abstract
Recently, significant research efforts have been focused on vehicle parking detection due to fuel consumption and traffic congestion. Many solutions have been successfully applied in indoor parking lots. However, due to the strong noise disturbance in outdoor parking environment, the detection accuracy for on-street parking is still a challenging task. In this paper, we propose a vehicle parking detection method by the use of normalized cross-correlation (NCC) of magnetic signals generated by magnetoresistive sensors. In the proposed method, the sensed signal is correlated with a reference. If the result is greater than a threshold, a pulse is generated. One of the primary factors that affect the accuracy of the NCC-based detection is the choice of reference which is obtained by using a k-means clustering algorithm in this paper. Compared with the-state-of-the-art vehicle detection methods, the proposed method is competitive in terms of cost, accuracy, and complexity. The proposed method is simulated and tested on the Xueyuan Boulevard, University Town of Shenzhen, Nanshan, Shenzhen, China. The experimental results show that the proposed method can provide the detection accuracy of 99.33% for arrival and 99.63% for departure.
1. Introduction
Nowadays, parking problem becomes one of the major issues in densely populated urban cities since the spatial resource of a city is limited and the parking cost is expensive [1]. Searching for an available parking space during peak hours is usually difficult, leading to additional energy waste, traffic jam, and air pollution. Hence, over the past two decades, many parking guidance and information (PGI) systems which present drivers with dynamic information and guide them to vacant parking spaces are built for better parking management [2]. Obviously, the key ingredient in being able to direct drivers to available parking spaces in PGI systems is to have accurate autonomous vehicle detection.
At present, most of solutions for vehicle detection in parking applications are based on wireless sensor networks (WSN) [3]. WSN employs the self-powered sensor which is installed at each individual parking spot to collect environmental data [4]. The collected data will be sent to the base station hop by hop via the wireless channel [5]. The major advantage of WSN is that it can be deployed in existing parking lots without installing new electric wire and network cable. Due to its flexibility in deployment and variety in function [6], WSN is a natural candidate for parking lot management system. Based on the comparison and analysis, magnetic signal detection for vehicle parking is a cost effective solution.
As mentioned, a WSN consists of a large number of sensor nodes which can be self-organized to establish an ad hoc network. A variety of sensors, including video camera [7, 8], ultrasonic sensor [9], acoustic sensor [10], and magnetic sensor [11–18], are adopted to obtain occupancy information from parking spots. Ultrasonic detector is a common approach which has some advantages, such as easy installation, high accuracy, and low cost. However, ultrasonic sensor is sensitivity to the fluctuation of temperature and extreme air turbulence. In addition, it is not applicable to on-street parking where the parking spaces are located along the traffic flow [8]. Instead, video-based detector, which has attracted great attention in recent years, has also been adopted for parking occupancy detection purposes. However, the video-based method suffers from a lack of accuracy and can be affected by the fluctuation of lighting condition, shadow, and perspective distortion. Hence, the deployment of video-based parking detection system in an on-street parking lot is still a challenging task.
A strong candidate for such application is an anisotropic magnetoresistive (AMR) sensor which can detect passing ferromagnetic objects, like vehicles. Compared with other sensors, magnetic sensor which is placed at the center of each parking space is quite small, sensitive, and more immune to environment noise (such as rain, fog, and wind) than other sensors [19]. In addition, magnetic sensor detector has the advantage of simple installation and easy maintenance. Hence, applying magnetic sensors to on-street parking detection is promising.
Over the past few years, the use of AMR sensors for vehicle detection in parking lot and measurement of the traffic flow has been widely studied. However, most of the previous works were based on the threshold methods which can be categorized into fixed-threshold and adaptive-threshold. In the program of California PATH [3], the authors reported the detection capabilities of magnetic sensors and proposed a fixed-threshold method for traffic measurement and vehicle classification with a single magnetic sensor. However, there are two major issues in practice with the fixed-threshold method. First, the earth magnetic field drifts over time. It also varies with location and environment. Hence, the fixed-threshold method may cause false positive and negative detection. Second, the measured magnetic signal may cross the threshold multiple times during vehicle parking and the fixed-threshold method reports multiple vehicles instead of one. A conventional way to deal with magnetic signal drift is to track ambient magnetic field and update when there is no vehicle over the sensor [12]. As for the problem of multiple threshold crossing, the unwanted crossing information should be ignored if magnetic signal is across the threshold twice during a predefined time interval δ. The threshold update method has been studied by many people and many techniques [17]. Although many research efforts have been made for vehicle detection by adopting AMR sensors, most of them are designed for moving vehicle detection. By using optical triggering to wake up the magnetic sensor, the authors in [13] designed a WSN-based method to detect the presence of a vehicle in parking lot using magnetic sensor. Experimental results suggest that the method is power efficient and reliable, but it needs extra hardware. The detection of vehicle based on the analysis of disturbance curve was presented in [16]. The authors introduced a static detection method.
Such methods, including threshold-based and state-machine-based, can be successfully applied when the magnetic signal has a high signal-to-noise ratio (SNR). However, the magnetic signals obtained from sensors installed in an on-street parking lot may contain background noise and adjacent vehicle noise. Therefore, the performance of these methods is largely affected by the noises. Furthermore, it is difficult to determine the threshold, because the magnitude of magnetic signal for different vehicles may vary from tens to hundreds milliGauss. If the threshold is set high, the vehicle which generates small magnetic signal will not be detected. On the other hand, if it is set low, a passing-by vehicle may be detected as a target. Hence, the threshold was experimentally determined in the previous works. To overcome these problems, Zhang et al. [17] proposed a similarity based vehicle detection (SBVD) algorithm for vehicle detection in low SNR conditions by calculating the similarity between measured magnetic signals and a reference signal. In their work, a Gaussian function is adopted as the reference signal. And a similar work was presented in [18] which measured the curve change of magnetic flux when a vehicle passes a sensor as the reference. However, the methods in [17, 18] are dedicated to moving vehicle detection. These moving vehicle detection methods are not suited to detect the arrival or departure of vehicle in parking lot [11].
Considering problems in the previous works, this paper suggests an improved cross-correlation-based detection method using anisotropic magnetoresistive (AMR) sensors for vehicle parking detection. To overcome the drawbacks in the previous works, we adopt the k-means clustering algorithm to find a good reference signal which is the key factor of the cross-correlation-based method. Based on the proposed method, a vehicle parking detection system is designed and applied on the Xueyuan Boulevard, University Town of Shenzhen, Nanshan, Shenzhen, China.
The proposed method has the following merits. First, compared with the video-based method, the proposed method is more accurate in detecting the occupancy of a parking space because it is not affected by environment conditions, such as lighting, shadow, and perspective. In addition, compared with ultrasonic-based method, the proposed method is more robust because it is more immune to the fluctuation of temperature and air turbulence. Furthermore, the proposed method is quite easy to implement and maintain. In addition, the proposed method has more advantages, such as high sensitivity, low cost, small size, and immunity to environment noise (rain, fog, and wind). Finally, the proposed method is tested on the Xueyuan Boulevard, University Town of Shenzhen, Nanshan, Shenzhen, China. It achieves high accuracy of 99.33% for arrival and 99.63% for departure.
The remainder of this paper is organized as follows. In Section 2, we give a short introduction to the vehicle detection system. The detailed discussion of NCC-based detection method is presented in Section 3. Experiments and discussion are provided in Section 4. Section 5 draws the conclusions.
2. System Overview
There are three kinds of nodes in our vehicle detection system, which are sensor nodes, routers, and a base station, as shown in Figure 1. All of these nodes communicate wirelessly and are self-organized into an ad hoc network. As mentioned, a magnetic sensor node is installed at the center of each parking space to obtain the information of occupancy and transmit it to the base station through routers hop by hop.

Three kinds of nodes in the proposed system: (a) sensor node, (b) router, and (c) base station.
As mentioned, a ferromagnetic object, such as a vehicle, disturbs the earth's magnetic field when it is passing by. As the earth's magnetic field is uniform over a wide area, the disturbance of magnetic field caused by a vehicle can be detected by a magnetic sensor. One type of magnetic sensors is AMR sensor, which is suitable for a sensor node because of its small size. In our work, a three-axis AMR sensor, which can measure the magnetic field in x-axis, y-axis, and z-axis simultaneously with high accuracy, is deployed. Figure 2 shows the measured magnetic signals in x-axis, y-axis, and z-axis during a vehicle parking over the sensor placed at the center of a parking slot. The x-axis is parallel to the vehicle moving direction, the z-axis is perpendicular to the earth surface and upward, and the y-axis is perpendicular to the moving direction and forms right-handed coordinate system.

The measured magnetic signal at a parking space.
The outline of the proposed system is shown in Figure 3. The system consists of four parts: preprocessing, features extraction, k-means clustering, and normalized cross-correlation detection. Firstly, we preprocess the magnetic signals obtained from AMR sensors. Secondly, feature extraction is applied to extract the arrival and departure signatures of magnetic signals. Thirdly, a k-means clustering algorithm is applied to obtain the proper reference signal. Finally, the cross-correlation between the reference signal and the detected magnetic signal is calculated and compared with a predefined threshold to determine the presence of a vehicle.

The outline of the proposed vehicle detection method.
3. NCC-Based Detection Method
3.1. Overview of the NCC-Based Detection
We define
It is noted that the change of magnetic field depends on the ferromagnetic material and structure of vehicle chassis. Figure 4 presents the changes of the magnetic field caused by various types of vehicles. Based on the observations, it is possible to find common features for a type of vehicles. In this case, the patterns are adopted as reference signals. And, then, the similarity between the reference signals and incoming signal is calculated to monitor the occupancy of a parking space. The normalized cross-correlation (NCC) function can be used to measure the similarity between two signals [20].

The measured magnetic signals.
The proposed method gives the enhancement in SNR, which is achieved by coherent signal processing. Our work aims at developing a reliable algorithm for vehicle occupancy detection for on-street parking by using NCC method to improve the SNR.
The measured signal
The NCC value between the reference signal and the measured signal
Based on the analysis earlier, we keep a sliding window over the incoming data streams. When correlation between the incoming data and reference reaches a threshold, that is,
Step 1.
Input the measured signal
Step 2.
The result of
As mentioned before, the performance can be improved by increasing SNR through NCC method. However, the key issue for the success of detection is to choose a proper reference signal
To solve the problem, we propose a reference signal model using k-means clustering algorithm. The reference signal can be obtained as follows.
Step 1.
Collect the vehicle magnetic signals in an on-street parking lot for training purpose.
Step 2.
Preprocess the collected signals and extract the magnetic signatures of vehicle arrival and departure.
Step 3.
By adopting the k-means clustering algorithm, the centers of k clusters are the reference signals.
As previously stated in Section 2, the proposed method consists of four parts: preprocessing, features extraction, k-means clustering, and cross-correlation detection. The details are discussed as follows.
3.2. Preprocessing
To test the proposed algorithms, fifty sensor nodes are deployed on the Xueyuan Boulevard, University Town of Shenzhen, Nanshan, Shenzhen, China. A large number of vehicle magnetic signals are collected, including the information of vehicle type and model.
3.2.1. Filtering
The output of AMR sensor needs to be filtered due to environment noise. Therefore, to prevent slow magnetic field fluctuations, a moving-average filter is adopted to smooth out the measured signal. The filter takes a running average of the signal, which is given by
The

An example of signal filtering.
3.2.2. Debaseline Processing
Instead of the entire car together with Earth's magnetic field, this work is interested in acquiring the isolated anomalous field of the vehicle itself. For the purpose of extracting the isolated anomalous field of the car, the debaseline process has to be done after filtering, as shown in
There is a drift in the baseline of magnetic signal, which is mainly caused by the interference of adjacent vehicles and temperature, as show in Figure 6. In order to remove the drift, an adaptive algorithm is introduced to track the baseline

The measured baseline by AMR.
3.2.3. The Module of the Measured Magnetic Signal
The direction of the magnetic field is not important in vehicle parking application. However, the drift of the magnetic signal is the extremely important in vehicle parking detection. As mentioned earlier, the module magnitude of the measured magnetic signal

An example of signal preprocess: (a) raw signal (left), (b) the magnitude of magnetic signal
3.3. Signature Extraction
3.3.1. Segmentation
It can be seen that only a small portion of the signal contains the useful information of vehicle arrival and departure in Figure 7(a). While the parking space is vacant or occupied, the signal keeps static. In order to save computation time of vehicle detection, the static part of the signal should be removed. The signature varies for different vehicles and mostly depends on the metallic composition and configuration of the vehicle which is the basis of finding reference signal. In our work, the vehicle signature extraction process is as follows.
The preprocessed signal
3.3.2. Interpolation and Normalization
The sensor output is sampled at 50 Hz. Since the metallic structures are different for different type of vehicles, the group of vehicle signatures usually contains a large number of samples, that is, sample vectors. In addition, the number of sample vectors in a signature group is affected by vehicle moving speed. In order to eliminate the effect of speed on vehicle detection, interpolation process is applied to resample the signals at a certain rate. In this work, neighbor interpolation method is adopted to resample the detected vehicle signal to a fixed length M. The neighbor interpolation algorithm selects the nearest samples and their magnitudes are normalized between −1 and 1 with 0 mean.
Figure 8 shows the raw and processed samples of the detected four vehicles in an on-street parking lot. The signals of vehicle arrival are shown in Figures 8(a), 8(c), 8(e), and 8(g). On the other hand, the departure signals are shown in Figures 8(b), 8(d), 8(f), and 8(h). As illustrated in Figure 8, the processed signals have fixed length

The raw and processed signals for different vehicles.
3.4. k-Means Clustering
Since the magnetic field of earth is uniform over a couple of kilometers, the magnetic signals of the same vehicle measured at adjacent locations in the same moving direction and velocity are expected to be the same. To classify the vehicle signals into several groups, clustering method is adopted in this paper. Clustering is an unsupervised learning method which partitions a given data set into a certain number of groups. Each group consists of similar vehicle signals that are different to those in other groups [21].
Among clustering algorithms, the most popular and most widely studied one is the k-means clustering algorithm [22–24]. It is known that this algorithm converges to a local optimum by minimizing the mean square distance between each measured signal and the nearest centroid. In this algorithm, the training samples are classified into k partitions
Step 1.
Choose k cluster centers
Step 2.
Each sample
Step 3.
Each centroid is updated by calculating the mean of all signal samples which are labeled to this centroid
Step 4.
Return to Step 2 if the procedure is not convergent to a local minimum.
The resulting set of k cluster centroids provide a model which can be used as reference signal in NCC-based detection algorithm. The k is chosen as 2 based on our experiments. The vehicle arrival and departure for two clusters are shown in Figure 9.

The result of
3.5. Normalization of Cross-Correlation Detection
Based on the analysis in Section 3.4, we have found two reference signals for vehicle arrival detection and two for departures detection. We keep a sliding window over the data stream to monitor the most recent incoming signals. The cross-correlation coefficient
We denote the A_C1 and A_C2 as the reference signals for vehicle arrival and D_C1 and D_C2 for departure. When
The previous status of parking space: The detection signal: The reference signals for arrival: The reference signals for departure: The current status of parking space: S_C = 1; S_C = 1; S_C = 0; S_C = 0; S_C = 0; S_C = 1; S_P = S_C;
The “Corr(·)” denotes the cross-correlation given by (3). An example of the cross-correlation of a given vehicle signal with the reference is shown in Figure 10. According to Algorithm 1, the “arrival” and “departure” are detected when the value of NCC exceeds the predefined threshold TH. As shown in Figure 10, the “arrival” events are detected at the points “A1” to “A12”, and “departure” events are detected at the points “D1” to “D12.”

An example of occupancy detection using NCC-based method.
4. Experiment and Discussion
To verify the performance of the proposed techniques, several experiments were conducted on Xueyuan Boulevard, University Town of Shenzhen, Nanshan, Shenzhen, China, where fifty sensor nodes are deployed.
4.1. Experiment Configuration and Parameter Setting
In the experiments, an AMR sensor is installed at each parking space, as shown in Figure 11. The parameters related to the proposed algorithm are given in Table 1.
Parameters in the experiments.

Sensor nodes are deployed in our experiments. The router is installed on the street light.
4.2. Results of Detection
The performance of the vehicle detection in a parking lot can be evaluated by calculating the success rate of vehicle arrival (RVA) and departure (RVD), which are defined as follows:

The detected vehicle signals of a parking space in a normal day.
4.3. Comparison
For comparing the proposed method with those in [15, 17, 18], simulations using the same data set were conducted. The accuracy of vehicle detection is shown in Table 2 and the histogram is shown in Figure 13.
Vehicle detection results.

The accuracy of the four different methods.
4.4. Discussion
4.4.1. Performance
As mentioned, the threshold-based detection method is a simple and efficient solution for vehicle detection. However, it is difficult to determine the threshold value since magnetic field varies from tens to hundreds milliGauss. For example, if we define the threshold as 50 and the incoming signal is shown in Figure 14, obviously, the departure event may be missed and the interference may cause wrong decision. However, as we can see in Figure 14, our NCC-based algorithm works well in this situation.

The vehicle detection for small change in magnetic field using NCC-based method.
Moreover, the performance of threshold-based method is largely affected by the background noise or adjacent vehicle. As illustrated in Figure 15, there are interference signals caused by adjacent vehicles.

The vehicle detection with interference signals using NCC-based method.
As we can see, the fluctuation of magnetic field is more than 180 which may cause the false alarm in the threshold-based method. However, the NCC of the interference and reference signal is lower than 0.5 while the threshold of the NCC is predefined as 0.9 in our experiment. The result yielded by the proposed method is shown in Figure 15.
4.4.2. Energy Consumption
As we know, magnetic signal is almost static if there is no vehicle arrival or departure. The time duration of arrival or departure is usually between 5 s and 60 s. In order to make the best tradeoff between the energy consumption and performance of the vehicle detection, an adaptive sampling algorithm is designed for vehicle detection. In the algorithm, the sampling rate is adaptive to the fluctuation of the magnetic signal. For example, if there is a vehicle arriving or leaving, the sampling rate may rise up to 50 Hz. Otherwise, the sampling rate is kept as low as 1 Hz for static magnetic signal, as shown in Figure 16.

An example of adaptive sampling mechanism.
Another energy consumption happens in packet exchange among nodes. After the accomplishment of network deployment, the sensor nodes exchange packets for maintaining the network infrastructure. If there is vehicle arrival or departure, the sensor node sends detection flag to the base station. Otherwise, the sensor node goes into sleep when there is no signal fluctuation.
The consumption of energy can be expressed as
The primary parameters are estimated in experiments for calculating energy consumption, as shown in Table 3.
Parameters for energy consumption estimation.
According to adaptive sampling algorithm,
A pair of 2700 mAh AA Li batteries are used in each magnetic sensor node. The battery lifetime, which can be easily calculated, is about 5 years.
5. Conclusion
By using the measured signals from a magnetic sensor with three axes, we have proposed a vehicle parking detection algorithm based on the cross-correlation method. The cross-correlation of the magnetic signal with a reference is calculated. Then, the decision is made based on the cross-correlation result. A k-means clustering algorithm has been introduced to obtain a good reference which is important in the proposed algorithm. By increasing the SNR through NCC-based algorithm, the performance of vehicle detection for on-street has been improved in a low SNR situation.
In order to evaluate the performance of the proposed method, experiments have been conducted. Three state-of-the-art methods have been compared. In the experiments, some false positive and negative decisions have been made using the three methods due to the small change of the magnetic signal or the interference of noise. As we can see, our proposed NCC-based algorithm can work well in these situations. The NCC-based algorithm can provide the detection accuracy of 99.33% for arrival and 99.63% for departure. It is more reliable for the on-street parking applications.
Footnotes
Conflict of Interests
The authors declare that there is no conflict of interests regarding the publication of this paper.
Acknowledgments
This work was partially supported by Shenzhen Key Lab for RF Integrated Circuits, Shenzhen Shared Technology Service Center for Internet of Things, Fujian Government Fund with Grant no. 2013HZ0004, Guangdong Government Fund with Grant no. 2012B090600035, and Foshan Government Fund with Grant no. 2013HK100142.
