Next Article in Journal
Improved Ensemble-Learning Algorithm for Predictive Maintenance in the Manufacturing Process
Previous Article in Journal
Arthroscope Localization in 3D Ultrasound Volumes Using Weakly Supervised Deep Learning
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Multi-Loop Vehicle-Counting Method under Gray Mode and RGB Mode

1
Jiangsu Key Laboratory of Urban ITS, Southeast University, Nanjing 211189, China
2
Jiangsu Province Collaborative Innovation Center of Modern Urban Traffic Technologies, Southeast University, Nanjing 211189, China
3
School of Transportation, Southeast University, Nanjing 211189, China
*
Author to whom correspondence should be addressed.
Appl. Sci. 2021, 11(15), 6831; https://doi.org/10.3390/app11156831
Submission received: 27 June 2021 / Revised: 22 July 2021 / Accepted: 23 July 2021 / Published: 25 July 2021
(This article belongs to the Section Transportation and Future Mobility)

Abstract

:
With the rapid development of road traffic, real-time vehicle counting is very important in the construction of intelligent transportation systems (ITSs). Compared with traditional technologies, the video-based method for vehicle counting shows great importance and huge advantages in its low cost, high efficiency, and flexibility. However, many methods find difficulty in balancing the accuracy and complexity of the algorithm. For example, compared with traditional and simple methods, deep learning methods may achieve higher precision, but they also greatly increase the complexity of the algorithm. In addition to that, most of the methods only work under one mode of color, which is a waste of available information. Considering the above, a multi-loop vehicle-counting method under gray mode and RGB mode was proposed in this paper. Under gray and RGB modes, the moving vehicle can be detected more completely; with the help of multiple loops, vehicle counting could better deal with different influencing factors, such as driving behavior, traffic environment, shooting angle, etc. The experimental results show that the proposed method is able to count vehicles with more than 98.5% accuracy while dealing with different road scenes.

1. Introduction

In recent years, real-time traffic monitoring has attracted extensive attention [1] with the development of intelligent transportation systems (ITSs). In order to build a powerful and reliable intelligent transportation system, vehicle detection and counting is one of the most important parts of collecting and analyzing large mode traffic information data [2]. In particular, it plays an important role in many practical situations, such as solving traffic congestion problems and improving traffic safety.
In the past, vehicle counting was mostly based on a dedicated hardware [3], such as an infrared detector, an electromagnetic induction loop coil, an ultrasonic detector, aradar detector, etc. However, there are many disadvantages of traditional detectors, such as inconvenient installation, maintenance, sensitivity to changes in the environments, etc. [4]. At the same time, the information obtained with traditional technology lacks diversity.
Compared with traditional vehicle-counting technology, counting vehicles based on traffic videos shows great advantages. The video-based method is based on complex image-processing techniques over software. Compared with traditional detectors, a traffic surveillance camera is more convenient for installation and maintenance and has a lower cost. More importantly, the information obtained with traffic videos can be vieweed in real-time and is more efficient and flexible. In addition to that, more diverse traffic information could be obtained, which is why it has become an important area of research.
In this paper, a multi-loop vehicle-counting method under gray mode and RGB mode is proposed. To be specific, the preliminary vehicle detection is operated under gray mode first, and further detection is operated under RGB mode, which could greatly improve the integrity of vehicle detection. Then, the detection information is converted into counting information based on multiple loops to better deal with different influencing factors, such as driving behavior, traffic environment, shooting angle, etc. The counting information is produced per lane.
The rest of the paper is structured as follows: Section 2 introduces related work in vehicle counting. In Section 3, we present a vehicle-detection method under gray mode and RGB mode to improve the integrity of vehicle, and a multi-loop vehicle-counting method to count vehicles with a higher accuracy. The experimental results obtained with the proposed method are presented in Section 4, while a discussion is given in Section 5. Finally, the conclusion is provided in Section 6.

2. Related Work

To obtain counting information, most approaches often need two links: vehicle detection and vehicle counting. For vehicle detection, two kinds of techniques are most often applied: feature-based methods and motion-based methods. Feature-based methods are based on the visual features of a vehicle [5], such as color [6]; texture [7]; edge [8]; or characteristic parts of a vehicle, such as vehicle lights [9], license plates [10], windshield [11], etc. Extraction with low-dimension features is fast and convenient, but it cannot represent all useful information efficiently. In this case, deep learning methods were proposed. These methods need to collect a lot of information prior to training the neural network and then use the trained neural network model to recognize the target. Many deep learning models could help improveme the accuracy by a lot. Two-step methods include Spatial Pyramid Pooling Network (SPPNet) [12], Region-Based Convolutional Neural Network (R-CNN) [13], Fast Region-Based Convolutional Neural Network (Fast R-CNN) [14], Faster Region-Based Convolutional Neural Network (Faster R-CNN) [15], etc., while one-step methods include You Only Look Once (YOLO) [16], Single Shot Multi-Box Detector (SSD) [17], Retina-Net [18], SqueezeDet [19], etc. Although the deep learning method has a high accuracy, it is realized at the cost of time-consuming network training by applying a large amount of prior knowledge. Meanwhile, the generality of the model is not very high. The effectiveness of the algorithm may be greatly reduced when the scene is changed. Although transfer learning is also a common way to compensate for this, the effect is often not very good.
Motion-based methods are methods based on the relationship between image sequences. The principle of a motion-based method is to use the correlation between images to segment the moving vehicle from the background, and the video meets the requirements of this method perfectly for its high image refresh rate. Moreover, the motion-based method does not require much prior knowledge but based on a set of images. Therefore, its algorithm complexity is lower and its generality is high. The interframe differencing and background subtraction are the most two characteristic examples. Interframe differencing [20] is based on the difference between two or more successive image frames, whereas background subtraction is based on the difference between moving vehicles and a stationary background [3]. However, due to the influence of environment, the vehicle detected by this method is often incomplete, which further affects the accuracy of vehicle counting. More importantly, most motion-based methods were only applied under gray mode, which is a waste for a color image.
For the counting step, the use of vehicle tracking is a relatively mature approach, such as using a Kalman filter [21] or exploiting feature tracking [22], but its algorithm complexity is high. By contrast, the method based on ROIs has little computational cost. The mechanism of this algorithm is to extract the detection information of the vehicle by analyzing the changes of pixel value in the ROIs and by turning it into the counting information of the vehicle. For example, a linear ROI [23] or a large loop set perpendicular to the road direction could be used to count the total number of vehicles in one direction. To count vehicles by lane, short line or small loop sets for each lane [24] could be applied. However, when the vehicle does not drive by strictly following the lane, counting based on the ROIs set by each lane could be problematic, such as repeat counts in adjacent lanes or missing counts.
Based on the shortcomings introduced above, a vehicle detection and counting method is proposed. The detection of moving vehicles is based on its motion characteristics and is operated under both gray mode and RGB mode, which could greatly improve the integrity of the detected vehicle. The counting is based on multiple loops with overlapping areas to improve the accuracy of counting. Based on the changes of the pixel value in each loop, the detection information could be converted into lane-splitting counting information.

3. Methods

The proposed method is based on surveillance traffic video. It contains two main parts: vehicle detection and vehicle counting, which are described in the following sections. The block diagram of proposed method is shown in Figure 1.

3.1. Vehicle Detection under Gray and RGB Modes

As mentioned in Section 2, the counting information is obtained based on the changes of pixel value in multiple loops. Therefore, for vehicle detection, the goal is to extract the vehicle as complete as possible. In view of the problem that the vehicle extracted by the existing motion-based method easily produces holes, a detection method operated under two modes of color, that is gray mode and RGB mode, is proposed to improve the integrity of vehicle.

3.1.1. Preliminary Detection under Gray Mode

The traditional gray background subtraction was applied for preliminary vehicle detection. Under gray mode, there are two main approaches to obtain a gray-mode background: Gaussian mixture model (GMM) [25] and statistical median model (SMM) [26]. GMM has relatively higher extraction accuracy than SMM, but its algorithm complexity is higher and takes 40 to 50 times longer than SMM. Moreover, GMM contains not only the parameter of total number of images in the image library for extracting the gray-mode background (N) but also one more parameter: the learning constant ( α ), which is an empirical value and is not easily determined [27]. In contrast, SMM contains only one parameter (N). Taking the above factors into consideration, SMM was selected for extracting the gray-mode background in this study.
An image library under gray mode for extracting the gray-mode background should be built first. In this image library, every image is labeled, which could be expressed as I n 0 g r a y , where n 0 = 1 , 2 , , N , and N is the total number of images in the image library.
The establishment of background is calculated at the pixel level. The basic idea of establishing the background is to find the gray value in the median position at each pixel in the image library. Different from the previous methods, we not only need to obtain the gray value in the median position at each pixel but also need to record the label of the image that provides the median-position gray value.
At each pixel ( i , j ) , the images in the image library is sorted according to the gray-mode value first:
I 1 ( i , j ) g r a y ( i , j ) I n ( i , j ) g r a y ( i , j ) I N ( i , j ) g r a y ( i , j )
where n ( i , j ) is the sorted label and n ( i , j ) = 1 , 2 , , N ; I n ( i , j ) g r a y ( i , j ) is the gray-mode value at each pixel ( i , j ) of image n ( i , j ) . In this case, the label of the image that provides the median-position gray value is recorded as follows:
n ( i , j ) m i d = [ N 2 ] ( i , j )
where [ x ] is the integral function. At each pixel ( i , j ) , the background value equals to the median-position gray value:
B g r a y ( i , j ) = I n ( i , j ) m i d g r a y ( i , j )
where B g r a y is the gray-mode background.
The result of vehicle detection is in the form of binary image, that is, white represents the vehicle and black represents the background. By subtracting the background image from the current frame and by binarizing the subtracting result, vehicle segmentation could be realized. The result of subtracting the background from current frame under gray mode could be expressed as follows:
δ k g r a y = | I k g r a y B g r a y |
where I k g r a y is the gray-mode image of the current frame k. The Otsu’s method [28] was used to binarize the subtracting result in this study and the result of vehicle detection under gray mode could be expressed as I k b i n a r y g r a y .
To illustrate the proposed detection method better, we selected a benchmark dataset for example. The video is called M-30 and could be obtained from the Road-Traffic Monitoring (GRAM-RTM) dataset [29], and a frame ( k = 539 ) from M-30 was selected as the current image for further illustration. The current image under RGB mode ( I 539 R G B ) and under gray mode ( I 539 g r a y ) are shown in Figure 2a,b. Under the proposed detection method, the established gray-mode background ( B g r a y ) is shown in Figure 3a, and the detection under gray mode ( I 539 b i n a r y g r a y ) is shown in Figure 3b.
As shown in Figure 3b, the detection under gray mode was incomplete, especially for the red vehicle on the right. The reason for this phenomenon is that the background subtraction values at the position of the red vehicle is too small under gray mode. To analyze the unsuccessful detection more clearly, the result of background subtraction under gray mode ( δ k g r a y ) was studied by mapping it to another color pattern to make it more intuitive.
The constructed color pattern is a smooth transition from black to red, orange to yellow, and finally to white, as shown in Figure 4. The darker the color, the lower the background subtraction value. By comparing with Figure 2a, it can be seen that the background subtraction values at the position of the red vehicle were generally low, which directly led to the holes in Figure 3b. Therefore, the main reason for this result is that the detection fails when the gray-mode values of foreground and background are close to each other, as could be clearly reflected by comparing Figure 3a with Figure 2b.
In this case, under gray mode, the detection could be said to be a failure, especially for the red vehicle. Under the RGB mode, however, things are different. Next, the detection of vehicle is further operated under RGB mode.

3.1.2. Further Detection under RGB Mode

Under RGB mode, the background subtraction was also applied for vehicle detection. However, there are not many existing methods for the extraction of the RGB background. Here, a method to quickly establish the RGB-mode background based on gray-mode background was proposed.
Since the pixel value of RGB image is composed of three-color channels, namely the red channel, the green channel, and the blue channel, vehicle detection is also realized based on the three-color channels. The current images under red mode ( I 539 r e d ), green mode ( I 539 g r e e n ), and blue mode ( I 539 b l u e ) are shown in Figure 5a–c. It is worth noting that the image library for extracting the RGB-mode background is the same as that for extracting gray-mode background except that the images in the image library are under red mode, green mode, and blue mode.
Similarly, the RGB background is also calculated at the pixel level but in a different way. For the gray-mode background, it is established by finding the gray value in the median position at each pixel in the image library and by selecting the gray value as the background value. Additionally, the label of the image that provides the median-position gray value ( n ( i , j ) m i d ) was recorded, as shown in Equation (2). However, for the RGB-mode background, there is no step to find the value in the median position at each pixel in the image library. Instead, the variable n ( i , j ) m i d is used to obtain the background values directly. This is not only to reduce the complexity of the algorithm but also to unify the three-color channels and to reconstruct the RGB background. The background value under red mode, green mode, and blue mode could be expressed as follows:
B r e d ( i , j ) = I n ( i , j ) m i d r e d ( i , j )
B g r e e n ( i , j ) = I n ( i , j ) m i d g r e e n ( i , j )
B b l u e ( i , j ) = I n ( i , j ) m i d b l u e ( i , j )
where B r e d , B g r e e n , and B b l u e are the red-mode, green-mode, and blue-mode backgrounds, while I n ( i , j ) m i d r e d ( i , j ) , I n ( i , j ) m i d g r e e n ( i , j ) , and I n ( i , j ) m i d b l u e ( i , j ) are the red-mode, green-mode, and blue-mode values at each pixel ( i , j ) of image I n ( i , j ) m i d R G B . The established background under red mode, green mode, and blue mode are shown in Figure 6a–c. Moreover, with the background under red mode, green mode, and blue mode, the RGB-mode background could be reconstructed, as shown in Figure 6d.
Similarly, the result of subtracting the background from current frame under red mode, green mode, and blue mode could be expressed as follows:
δ k r e d = | I k r e d B r e d |
δ k g r e e n = | I k g r e e n B g r e e n |
δ k b l u e = | I k b l u e B b l u e |
where I k r e d , I k g r e e n , and I k b l u e are the current frame k under red mode, green mode, and blue mode.
The mapped results of the background subtraction under red mode, green mode, and blue mode are shown in Figure 7. By comparing Figure 4, Figure 7a, Figure 7b, and Figure 7c, it could be found that the results of background subtraction under gray mode, red mode, green mode, and blue mode were very different. Under gray mode and blue mode, the background subtraction values of the red vehicle were generally low, while under red mode and green mode, the background subtraction values were much higher, especially under red mode. In contrarst, for the black vehicle on the left, the results of background subtraction under gray mode were higher.
The vehicle segmentation is obtained by binarizing the subtracting result, as mentioned in Section 3.1.1. In this case, based on subtraction results with different properties, the detection under gray mode, red mode, green mode, and blue mode also has different characteristics, as shown in Figure 3b and Figure 8a–c.

3.1.3. Final Detection

As mentioned at the beginning of this section, the goal of vehicle detection is to make the vehicle as complete as possible, but the four detection results are all very incomplete. Each result, when evaluated separately, can be considered a failure.
However, similar to the situation of the background subtraction results, each of them is different in their incompleteness, as shown in Figure 3b and Figure 8a–c. In particular, the detection results of the red vehicle under red mode and green mode were much better than that under gray mode and blue mode, while the detection results of the black vehicle were better under gray mode. Therefore, by taking the union of four detection results, a more ideal detection result could be obtained. The union ( I k b i n a r y u n i o n ) could be expressed as follows:
I k b i n a r y u n i o n = I k b i n a r y g r a y I k b i n a r y g r a y I k b i n a r y g r a y I k b i n a r y g r a y
As shown in Figure 9a, the union of four detection results ( I 539 b i n a r y u n i o n ) is much more complete and successful than any of the detection shown in Figure 3b and Figure 8a–c. Finally, a simple morphological closing operation [30] could be used to obtain an optimized final detection I k b i n a r y , as shown in Figure 9.
Moreover, in order to further verify the effectiveness of the detection algorithm for vehicles of different colors, in addition to the red and black vehicles shown in Figure 2a, we also detected vehicles of white, silver, blue, brown, yellow, and green, as shown in Figure 10.

3.2. Vehicle Counting Based on Multiple Loops

As can be seen in Figure 9b, the vehicle has been successfully detected with a relatively high degree of integrity. However, it is not enough to obtain counting information. A method to convert detection information into counting information is needed. In this paper, multiple loops with overlapping areas are set to count vehicles by lane. Two kinds of loop, that is the primary loop and secondary loop, are designed under RGB mode first, including its scope, type, number, width, and length, and the designed loops are set on the result of binary detection I k b i n a r y obtained from Section 3.1. By analyzing the changes of pixel value in each loop, the states of each loop could be judged. Then, based on the state of the loops associated with this lane and adjacent lanes, the occupation of each lane could be determined. Finally, with a strategy set for counting, the lane-splitting counting message could be obtained.

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 roadbed, 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.
  • 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 L a n e i , and the number of lane on the road is expressed as N l a n e . Each primary loop is expressed as P L o o p i , where i = 1 , 2 , , N l a n e , and each secondary loop is expressed as S L o o p i , where i = 1 , 2 , , N l a n e , N l a n e +1. In this case, for L a n e i , the three corresponding loops are P L o o p i , S L o o p i and S L o o p 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. When a secondary loop matches only one primary loop, its width is half the width of the primary loop plus the width of the shoulder on the side on which it sits, as shown in Figure 12b.
  • Length of Loops
For safety reasons, the front and back vehicles driving on the same lane always keep a certain distance between them. Therefore, if the length of each loop is lower than the safety spacing of vehicles, it is guaranteed that only one vehicle exists in a loop at the same time.
The safety spacing of vehicles consists of two parts, namely reaction distance and braking distance [31]. Therefore, the length is designed to be less than the reaction distance in this study. The reaction distance is the product of reaction time and driving speed [31]. For reaction time, the American Association of State Highway and Transportation Officials (AASHTO) mandated the use of 2.5 s for the reaction time [32]. While for the driving speed, we set it as 10 km/h—which is a very low speed—to ensure a long enough distance to react. In this case, the length is designed to be less than seven meters, which can ensure that there is at most one vehicle in P L o o p i or S L o o p i .

3.2.2. Judgement of Loop States

The first step to counting the vehicles is to judge the state of each loop, and the designed loops are set on the result of binary detection I k b i n a r y . As shown in Figure 9b, when a pixel position is in the foreground, the pixel value at that position is 1; otherwise, it is 0. Therefore, the judgement of loop states can be realized by analyzing the change of pixel value in the position of each loop. The binary detection I 539 b i n a r y set with loops is shown in Figure 13.
For each P L o o p i and S L o o p i at frame k, we set up a state detector to record the state of P L o o p i and S L o o p i , which could be expressed as P S t a t e k i and S S t a t e k i , respectively, where k is the frame number of current image. The study on the state of primary loop and secondary loop is similar. For the convenience of description, in the subsequent paragraphs of this subsection, we collectively refer to them as L o o p i and S t a t e k i .
The state of L o o p i was divided into active state and inactive state, representing the state with and without vehicles in L o o p i , and the corresponding values are 1 and 0, respectively. As mentioned above, the pixel value at each loop position is the key to determining the state of the loop and we designed three indicators to make the judgement.
The first two are the ratio of the number of pixels with a value of 1 to the total number of pixels contained in the upper line and the lower line, which could be expressed as u p p e r k i and l o w e r k i . When a vehicle enters or leaves one loop, the values of these two indicators change. However, it is not enough to only take the upper line and the lower line of L o o p i as the discriminant basis because some small noises may also cause u p p e r k i or l o w e r k i to be large. Therefore, the situation of pixel values on the whole region of loop should also be used as the discriminant basis, which could be expressed as r e g i o n k i .
When there are no vehicles or noise in L o o p i , u p p e r k i , l o w e r k i , and r e g i o n k i are all zero. When there is noise in L o o p i but no vehicle, r e g i o n k i , u p p e r k i , or l o w e r k i are small. However, r e g i o n k i , u p p e r k i or l o w e r k i are large when there is a vehicle in L o o p i . In this case, the state of L o o p i in frame k could be judged based on the three indicators, which could be expressed as follows:
S t a t e k i = 1 , i f ( u p p e r k i > T u p p e r ) ( l o w e r k i > T l o w e r ) ( r e g i o n k i > T r e g i o n ) 0 , o t h e r s
where T r e g i o n , T u p p e r and T l o w e r are the thresholds for the whole region, the upper line, and the lower line. Additionally, it is worth noting that the activation threshold of the secondary loop is slightly higher than that of the primary loop.
As shown in Figure 13, the state of P L o o p 1 , S L o o p 1 and S L o o p 2 are active while the state of other primary loops and secondary loops are inactive. The mathematical form of the states in frame 539 is expressed as Table 1.

3.2.3. Occupancy of Lanes

Whether a L a n e i is occupied depends not only on the three states ( P L o o p k i , S L o o p k i , and S L o o p k i + 1 ) corresponding to the lane but also on the loop states of its two adjacent lanes ( L a n e i 1 and L a n e 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 L a n e 1 as an example.
The loops corresponding to L a n e 1 are S L o o p 1 , P L o o p 1 , and S L o o p 2 . However, S L o o p 2 also corresponds to L a n e 2 . In this case, the primary loop of L a n e 2 ( P L o o p 2 ) should also be considered to determine whether L a n e 1 is occupied. First, we assess S L o o p 1 . It is located at the most edge of the lane, so S S t a t e 1 is only related to L a n e 1 . In this case, L a n e 1 can be considered occupied when S L o o p 1 is activated. Then, we assess P L o o p 1 . It is a kind of primary loop, which is set matching L a n e 1 . Therefore, L a n e 1 can also be considered occupied when P L o o p 1 is activated. However, for S L o o p 2 , it is a little complicated because both L a n e 1 and L a n e 2 are involved. At this point, we need to consider the status of P L o o p 2 . When the status of S L o o p 2 is active while the statuses of S L o o p 1 , P L o o p 1 , and P L o o p 2 are inactive, L a n e 1 can be considered occupied. However, if the status of P L o o p 2 is active, L a n e 1 is not considered occupied. Whether L a n e 1 is occupied can be summarized in Table 2. A similar analysis could also apply to L a n e 4 , as shown in Table 3.
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 L a n e 3 as an example. The loops corresponding to L a n e 3 are S L o o p 3 , P L o o p 3 , and S L o o p 4 . However, S L o o p 3 lso corresponds to L a n e 2 , while S L o o p 4 also corresponds to L a n e 4 . In this case, the primary loop of L a n e 2 ( P L o o p 2 ) and L a n e 4 ( P L o o p 4 ) should also be considered to determine whether L a n e 3 is occupied. First, we assess P L o o p 3 . It is set to match L a n e 3 , so L a n e 3 can be considered occupied when P L o o p 3 is activated. For S L o o p 3 , when the status of S L o o p 3 is active while the statuses of P L o o p 2 , P L o o p 3 , and S L o o p 4 are inactive, L a n e 1 can be considered occupied. However, if the status of P L o o p 2 is active, L a n e 3 should not be considered occupied. For S L o o p 4 , when the status of S L o o p 4 is active while the status of P L o o p 3 P L o o p 4 is inactive, L a n e 3 can be considered occupied. However, if the status of P L o o p 4 is active, L a n e 3 should not be considered occupied. Whether L a n e 1 is occupied can be summarized in Table 4. A similar analysis could also apply to L a n e 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 L a n e 1 is occupied while L a n e 2 , L a n e 3 , and L a n e 4 are not occupied.

3.2.4. Counting Strategy

To count vehicles, we set up a counter variable, which is used to count the cumulative number of vehicles in each lane. Slightly different from the setting of the loop, for each lane, only one counter that matches the lane is set and no secondary counters are set. The counter could be expressed as C o u n t e d k i , where i = 1 , 2 , , N l a n e , which represents the cumulative number of vehicles driving on L a n e i that have been counted until frame k.
The strategy of increasing the value of C o u n t e d k i is as follows: if and only if the lane is not occupied by a vehicle in the previous frame and is occupied in the current frame, the cumulative number of vehicles on L a n e i should be increase by 1; otherwise, the cumulative number remains the same. In this case, the cumulative number of vehicles driving on L a n e i until frame k could be expressed as follows:
C o u n t e d k i = C o u n t e d k 1 i + 1 , i f   L a n e i   i s   n o t   o c c u p i e d   a t   k 1   b u t   o c c u p i e d   a t   k C o u n t e d k 1 i , o t h e r w i s e
As can be seen from Equation (13), in order to accurately count the vehicles on the lane, two important nodes need to be accurately discriminated. The first one is from the frame in which the lane is not occupied to the frame in which the lane is occupied. At this point, the counter for the lane increases by 1 in the frame in which the lane is occupied. The second important node is from the frame in which the lane is occupied to the frame in which the lane is not occupied. This is in preparation for the next increment in the counter. Therefore, these four frames are key for the counter to count properly.
Take the left black vehicle in Figure 2a as an example. The loop states of its four key frames is expressed in Table 6 and displayed in Figure 14. Using the counting strategy described above, the counter for L a n e 1 should be increased by 1 in frame 534.

3.3. Evaluation Index

To evaluate the counting result, four metrics were used in this paper, that is, R e c a l l , P r e c i s i o n , F-measure , and A c c u r a c y .
R e c a l l is a measure of the success in detecting relevant objects, that is, the percentage of vehicles correctly counted in all vehicles that should be counted, while P r e c i s i o n is the percentage of vehicles correctly counted in all counted objects. These two metrics could be expressed as follows [33]:
R e c a l l = T P T P + F N
P r e c i s i o n = T P T P + F P
where T P is the number of vehicles correctly counted, F N is the number of vehicles that should be counted but not, and F P is the number of objects that should be not counted. In this case, the number of vehicles that should be counted ( T r u e ) and the number of counted objects ( C o u n t e d ) could be calculated as follows:
T r u e = T P + F N , C o u n t e d = T P + F P
where F-measure is the weighted harmonic average of R e c a l l and P r e c i s i o n , which combines the results of R e c a l l and P r e c i s i o n , and we make the weights equal to each other in this paper. In this case, F-measure could be expressed as follows [33]:
F-measure = 2 × R e c a l l × P r e c i s i o n R e c a l l + P r e c i s i o n
In contrast, for A c c u r a c y , it is used to evaluate the difference between the true value and the counted value, which is defined as follows [34]:
A c c u r a c y = 1 | T r u e C o u n t e d | T r u e
Using Equation (16) to replace T r u e and C o u n t e d with T P , F N , and F P , Equation (18) could also be expressed as follows:
A c c u r a c y = 1 | F N F P | T P + F N
Let us analyze these metrics briefly. Compared with the F-measure introduced above, A c c u r a c y evaluates the overall difference between counted values and true values, ignoring the details of errors in treating noise as vehicle or errors with missing vehicles. As a result, it is a more direct metric of the overall outcome. Therefore, a comprehensive analysis of F-measure and A c c u r a c y is more scientific.

3.4. Experimental Dataset

In this paper, the performance of the proposed method was experimented on six traffic videos. Video I and Video II are two videos recorded on a highway, which are called M-30 and M-30-HD and could be obtained from the GRAM-RTM dataset [29]. These two videos were shot from the rear of the vehicle on a sunny and cloudy day. Video III is also a video recorded on a highway, which is called Highway and could be obtained from the Change Detection Benchmark [35]. Unlike Video I and Video II, it was shot from the front. The weather of Video III is sunny.
Video IV, Video V, and Video VI are three videos [36] recorded by us in Nanjing, Jiangsu, China, which are called NJ-1, NJ-2, and NJ-3. Similar to Video III, Video IV was also shot from the front, but the location is on an urban road and the weather is cloudy. Video V and Video VI were shot from the side on two expressways on a sunny and cloudy day, respectively.
The basic information in each video and road is shown in Table 7, including the name of video, recording site, number of frames, and the average pixel number for a vehicle. Among them, the meaning of “Average Pixel No. for a Vehicle” needs some explanation. As we all know, the imaging principle of the camera is pinhole imaging. Therefore, through perspective, the same vehicle in the image appears to be small at a distance but large at close distances. Based on this, for the statistics of the pixel number for a vehicle in each video, we aim for the average pixel number of vehicles that are at close distance. At the same time, it is worth mentioning that the multi-loop is also set at close distance. From this point of view, the information of how many pixels for a vehicle is useful to apply the proposed method in different videos. The characteristics in each video and road is shown in Table 8, including road category, number of lanes, weather, and shooting angle.

4. Results

The experimental results of each sequence are shown in Table 9, Table 10, Table 11, Table 12, Table 13, Table 14 and Table 15, and examples of experimental results of each sequence are shown in Figure 15, Figure 16, Figure 17, Figure 18, Figure 19 and Figure 20.
The total number of vehicles that should be counted are 988, and there are only six missing errors and fourteen noise errors. As a whole, the total R e c a l l , P r e c i s i o n , F-measure , and A c c u r a c y of thte proposed method achieved 99.39%, 98.59%, 98.99%, and 99.19%, which reached more than 98.5%.

5. Discussion

In this section, we make a comparison with other methods and discuss the factors that affect the experimental results and the countermeasures of the proposed method. Additionally, the limitations of the proposed method are analyzed in Section 5.3.

5.1. Comparison with Recent Methods

The proposed method was compared to state-of-the-art methods that used the three benchmark sequences: Highway (Video I), M-30 (Video II), and M-30-HD (Video III). As shown in Table 16 and Table 17, the proposed method achieved the highest accuracy, with no error in the Highway sequence.
For M-30-HD, the accuracy of the proposed method is lower than that in [37]. However, the experimental vehicles in the study are larger, which increases the probability of errors, as shown in Table 18.

5.2. Discussion of Influencing Factors and Countermeasures

Let us give a discussion of the influencing factors from the aspects of the characteristics mentioned in Table 8: road category, number of lanes, weather and shooting angle, and the countermeasures of the proposed method.
  • Road Category
Road category is a relatively important factor that has a certain influence on both vehicle detection and vehicle counting. Specifically, its influence on the results is mainly reflected in the complexity of the traffic environment and road environment. Compared with videos taken from the highways (Figure 15, Figure 16 and Figure 17), the traffic environment and road environment of videos taken from urban roads (Figure 18) and expressways (Figure 19 and Figure 20) are more complex, such as the higher proportion of large vehicles and more trees on both sides of the road. In the same way, videos taken from urban roads may contain more disadvantages than videos taken from expressways.
Therefore, it is not enough to carry out the experiment only on the highway. We also added three groups of experiments on urban roads and expressways. The influence of the road category could also be reflected in the experiment. As shown in Table 15, the three benchmarks (Video I, Video II, and Video III), which were all taken from highways, achieved the highest accuracy. Although the accuracy of urban roads (Video IV) and expressways (Video V and Video VI) is not as good as that of the highway, it is not bad either.
  • Number of Lanes
The influence of lane number is mainly reflected in the vehicle count. To be specific, it basically shows the trend that the less lanes, the higher the accuracy of the results. This is mainly because vehicle counting is easily affected by vehicles driving side by side in different lanes. At the same time, as the number of lanes increases, drivers have more choices of roads to take, which makes it easier for drivers to engage in driving behaviors that do not strictly follow the designated lane lines. Therefore, the ability of a traditional ROI completely matching the lane is a little inadequate to deal with this situation. Additionally, this is one of the reasons that multiple loops were set on the road.
As shown in Figure 21a, this is a vehicle driving right on the middle of L a n e 2 and L a n e 3 . If only four traditional primary loops were set, the counting for this vehicle may be problematic. To be specific, with stricter thresholds, P L o o p 2 and P L o o p 3 are not activated and this vehicle is missed. If looser thresholds are set, the P L o o p 2 and P L o o p 3 are activated at the same time and this vehicle is counted repeatedly. However, with the multiple loops and counting strategy designed in this study, this vehicle is only counted once on L a n e 3 , regardless of the strict threshold or the loose threshold, as shown in Table 19.
The influence of lane number could be also reflected in the experimental results. As shown in Table 15, Video III, with only two lanes, achieved the highest accuracy. However, for Video V and Video VI, they only contain three lanes but the experimental results are not as good as Video I and Video II, which contain four lanes. One of the reasons is that Video I and Video II were shot on the highway with a simpler environment, but the setting of multiple loops also helped to greatly improve the accuracy of the experimental results.
Moreover, in terms of where the lane is on the road, errors are more likely to occur in the median lane and its adjacent lanes. For example, errors all occurred in the two median lanes ( L a n e 2 and L a n e 3 ) in Video I (Table 9), while errors all occurred in its median lane ( L a n e 2 ) in Video VI (Table 14). Of course, this also has to do with the general tendency of drivers to drive in the median lane, which further increases the chance of errors. While in Video II, Video IV, and Video V, errors not only occurred in the median lane but also occurred in its adjacent lane. This is especially evident in Video V. As shown in Table 13, two errors occurred in L a n e 2 and three errors occurred in L a n e 3 . This is mainly due to the phenomenon of vehicles driving side by side on different lanes affecting the vehicle count. At the same time, vehicles not only tend to drive in L a n e 2 but also tend to drive in L a n e 3 , which is also a factor. This could be seen in the number of vehicles. As shown in Table 13, the number of vehicles that should be counted ( T r u e ) in L a n e 2 is 123, while the T r u e number in L a n e 2 is 116, which is also a reflection of the propensity of the driving behavior for drivers. Therefore, compared with the lanes on both sides of the road, the counting strategies proposed in Section 3.2.4 set for the middle lane are also more complex.
  • Weather
Weather mainly affects vehicle detection. A video shot in sunny weather is brighter in color. Therefore, the detection algorithm in RGB mode proposed in this study has better ability to repair vehicle holes. In addition, compared with a sunny day, a cloudy day contains more undesirable factors, such as changes in the lighting environment caused by the influence of clouds. As shown in Table 15, the three videos taken on sunny days (Video I, Video III, and Video V) have better performance overall than those taken on cloudy days (Video II, Video IV, and Video VI).
  • Shooting Angle
As for the shooting angle, it mainly affects vehicle counting, and it is due to the distortion of the image caused by perspective. The imaging principle of the camera is pinhole imaging. As a result, the view of the camera on the road and the vehicle usually produce a certain distortion. In general, the more oblique the shooting angle, the more severe the distortion. As shown in Figure 16, the projection of vehicle driving on l a n e 1 was tilted to the left, while the projection of vehicle driving on l a n e 4 was tilted to the right. This phenomenon is most obvious when the vehicles were shot from the side. As shown in Figure 19 and Figure 20, the projection of vehicle was tilted to the right by very much.
If only the primary loops were set, there may be some errors in counting. However, with the help of the secondary loops, the counting was not greatly affected by the shooting angle. The experimental results also prove that the multi-loop setup works well against this adverse effect, as shown in Table 15.

5.3. Analysis of Limitations of the Proposed Method

Benefiting from vehicle detection under two color modes and the setting with multiple loops, the counting accuracy of vehicles greatly improved, but there are still some false results. There are two types of counting errors, namely missed counting ( F N ) and redundant counting ( F P ). We start from these two aspects to analyze the causes of the errors and the limitations of the proposed method.
  • Missed Counting
Incomplete vehicle detection and unreasonable ROI settings could both lead to the generation of missed counting, while redundant counting is mainly caused by unreasonable ROI settings. Therefore, in previous studies, a reduction in counting accuracy was mainly due to errors missing counts. Benefiting from vehicle detection under two color modes and the setting with multiple loops proposed in this paper, the number of errors due to missing counts was greatly reduced and the counting accuracy significantly improved. However, as shown in Table 15, there are still a small number of missing counts ( F N = 6 ) in the experiments, which is mainly affected by incomplete detection of the vehicle and has little to do with the setting with multiple loops. Here is an example. As shown in Figure 22a, the color of the incomplete part is very similar to the color of the road background. Therefore, it is difficult to separate them no matter whether under gray mode or RGB mode, resulting in incomplete vehicle detection. As a result, no matter using the primary loops or the secondary loops, this vehicle does not meet the activation conditions, leading to a missed count.
  • Redundant Counting
The error of redundant counting mainly occurs for large vehicles, that is, counting are carried out simultaneously in two adjacent lanes. As shown in Figure 23a, this large vehicle spanned two lanes, so it was counted both in l a n e 1 and l a n e 2 , resulting in redundant counting. This phenomenon could also be proven by the experimental results. As shown in Table 15, the error of redundant counting ( F P ) is more likely to occur in Video IV, Video V, and Video VI, mainly because the proportion of large vehicles on urban roads and expressways is higher than on highways.

6. Conclusions

In this paper, we presented a multi-loop vehicle counting method under gray mode and RGB mode. For vehicle detection, the detection operated under gray mode and RGB mode and the final detection was obtained by integrating four detection results and by optimizing using a morphological closing operation. Under this kind of algorithm, the integrity of the detected vehicles greatly improved. As for counting, the setting with multiple of loops could count vehicles by lane and could better deal with different influencing factors, such as driving behavior, traffic environment, shooting angle, etc.
The experimental results showed that the proposed method performs well in videos shot in different weather at different road scenes. The proposed method successfully counted the vehicles with a high performance, e.g., the total R e c a l l , P r e c i s i o n , F-measure , and A c c u r a c y of proposed method achieved 99.39%, 98.59%, 98.99%, and 99.19%, all of which are more than 98.5%.
There is still much to study in future work. As analyzed in Section 5.3, when the color of the vehicle is very similar to the color of the road background, the effect of vehicle detection is not ideal. Therefore, it is necessary to find other methods to further improve the detection algorithm, such as the applications in proposed regions with objects to further improve the integrity of the vehicle, etc.

Author Contributions

Conceptualization, Y.C. and J.L.; methodology, Y.C.; software, Y.C.; validation, Y.C.; writing—original draft preparation, Y.C.; writing—review and editing, Y.C. and J.L. Both authors have read and agree to the published version of the manuscript.

Funding

This research was funded by the Jiangsu Provincial Key Research and Development Program (Social Development) Project (BE2018754).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The data presented in this study are available on request from the author.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Buch, N.; Velastin, S.A.; Orwell, J. A Review of Computer Vision Techniques for the Analysis of Urban Traffic. IEEE Trans. Intell. Transp. Syst. 2011, 12, 920–939. [Google Scholar] [CrossRef]
  2. Tsai, L.W.; Hsieh, J.W.; Fan, K.C. Vehicle detection using normalized color and edge map. IEEE Trans. Image Process. 2007, 16, 850–864. [Google Scholar] [CrossRef] [PubMed]
  3. Celik, T.; Kusetogullari, H. Solar-Powered Automated Road Surveillance System for Speed Violation Detection. IEEE Trans. Ind. Electron. 2010, 57, 3216–3227. [Google Scholar] [CrossRef]
  4. Yang, Z.; Pun-Cheng, L.S.C. Vehicle detection in intelligent transportation systems and its applications under varying environments: A review. Image Vis. Comput. 2018, 69, 143–154. [Google Scholar] [CrossRef]
  5. Liu, Y.; Tian, B.; Chen, S.; Zhu, F.; Wang, K. A survey of vision-based vehicle detection and tracking techniques in ITS. In Proceedings of the 2013 IEEE International Conference on Vehicular Electronics and Safety (ICVES 2013), Dongguan, China, 28–30 July 2013; pp. 72–77. [Google Scholar] [CrossRef]
  6. Yang, Y.; Gao, X.; Yang, G. Study the method of vehicle license locating based on color segmentation. In Proceedings of the 2011 International Conference on Advanced in Control Engineering and Information Science (CEIS 2011), Dali, China, 18–19 August 2011; Volume 15, pp. 1324–1329. [Google Scholar] [CrossRef] [Green Version]
  7. Haralick, R.; Shanmugam, K.; Dinstein, I. Textural features for image classification. IEEE Trans. Syst. Man Cybern. 1973, smc 3, 610–621. [Google Scholar] [CrossRef] [Green Version]
  8. Matthews, N.; An, P.; Charnley, D.; Harris, C. Vehicle detection and recognition in greyscale imagery. Control Eng. Pract. 1996, 4, 473–479. [Google Scholar] [CrossRef]
  9. Chen, D.Y.; Lin, Y.H.; Peng, Y.J. Nighttime brake-light detection by Nakagami imaging. IEEE Trans. Intell. Transp. Syst. 2012, 13, 1627–1637. [Google Scholar] [CrossRef]
  10. Abolghasemi, V.; Ahmadyfard, A. An edge-based color-aided method for license plate detection. Image Vis. Comput. 2009, 27, 1134–1142. [Google Scholar] [CrossRef]
  11. Yang, J.; Wang, Y.; Sowmya, A.; Li, Z. Vehicle detection and tracking with low-angle cameras. In Proceedings of the 2010 IEEE International Conference on Image Processing, ICIP 2010, Hong Kong, China, 26–29 September 2010; pp. 685–688. [Google Scholar] [CrossRef]
  12. He, K.; Zhang, X.; Ren, S.; Sun, J. Spatial pyramid pooling in deep convolutional networks for visual recognition. In Proceedings of the 13th European Conference on Computer Vision, ECCV 2014, Zurich, Switzerland, 6–12 September 2014; Volume 8691 LNCS, pp. 346–361. [Google Scholar] [CrossRef] [Green Version]
  13. Girshick, R.; Donahue, J.; Darrell, T.; Malik, J. Rich feature hierarchies for accurate object detection and semantic segmentation. In Proceedings of the 27th IEEE Conference on Computer Vision and Pattern Recognition (CVPR 2014), Columbus, OH, USA, 23–28 June 2014; pp. 580–587. [Google Scholar] [CrossRef] [Green Version]
  14. Girshick, R. Fast R-CNN. In Proceedings of the 15th IEEE International Conference on Computer Vision, (ICCV 2015), Santiago, Chile, 11–18 December 2015; pp. 1440–1448. [Google Scholar] [CrossRef]
  15. Ren, S.; He, K.; Girshick, R.; Sun, J. Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. IEEE Trans. Pattern Anal. Mach. Intell. 2017, 39, 1137–1149. [Google Scholar] [CrossRef] [PubMed] [Green Version]
  16. Redmon, J.; Divvala, S.; Girshick, R.; Farhadi, A. You only look once: Unified, real-time object detection. In Proceedings of the 29th IEEE Conference on Computer Vision and Pattern Recognition, (CVPR 2016), Las Vegas, NV, USA, 26 June–1 July 2016; pp. 779–788. [Google Scholar] [CrossRef] [Green Version]
  17. Liu, W.; Anguelov, D.; Erhan, D.; Szegedy, C.; Reed, S.; Fu, C.Y.; Berg, A.C. SSD: Single shot multibox detector. In Proceedings of the 14th European Conference on Computer Vision, (ECCV 2016), Amsterdam, The Netherlands, 8–16 October 2016; Volume 9905 LNCS, pp. 21–37. [Google Scholar] [CrossRef] [Green Version]
  18. Lin, T.Y.; Goyal, P.; Girshick, R.; He, K.; Dollar, P. Focal Loss for Dense Object Detection. In Proceedings of the 16th IEEE International Conference on Computer Vision, (ICCV 2017), Venice, Italy, 22–29 October 2017; pp. 2999–3007. [Google Scholar] [CrossRef] [Green Version]
  19. Wu, B.; Iandola, F.; Jin, P.H.; Keutzer, K. SqueezeDet: Unified, Small, Low Power Fully Convolutional Neural Networks for Real-Time Object Detection for Autonomous Driving. In Proceedings of the 30th IEEE Conference on Computer Vision and Pattern Recognition Workshops, (CVPRW 2017), Honolulu, HI, USA, 21–26 July 2017; pp. 446–454. [Google Scholar] [CrossRef] [Green Version]
  20. Kim, J.B.; Kim, H.J. Efficient region-based motion segmentation for a video monitoring system. Pattern Recognit. Lett. 2003, 24, 113–128. [Google Scholar] [CrossRef]
  21. Zhang, X.; Gao, H.; Xue, C.; Zhao, J.; Liu, Y. Real-time vehicle detection and tracking using improved histogram of gradient features and Kalman filters. Int. J. Adv. Robot. Syst. 2018, 15. [Google Scholar] [CrossRef]
  22. Abdelwahab, M.A.; Abdelwahab, M.M. A Novel Algorithm for Vehicle Detection and Tracking in Airborne Videos. In Proceedings of the 17th IEEE International Symposium on Multimedia, (ISM 2015), Miami, FL, USA, 14–16 December 2015; pp. 65–68. [Google Scholar] [CrossRef]
  23. Kadikis, R.; Freivalds, K. Vehicle Classification in Video Using Virtual Detection Lines. In Sixth International Conference on Machine Vision (icmv 2013); Verikas, A., Vuksanovic, B., Zhou, J., Eds.; Spie-Int Soc Optical Engineering: Bellingham, QA, USA, 2013; Volume 9067, p. 906715. [Google Scholar]
  24. Barcellos, P.; Bouvie, C.; Escouto, F.L.; Scharcanski, J. A novel video based system for detecting and counting vehicles at user-defined virtual loops. Expert Syst. Appl. 2015, 42, 1845–1856. [Google Scholar] [CrossRef]
  25. Stauffer, C.; Grimson, W.E.L. Learning patterns of activity using real-time tracking. IEEE Trans. Pattern Anal. Mach. Intell. 2000, 22, 747–757. [Google Scholar] [CrossRef] [Green Version]
  26. Gloyer, B.; Aghajan, H.K.; Siu, K.Y.S.; Kailath, T. Video-based freeway-monitoring system using recursive vehicle tracking. In Proceedings of the Image and Video Processing III, San Jose, CA, USA, 9–10 February 1995; Volume 2421, pp. 173–180. [Google Scholar]
  27. Wan, Q.; Wang, Y. Background subtraction based on adaptive non-parametric model. In Proceedings of the 7th World Congress on Intelligent Control and Automation, (WCICA’08), Chongqing, China, 25–27 June 2008; pp. 5960–5965. [Google Scholar] [CrossRef]
  28. Otsu, N. Threshold Selection Method from Gray-Level Histograms. IEEE Trans. Syst. Man Cybern. 1979, SMC-9, 62–66. [Google Scholar] [CrossRef] [Green Version]
  29. GRAM Road-Traffic Monitoring. Available online: http://agamenon.tsc.uah.es/Personales/rlopez/data/rtm/ (accessed on 24 January 2021).
  30. Gonzalez, R.C.; Woods, R.E. Morphological Image Processing. In Digital Image Processing, 4th ed.; Pearson Prentice Hall: New York, NY, USA, 2007; pp. 657–661. [Google Scholar]
  31. Roess, R.P.; Prassas, E.S.; McShane, W.R. Road User and Vehicle Characterstics. In Traffic Engineering; Prentice Hall: Upper Saddle River, New Jersey, 2011; pp. 18–24. [Google Scholar]
  32. AASHTO. A Policy on Geometric Design of Highways and Streets, 5th ed.; AASHTO: Washington, DC, USA, 2004. [Google Scholar]
  33. Wang, Y.; Jodoin, P.M.; Porikli, F.; Konrad, J.; Benezeth, Y.; Ishwar, P. CDnet 2014: An Expanded Change Detection Benchmark Dataset. In Proceedings of the 2014 IEEE Conference on Computer Vision and Pattern Recognition Workshops, (CVPRW 2014), Columbus, OH, USA, 23–28 June 2014; pp. 393–400. [Google Scholar] [CrossRef] [Green Version]
  34. Quesada, J.; Rodriguez, P. Automatic Vehicle Counting Method Based on Principal Component Pursuit Background Modeling. In 2016 IEEE International Conference on Image Processing (icip); IEEE: New York, NY, USA, 2016; pp. 3822–3826. [Google Scholar]
  35. Change Dectection Benchmark Web Site. Available online: http://jacarini.dinf.usherbrooke.ca/dataset2014/ (accessed on 24 January 2020).
  36. Videos for Experiments. Available online: https://pan.baidu.com/s/1Kq7R-paqIMOFhD8o4nJaDA (accessed on 24 January 2020).
  37. Abdelwahab, M.A. Fast approach for efficient vehicle counting. Electron. Lett. 2019, 55, 20–21. [Google Scholar] [CrossRef]
  38. Shakeri, M.; Zhang, H. COROLA: A sequential solution to moving object detection using low-rank approximation. Award Sel. Pap. ACCV 2014 2016, 146, 27–39. [Google Scholar] [CrossRef] [Green Version]
  39. Yang, H.; Qu, S. Real-time vehicle detection and counting in complex traffic scenes using background subtraction model with low-rank decomposition. IET Intell. Transp. Syst. 2018, 12, 75–85. [Google Scholar] [CrossRef]
  40. Gomaa, A.; Abdelwahab, M.M.; Abo-Zahhad, M.; Minematsu, T.; Taniguchi, R.I. Robust Vehicle Detection and Counting Algorithm Employing a Convolution Neural Network and Optical Flow. Sensors 2019, 19, 4588. [Google Scholar] [CrossRef] [PubMed] [Green Version]
  41. Rosas-Arias, L.; Portillo-Portillo, J.; Hernandez-Suarez, A.; Olivares-Mercado, J.; Sanchez-Perez, G.; Toscano-Medina, K.; Perez-Meana, H.; Sandoval Orozco, A.L.; Garcia Villalba, L.J. Vehicle Counting in Video Sequences: An Incremental Subspace Learning Approach. Sensors 2019, 19, 2848. [Google Scholar] [CrossRef] [PubMed] [Green Version]
  42. Bouvié, C.; Scharcanski, J.; Barcellos, P.; Escouto, F.L. Tracking and counting vehicles in traffic video sequences using particle filtering. In Proceedings of the 2013 IEEE International Instrumentation and Measurement Technology Conference (I2MTC), Minneapolis, MN, USA, 6–9 May 2013; pp. 812–815. [Google Scholar] [CrossRef]
  43. Harikrishnan, P.M.; Thomas, A.; Nisha, J.S.; Gopi, V.P.; Palanisamy, P. Pixel matching search algorithm for counting moving vehicle in highway traffic videos. Multimed. Tools Appl. 2020. [Google Scholar] [CrossRef]
Figure 1. Block diagram of the proposed method.
Figure 1. Block diagram of the proposed method.
Applsci 11 06831 g001
Figure 2. Current frame under (a) RGB mode ( I 539 R G B ) and (b) gray mode ( I 539 R G B ).
Figure 2. Current frame under (a) RGB mode ( I 539 R G B ) and (b) gray mode ( I 539 R G B ).
Applsci 11 06831 g002
Figure 3. Detection under gray mode. (a) Established gray-mode background ( B g r a y ). (b) Detection result under gray mode ( I 539 b i n a r y g r a y ).
Figure 3. Detection under gray mode. (a) Established gray-mode background ( B g r a y ). (b) Detection result under gray mode ( I 539 b i n a r y g r a y ).
Applsci 11 06831 g003
Figure 4. Mapped gray-mode result of background subtraction.
Figure 4. Mapped gray-mode result of background subtraction.
Applsci 11 06831 g004
Figure 5. Current frame under (a) red mode ( I 539 r e d ), (b) green mode I 539 g r e e n ), and (c) blue mode ( I 539 b l u e ).
Figure 5. Current frame under (a) red mode ( I 539 r e d ), (b) green mode I 539 g r e e n ), and (c) blue mode ( I 539 b l u e ).
Applsci 11 06831 g005
Figure 6. Background under (a) red mode ( B r e d ), (b) green mode ( B g r e e n ), and (c) blue mode ( B b l u e ) and (d) the reconstructed RGB-mode background ( B R G B ).
Figure 6. Background under (a) red mode ( B r e d ), (b) green mode ( B g r e e n ), and (c) blue mode ( B b l u e ) and (d) the reconstructed RGB-mode background ( B R G B ).
Applsci 11 06831 g006
Figure 7. The mapped result of background subtraction under (a) red mode, (b) green mode, and (c) blue mode.
Figure 7. The mapped result of background subtraction under (a) red mode, (b) green mode, and (c) blue mode.
Applsci 11 06831 g007
Figure 8. Detection under (a) red mode ( I 539 b i n a r y r e d ), (b) green mode ( I 539 b i n a r y g r e e n ), and (c) blue mode ( I 539 b i n a r y b u l e ).
Figure 8. Detection under (a) red mode ( I 539 b i n a r y r e d ), (b) green mode ( I 539 b i n a r y g r e e n ), and (c) blue mode ( I 539 b i n a r y b u l e ).
Applsci 11 06831 g008
Figure 9. Final detection. (a) Union of four detection results ( I 539 b i n a r y u n i o n ). (b) Optimized final detection ( I 539 b i n a r y ).
Figure 9. Final detection. (a) Union of four detection results ( I 539 b i n a r y u n i o n ). (b) Optimized final detection ( I 539 b i n a r y ).
Applsci 11 06831 g009
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.
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.
Applsci 11 06831 g010
Figure 11. Composition of a road.
Figure 11. Composition of a road.
Applsci 11 06831 g011
Figure 12. Setting of loops. (a) Primary loops. (b) Secondary loops. (c) The overlap between primary loops and secondary loops.
Figure 12. Setting of loops. (a) Primary loops. (b) Secondary loops. (c) The overlap between primary loops and secondary loops.
Applsci 11 06831 g012
Figure 13. Binary detection I 539 b i n a r y set with (a) primary loops and (b) secondary loops.
Figure 13. Binary detection I 539 b i n a r y set with (a) primary loops and (b) secondary loops.
Applsci 11 06831 g013
Figure 14. Four key frames of the left black vehicle in Figure 2a. (a) Frame 533 ( L a n e 1 is not occupied). (b) Frame 534 ( L a n e 1 is occupied). (c) Frame 544 ( L a n e 1 Lane1 is occupied). (d) Frame 545 ( L a n e 1 is not occupied).
Figure 14. Four key frames of the left black vehicle in Figure 2a. (a) Frame 533 ( L a n e 1 is not occupied). (b) Frame 534 ( L a n e 1 is occupied). (c) Frame 544 ( L a n e 1 Lane1 is occupied). (d) Frame 545 ( L a n e 1 is not occupied).
Applsci 11 06831 g014
Figure 15. Example of the experimental results in Video I.
Figure 15. Example of the experimental results in Video I.
Applsci 11 06831 g015
Figure 16. Example of the experimental results in Video II.
Figure 16. Example of the experimental results in Video II.
Applsci 11 06831 g016
Figure 17. Example of the experimental results in Video III.
Figure 17. Example of the experimental results in Video III.
Applsci 11 06831 g017
Figure 18. Example of the experimental results in Video IV.
Figure 18. Example of the experimental results in Video IV.
Applsci 11 06831 g018
Figure 19. Example of the experimental results in Video V.
Figure 19. Example of the experimental results in Video V.
Applsci 11 06831 g019
Figure 20. Example of the experimental results in Video VI.
Figure 20. Example of the experimental results in Video VI.
Applsci 11 06831 g020
Figure 21. Example of a vehicle driving right in the middle of L a n e 2 and L a n e 3 . (a) Example frame under RGB mode. (b) Detection result set with primary loops. (c) Detection result set with secondary loops.
Figure 21. Example of a vehicle driving right in the middle of L a n e 2 and L a n e 3 . (a) Example frame under RGB mode. (b) Detection result set with primary loops. (c) Detection result set with secondary loops.
Applsci 11 06831 g021
Figure 22. Example of missed counting. (a) Example frame under RGB mode. (b) Detection result set with primary loops. (c) Detection result set with secondary loops.
Figure 22. Example of missed counting. (a) Example frame under RGB mode. (b) Detection result set with primary loops. (c) Detection result set with secondary loops.
Applsci 11 06831 g022
Figure 23. Example of redundant counting. (a) Example frame under RGB mode. (b) Detection result set with primary loops. (c) Detection result set with secondary loops.
Figure 23. Example of redundant counting. (a) Example frame under RGB mode. (b) Detection result set with primary loops. (c) Detection result set with secondary loops.
Applsci 11 06831 g023
Table 1. Mathematical form of states in frame 539.
Table 1. Mathematical form of states in frame 539.
PLoop 1 PLoop 2 PLoop 3 PLoop 4
SLoop 1 SLoop 2 SLoop 3 SLoop 4 SLoop 5
P S t a t e 539 1 0 0 0
S S t a t e 539 1 1 0 0 0
Table 2. Judgement of whether L a n e 1 is occupied.
Table 2. Judgement of whether L a n e 1 is occupied.
SLoop 1 PLoop 1 SLoop 2 PLoop 2 SLoop 3 PLoop 3 SLoop 4 PLoop 4 SLoop 5 Judgement
111//////Occupied
110//////Occupied
101//////Occupied
100//////Occupied
011//////Occupied
010//////Occupied
0010/////Occupied
0011/////Not occupied
000//////Not occupied
Table 3. Judgement of whether L a n e 4 is occupied.
Table 3. Judgement of whether L a n e 4 is occupied.
SLoop 1 PLoop 1 SLoop 2 PLoop 2 SLoop 3 PLoop 3 SLoop 4 PLoop 4 SLoop 5 Judgement
//////111Occupied
//////011Occupied
//////101Occupied
//////001Occupied
//////110Occupied
//////010Occupied
/////0100Occupied
/////1100Not occupied
//////000Not occupied
Table 4. Judgement of whether L a n e 3 is occupied.
Table 4. Judgement of whether L a n e 3 is occupied.
SLoop 1 PLoop 1 SLoop 2 PLoop 2 SLoop 3 PLoop 3 SLoop 4 PLoop 4 SLoop 5 Judgement
////111//Occupied
////011//Occupied
////1010/Occupied
////1011/Not occupied
////0010/Occupied
////0011/Not occupied
////110//Occupied
////010//Occupied
///0100//Occupied
///1100//Not occupied
////000//Not occupied
Table 5. Judgement of whether L a n e 2 is occupied.
Table 5. Judgement of whether L a n e 2 is occupied.
SLoop 1 PLoop 1 SLoop 2 PLoop 2 SLoop 3 PLoop 3 SLoop 4 PLoop 4 SLoop 5 Judgement
//111////Occupied
//110////Occupied
/0101////Occupied
/1101////Not occupied
/0100////Occupied
/1100////Not occupied
//011////Occupied
//010////Occupied
//0010///Occupied
//0011///Not occupied
//000////Not occupied
Table 6. The state of loops at the four key frames of the left black vehicle in Figure 2a.
Table 6. The state of loops at the four key frames of the left black vehicle in Figure 2a.
SLoop 1 PLoop 1 SLoop 2 PLoop 2 SLoop 3 PLoop 3 SLoop 4 PLoop 4 SLoop 5 Occupancy of Lane 1
Frame 533000000000Not occupied
Frame 534110000000Occupied
Frame 544111000000Occupied
Frame 545000000000Not occupied
Table 7. Basic information of the videos and the roads.
Table 7. Basic information of the videos and the roads.
Video NameRecording SiteFrame No.Average Pixel No. for a Vehicle
Video IM-30Madrid, Spain75204000 ∼ 5000
Video IIM-30-HDMadrid, Spain93904000 ∼ 5000
Video IIIHighwayN/A17004000 ∼ 4500
Video IVNJ-1Jiangsu, China10,00013,000 ∼ 15,000
Video VNJ-2Jiangsu, China10,0009000 ∼ 10,000
Video VINJ-3Jiangsu, China10,0009000 ∼ 10,000
Table 8. Characteristics of the videos and the roads.
Table 8. Characteristics of the videos and the roads.
Road CategoryLane No.WeatherShooting Angle
Video IHighway4SunnyRear
Video IIHighway4CloudyRear
Video IIIHighway2SunnyFront
Video IVUrban Road3CloudyFront
Video VExpressway3SunnySide
Video VIExpressway3CloudySide
Table 9. Experimental results of Video I.
Table 9. Experimental results of Video I.
TP FN FP True Counted Recall Precision F-Measure Accuracy
L a n e 1 79007979100%100%100%100%
L a n e 2 70017071100%98.59%99.29%98.57%
L a n e 3 69016970100%98.57%99.28%98.55%
L a n e 4 36003636100%100%100%100%
Table 10. Experimental results of Video II.
Table 10. Experimental results of Video II.
TP FN FP True Counted Recall Precision F-Measure Accuracy
L a n e 1 68016869100%98.55%99.27%98.53%
L a n e 2 75017576100%98.68%99.34%98.67%
L a n e 3 5910605998.33%100%99.16%98.33%
L a n e 4 31003131100%100%100%100%
Table 11. Experimental results of Video III.
Table 11. Experimental results of Video III.
TP FN FP True Counted Recall Precision F-Measure Accuracy
L a n e 1 17001717100%100%100%100%
L a n e 2 10001010100%100%100%100%
Table 12. Experimental results of Video IV.
Table 12. Experimental results of Video IV.
TP FN FP True Counted Recall Precision F-Measure Accuracy
L a n e 1 40044100%100%100%100%
L a n e 2 3611373797.30%97.30%97.30%100%
L a n e 3 44014445100%97.78%98.88%97.73%
L a n e 4 1911202095.00%95.00%95.00%100%
Table 13. Experimental results of Video V.
Table 13. Experimental results of Video V.
TP FN FP True Counted Recall Precision F-Measure Accuracy
L a n e 1 4411454597.78%97.78%97.78%100%
L a n e 2 12302123125100%98.40%99.19%98.37%
L a n e 3 1141211511699.13%98.28%98.70%99.13%
Table 14. Experimental results of Video VI.
Table 14. Experimental results of Video VI.
TP FN FP True Counted Recall Precision F-Measure Accuracy
L a n e 1 14001414100%100%100%100%
L a n e 2 5212535498.11%96.30%97.20%98.11%
L a n e 3 18001818100%100%100%100%
Table 15. Experimental results of each sequence.
Table 15. Experimental results of each sequence.
Sequence TP FN FP True Counted Recall Precision F-Measure Accuracy
Video I25402254256100%99.22%99.61%99.21%
Video II2331223423599.57%99.15%99.36%99.57%
Video III27002727100%100%100%100%
Video IV1032310510698.10%97.17%97.63%99.05%
Video V2812528328699.29%98.25%98.77%98.94%
Video VI8412858698.82%97.67%98.25%98.82%
Total98261498899699.39%98.59%98.99%99.19%
Table 16. Comparison results of the benchmark Highway.
Table 16. Comparison results of the benchmark Highway.
True Counted Recall Precision F-Measure Accuracy
Shakeri [38]27N/A85.40%95.10%89.99%N/A
H. Yang [39]161488.89%100%94.12%87.50%
Abdelwahab [37]2729100%93.10%96.43%92.59%
Gomaa [40]27N/A99.20%98.20%98.70%N/A
Rosas-Arias [41]272696.43%100%98.18%96.30%
Proposed Method2727100%100%100%100%
Table 17. Comparison results of the benchmark M-30.
Table 17. Comparison results of the benchmark M-30.
True Counted Recall Precision F-Measure Accuracy
Bouvié [42]776989.61%100%94.52%89.61%
Quesada [34]777597.40%100%98.68%97.40%
H. Yang [39]777188.51%95.06%91.67%92.21%
Abdelwahab [37]777698.72%100%99.35%98.70%
Harikrishnan [43]7776N/AN/AN/A98.70%
Proposed Method254256100%99.22%99.61%99.21%
Table 18. Comparison results of the benchmark M-30-HD.
Table 18. Comparison results of the benchmark M-30-HD.
True Counted Recall Precision F-Measure Accuracy
Bouvié [42]423378.57%100%88.00%78.57%
Quesada [34]423992.86%100%96.30%92.86%
H. Yang [39]423789.36%100%94.38%88.10%
Abdelwahab [37]4242100%100%100%100%
Harikrishnan [43]4240N/AN/AN/A95.24%
Proposed Method23423599.57%99.15%99.36%99.57%
Table 19. Example of a vehicle driving right in the middle of L a n e 2 and L a n e 3 .
Table 19. Example of a vehicle driving right in the middle of L a n e 2 and L a n e 3 .
PLoop 1 PLoop 2 PLoop 3 PLoop 4 Lane 2 Lane 3
Stricter 0 0 0 0 ××
Looser 0 1 1 0
SLoop 1 PLoop 1 SLoop 2 PLoop 2 SLoop 3 PLoop 3 SLoop 4 PLoop 4 SLoop 5 Lane 2 Lane 3
Stricter000010000×
Looser000111000×
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Chen, Y.; Lu, J. A Multi-Loop Vehicle-Counting Method under Gray Mode and RGB Mode. Appl. Sci. 2021, 11, 6831. https://doi.org/10.3390/app11156831

AMA Style

Chen Y, Lu J. A Multi-Loop Vehicle-Counting Method under Gray Mode and RGB Mode. Applied Sciences. 2021; 11(15):6831. https://doi.org/10.3390/app11156831

Chicago/Turabian Style

Chen, Yue, and Jian Lu. 2021. "A Multi-Loop Vehicle-Counting Method under Gray Mode and RGB Mode" Applied Sciences 11, no. 15: 6831. https://doi.org/10.3390/app11156831

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop