# A Multi-Loop Vehicle-Counting Method under Gray Mode and RGB Mode
## 3 Methods
### Vehicle Counting Based on Multiple Loops
#### 3.2.3 Occupancy of Lanes  
Whether a \(Lane^{i}\) is occupied depends not only on the three states (\(PLoop^{i}_{k}\), \(SLoop^{i}_{k}\), and \(SLoop^{i+1}_{k}\)) corresponding to the lane but also on the loop states of its two adjacent lanes (\(Lane^{i-1}\) and \(Lane^{i+1}\)). Since the lane located on both sides of the road has only one adjacent lane, the situation is relatively simple, so we discuss this type of lane first. Take \(Lane^{1}\) as an example.  
The loops corresponding to \(Lane^{1}\) are \(SLoop^{1}\), \(PLoop^{1}\), and \(SLoop^{2}\). However, \(SLoop^{2}\) also corresponds to \(Lane^{2}\). In this case, the primary loop of \(Lane^{2}\) (\(PLoop^{2}\)) should also be considered to determine whether \(Lane^{1}\) is occupied. First, we assess \(SLoop^{1}\). It is located at the most edge of the lane, so \(SState^{1}\) is only related to \(Lane^{1}\). In this case, \(Lane^{1}\) can be considered occupied when \(SLoop^{1}\) is activated. Then, we assess \(PLoop^{1}\). It is a kind of primary loop, which is set matching \(Lane^{1}\). Therefore, \(Lane^{1}\) can also be considered occupied when \(PLoop^{1}\) is activated. However, for \(SLoop^{2}\), it is a little complicated because both \(Lane^{1}\) and \(Lane^{2}\) are involved. At this point, we need to consider the status of \(PLoop^{2}\). When the status of \(SLoop^{2}\) is active while the statuses of \(SLoop^{1}\), \(PLoop^{1}\), and \(PLoop^{2}\) are inactive, \(Lane^{1}\) can be considered occupied. However, if the status of \(PLoop^{2}\) is active, \(Lane^{1}\) is not considered occupied. Whether \(Lane^{1}\) is occupied can be summarized in Table 2. A similar analysis could also apply to \(Lane^{4}\), as shown in Table 3.  
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline  & \(PLoop^{1}\) & \(PLoop^{2}\) & \(PLoop^{3}\) & \(PLoop^{4}\) & \(PLoop^{4}\) & \(SLoop^{5}\) & Judgement \\  & \  
Now, regarding the lane located on the middle of the road, this kind of lane has two adjacent lanes, and the situation is relatively complicated. Here, take \(Lane^{3}\) as an example. The loops corresponding to \(Lane^{3}\) are \(SLoop^{3}\), \(PLoop^{3}\), and \(SLoop^{4}\). However, \(SLoop^{3}\) also corresponds to \(Lane^{2}\), while \(SLoop^{4}\) also corresponds to \(Lane^{4}\). In this case, the primary loop of \(Lane^{2}\) (\(PLoop^{2}\)) and \(Lane^{4}\) (\(PLoop^{4}\)) should also be considered to determine whether \(Lane^{3}\) is occupied. First, we assess \(PLoop^{3}\). It is set to match \(Lane^{3}\), so \(Lane^{3}\) can be considered occupied when \(PLoop^{3}\) is activated. For \(SLoop^{3}\), when the status of \(SLoop^{3}\) is active while the statuses of \(PLoop^{2}\), \(PLoop^{3}\), and \(SLoop^{4}\) are inactive, \(Lane^{1}\) can be considered occupied. However, if the status of \(PLoop^{2}\) is active, \(Lane^{3}\) should not be considered occupied. For \(SLoop^{4}\), when the status of \(SLoop^{4}\) is active while the status of \(PLoop^{3}\)\(PLoop^{4}\) is inactive, \(Lane^{3}\) can be considered occupied. However, if the status of \(PLoop^{4}\) is active, \(Lane^{3}\) should not be considered occupied. Whether \(Lane^{1}\) is occupied can be summarized in Table 4. A similar analysis could also apply to \(Lane^{2}\), as shown in Table 5.  
Using the above criterion, the occupancy of each lane shown in Figure 13 and Table 1 can be discriminated, that is \(Lane^{1}\) is occupied while \(Lane^{2}\), \(Lane^{3}\), and \(Lane^{4}\) are not occupied.