# A Multi-Loop Vehicle-Counting Method under Gray Mode and RGB Mode
## 3 Methods
### Vehicle Counting Based on Multiple Loops
#### 3.2.1 Design of Multiple Loops  
As explained in Section 2, in order to count vehicles by lane, multiple short lanes or multiple detection areas are often set up according to lane. However, in actual traffic scenarios, drivers do not always drive strictly following the lanes. In this case, the vehicle may be double counted by two adjacent loops at the same time or missed, especially if the vehicle is right in the middle of two adjacent lanes. To solve this problem, multiple loops that partially overlap each other are set to improve the counting accuracy. * _Scope of Loops_  
While the vehicle may not strictly follow the lane, it is always on the road. Therefore, the basic principle of designing multiple loops is according to the movement of a vehicle on the road. In general, a road is made up of the pavement and shoulders on both sides. The pavement is the part of the road for vehicle driving and is usually divided into lanes, while the shoulder refers to a strip of certain width located from the outer edge of the pavement to the edge of the roaded, which is used for maintaining the function of the road and temporary parking and serves as lateral support for the pavement, as shown in Figure 11. For the most part, vehicles are on the pavement, but occasionally, they may be on the shoulder of the road. Therefore, in this paper, the overall scope of loops includes both the pavement and shoulder. Figure 11: Composition of a road. Figure 10: Detection for vehicles of different colors. (**a**) White vehicle. (**b**) Silver vehicle. (**c**) Blue vehicle. (**d**) Brown vehicle. (**e**) Yellow vehicle. (**f**) Green vehicle. * _Type and Number of Loops_  
In most studies, only one type of loop was set, which is usually set matching each lane and isolated from each other. However, the loop matching with each lane is sometimes not sufficient for the actual driving situation. Different from previous methods, multiple loops that partially overlap each other were designed for counting. Two types of loops were set up in this study, which are called primary loops and secondary loops. For the primary loop, it was set matching each lane, and the range of the set was the pavement. In contrast, for the secondary loop, it was set at the base of the primary loop, and the range of the set concluded at the pavement and shoulder. To be specific, each primary loop matched two secondary loops and two adjacent primary loops shared one secondary loop. Therefore, correspondingly, when the matched primary loop was in the middle of the pavement, the secondary loop matched the two primary loops. When the matched primary loop was located on either side of the pavement, the secondary loop far from the center of the pavement matched only one primary loop. Additionally, it is worth noting that primary loops overlap their matching secondary loops but primary loops or secondary loops themselves do not overlap with each other. In this case, for one lane, one primary loop and two secondary loops are used for counting. Take the road in video M-30 as an example. The road in video M-30 is a four-lane road; in this case, four primary loops and five secondary loops are set, as shown in Figure 12.  
Moreover, for the sake of description, each lane is expressed as \(Lane^{i}\), and the number of lane on the road is expressed as \(N^{lane}\). Each primary loop is expressed as \(PLoop^{i}\), where \(i=1,2,\cdots,N^{lane}\), and each secondary loop is expressed as \(SLoop^{i}\), where \(i=1,2,\cdots,N^{lane}\), \(N^{lane}\)+1. In this case, for \(Lane^{i}\), the three corresponding loops are \(PLoop^{i}\), \(SLoop^{i}\) and \(SLoop^{i+1}\). * _Width of Loops_  
The width of the primary loop is relatively simple to set, which is equal to the width of its corresponding lane, as shown in Figure 12a. For secondary loop, it is a little bit more complicated, depending on the number of the primary loop it matches. When a secondary loop matches two primary loops, its width is half the sum of the two primary loops.