# A Vehicle Parking Detection Method Based on Correlation of Magnetic Signals

Authors: Hongmei Zhu; Fengqi Yu
Journal: International Journal of Distributed Sensor Networks
 (2015)

---

## 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 ak-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.


---

## Body

## 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 thek-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 Section2, 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 Figure1. 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.Figure 1
Three kinds of nodes in the proposed system: (a) sensor node, (b) router, and (c) base station.
(a)
(b)
(c)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 inx-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.Figure 2
The measured magnetic signal at a parking space.The outline of the proposed system is shown in Figure3. 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.Figure 3
The outline of the proposed vehicle detection method.


## 3. NCC-Based Detection Method

### 3.1. Overview of the NCC-Based Detection

We defineG(t) as the magnitude of magnetic field which can be expressed as(1)Gt=x2t+y2t+z2t.It is noted that the change of magnetic field depends on the ferromagnetic material and structure of vehicle chassis. Figure4 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].Figure 4
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 signalG(m) can be expressed as(2)Gm=Sm+Nm,where S(m) is generated by a vehicle and N(m) is the noise caused by surrounding. The m is the mth sample of the measured signal (1≤m≤M and M is the total number of samples). If the signal S(m) can be expressed by a reference Y(m), the vehicle can be detected by the measured signal G(m).The NCC value between the reference signal and the measured signalG(m), RGY, is calculated as(3)RGYτ=∑m=0M-τ-1Gm-G-Ym+τ-Y-∑m=0M-τ-1Gm-G-2∑m=τM-1Ym-Y-2,where G-=(1/(M-τ))∑m=0M-τ-1Gm and Y-=(1/(m-τ))∑m=τM-1Ym, respectively. G(m) and Ym are both sampled at Δt intervals and τ (τ=nΔt) is the shift between the two sequences. Hence,(4)RG0=∑m=0M-τ-1Gm-G-2,RY0=∑m=τM-1Ym-Y-2.Equation (3) can be simplified as(5)RGYτ=∑m=0M-τ-1Sm+Nm-G-Ym+τ-Y-RG0RY0,where RGY∈[-1,1] indicates the correlation behavior of sequences. For the purpose of improving the SNR, we should maximize the spectral energy of magnetic signal S(m). At the same time, minimize the spectral energy of noise signal N(m). Obviously, if the reference signal Yτ=St0-τ(at the time t0), the largest SNR can be achieved. And the NCC of S(m) and Y(m) reaches the peak value at t0, whilst the NCC of N(m) and Y(m) keeps low.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,RGY≥TH, an event (arrival or departure) is considered to be detected. The detection result, including the corresponding time delay τ, is reported. The proposed NCC-based detection algorithm can be accomplished in two steps as follows.Step 1.
Input the measured signalG(m), and then calculate the cross-correlation coefficient RGY(τ) of Gm and reference Y(m).Step 2.
The result ofRGY(τ) is used to make decision by comparing it with a predefined threshold value TH.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 signalY(m). Obviously, the choice of reference signal is to try to maximize the correlation between S(m) and reference and minimize the correlation between N(m) and reference.To solve the problem, we propose a reference signal model usingk-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 thek-means clustering algorithm, the centers of k clusters are the reference signals.As previously stated in Section2, 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(6)xst=xrawt+xrawt-1+⋯+xraw1t,t<N,xrawt+xrawt-1+⋯+xrawt-N+1N,t≥N.Thexrawt is the raw magnetic value of x-axis at time t. The N is the predefined signal size for running average. The plots of the raw magnetic signal and its filtering are shown in Figure 5. We can see that the vehicle waveform is smoother and better for making decision.Figure 5
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(7)xs-bt=xst-xbaset,where xs(t) and xbase(t) are the filtered magnetic signal and baseline of x-axis, respectively.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 Figure6. In order to remove the drift, an adaptive algorithm is introduced to track the baseline xbase(t). The updated equation is given as follows:(8)xbaset=xbaset-1×α+xst×1-α,vacant,xbaset-1,occupied,where α is the forgetting factor which denotes the update frequency of baseline. And the xs(t) is the filtered value of sensed signal. From (8), we can see the baseline is updated only when the parking space is vacant. The y-axis and z-axis can be processed in a similar way.Figure 6
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 signalG(t) is defined by (1). After applying the preprocess, the result is shown in Figure 7. The raw signal (in x, y, and z direction) is presented in Figure 7(a) and the preprocessed signalG(t) is plotted in Figure 7(b).Figure 7
An example of signal preprocess: (a) raw signal (left), (b) the magnitude of magnetic signalG(t) (right).
(a)
(b)


### 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 Figure7(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 signalG(t) is a time-stamped sequence and is stored in a buffer. The signatures of vehicle arrival and departure, denoted as Ga and Gd, respectively, are extracted from the sequence in the buffer with a time window, expressed as (9a) and (9b):(9a)Ga=Gt,t1-td≤t≤t2+td,(9b)Gd=Gt,t3-td≤t≤t4+td,where t1 is the start point and t2 is the end point of arrival; on the other hand, t3 and t4 are the start point and the end point of departure, respectively. The td is a parameter that represents a time window which includes an addition to the detected event time window. An example of segmentation can be seen in Figure 7(b).


#### 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 lengthM. The neighbor interpolation algorithm selects the nearest samples and their magnitudes are normalized between −1 and 1 with 0 mean.Figure8 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 M=20 and range [-1,1].Figure 8
The raw and processed signals for different vehicles.
(a)
Arrival signal of vehicle 1
(b)
Departure signal of vehicle 1
(c)
Arrival signal of vehicle 2
(d)
Departure signal of vehicle 2
(e)
Arrival signal of vehicle 3
(f)
Departure signal of vehicle 3
(g)
Arrival signal of vehicle 4
(h)
Departure signal of vehicle 4


### 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 thek-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 {Cj}j=1,…,k by minimizing the distortion as(10)Ψk-means=min⁡∑j=1k∑xi→∈Cjxi→-μj→2,where xi→ is the ith training sample and μj→ is the center of the jth partition Cj. The steps of k-means algorithm can be described as follows.Step 1.
Choosek cluster centers {μj→}j=1,…,k. There are a number of methods for initialization of k cluster centers. To simplify the task, the centers are initialized by randomly choosing k samples from the training sequence.Step 2.
Each samplexi→ is labeled and assigned to the nearest cluster Cj (j=1,…,k) according to Euclidean distance.Step 3.
Each centroid is updated by calculating the mean of all signal samples which are labeled to this centroidxi→∈Cj (j=1,…,k) according to(11)μj→=1μj→∑xi→∈Cjxi→.Step 4.
Return to Step2 if the procedure is not convergent to a local minimum.The resulting set ofk 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.Figure 9
The result ofk=2 cluster centroids.


### 3.5. Normalization of Cross-Correlation Detection

Based on the analysis in Section3.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 RGY(τ) of G(m) and references are calculated one by one.We denote theA_C1 andA_C2 as the reference signals for vehicle arrival andD_C1 andD_C2 for departure. When RGYτ>TH, the vehicle arrival or departure is detected with delay τ. The detection process can be described as in Algorithm 1.Algorithm 1:NCC-based detection.
Input:
The previous status of parking space:S_P;
The detection signal:G(m);
The reference signals for arrival:A_C1, A_C2;
The reference signals for departure:D_C1, D_C2.
Output:
The current status of parking space: S_C.
if  S_P == 0, then
RGA = Corr(G(m)⋅A_C1);
if  RGA > TH, then
S_C = 1;
else
RGA = Corr(G(m)⋅A_C2);
if  RGA > TH, then
S_C = 1;
else
S_C = 0;
end if
end if
else
RDA = Corr(G(m)⋅D_C1);
if  RDA > TH, then
S_C = 0;
else
RDA = Corr(G(m)⋅D_C2);
if  RDA > TH, then
S_C = 0;
else
S_C = 1;
end if
end if
end if
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.”Figure 10
An example of occupancy detection using NCC-based method.


## 3.1. Overview of the NCC-Based Detection

We defineG(t) as the magnitude of magnetic field which can be expressed as(1)Gt=x2t+y2t+z2t.It is noted that the change of magnetic field depends on the ferromagnetic material and structure of vehicle chassis. Figure4 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].Figure 4
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 signalG(m) can be expressed as(2)Gm=Sm+Nm,where S(m) is generated by a vehicle and N(m) is the noise caused by surrounding. The m is the mth sample of the measured signal (1≤m≤M and M is the total number of samples). If the signal S(m) can be expressed by a reference Y(m), the vehicle can be detected by the measured signal G(m).The NCC value between the reference signal and the measured signalG(m), RGY, is calculated as(3)RGYτ=∑m=0M-τ-1Gm-G-Ym+τ-Y-∑m=0M-τ-1Gm-G-2∑m=τM-1Ym-Y-2,where G-=(1/(M-τ))∑m=0M-τ-1Gm and Y-=(1/(m-τ))∑m=τM-1Ym, respectively. G(m) and Ym are both sampled at Δt intervals and τ (τ=nΔt) is the shift between the two sequences. Hence,(4)RG0=∑m=0M-τ-1Gm-G-2,RY0=∑m=τM-1Ym-Y-2.Equation (3) can be simplified as(5)RGYτ=∑m=0M-τ-1Sm+Nm-G-Ym+τ-Y-RG0RY0,where RGY∈[-1,1] indicates the correlation behavior of sequences. For the purpose of improving the SNR, we should maximize the spectral energy of magnetic signal S(m). At the same time, minimize the spectral energy of noise signal N(m). Obviously, if the reference signal Yτ=St0-τ(at the time t0), the largest SNR can be achieved. And the NCC of S(m) and Y(m) reaches the peak value at t0, whilst the NCC of N(m) and Y(m) keeps low.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,RGY≥TH, an event (arrival or departure) is considered to be detected. The detection result, including the corresponding time delay τ, is reported. The proposed NCC-based detection algorithm can be accomplished in two steps as follows.Step 1.
Input the measured signalG(m), and then calculate the cross-correlation coefficient RGY(τ) of Gm and reference Y(m).Step 2.
The result ofRGY(τ) is used to make decision by comparing it with a predefined threshold value TH.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 signalY(m). Obviously, the choice of reference signal is to try to maximize the correlation between S(m) and reference and minimize the correlation between N(m) and reference.To solve the problem, we propose a reference signal model usingk-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 thek-means clustering algorithm, the centers of k clusters are the reference signals.As previously stated in Section2, 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(6)xst=xrawt+xrawt-1+⋯+xraw1t,t<N,xrawt+xrawt-1+⋯+xrawt-N+1N,t≥N.Thexrawt is the raw magnetic value of x-axis at time t. The N is the predefined signal size for running average. The plots of the raw magnetic signal and its filtering are shown in Figure 5. We can see that the vehicle waveform is smoother and better for making decision.Figure 5
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(7)xs-bt=xst-xbaset,where xs(t) and xbase(t) are the filtered magnetic signal and baseline of x-axis, respectively.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 Figure6. In order to remove the drift, an adaptive algorithm is introduced to track the baseline xbase(t). The updated equation is given as follows:(8)xbaset=xbaset-1×α+xst×1-α,vacant,xbaset-1,occupied,where α is the forgetting factor which denotes the update frequency of baseline. And the xs(t) is the filtered value of sensed signal. From (8), we can see the baseline is updated only when the parking space is vacant. The y-axis and z-axis can be processed in a similar way.Figure 6
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 signalG(t) is defined by (1). After applying the preprocess, the result is shown in Figure 7. The raw signal (in x, y, and z direction) is presented in Figure 7(a) and the preprocessed signalG(t) is plotted in Figure 7(b).Figure 7
An example of signal preprocess: (a) raw signal (left), (b) the magnitude of magnetic signalG(t) (right).
(a)
(b)


## 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(6)xst=xrawt+xrawt-1+⋯+xraw1t,t<N,xrawt+xrawt-1+⋯+xrawt-N+1N,t≥N.Thexrawt is the raw magnetic value of x-axis at time t. The N is the predefined signal size for running average. The plots of the raw magnetic signal and its filtering are shown in Figure 5. We can see that the vehicle waveform is smoother and better for making decision.Figure 5
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(7)xs-bt=xst-xbaset,where xs(t) and xbase(t) are the filtered magnetic signal and baseline of x-axis, respectively.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 Figure6. In order to remove the drift, an adaptive algorithm is introduced to track the baseline xbase(t). The updated equation is given as follows:(8)xbaset=xbaset-1×α+xst×1-α,vacant,xbaset-1,occupied,where α is the forgetting factor which denotes the update frequency of baseline. And the xs(t) is the filtered value of sensed signal. From (8), we can see the baseline is updated only when the parking space is vacant. The y-axis and z-axis can be processed in a similar way.Figure 6
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 signalG(t) is defined by (1). After applying the preprocess, the result is shown in Figure 7. The raw signal (in x, y, and z direction) is presented in Figure 7(a) and the preprocessed signalG(t) is plotted in Figure 7(b).Figure 7
An example of signal preprocess: (a) raw signal (left), (b) the magnitude of magnetic signalG(t) (right).
(a)
(b)


## 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 Figure7(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 signalG(t) is a time-stamped sequence and is stored in a buffer. The signatures of vehicle arrival and departure, denoted as Ga and Gd, respectively, are extracted from the sequence in the buffer with a time window, expressed as (9a) and (9b):(9a)Ga=Gt,t1-td≤t≤t2+td,(9b)Gd=Gt,t3-td≤t≤t4+td,where t1 is the start point and t2 is the end point of arrival; on the other hand, t3 and t4 are the start point and the end point of departure, respectively. The td is a parameter that represents a time window which includes an addition to the detected event time window. An example of segmentation can be seen in Figure 7(b).


### 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 lengthM. The neighbor interpolation algorithm selects the nearest samples and their magnitudes are normalized between −1 and 1 with 0 mean.Figure8 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 M=20 and range [-1,1].Figure 8
The raw and processed signals for different vehicles.
(a)
Arrival signal of vehicle 1
(b)
Departure signal of vehicle 1
(c)
Arrival signal of vehicle 2
(d)
Departure signal of vehicle 2
(e)
Arrival signal of vehicle 3
(f)
Departure signal of vehicle 3
(g)
Arrival signal of vehicle 4
(h)
Departure signal of vehicle 4


## 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 Figure7(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 signalG(t) is a time-stamped sequence and is stored in a buffer. The signatures of vehicle arrival and departure, denoted as Ga and Gd, respectively, are extracted from the sequence in the buffer with a time window, expressed as (9a) and (9b):(9a)Ga=Gt,t1-td≤t≤t2+td,(9b)Gd=Gt,t3-td≤t≤t4+td,where t1 is the start point and t2 is the end point of arrival; on the other hand, t3 and t4 are the start point and the end point of departure, respectively. The td is a parameter that represents a time window which includes an addition to the detected event time window. An example of segmentation can be seen in Figure 7(b).


## 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 lengthM. The neighbor interpolation algorithm selects the nearest samples and their magnitudes are normalized between −1 and 1 with 0 mean.Figure8 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 M=20 and range [-1,1].Figure 8
The raw and processed signals for different vehicles.
(a)
Arrival signal of vehicle 1
(b)
Departure signal of vehicle 1
(c)
Arrival signal of vehicle 2
(d)
Departure signal of vehicle 2
(e)
Arrival signal of vehicle 3
(f)
Departure signal of vehicle 3
(g)
Arrival signal of vehicle 4
(h)
Departure signal of vehicle 4


## 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 thek-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 {Cj}j=1,…,k by minimizing the distortion as(10)Ψk-means=min⁡∑j=1k∑xi→∈Cjxi→-μj→2,where xi→ is the ith training sample and μj→ is the center of the jth partition Cj. The steps of k-means algorithm can be described as follows.Step 1.
Choosek cluster centers {μj→}j=1,…,k. There are a number of methods for initialization of k cluster centers. To simplify the task, the centers are initialized by randomly choosing k samples from the training sequence.Step 2.
Each samplexi→ is labeled and assigned to the nearest cluster Cj (j=1,…,k) according to Euclidean distance.Step 3.
Each centroid is updated by calculating the mean of all signal samples which are labeled to this centroidxi→∈Cj (j=1,…,k) according to(11)μj→=1μj→∑xi→∈Cjxi→.Step 4.
Return to Step2 if the procedure is not convergent to a local minimum.The resulting set ofk 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.Figure 9
The result ofk=2 cluster centroids.


## 3.5. Normalization of Cross-Correlation Detection

Based on the analysis in Section3.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 RGY(τ) of G(m) and references are calculated one by one.We denote theA_C1 andA_C2 as the reference signals for vehicle arrival andD_C1 andD_C2 for departure. When RGYτ>TH, the vehicle arrival or departure is detected with delay τ. The detection process can be described as in Algorithm 1.Algorithm 1:NCC-based detection.
Input:
The previous status of parking space:S_P;
The detection signal:G(m);
The reference signals for arrival:A_C1, A_C2;
The reference signals for departure:D_C1, D_C2.
Output:
The current status of parking space: S_C.
if  S_P == 0, then
RGA = Corr(G(m)⋅A_C1);
if  RGA > TH, then
S_C = 1;
else
RGA = Corr(G(m)⋅A_C2);
if  RGA > TH, then
S_C = 1;
else
S_C = 0;
end if
end if
else
RDA = Corr(G(m)⋅D_C1);
if  RDA > TH, then
S_C = 0;
else
RDA = Corr(G(m)⋅D_C2);
if  RDA > TH, then
S_C = 0;
else
S_C = 1;
end if
end if
end if
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.”Figure 10
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 Figure11. The parameters related to the proposed algorithm are given in Table 1.Table 1
Parameters in the experiments.
Parameters
Description
Value
α
Forgetting factor in baseline update
0.95
N
Buffer length of moving filter
26
t
d
An additional time for detection window
5 s
k
The number ofk-means clusters
2
TH
The threshold for NCC detection
0.9Figure 11
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:(12a)RVA=NaNaa,(12b)RVD=NdNad,(12c)MAV=Na+NdNaa+Nad.The Na and Nd refer to the number of times of successful detection of vehicle arrival and departure, respectively. And Naa and Nad denote the total number of times of vehicle arrival and departure, respectively. The mean accuracy of vehicle detection (MAV) is expressed in (12c). In our experiments, totally 2718 events were detected during three days. Only 9 out of 1359 arrival events and 5 out of 1359 departure events were missed. The accuracy was 99.33% for arrival detection and 99.63% for departure. Figure 12 shows the occupancy detection of a parking space for a normal day using the proposed method.Figure 12
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.Table 2
Vehicle detection results.
Method
Arrival
Departure
MAV
Total
Detected
RVA
Total
Detected
RVD
In [15]
1359
1319
97.06%
1359
1315
97.76%
96.91%
In [17]
1223
89.99%
1227
90.29%
90.14%
In [18]
1235
90.88%
1229
90.43%
90.65%
Our work
1350
99.33%
1354
99.63%
99.48%Figure 13
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 Figure14, 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.Figure 14
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 Figure15, there are interference signals caused by adjacent vehicles.Figure 15
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 Figure15.


#### 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 Figure16.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(13)E=Esample+Etransmit+Enetwork+Esleep,where Esample is the energy consumption of sampling, Etransmit denotes the energy consumption of transmission, Enetwork is the energy consumption of network deployment, and Esleep is the energy consumption of sensor node while sleeping. Enetwork is very small that it can be ignored.The primary parameters are estimated in experiments for calculating energy consumption, as shown in Table3.Table 3
Parameters for energy consumption estimation.
Parameters
Description
Value
I
sleep
Current for sensor sleeping
2μA
I
sample
Current for sensor sampling
10 mA
I
transmit
Current for sensor transmission
28 mA
F
fast
High frequency for detection
50 Hz
N
fast
Number of high frequency
50
N
transmit
Number of transmission
50
T
fast
Time duration per high frequency
30 s
T
sample
Time duration per sampling
5 ms
T
transmit
Time duration per transmission
5 ms
F
slow
Slow frequency for detection
1 Hz
V
Voltage of battery
3 VAccording to adaptive sampling algorithm,Esample can be expressed as (14)Esample=Isample×V×tsample,where tsample is the average time for sampling per day and it can be described as (15)tsample=tfast_sample+tslow_sample,where tfast_sample=Nfast×Tfast×Ffast×Tsample and tslow_sample=(Tday-Nfast×Tfast)×Fslow×Tsample. Tday is one day in seconds, which is equal to 86400. Tsample is the sampling time. The energy consumption of transmission is expressed as (16)Etransmit=Itransmit×V×ttransmit,where ttransmit is average time for transmission per day, which can be described expressed as:(17)ttransmit=Ntransmit×Ttransmit,where Ntransmit and Ttransmit are the average number of transmissions in one day and the average time duration for one transmission, respectively. The sleep energy consumption of sensor node is(18)Esleep=Isleep×V×tsleep,where the average sleep time can be expressed as(19)tsleep=Tday-tsample-ttransmit.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.


## 4.1. Experiment Configuration and Parameter Setting

In the experiments, an AMR sensor is installed at each parking space, as shown in Figure11. The parameters related to the proposed algorithm are given in Table 1.Table 1
Parameters in the experiments.
Parameters
Description
Value
α
Forgetting factor in baseline update
0.95
N
Buffer length of moving filter
26
t
d
An additional time for detection window
5 s
k
The number ofk-means clusters
2
TH
The threshold for NCC detection
0.9Figure 11
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:(12a)RVA=NaNaa,(12b)RVD=NdNad,(12c)MAV=Na+NdNaa+Nad.The Na and Nd refer to the number of times of successful detection of vehicle arrival and departure, respectively. And Naa and Nad denote the total number of times of vehicle arrival and departure, respectively. The mean accuracy of vehicle detection (MAV) is expressed in (12c). In our experiments, totally 2718 events were detected during three days. Only 9 out of 1359 arrival events and 5 out of 1359 departure events were missed. The accuracy was 99.33% for arrival detection and 99.63% for departure. Figure 12 shows the occupancy detection of a parking space for a normal day using the proposed method.Figure 12
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.Table 2
Vehicle detection results.
Method
Arrival
Departure
MAV
Total
Detected
RVA
Total
Detected
RVD
In [15]
1359
1319
97.06%
1359
1315
97.76%
96.91%
In [17]
1223
89.99%
1227
90.29%
90.14%
In [18]
1235
90.88%
1229
90.43%
90.65%
Our work
1350
99.33%
1354
99.63%
99.48%Figure 13
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 Figure14, 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.Figure 14
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 Figure15, there are interference signals caused by adjacent vehicles.Figure 15
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 Figure15.


### 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 Figure16.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(13)E=Esample+Etransmit+Enetwork+Esleep,where Esample is the energy consumption of sampling, Etransmit denotes the energy consumption of transmission, Enetwork is the energy consumption of network deployment, and Esleep is the energy consumption of sensor node while sleeping. Enetwork is very small that it can be ignored.The primary parameters are estimated in experiments for calculating energy consumption, as shown in Table3.Table 3
Parameters for energy consumption estimation.
Parameters
Description
Value
I
sleep
Current for sensor sleeping
2μA
I
sample
Current for sensor sampling
10 mA
I
transmit
Current for sensor transmission
28 mA
F
fast
High frequency for detection
50 Hz
N
fast
Number of high frequency
50
N
transmit
Number of transmission
50
T
fast
Time duration per high frequency
30 s
T
sample
Time duration per sampling
5 ms
T
transmit
Time duration per transmission
5 ms
F
slow
Slow frequency for detection
1 Hz
V
Voltage of battery
3 VAccording to adaptive sampling algorithm,Esample can be expressed as (14)Esample=Isample×V×tsample,where tsample is the average time for sampling per day and it can be described as (15)tsample=tfast_sample+tslow_sample,where tfast_sample=Nfast×Tfast×Ffast×Tsample and tslow_sample=(Tday-Nfast×Tfast)×Fslow×Tsample. Tday is one day in seconds, which is equal to 86400. Tsample is the sampling time. The energy consumption of transmission is expressed as (16)Etransmit=Itransmit×V×ttransmit,where ttransmit is average time for transmission per day, which can be described expressed as:(17)ttransmit=Ntransmit×Ttransmit,where Ntransmit and Ttransmit are the average number of transmissions in one day and the average time duration for one transmission, respectively. The sleep energy consumption of sensor node is(18)Esleep=Isleep×V×tsleep,where the average sleep time can be expressed as(19)tsleep=Tday-tsample-ttransmit.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.


## 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 Figure14, 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.Figure 14
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 Figure15, there are interference signals caused by adjacent vehicles.Figure 15
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 Figure15.


## 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 Figure16.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(13)E=Esample+Etransmit+Enetwork+Esleep,where Esample is the energy consumption of sampling, Etransmit denotes the energy consumption of transmission, Enetwork is the energy consumption of network deployment, and Esleep is the energy consumption of sensor node while sleeping. Enetwork is very small that it can be ignored.The primary parameters are estimated in experiments for calculating energy consumption, as shown in Table3.Table 3
Parameters for energy consumption estimation.
Parameters
Description
Value
I
sleep
Current for sensor sleeping
2μA
I
sample
Current for sensor sampling
10 mA
I
transmit
Current for sensor transmission
28 mA
F
fast
High frequency for detection
50 Hz
N
fast
Number of high frequency
50
N
transmit
Number of transmission
50
T
fast
Time duration per high frequency
30 s
T
sample
Time duration per sampling
5 ms
T
transmit
Time duration per transmission
5 ms
F
slow
Slow frequency for detection
1 Hz
V
Voltage of battery
3 VAccording to adaptive sampling algorithm,Esample can be expressed as (14)Esample=Isample×V×tsample,where tsample is the average time for sampling per day and it can be described as (15)tsample=tfast_sample+tslow_sample,where tfast_sample=Nfast×Tfast×Ffast×Tsample and tslow_sample=(Tday-Nfast×Tfast)×Fslow×Tsample. Tday is one day in seconds, which is equal to 86400. Tsample is the sampling time. The energy consumption of transmission is expressed as (16)Etransmit=Itransmit×V×ttransmit,where ttransmit is average time for transmission per day, which can be described expressed as:(17)ttransmit=Ntransmit×Ttransmit,where Ntransmit and Ttransmit are the average number of transmissions in one day and the average time duration for one transmission, respectively. The sleep energy consumption of sensor node is(18)Esleep=Isleep×V×tsleep,where the average sleep time can be expressed as(19)tsleep=Tday-tsample-ttransmit.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. Ak-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.



---

*Source: 361242-2015-07-08.xml*