A two-stage approach for front-view vehicle detection and counting at nighttime

In this paper, we introduce an approach to car detection and counting using a two-stage method of car dectection and counting. For car hypothesis, we propose a method of headlight candidate extraction using k-means clustering based segmentation which is used as a multi-thresholding method to segment the gray-image of the traffic scene with the lowest level and highest level of intensities included in seed configuration. In verification stage, both individual and paired headlights are tracked during their existence in the ROI. Kalman filter is used to track the detected headlights and counting decision is given when the pairs of headlights follow specified counting rules. The experiments are evaluated on real world traffic videos at the resolution of 640x480, 15fps. The method is robust with various situations of illumination at nighttime.


Introduction
Although vehicle detection systems are reported to produce really high accuracy in detecting and tracking vehicles at daytime [1], its inherent characteristic of using motion detection heavily relies on the assumption that the shape of the vehicles are always good so that the neighboring moving pixels can be classified as one vehicle.This assumption, however fails badly when the illumination becomes weaker, especially at nighttime, where the shapes of the vehicles are hardly visible to normal CCTV cameras.In addition, the reflection of vehicle headlights on the road do appear very similar in motion perspective to its actual vehicle shape.Most of motion detection algorithms will easily detect the whole big blob including vehicle, vehicle's reflection on the road, and any occluded vehicles right behind as one big vehicle.Those disadvantages of Daytime Traffic Surveillance Systems have motivated a different research stream which approaches Nighttime Traffic Surveillance with a separate methodology.
As methods applied for detecting and counting cars daytime are generally quite different for that at nighttime [2][3][4], together with the proposed front-view car detection and counting at daytime based on car's windshields described in [1], we develop a system for car counting at nighttime to cover a more complete range of solving the car counting problem using a fixed camera capturing car images at front-view.
At nighttime, the only promising cue is the headlights which can be easily extracted with reasonable threshold of brightness.The straightforward and feasible approach is using the headlight appearance in pairs and tracking the pairs during their appearance in traffic scenes to help counting decision.
The headlight candidate extraction process is the hypothesis generation and the pairing process works as the verification stage.We propose a method of headlight candidate extraction using k-means clustering based segmentation [5].The method is much like an adaptive multi-threshold segmentation that is robust with various situations of illumination (darkness) at nighttime.Similar to the method of daytime car counting, Kalman filters are used to track the detected headlights and counting decision is given when the pairs of headlights follow specified counting rules.The experiments are evaluated on real world traffic videos at the resolution of 640x480, 15fps.
The rest of this paper is organized as follows.Car hypothesis is introduced in Section 2, including the perspective transformation and headlight candidate detection.In Section 3, we describe method of car verification by pairing detected headlight candidates that satisfy the size and distance criteria.In the Section 4, our proposed counting system is described.The experimental results for the 2 stages mentioned are shown in Section 5 and concluded in Section 6.

Car hypothesis based on headlight detection 2.1
Perspective transformation Our proposed system uses a fixed camera looking down the traffic lanes to get car images.Because of the perspective view, when the human eye looks at a scene, objects in the distance appear smaller than objects close by.This causes the difference in distance estimation between pairs of car's headlights with respect to the distance from the camera.To suppress the horizontal and vertical constrain errors when dealing with headlight pair matching, we take into account a simple perspective transformation, bird's eye view transformation, a common task in navigation to convert the camera view of the scene into a top-down "bird's-eye" view.Figure 1 shows an example of a transformation of a scene and its bird's eye view.
For simplicity, our system requires user input of four points for the transformation at the beginning of the detection process.The corresponding minimum rectangle including the four input points is automatically calculated and used as the region of interest where the algorithm is applied to.

Figure 1. User ROI and the transformed region
In our method, the transformation is only applied to the center points of the blobs of headlight candidates obtained from the detection stage by using the homography matrix remaping the input trapezoid to the region of interest.It is no need to remap the original image piece into a bird's-eye view because it can reduce the image quality by interpolation during the transformation process.Figure 1 shows an example of a user input trapezoid, the derived ROI and the transformed region.

2.2
Car headlight detection The traffic scene illumination condition varies at different time at nighttime and depends on the traffic infrastructure itself.In the early nighttime the background is lit brighter, but in later time, the background is darker and only car headlights are clearly visible.Another problem is to deal with light reflection from headlights.
We propose a more robust method to extract car headlights based on k-means clustering.K-means clustering work as an adaptive multi-thresholding segmentation that clusters different levels of brightness in the gray image.
Let consider a traffic scene at night time.The highest level of brightness is of the car headlights, the lower levels are of the reflection of headlights on the background, the lit background and the dark background in decrease order of brightness, respectively.Headlight regions can be easily extracted using thresholding method with a specified high threshold.But using a static threshold make the system not robust with various lighting condition of traffic scenes.The idea here is to partition the image into difference regions of the brightness levels corresponding to the four object regions mentioned.K-means method works well in this situation which the number of region k is equal to the number of object regions.
Headlight candidates are regions of the highest level of intensity from k-means segmentation.The reflection of lights on background also appears in a clear pattern that can be detected by considering the shape and brightness transition.Some morphological operations such as opening are used to reduce noise and filter out small regions.
Figure 2 shows a segmentation result in different levels of gray levels of a traffic scene (upper right) and the extracted light candidates (lower right).
Using the projective transformation, it is easy to find the appropriate size of headlights, those white blobs that match the criteria will be considered as positions headlights on the vehicles, and the center weight of the blob will be recorded as the headlight position with a corresponding size.
Headlights detection works well as long as headlight brightness is high enough that all headlight regions are in the highest level of intensity of the image.In that case, the segmentation results are usually over-segmentations which mean that there are more regions of headlights than needed but also other regions such as light reflection, and other highly lit objects.Over-segmentation is what we are expecting for the next steps because noise and other objects out of interest can be filter out in the pairing step, and we don't expect for missed regions of headlight candidates.

Headlight pairing for car verification
Once individual headlights are detected, car positions can be estimated by relevant pairs of headlights thanks to that cars and lights are rigid of objects and each pair of lights with some constrains potentially represents a position of car.Finding relevant pairs is matching individual lights that hold for specific criteria.Perspective transformation is applied at first to the estimated headlight positions to suppress distance errors.Then every pair of headlights is judge for matching using the following constrains:

3.1
Size constrain Size constrain is apply to filter out non-related regions such as over-sized regions of light reflection or other object rather than car headlights.The size of headlight region should be in a specified range: A min < A Blob < A max where A min , A max are minimum and maximum area for a headlight region; A Blob is blob area of the headlight.The lower and upper bound area thresholds depend on the input image size of the traffic scene.
The relative size of the two blobs of headlights is not taken into account because experimentally, two headlights in each pair can have different intensities of brightness causing various sizes of blobs.In this case, the blob's centers still work as headlight positions as shown in example in Figure 3.

3.2
Relative position constrains With a given input image size (traffic scene) and after the projective transformation, we assume that the two headlight positions belonging to the same car are at a relative distance with some small errors.
The two headlights of the same car are an appropriate distance away from each other and are aligned horizontally on the image plane: where and are coordinates of the i th headlight position (1<i<n), is the pre-defined distance between headlights of a car that we expected., are allowable errors in pixels of the positions in horizontal and vertical direction, respectively.
Every matching pair of headlight position is consider as a car position assumedly having the two corresponding headlights at the positions.Recall that at the headlight extraction stage, we aim at extract all the possible headlight positions with allowing some more noise positions.Together with some special cases such as two side headlights in two cars are too close that they can be matched, we decide to allow redundancy pairings for counting purpose.It means that there can be many false positive regions where cars are falsely detected.By tracking individual headlights and pairs of headlights, the false positives can be easily eliminated.Figure 4 shows some common appearance situations of headlights.Rule-based judgment for counting is similar to the daytime car counting.The overall counting process is show in Figure 5. Occlusion handling By the tracking process using Kalman filter, temporarily occlusion can be overcome by using predictions.In the case of our system setup, most of occlusions occur when a car is occluded by another car ahead with one or two headlights occluded.Another case but not very often is some cars with one-operating light only.

Experimental results
The experiments perform on 640x 480 input frames.Figure 6 shows some results of the segmentation results with different k.Experiments on some real-world traffic videos at the resolution of 640x480, 15fps, our system can obtain the accuracy at about 98%.The accuracy varies with respect to the illumination condition, occlusion density …

Conclusion
In comparison with car detection in daytime, detection of car in nighttime is considered independently because the only promising cue is the headlights which can be easily extracted with reasonable threshold of brightness.The extraction process is the hypothesis generation and the pairing process works as the verification stage.

Figure 2 .
Figure 2. K-means clustering for headlight extraction (k=6): K-means clustering result (top) on a traffic scene (left) and the extracted headlight regions.

Figure 3 .
Figure 3.An example of different headline appearance in a pair

Figure 4 .
Figure 4. Some situations of headlight appearance

Figure 5 .
Figure 5.The proposed car counting flowchart in nighttime Kmeans clustering based method of headlight extraction give quite good results.Experimental results are shown below with different k(s).It is shown that k=6 is good for the segmentation.The seeds for k-means are chosen with the bias to the right of the gray level axis so that the dark background and the headlights are well clustered.Experiments show that including 0 and 255 gray level in the initial seeds gives better results.For example, with k=5, the seed configuration can be [0, 120, 200, 220, 255].

Figure 6 .
Figure 6.K-means clustering headlight extraction results with k = 3, 4 ,5Some results of the extraction process are shown in Figure7and Figure8.A result of the pairing process is shown in Figure7.Figure8shows a car detection result for a night scene in a region of interest.The result is quite good with the existence of remarkably reflection on the

Figure 7 .
Figure 7.A result of car headlight pairing.Paired lights are connected by lines.

Figure 8 .
Figure 8.A headlight based car detection result: car position are estimated by pairs of headlights.

Figure 9 .
Figure 9.An example of redundancy of tracking of headlight pairs.A traffic scene (left), headlight extraction result (right) and pairing result (below).