## 5 Case Study
### Vehicle Detection Algorithm  
Figure 18 depicts an overview of our vehicle detection algorithm. As WSN-based systems have low computing power, algorithms with high computational complexity cannot be applied. Moreover,  
Figure 16: Ultrasonic sensor positioning.  
Figure 15: Modified analysis model on a two-lane road.  
memory reduction mechanisms should be included owing to the limited memory size. Our algorithm is designed based on these restrictions.  
Our algorithm is classified into five steps. The raw distance data \(r(n)\) measured by an ultrasonic sensor are passed through a noise filter. We use a median filter, because this retains good performance with the low sampling rate of ultrasonic data. To minimize the computational complexity of the median filter, a mask size of three is used. The filtered distance data \(e(n)\) are then quantized according to the lane width. This step is very important, because it limits the type of vectors to be handled in the vector extraction step. This, in turn, minimizes the search overhead in the pattern matching step. Moreover, quantization simplifies the segmentation operations.  
Figure 19 shows the effect of noise filtering and quantization on a two-lane road, where \(r(n)\) is raw distance data, \(e(n)\) is noise filtered data and \(q(n)\) is quantized data, with a mask size of three and a quantization level of 3.5 m. From the filtered data \(e(n)\), we can confirm that the median filter exhibits proper filtering performance with ultrasonic data. The quantized data \(q(n)\) clearly show information about the passing vehicles.  
As shown in Figure 20, if the specific data that includes traffic information can be segmented, we can greatly reduce the amount of memory needed. The starting point \(s_{s}\) and end point \(s_{e}\) of segmentation can be easily selected as:  
\[\begin{split} s_{s}=q(t),\;\;if\;q(t)<q_{max}\\ s_{e}=q(t),\;\;if\;q(t)<q_{max}\;and\;s_{s}\;is\;enabled\end{split} \tag{9}\]  
Figure 17: Available detection interval on a two-lane road.  
Figure 18: Vehicle detection algorithm.  
where \(q_{max}\) is the maximum distance data measured by an ultrasonic sensor, which means that there are no vehicles on roads where \(q(t)\) is the quantized distance data at time \(t\). This simple method can be applied owing to the previous quantization step. More complicated mechanisms would be needed to select \(s_{S}\) and \(s_{e}\) without the quantization.  
After quantization, a segmentation process is employed to minimize the amount of memory required. The periodic collection of traffic information is widely used in traffic information acquisition systems. For instance, the intelligent roadway information system in Minneapolis, Minnesota, USA, collects traffic information every 30 s [17]. If two bytes of distance data are collected at 50 ms intervals, a total of 1.2 KB will be generated every 30 s. The widely used WSN platform MICAz (Crossbow, Milpitas, CA, USA) has 4 KB memory space [18]. Thus, considering that the WSN computing platform must run a routing protocol and operating system at the same time, 1.2 KB is a significant amount of data.  
The segmented distance data are then represented as vectors, as depicted in Figure 21. To change the segmented distance data \(s(k)\) to vectors, a high-pass filter is applied. As shown in Figure 21, high-pass-filtered data have their own size and direction, depending on the quantized distance data. The quantization according to lane width in the previous step limits the possible vector types. For a  
Figure 19: Example of noise filtering and quantization.  
Figure 20: Segmentation.  
two-lane road, only four different vectors can be generated (two different directions and two different sizes). Figure 22 illustrates example vectors and patterns for our target road. Each pattern represents the number of lanes on the road. There are a total of six patterns for our target road. Using these patterns, traffic information is generated in the final pattern matching step.