The fast recognition of vehicle license plate based on the improved template matching

In order to solve the problem of low accuracy and slow speed in vehicle license plate recognition, a method of number-plate recognition using template matching is proposed. It can effectively recognize low quality and fuzzy number-plate image in real system .The accuracy is 95%, and the recognition time is close to 0.14s.


Introduction
Vehicle license plate recognition (VLPR) system is a typical application of remote digital video monitoring and image recognition technology. The fast and accurate recognition of vehicle license plate is important to the function of automatic traffic violation detection systems. Many factors will influence the recognition accuracy and speed, such as uneven brightness, inclination of image shooting, complex background, stained plate and different plate styles. In order to solve these problems, an improved template matching method is proposed in this paper. This method will improve the recognition accuracy and speed for images with different resolution and interferences.

Methodology
In this study, the improved recognition method consists of three steps: location of license plate, character segmentation and recognition of character, which is shown in Figure 1.

Characteristics Of License Plate
Before choosing the method, the characteristics of license plate are analyzed. In this study, the Chinese vehicle license plate is chosen as a sample to be recognized. The size of Chinese vehicle license plate is 440mm×140mm with 7 characters. The width and strokes of each character is 45mm and 10mm respectively. What's more, the distance between the second and third character is 34mm.The distances of other characters are all 12mm.The typical Chinese vehicle license plate are shown in Figure 2.

Coarse and accurate positioning
The color features of license plate are important factors that influence the selecting of recognition methodology. area ratio, vertical projection and characters strokes uniformity of each character. Based on the features described above, the location of license plate is divided into two steps .Firstly, the coarse positioning of plate is conducted by color spaces; secondly, the accurate positioning of plate is completed by statistical analysis of pixel.
(1) Coarse positioning of license plate OpenCV is used to process the data in captured image and coarse positioning of license plate is accomplished based on the color features. Taking the license plate of white characters and blue background as example ,firstly, the white-blue color is converted from RGB to HSV color space; secondly, the image is scanned completely, and binarization process is conducted for the H, S and V value of HSV image according to the pixel range; finally, the three image intersect byte by byte. Then the blue color is obtained. The primary location of license plate can be obtained after denoising process.
Several images containing the license plate are selected as samples to have the coarse positioning treatment, which are shown in   (2) Accurate positioning of license plate The accurate positioning of license plate is accomplished based on the statistical analysis of pixel. As for the license plate with white characters and blue background, rank scanning is used to capture the information of blue pixel. The line scanning is used to detect the upper and lower boundary of license plate, and the threshold of pixel is chosen as Th=5; while row scanning is used to detect the left and right boundary, and the threshold of pixel is chosen as Th=3( [2]). Then the additive operation is made between the line and row blue pixel matrix, then the whole license plate can be extracted, which is shown in Figure5.

Character segmentation and character size normalization
The purpose of the license plate character segmentation is to separate the seven characters in the license plate using the characteristics of each character and character spacing. In order to improve the anti-interference ability of character segmentation, this paper uses the method of combining prior knowledge and vertical projection to realize the segmentation of license plate characters.
(1) Coarse Character segmentation The position of each character in the license plate image is determined by the position of each character in the character segmentation template. According to prior knowledge analysis, ordinary license plate consists of Chinese characters, English letters, and numbers. If the total length of the character area on the license plate is T_Length, the width of a single character is approximately 7.5-1 of the total length (T_Lengthꞏ7.5-1). In an actual license plate binary image, the character width and character spacing are about 1 to 2 pixels apart from the theoretically estimated value. The first two characters are divided from left to right, and then the remaining five characters are divided from right to left. This avoids the problem of splitting the second and third characters consecutively. This method could minimize the impact of weather factors such as characters and lighting.
(2) Precise segmentation of license plate characters The license plate candidate region image is preprocessed to obtain a binary image. The matching degree of vertical projection and character segmentation template are calculated to achieve more accurate license plate character segmentation. The equation is shown in equation 1: represents the character interval template matching degree, V(j) represents the vertical projection of the license plate area which is shown in Figure 6. As a result, the incorrect segmentation points that still exist in the rough segmentation are removed, and the accurate character segmentation result is obtained, which is shown in Figure 7.
Character size normalization In general, compared with the standard character library, large inconsistencies in the characters size could exist during character dividing procedure. In order to facilitate the subsequent processing, the character size must be normalized before the character recognition. In this article, the characters are uniformly normalized to the size of 40×20 pixels, as shown in Figure 8.

Character recognition method based on template matching
Deformation and rotation of images could cause severe interference to the recognition results. To solve this problem, many studies on character recognition introduce neighborhood distances based on template matching method. This paper improves a template matching method based on Hausdorff distance to identify the license plate characters. The character recognition template used is shown in Figure 9 below.

General method of template matching based on Hausdorff distance
The Hausdorff distance is the method to analyze the similarity degree between two sets of point sets. The smaller the value, the better the matching, between the set of points( [3]). The Hausdorff distance between two sets of points is defined as equation 2: ||.|| is the distance paradigm between set A and set B. The equation (2) is the bi-directional Hausdorff distance, which is the basic form of the Hausdorff distance. The h(A,B) in equation (3) is called the unidirectional Hausdorff distance from set A to set B. By equation (2), the bidirectional Hausdorff distance H(A, B) is the max value of the one-way distances h(A, B) and h(B, A). When using Hausdorff distance for template matching, edge features of the image are usually selected as the matching basis. Firstly, the edges of the template image and the to-be-matched image are extracted to obtain the corresponding edge image. Then the edge image is converted to a binary image. The edge pixel grayscale value is set to 1 (or 0) and the non-edge pixel grayscale value is set to 0 (or 1)( [4]). Each edge point is represented by its coordinate position in the binary image. Finally, the edge binary image of the sample and the image to be identified is calculated.
The Haursdorff distances for edge binary images and perform template matching are calculated in the following procedure: Firstly, the parameter A and B are

Improved Hausdorff distance template matching
In the general algorithm, calculating the one-way distance directly always requires all points to be traversed, which takes a long time to complete the calculation. In fact, the scanning in the inner loop does not always have to be fully executed. The goal of the algorithm is to find the unidirectional Hausdorff distance cmax ( [5]). In the inner loop, When d<cmax is found, cmax will not change. This means that the algorithm can end the inner loop and continue with the next outer loop. Here, the idea of Early Interruption is proposed. The improved algorithm is shown in Table 1. B represents all the random list which is used to iterate through the inner loop. In the same way, E represents all random list in the outer loop . Since picking a random candidate set in a loop does not ensure all points are traversed, it is necessary to prepare a random set in advance. . It is possible to generate a random sequence by swapping each point in the set randomly selected. Random scan eliminate the effect of spatial locality in point concentration. The improved algorithm is shown in Table 2. 0.14 In order to make template matching apply to the condition of slight character rotation, deformation, etc. When calculating the distance metric, the minimum distance of the 3×3 neighborhood will be considered( [6]). The main steps of the improved character recognition method based on the Hausdorff algorithm are as follows.
(1) Initializing the character template distance. (2) Scanning the binary edge image of the character to be recognized pixel by pixel from left to right and from top to bottom. If it is 1, recording the position information of this point. If it is 0, skip it.
(3) In the template edge image, searching 1 in the 3×3 domain centered on Px. Finding the nearest point to Px and calculating the closest distance between Px and that point. This distance is the minimum distance between the image to be identified and the template image at this point.
(4) Adding the calculated distance to the one-way Hausdorff distance ( , ) Calculating max( ( , ), ( , )) . Traversing all the template to be identified, when Di is the minimum, the corresponding template character is the result of the recognition.

Experimental results and analysis
This article selects 357 vehicle images from the video image of the car camera. The image size is mostly 720×576, 1920×1080, and 556×390 pixels. The experimental example is shown in Figure 10. The experimental results presented in this paper are compared with the experimental results of the original method as shown in Table 3. The experimental results show that, the average accuracy of license plate recognition reached 95% in the improved method, and the average execution time is about 0.14s. The experimental results show that the method proposed in this paper has improved the character recognition accuracy and recognition efficiency of the license plate, which is better than the original method.

Conclusion
In order to solve the problem of low accuracy and slow speed in vehicle license plate recognition, a fast recognition method based on the improved Template matching is proposed .The experimental results show that this method can improve the accuracy and effectiveness of vehicle license plate recognition.