A license plate recognition method and device
By using color feature extraction and edge detection technologies, and leveraging the Sobel operator and a custom gradient operator, the problem of insufficient accuracy in license plate recognition under smoggy weather was solved, enabling accurate license plate location and recognition in harsh environments.
Patent Information
- Application Number
- CN202310917581.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-25
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2043-07-25
AI Technical Summary
Existing license plate recognition technology suffers from insufficient accuracy and poor clarity and distinguishability of license plates in adverse environments such as smog, making accurate license plate recognition difficult.
By employing color feature extraction and edge detection techniques, and utilizing the Sobel operator and a custom second gradient operator, preliminary localization and accurate detection of license plate regions are performed. This includes grayscale processing, binarization processing, edge detection, and character segmentation, thereby improving the recognition accuracy of license plate images.
It can quickly and accurately detect license plate areas in harsh environments, improving the accuracy and precision of license plate recognition, and adapting to complex weather conditions such as fog and haze.
Smart Images

Figure CN116844150B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of license plate recognition technology, and more specifically, to a license plate recognition method and apparatus. Background Technology
[0002] ETC (Electronic Toll Collection) and license plate recognition technologies have a wide range of applications and development prospects in intelligent transportation systems. ETC enables vehicles to pay tolls without stopping, making toll collection more convenient, safe, and fast, while license plate recognition is used to record vehicle license plate numbers, license plate colors, and entry and exit times, enabling automatic vehicle management to save manpower and improve efficiency.
[0003] The accuracy and efficiency of license plate recognition at highway entrances significantly impact highway congestion. Existing license plate recognition technology offers high accuracy in well-lit conditions, but accuracy needs improvement in foggy, rainy, and nighttime conditions. Particularly in smoggy weather, images are noisy, resulting in poor license plate clarity and differentiation, posing a significant challenge to accurate license plate recognition. Summary of the Invention
[0004] The purpose of this application is to provide a license plate recognition method and apparatus to improve the accuracy of license plate recognition.
[0005] To achieve the above objectives, the embodiments of this application are implemented in the following manner:
[0006] In a first aspect, embodiments of this application provide a license plate recognition method, comprising: acquiring an image to be recognized, wherein the image to be recognized contains a vehicle license plate; determining a license plate image based on the image to be recognized; performing character segmentation on the license plate image to obtain a character image of each character; and recognizing the character image of each character to determine the license plate number.
[0007] In conjunction with the first aspect, in a first possible implementation of the first aspect, determining the license plate image based on the image to be identified includes: extracting color features from the image to be identified to obtain a color feature map; preliminarily locating the license plate region in the image to be identified based on the color feature map to determine a first image; preprocessing the first image to obtain a preprocessed second image; and performing edge detection on the second image to determine the license plate image.
[0008] In conjunction with the first possible implementation of the first aspect, in the second possible implementation of the first aspect, based on the color feature map, the license plate region in the image to be identified is initially located to determine the first image, including: determining the license plate region from the color feature map; expanding the license plate region in all directions with the center of the license plate region as the center to obtain the expanded license plate region; and segmenting the first image from the image to be identified based on the expanded license plate region.
[0009] In conjunction with the first possible implementation of the first aspect, in the third possible implementation of the first aspect, the first image is preprocessed to obtain a preprocessed second image, including: performing grayscale processing on the first image to determine a grayscale image; performing binarization processing on the grayscale image to obtain a binarized image; establishing a pixel mapping relationship between the grayscale image and the binarized image to obtain a grayscale image with a corresponding black and white threshold as the second image.
[0010] In conjunction with the third possible implementation of the first aspect, in the fourth possible implementation of the first aspect, edge detection is performed on the second image to determine the license plate image, including: using a preset first gradient operator to calculate the first gradient corresponding to each pixel in the second image; determining the undetermined edge region based on the first gradient corresponding to each pixel; using a preset second gradient operator to calculate the second gradient corresponding to each pixel in the undetermined edge region; determining the edge image based on the second gradient corresponding to each pixel; and determining the license plate image based on the edge image.
[0011] In conjunction with the fourth possible implementation of the first aspect, in the fifth possible implementation of the first aspect, the first gradient operator includes Gx and Gy. Using a preset first gradient operator, the first gradient corresponding to each pixel in the second image is calculated, including: convolving each pixel of the second image I with Gx, and detecting the gradient change of the second image in the x-direction.
[0012]
[0013] Where Gx is the x-direction convolution kernel of the first gradient operator; Gy is used to convolve each pixel of the second image I to detect the gradient change of the second image in the y-direction:
[0014]
[0015] Where Gy is the y-direction convolution kernel of the first gradient operator; the first gradient corresponding to each pixel in the second image is calculated using the following formula:
[0016]
[0017] Where G represents the first gradient.
[0018] Combining the fifth possible implementation of the first aspect, in the sixth possible implementation of the first aspect, the calculation methods for Gx and Gy are as follows:
[0019] Gx x,y =-1*I x-1,y-1 +0*I x-1,y +1*I x-1,y+1 -2*I x,y-1 +0*I x,y +2*I x,y+1 -1*I x+1,y-1 +0*I x+1,y +1*I x+1,y+1 ,
[0020] Gy x,y =-1*I x-1,y-1 -2*I x-1,y -1*I x-1,y+1 +0*I x,y-1 +0*I x,y +0*I x,y+1 +1*I x+1,y-1 +2*I x+1,y +1*I x+1,y+1 ,
[0021] Among them, Gx x,y and Gy x,y They represent pixels I respectively x,y The gradient values in the x-direction and the gradient values in the y-direction, I x,y This represents the grayscale value of the x-th pixel in the y-th column of the second image I.
[0022] In conjunction with the fourth possible implementation of the first aspect, in the seventh possible implementation of the first aspect, a second gradient corresponding to each pixel in the undetermined edge region is calculated using a preset second gradient operator, including: obtaining the second gradient operator Hxy:
[0023]
[0024] Where Hxy is the second gradient operator, a1, a2, a3, a4, a6, a7, a8, and a9 are the corresponding weights, and δ is the weight configuration parameter;
[0025] The second gradient operator Hxy is used to convolve each pixel of the edge region Q to detect the gradient changes of the edge region in the x and y directions:
[0026] Hx x,y =a3*Qx-1,y+1 -a1*Q x-1,y-1 +a6*Q x,y+1 -a4*Q x,y-1 +a9*Q x+1,y+1 -a7*Q x+1,y-1 ,
[0027] Hy x,y =a7*Q x+1,y-1 -a1*Q x-1,y-1 +a8*Q x+1,y -a2*Q x-1,y +a9*Q x+1,y+1 -a3*Q x-1,y+1 ,
[0028] Among them, Hx x,y and Hy x,y They represent the pixel Q x,y The gradient values in the x-direction and the gradient values in the y-direction, Q x,y This represents the grayscale value of the x-th pixel in the y-th column of the undetermined edge region Q.
[0029] Combining the seventh possible implementation of the first aspect, in the eighth possible implementation of the first aspect, the weight configuration parameter δ satisfies:
[0030]
[0031] Among them, Q x,y Let T be the grayscale value of the x-th pixel in the x-th row and y-th column of the undetermined edge region Q. bw The black and white threshold of the second image;
[0032] The weights a1, a2, a3, a4, a6, a7, a8, and a9 satisfy the following:
[0033]
[0034]
[0035]
[0036]
[0037]
[0038]
[0039]
[0040]
[0041] in,
[0042] Q x-1,y-1 Q x-1,y Q x-1,y+1 Q x,y-1 Q x,y Q x,y+1 Q x+1,y-1 Q x+1,y Q x+1,y+1 When all are equal, sumQ = 1;
[0043] otherwise,
[0044] sumQ=|Q x,y -Q x-1,y-1 | δ +|Q x,y -Q x-1,y | δ +|Q x,y -Q x-1,y+1 | δ +|Q x,y -Q x,y-1 | δ +|Q x,y -Q x,y+1 | δ +|Q x,y -Q x+1,y-1 | δ +|Q x,y -Qx+1, y / δ+ / Qx, y-Qx+1, y+1 / δ.
[0045] Secondly, embodiments of this application provide a license plate recognition device, comprising: an image acquisition unit for acquiring an image to be recognized, wherein the image to be recognized contains a vehicle license plate; a license plate determination unit for determining a license plate image based on the image to be recognized; a character segmentation unit for segmenting the license plate image into characters to obtain a character image of each character; and a license plate recognition unit for recognizing the character image of each character to determine the license plate number.
[0046] Beneficial effects:
[0047] 1. By acquiring the image to be recognized, a color feature map is obtained using color feature extraction. This map is then used to initially locate the license plate region within the image, resulting in a first image. After preprocessing, a second image is obtained for edge detection, thus identifying the license plate image. Next, character segmentation is performed on the license plate image to obtain character images for each character, which are then recognized to determine the license plate number. This method allows for rapid detection of the license plate area using color features, enabling initial region delineation. Edge detection technology is then used for precise detection of the license plate image, accurately determining the license plate region. This facilitates accurate license plate localization even in harsh environmental conditions, thereby improving the accuracy of license plate recognition.
[0048] 2. The first image is converted to grayscale to obtain a grayscale image; the grayscale image is then binarized to obtain a binarized image; a pixel mapping relationship is established between the grayscale image and the binarized image to obtain a grayscale image with corresponding black and white thresholds, which is the second image. The second image is mainly used for accurate edge detection. This scheme utilizes the first gradient operator to calculate the first gradient corresponding to each pixel in the second image; based on the first gradient corresponding to each pixel, the edge region to be determined is determined; the second gradient operator is used to calculate the second gradient corresponding to each pixel in the edge region to be determined; based on the second gradient corresponding to each pixel, the edge image is determined, and the license plate image is further determined. The first gradient operator in this scheme is mainly used to determine the edge region and perform preliminary edge recognition; therefore, the Sobel operator is selected due to its high computational efficiency. The second gradient operator is designed in this scheme to address the problems of high noise and image blurring caused by severe weather such as heavy fog. In the specific calculation, it can take into account the black and white thresholds corresponding to the pixels (the second image is a grayscale image with corresponding black and white thresholds) to improve the edge detection accuracy.
[0049] 3. The second gradient operator is designed to detect the current pixel (i.e., Q). x,y The weight configuration parameter δ is determined by the pixel difference between the gray value and the black-and-white threshold. The closer the gray value is to the black-and-white threshold, the more evenly the weights a1, a2, a3, a4, a6, a7, a8, and a9 are distributed among the surrounding pixels. The greater the difference between the gray value and the black-and-white threshold, the more unevenly the weights a1, a2, a3, a4, a6, a7, a8, and a9 are distributed. The weight configuration parameter δ can refer to a relatively global gray value, and the weight allocation also takes into account a more direct factor (i.e., the difference between the gray value of the surrounding pixels and the gray value of the current pixel). As a result, the second gradient operator performs better in images with a lot of noise, relatively blurry images, and poor contrast, and can more accurately detect the edges of license plates, thereby improving the accuracy of license plate recognition.
[0050] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0051] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0052] Figure 1This is a flowchart of a license plate recognition method provided in an embodiment of this application.
[0053] Figure 2 This is a schematic diagram of the various stages of image processing in a license plate recognition method.
[0054] Figure 3 This is a structural block diagram of a license plate recognition device.
[0055] Icons: 10-License plate recognition device; 11-Image acquisition unit; 12-License plate determination unit; 13-Character segmentation unit; 14-License plate recognition unit. Detailed Implementation
[0056] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0057] Figure 1 This is a flowchart illustrating a license plate recognition method provided in an embodiment of this application. The license plate recognition method can be executed by a license plate recognition device to recognize license plates. The license plate recognition method may include steps S10, S20, S30, and S40.
[0058] In this embodiment, taking the license plate recognition of passing vehicles at a toll station at a highway entrance as an example, the set-up camera can capture the front of the vehicle (the front of the vehicle has a license plate) to obtain the image to be recognized, and then send the image to be recognized to the license plate recognition device.
[0059] The license plate recognition device can perform step S10.
[0060] Step S10: Obtain the image to be identified, wherein the image to be identified contains a vehicle license plate.
[0061] In this embodiment, the license plate recognition device can receive an image to be recognized captured at a certain moment by any camera that maintains a communication connection with it. This embodiment uses license plate recognition of a single image as an example for illustration.
[0062] After obtaining the image to be recognized, the license plate recognition device can execute step S20.
[0063] Step S20: Based on the image to be identified, determine the license plate image.
[0064] In this embodiment, the license plate recognition device can determine the license plate image based on the image to be recognized.
[0065] Please see Figure 2 , Figure 2This is a schematic diagram of the various stages of image processing in the license plate recognition method (here, the image to be recognized and the first image were originally color images, but were converted to grayscale images to meet the requirements).
[0066] First, the license plate recognition device can extract color features from the image to be recognized to obtain a color feature map.
[0067] For example, a license plate recognition device can use mature color feature extraction technologies (such as color histogram technology based on RGB, HSV, etc.) to obtain a color feature map, and then use the color feature map to initially locate the license plate area in the image to be recognized, thus determining the first image.
[0068] For example, a license plate recognition device can determine the license plate region from a color feature map, expand the license plate region in all directions (e.g., by 5% width in each direction) using the center of the license plate region as the center, and then obtain the expanded license plate region. Based on the expanded license plate region, a first image is segmented from the image to be recognized (the obtained first image is shown in the image below). Figure 2 (As shown).
[0069] Afterwards, the license plate recognition device can preprocess the first image to obtain a preprocessed second image. For example, the license plate recognition device can perform grayscale processing on the first image to determine the grayscale image, and then perform binarization processing on the grayscale image to obtain a binarized image. Then, it can establish a pixel mapping relationship between the grayscale image and the binarized image to obtain a grayscale image with a corresponding black and white threshold as the second image.
[0070] Based on this, the license plate recognition device can perform edge detection on the second image to determine the license plate image.
[0071] For example, the license plate recognition device can use a preset first gradient operator to calculate the first gradient corresponding to each pixel in the second image. Since the first gradient operator is mainly used to determine the edge region and perform preliminary edge recognition, the Sobel operator is selected because it has high computational efficiency.
[0072] The first gradient operator includes Gx and Gy. Therefore, we can use Gx to convolve each pixel of the second image I to detect the gradient change of the second image in the x-direction:
[0073]
[0074] Where Gx is the x-direction convolution kernel of the first gradient operator, and I is the second image.
[0075] For pixel I x,y The gradient value in the x-direction is calculated as follows:
[0076] Gx x,y =-1*I x-1,y-1 +0*I x-1,y +1*I x-1,y+1 -2*I x,y-1 +0*I x,y +2*I x,y+1 -1*I x+1,y-1 +0*I x+1,y +1*I x+1,y+1 (2)
[0077] Among them, Gx x,y Indicates pixel I x,y The gradient value in the x-direction, I x,y This represents the grayscale value of the x-th pixel in the y-th column of the second image I.
[0078] Furthermore, we can use Gy to convolve each pixel of the second image I to detect the gradient change of the second image in the y-direction:
[0079]
[0080] Where Gy is the y-direction convolution kernel of the first gradient operator.
[0081] For pixel I x,y The gradient value in the y-direction is calculated as follows:
[0082] Gy x,y =-1*I x-1,y-1 -2*I x-1,y -1*I x-1,y+1 +0*I x,y-1 +0*I x,y +0*I x,y+1 +1*I x+1,y-1 +2*I x+1,y +1*I x+1,y+1 (4)
[0083] Among them, Gy x,y Indicates pixel I x,y The gradient value in the y-direction, I x,y This represents the grayscale value of the x-th pixel in the y-th column of the second image I.
[0084] Then, the first gradient corresponding to each pixel in the second image is calculated using the following formula:
[0085]
[0086] Where G represents the first gradient.
[0087] That is, for pixel I x,y The corresponding first gradient value can be calculated using the following formula:
[0088]
[0089] Among them, G x,y Indicates pixel I x,y The corresponding first gradient value.
[0090] And, pixel I is calculated using the following formula x,y The corresponding first gradient direction:
[0091]
[0092] Where, θ x,y Indicates pixel I x,y The corresponding first gradient direction, where Gx x,y Non-zero, when Gx x,y When I is zero, x,y The first gradient direction is the y-direction, when Gy x,y When I is zero, x,y The first gradient direction is the x-direction.
[0093] After calculating the first gradient value and first gradient direction for each pixel in the second image, the license plate recognition device can determine the undetermined edge region based on the first gradient value and first gradient direction for each pixel.
[0094] For example, a license plate recognition device can perform non-maximum suppression on the first gradient value to preserve the detailed features of the edges. For each pixel, the device compares its first gradient value with the first gradient values of its surrounding pixels. If the first gradient value of the current pixel is the largest, the pixel is retained; otherwise, it is set to 0. Then, a dual-threshold algorithm is used to binarize the first gradient value to determine strong and weak edges in the second image: the first gradient value is divided into a high threshold and a low threshold. If the first gradient value is greater than or equal to the high threshold, it is marked as a strong edge; if the first gradient value is less than the low threshold, it is marked as a non-edge; if the first gradient value is between the high and low thresholds, it is marked as a weak edge. Then, for each weak edge pixel, it checks whether its eight surrounding pixels are strong edges. If so, the pixel is also marked as a strong edge; otherwise, it is marked as a weak edge. This yields the undetermined edge region containing both strong and weak edges.
[0095] After determining the edge region to be determined, the license plate recognition device can use a preset second gradient operator to calculate the second gradient corresponding to each pixel in the edge region to be determined.
[0096] For example, a license plate recognition device can obtain the second gradient operator Hxy:
[0097]
[0098] Where Hxy is the second gradient operator, a1, a2, a3, a4, a6, a7, a8, and a9 are the corresponding weights, and δ is the weight configuration parameter.
[0099] Here, the weight configuration parameter δ satisfies:
[0100]
[0101] Among them, Q x,y Let T be the grayscale value of the x-th pixel in the x-th row and y-th column of the undetermined edge region Q. bw The black and white threshold of the second image.
[0102] The weights a1, a2, a3, a4, a6, a7, a8, and a9 satisfy the following:
[0103]
[0104]
[0105]
[0106]
[0107]
[0108]
[0109]
[0110]
[0111] Among them, Q x-1,y-1 Q x-1,y Q x-1,y+1 Q x,y-1 Q x,y Q x,y+1 Q x+1,y-1 Q x+1,y Q x+1,y+1 When all are equal, sumQ = 1.
[0112] otherwise,
[0113] sumQ=|Q x,y -Q x-1,y-1 | δ +|Q x,y -Q x-1,y | δ +|Q x,y -Q x-1,y+1 | δ +|Q x,y-Q x,y-1 | δ +|Q x,y -Q x,y+1 | δ +|Q x,y -Q x+1,y-1 | δ +|Q x,y -Qx+1, y / δ+ / Qx, y-Qx+1, y+1 / δ, (18)
[0114] Among them, Q x,y Let sumQ represent the grayscale value of the x-th pixel in the y-th column of the undetermined edge region Q.
[0115] Based on this, the license plate recognition device can determine the corresponding second gradient operator Hxy for a single pixel.
[0116] Then, the license plate recognition device can use the second gradient operator Hxy to convolve each pixel of the target edge region Q, and detect the gradient changes of the target edge region in the x and y directions:
[0117] Hx x,y =a3*Q x-1,y+1 -a1*Q x-1,y-1 +a6*Q x,y+1 -a4*Q x,y-1 +a9*Q x+1,y+1 -a7*Q x+1,y-1 (19)
[0118] Hy x,y =a7*Q x+1,y-1 -a1*Q x-1,y-1 +a8*Q x+1,y -a2*Q x-1,y +a9*Q x+1,y+1 -a3*Q x-1,y+1 (20)
[0119] Among them, Hx x,y and Hy x,y They represent the pixel Q x,y The gradient values in the x-direction and the gradient values in the y-direction, Q x,y This represents the grayscale value of the x-th pixel in the y-th column of the undetermined edge region Q.
[0120] Then, the license plate recognition device can use the following formula to calculate the second gradient value and second gradient direction for each pixel of the edge region Q to be determined:
[0121] For pixel Q x,y The corresponding second gradient value can be calculated using the following formula:
[0122]
[0123] Among them, H x,y Represents pixel Q x,y The corresponding second gradient value.
[0124] And, pixel Q is calculated using the following formula x,y The corresponding second gradient direction:
[0125]
[0126] Where, ρ x,y Represents pixel Q x,y The corresponding second gradient direction, where Hx x,y Non-zero, when Hx x,y When Q is zero, x,y The second gradient direction is the y-direction, when Hy... x,y When Q is zero, x,y The second gradient direction is the x-direction.
[0127] Therefore, the license plate recognition device can calculate the second gradient value and second gradient direction of each pixel in the edge region to be determined, and then determine the edge image based on the second gradient value of each pixel.
[0128] Specifically, the license plate recognition device can perform non-maximum suppression on the second gradient value to preserve the detailed features of the edges. For each pixel within the edge region, the device compares its second gradient value with the second gradient values of its surrounding pixels. If the current pixel's second gradient value is the largest, it is retained; otherwise, it is set to 0. Then, a dual-threshold algorithm is used to binarize the second gradient value to determine strong and weak edges in the region to be determined: the second gradient value is divided into a high threshold and a low threshold. If the second gradient value is greater than or equal to the high threshold, it is marked as a strong edge; if the second gradient value is less than the low threshold, it is marked as a non-edge; if the gradient magnitude is between the high and low thresholds, it is marked as a weak edge. Then, for each weak edge pixel, it checks whether its eight surrounding pixels are strong edges. If so, the pixel is also marked as a strong edge; otherwise, it is marked as a non-edge. This yields an edge image containing strong edges.
[0129] Based on the determined edge image, the license plate recognition device can perform dilation, erosion, and closing operations on the strong edge regions in the edge image to connect the separated edges belonging to the license plate and eliminate the influence of non-license plate parts. Then, based on the processed license plate edges, the license plate image is segmented from the second image.
[0130] After obtaining the license plate image, the license plate recognition device can execute step S30.
[0131] Step S30: Perform character segmentation on the license plate image to obtain a character image for each character.
[0132] In this embodiment, the license plate recognition device can perform character segmentation on the license plate image to obtain a character image of each character.
[0133] Specifically, the license plate recognition device can use the second gradient operator to perform edge detection on the license plate image (detecting the edges of the characters), thereby obtaining a high-precision image of the license plate character edges (the specific processing procedure can be found in the previous section on using the second gradient operator to perform high-precision edge detection on the determined edge region, which will not be repeated here). Then, the license plate recognition device can segment each character to obtain a character image for each character.
[0134] After obtaining the character image of each character, the license plate recognition device can execute step S40.
[0135] Step S40: Recognize the character image of each character to determine the license plate number.
[0136] For character images, considering the varying tilt angles of license plates in actual images, license plate recognition devices can preprocess the character images. This includes preprocessing such as noise reduction (eliminating noise in the character image), character size adjustment (scaling the character image proportionally to adjust character size), and character shape adjustment (rotating, tilting, or filling the character image to make the characters more regular). Afterward, the characters can be recognized (for example, using a trained character recognition model) to identify the license plate number.
[0137] Please see Figure 3 Based on the same inventive concept, this application also provides a license plate recognition device 10, comprising:
[0138] Image acquisition unit 11 is used to acquire an image to be identified, wherein the image to be identified contains a vehicle license plate.
[0139] The license plate determination unit 12 is used to determine the license plate image based on the image to be identified.
[0140] The character segmentation unit 13 is used to segment the license plate image into characters to obtain a character image of each character.
[0141] The license plate recognition unit 14 is used to recognize the character image of each character and determine the license plate number.
[0142] In this embodiment, the license plate determination unit 12 is specifically used for: extracting color features from the image to be identified to obtain a color feature map; based on the color feature map, performing preliminary positioning of the license plate area in the image to be identified to determine a first image; preprocessing the first image to obtain a preprocessed second image; and performing edge detection on the second image to determine the license plate image.
[0143] In this embodiment, the license plate determination unit 12 is specifically used for: determining the license plate area from the color feature map; expanding the license plate area from all directions with the center of the license plate area as the center to obtain the expanded license plate area; and segmenting the first image from the image to be identified based on the expanded license plate area.
[0144] In this embodiment, the license plate determination unit 12 is specifically used for: performing grayscale processing on the first image to determine a grayscale image; performing binarization processing on the grayscale image to obtain a binarized image; establishing a pixel mapping relationship between the grayscale image and the binarized image to obtain a grayscale image with a corresponding black and white threshold as the second image.
[0145] In this embodiment, the license plate determination unit 12 is specifically used for: calculating the first gradient corresponding to each pixel in the second image using a preset first gradient operator; determining the undetermined edge region based on the first gradient corresponding to each pixel; calculating the second gradient corresponding to each pixel in the undetermined edge region using a preset second gradient operator; determining the edge image based on the second gradient corresponding to each pixel; and determining the license plate image based on the edge image.
[0146] In this embodiment, the first gradient operator includes Gx and Gy. The license plate determination unit 12 is specifically used to: convolve each pixel of the second image I using Gx to detect the gradient change of the second image in the x-direction.
[0147]
[0148] Where Gx is the x-direction convolution kernel of the first gradient operator;
[0149] By convolving each pixel of the second image I with Gy, the gradient change of the second image in the y-direction is detected:
[0150]
[0151] Where Gy is the y-direction convolution kernel of the first gradient operator;
[0152] The first gradient corresponding to each pixel in the second image is calculated using the following formula:
[0153]
[0154] Where G represents the first gradient.
[0155] In this embodiment, Gx and Gy are calculated as follows:
[0156] Gx x,y =-1*I x-1,y-1 +0*I x-1,y +1*I x-1,y+1 -2*I x,y-1 +0*I x,y +2*I x,y+1 -1*I x+1,y-1 +0*I x+1,y +1*I x+1,y+1 ,
[0157] Gy x,y =-1*I x-1,y-1 -2*I x-1,y -1*I x-1,y+1 +0*I x,y-1 +0*I x,y +0*I x,y+1 +1*I x+1,y-1 +2*I x+1,y +1*I x+1,y+1 ,
[0158] Among them, Gx x,y and Gy x,y They represent pixels I respectively x,y The gradient values in the x-direction and the gradient values in the y-direction, I x,y This represents the grayscale value of the x-th pixel in the y-th column of the second image I.
[0159] In this embodiment, the license plate determination unit 12 is specifically used to: obtain the second gradient operator Hxy:
[0160]
[0161] Where Hxy is the second gradient operator, a1, a2, a3, a4, a6, a7, a8, and a9 are the corresponding weights, and δ is the weight configuration parameter;
[0162] The second gradient operator Hxy is used to convolve each pixel of the edge region Q to detect the gradient changes of the edge region in the x and y directions:
[0163] Hx x,y =a3*Q x-1,y+1 -a1*Q x-1,y-1 +a6*Q x,y+1 -a4*Qx,y-1 +a9*Q x+1,y+1 -a7*Q x+1,y-1 ,
[0164] Hy x,y =a7*Q x+1,y-1 -a1*Q x-1,y-1 +a8*Q x+1,y -a2*Q x-1,y +a9*Q x+1,y+1 -a3*Q x-1,y+1 ,
[0165] Among them, Hx x,y and Hy x,y They represent the pixel Q x,y The gradient values in the x-direction and the gradient values in the y-direction, Q x,y This represents the grayscale value of the x-th pixel in the y-th column of the undetermined edge region Q.
[0166] In this embodiment, the weight configuration parameter δ satisfies:
[0167]
[0168] Among them, Q x,y Let T be the grayscale value of the x-th pixel in the x-th row and y-th column of the undetermined edge region Q. bw The black and white threshold of the second image;
[0169] The weights a1, a2, a3, a4, a6, a7, a8, and a9 satisfy the following:
[0170]
[0171]
[0172]
[0173]
[0174]
[0175]
[0176]
[0177]
[0178] in,
[0179] Q x-1,y-1 Q x-1,y Q x-1,y+1 Q x,y-1 Qx,y Q x,y+1 Q x+1,y-1 Q x+1,y Q x+1,y+1 When all are equal, sumQ = 1;
[0180] otherwise,
[0181] sumQ=|Q x,y -Q x-1,y-1 | δ +|Q x,y -Q x-1,y | δ +|Q x,y -Q x-1,y+1 | δ +|Q x,y -Q x,y-1 | δ +|Q x,y -Q x,y+1 | δ +|Q x,y -Q x+1,y-1 | δ +|Q x,y -Qx+1, y / δ+ / Qx, y-Qx+1, y+1 / δ.
[0182] In summary, the embodiments of this application provide a license plate recognition method and apparatus:
[0183] 1. By acquiring the image to be recognized, a color feature map is obtained using color feature extraction. This map is then used to initially locate the license plate region within the image, resulting in a first image. After preprocessing, a second image is obtained for edge detection, thus identifying the license plate image. Next, character segmentation is performed on the license plate image to obtain character images for each character, which are then recognized to determine the license plate number. This method allows for rapid detection of the license plate area using color features, enabling initial region delineation. Edge detection technology is then used for precise detection of the license plate image, accurately determining the license plate region. This facilitates accurate license plate localization even in harsh environmental conditions, thereby improving the accuracy of license plate recognition.
[0184] 2. The first image is converted to grayscale to obtain a grayscale image; the grayscale image is then binarized to obtain a binarized image; a pixel mapping relationship is established between the grayscale image and the binarized image to obtain a grayscale image with corresponding black and white thresholds, which is the second image. The second image is mainly used for accurate edge detection. This scheme utilizes the first gradient operator to calculate the first gradient corresponding to each pixel in the second image; based on the first gradient corresponding to each pixel, the edge region to be determined is determined; the second gradient operator is used to calculate the second gradient corresponding to each pixel in the edge region to be determined; based on the second gradient corresponding to each pixel, the edge image is determined, and the license plate image is further determined. The first gradient operator in this scheme is mainly used to determine the edge region and perform preliminary edge recognition; therefore, the Sobel operator is selected due to its high computational efficiency. The second gradient operator is designed in this scheme to address the problems of high noise and image blurring caused by severe weather such as heavy fog. In the specific calculation, it can take into account the black and white thresholds corresponding to the pixels (the second image is a grayscale image with corresponding black and white thresholds) to improve the edge detection accuracy.
[0185] 3. The second gradient operator is designed to detect the current pixel (i.e., Q). x,y The weight configuration parameter δ is determined by the pixel difference between the gray value and the black-and-white threshold. The closer the gray value is to the black-and-white threshold, the more evenly the weights a1, a2, a3, a4, a6, a7, a8, and a9 are distributed among the surrounding pixels. The greater the difference between the gray value and the black-and-white threshold, the more unevenly the weights a1, a2, a3, a4, a6, a7, a8, and a9 are distributed. The weight configuration parameter δ can refer to a relatively global gray value, and the weight allocation also takes into account a more direct factor (i.e., the difference between the gray value of the surrounding pixels and the gray value of the current pixel). As a result, the second gradient operator performs better in images with a lot of noise, relatively blurry images, and poor contrast, and can more accurately detect the edges of license plates, thereby improving the accuracy of license plate recognition.
[0186] In this document, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying any such actual relationship or order between these entities or operations.
[0187] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A license plate recognition method, characterized in that, include: Obtain an image to be identified, wherein the image to be identified contains a vehicle license plate; Based on the image to be identified, the license plate image is determined; The license plate image is segmented into characters to obtain a character image for each character; The license plate number is determined by recognizing the character image of each character. Based on the image to be identified, the license plate image is determined, including: Color features are extracted from the image to be identified to obtain a color feature map; Based on the color feature map, the license plate area in the image to be identified is initially located to determine the first image; The first image is preprocessed to obtain the preprocessed second image; Edge detection is performed on the second image to determine the license plate image; Edge detection is performed on the second image to determine the license plate image, including: Using a preset first gradient operator, calculate the first gradient corresponding to each pixel in the second image; Based on the first gradient corresponding to each pixel, the edge region to be determined is identified; Using a preset second gradient operator, the second gradient corresponding to each pixel in the edge region to be determined is calculated; The edge image is determined based on the second gradient corresponding to each pixel; The license plate image is determined based on the edge image; Using a preset second gradient operator, the second gradient corresponding to each pixel in the edge region to be determined is calculated, including: Obtaining the second gradient operator : , in, For the second gradient operator, These are the corresponding weights. Weight configuration parameters; Using the second gradient operator Convolution is performed on each pixel of the undetermined edge region Q to detect the gradient changes of the undetermined edge region in the x and y directions: , , in, and Representing pixels The gradient values in the x-direction and the gradient values in the y-direction, This represents the grayscale value of the x-th pixel in the y-th column of the undetermined edge region Q; Weight configuration parameters satisfy: , in, Let be the grayscale value of the x-th pixel in the y-th column of the undetermined edge region Q. The black and white threshold of the second image; Weight satisfy: , , , , , , , , in, , , , , , , , , When all are equal, ; otherwise, 2. The license plate recognition method according to claim 1, characterized in that, Based on the color feature map, the license plate region in the image to be identified is initially located to determine the first image, including: The license plate area is determined from the color feature map; Taking the center of the license plate area as the center, the license plate area is expanded in all directions to obtain the expanded license plate area; The first image is segmented from the image to be identified based on the expanded license plate area.
3. The license plate recognition method according to claim 1, characterized in that, The first image is preprocessed to obtain a preprocessed second image, including: The first image is converted to grayscale to determine a grayscale image; The grayscale image is binarized to obtain a binarized image; Establish a pixel mapping relationship between the grayscale image and the binarized image to obtain a grayscale image with a corresponding black and white threshold as the second image.
4. The license plate recognition method according to claim 1, characterized in that, The first gradient operator includes and Using a preset first gradient operator, the first gradient corresponding to each pixel in the second image is calculated, including: use For the second image Convolve each pixel of the second image to detect the gradient change in the y-direction: , in, The y-direction convolution kernel for the first gradient operator; The first gradient corresponding to each pixel in the second image is calculated using the following formula: , Where G represents the first gradient.
5. The license plate recognition method according to claim 4, characterized in that, and The calculation methods for each condition are as follows: , , in, and Representing pixels The gradient values in the x-direction and the gradient values in the y-direction, Represents the second image The grayscale value of the x-th pixel in the y-th column.
6. A license plate recognition device, characterized in that, include: An image acquisition unit is used to acquire an image to be identified, wherein the image to be identified contains a vehicle license plate; The license plate determination unit is used to determine the license plate image based on the image to be identified; A character segmentation unit is used to segment the license plate image into characters to obtain a character image for each character; The license plate recognition unit is used to recognize the character image of each character and determine the license plate number; The license plate determination unit is specifically used for: extracting color features from the image to be identified to obtain a color feature map; based on the color feature map, performing preliminary positioning of the license plate region in the image to be identified to determine a first image; preprocessing the first image to obtain a preprocessed second image; and performing edge detection on the second image to determine the license plate image. The license plate determination unit is specifically used for: calculating the first gradient corresponding to each pixel in the second image using a preset first gradient operator; determining the undetermined edge region based on the first gradient corresponding to each pixel; calculating the second gradient corresponding to each pixel in the undetermined edge region using a preset second gradient operator; determining the edge image based on the second gradient corresponding to each pixel; and determining the license plate image based on the edge image. The license plate determination unit is specifically used to: obtain the second gradient operator. : , in, For the second gradient operator, These are the corresponding weights. Weight configuration parameters; Using the second gradient operator Convolution is performed on each pixel of the undetermined edge region Q to detect the gradient changes of the undetermined edge region in the x and y directions: , , in, and Representing pixels The gradient values in the x-direction and the gradient values in the y-direction, This represents the grayscale value of the x-th pixel in the y-th column of the undetermined edge region Q; Weight configuration parameters satisfy: , in, Let be the grayscale value of the x-th pixel in the y-th column of the undetermined edge region Q. The black and white threshold of the second image; Weight satisfy: , , , , , , , , in, , When all are equal, ; otherwise,
Citation Information
Patent Citations
License plate recognition method and device, electronic equipment and storage medium
CN112883977A