License plate recognition method based on yov5 and HyperLPR

By combining the license plate recognition method of yolov5 and HyperLPR, it solves the problems of low license plate recognition accuracy and robustness in complex environments in the existing technology, and achieves the ability to quickly and accurately detect the license plate position and identify blocked license plates in complex environments. It is applicable For tasks such as highway violation detection.

CN118570790APending Publication Date: 2024-08-30昆山小眼探索信息科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410769664.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

Existing license plate recognition technology has low recognition accuracy when dealing with stains, diverse license plate styles, high-speed movements, and complex environments. It is especially unable to recognize incomplete or obscured license plates, and the detection process is complex and not robust.

Method used

Use yolov5 to detect the license plate position, perform attitude correction, and combine it with HyperLPR for character recognition. Add the occlusion character '@' to replace the unrecognized characters. Use the Focus structure, CSPDarknet53 and Path Aggregation Network to extract features, and use the Anchor-Free method to reduce hyperparameter dependence. , optimizing the license plate outline through Hough transform and erosion-expansion strategy.

Benefits of technology

It achieves rapid and accurate detection of license plate position and attitude correction in complex environments, can identify blocked or stained license plates, improves recognition accuracy and robustness, and is suitable for tasks such as high-speed violation detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570790A
    Figure CN118570790A
Patent Text Reader

Abstract

The invention discloses a license plate recognition method based on a yolov5 and a HyperLPR, and the method comprises the steps: S1, employing a yolov5 detection method, and obtaining the coordinate information of a license plate region in an image; s2, posture correction is carried out on the detection result in the S1, so that character intervals are obvious and easy to distinguish; and S3, performing character recognition on a result of the step S2, and returning a character recognition result. According to the method, the location of the license plate can be detected more quickly and accurately in the image in combination with the yoV5 algorithm, the location of the license plate can be detected quickly even under the condition that the angle inclination of the license plate is large, and after the location of the license plate is detected, posture correction is carried out on the detection result, so that character intervals are obvious and easy to distinguish; an'unknown character-at 'is added in a character library of a traditional HyperLPR to replace an unrecognized or shielded character, and the scheme of the invention can output the recognized character and replace the unrecognized character with the unknown character to output under the condition of limited recognizable characters, so that the relative position of the character in the license plate is kept.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of intelligent transportation and pattern recognition, and in particular to a license plate recognition method based on yolov5 and HyperLPR. Background Art

[0002] As a key component of intelligent transportation systems, license plate recognition technology is of great significance for improving traffic monitoring efficiency, realizing automated processing of violations, and promoting intelligent parking management. However, existing license plate recognition technology has low recognition accuracy or even fails to recognize vehicles with dirty and diverse license plate styles, high-speed movement, unconventional angles, and vehicles in complex environments.

[0003] Existing license plate recognition methods, such as the Chinese patent application publication number CN111461128A, the invention name is "A license plate recognition method and device", which discloses a license plate recognition method. This scheme relies on multi-scale features to detect the vehicle area from the image. Then the license plate area is detected from the vehicle area. Finally, the characters are detected from the license plate area. The process is too cumbersome and complicated, involving multiple independent detection stages. The independent design and optimization of each stage increases the complexity of the scheme, and the lack of integration between stages leads to repeated feature extraction and waste of computing resources. The robustness of the system is weakened in complex environments, and layer-by-layer detection is susceptible to error propagation, which reduces the recognition accuracy. This scheme is susceptible to multiple influences in actual road applications and is difficult to meet actual needs.

[0004] Therefore, the common problems of current license plate recognition technology are that it is slow to detect the position of the license plate and it cannot recognize certain specific angles. In addition, the HyperLPR license plate detection method can only recognize complete license plates, and no detection results will be obtained for incomplete or obscured license plates. Summary of the invention

[0005] In order to solve the above technical problems, a technical solution adopted by the present invention is: a license plate recognition method based on yolov5 and HyperLPR, comprising the following steps:

[0006] S1: Use yolov5 detection method to obtain the coordinate information of the license plate area in the image;

[0007] S2: Perform posture correction on the S1 detection result to make the character spacing clear and easy to distinguish;

[0008] S3: Perform character recognition on the result of S2 and return the character recognition result.

[0009] Furthermore, the step S1 specifically comprises the following sub-steps:

[0010] S1-1 collects image information containing vehicle license plates, and collects data for different situations, including front complete vehicle license plate images, side complete vehicle license plate images, front partially blocked vehicle license plate images, and side partially blocked vehicle license plate images;

[0011] S1-2 uses LabelImg to annotate the collected data and assign different labels according to different data types, where the front complete license plate is marked as FC, the front occlusion is marked as FO, the side complete is marked as SC, and the side occlusion is marked as SO;

[0012] After obtaining the labeled data, S1-3 uses YOLOV5 to train the data to obtain a model, which can quickly detect the position and posture of the vehicle license plate in the image.

[0013] Furthermore, the step S2 specifically comprises the following sub-steps:

[0014] After S2-1 obtains the vehicle license plate image, it cuts out the license plate area in the image;

[0015] S2-2 After obtaining the license plate area image, the area is binarized, and then the license plate contour is made clearer through the erosion and dilation strategy. After obtaining the contour information, the Hough transform is used to obtain the straight line inclination angle of the license plate edge contour in the image;

[0016] After obtaining the inclination angle of the straight line, S2-3 scales the image and then rotates the image to keep the license plate in a horizontal posture.

[0017] Furthermore, the step S3 specifically comprises the following sub-steps:

[0018] After acquiring the horizontal posture image, S3-1 uses the HyperLPR method to detect characters and obtain the index matrix of the character library. The dimension of the index matrix is ​​1*20;

[0019] After obtaining the index matrix, S3-2 counts the number of non-zero elements in the index matrix, determines whether there is occlusion, and processes the occlusion situation accordingly.

[0020] Furthermore, the step S1-3 specifically includes the following sub-steps:

[0021] S1-3-1 When training the detection model, the Focus structure is used as the benchmark network for the input data image, and the high-resolution image is divided into multiple low-resolution images to extract finer features. CSPDarknet53 is used as the Backbone network to extract image features, reduce repeated gradient learning, and improve the inference speed;

[0022] S1-3-2 uses PANet (Path Aggregation Network) as Neck. Through top-down path enhancement and bottom-up feature fusion, it retains more underlying features and realizes the fusion and utilization of multi-scale features.

[0023] S1-3-3 As vehicle license plates may be in different postures and angles, the Head part adopts the Anchor-Free method. It does not need to rely on pre-designed anchor frames, but directly learns the boundary information of the license plate area from the data, reducing dependence on hyperparameters and being able to cope with more complex scenarios.

[0024] Furthermore, the step S2-2 specifically includes the following sub-steps:

[0025] S2-2-1 performs binarization processing on the license plate area image, and the binarization threshold is the mean value of all pixel values ​​in the image;

[0026] S2-2-2 Erosion and dilation strategy, which relies on the erosion strategy to eliminate the influence of white noise generated after binarization processing, and relies on the dilation strategy to restore the boundary information eroded by the erosion strategy. After erosion and dilation, more obvious boundary information can be obtained;

[0027] S2-2-3 uses Hough transform to obtain the boundary line information and the angle between the line and the horizontal direction.

[0028] Furthermore, the step S3-1 specifically includes the following sub-steps:

[0029] S3-1-1 performs segmentation detection on the license plate area, segmenting it into 20 areas, detecting each area separately, and summarizing the detection results into a 1*20 matrix, namely the index matrix, where the elements in the matrix are 0-76;

[0030] S3-1-2 expands the character library. In the 77-character library of HyperLPR, a masking character "@" is added to represent the masked character. During character recognition, this character is used to replace the masked character, so that the number of non-zero elements in the index matrix can reach 7.

[0031] Furthermore, the step S3-2 specifically includes the following sub-steps:

[0032] S3-2-1 determines the number of non-zero elements in the index matrix. If the number is equal to 7, it is considered that there is no occlusion during detection, and the detection result is directly returned;

[0033] S3-2-2 determines the number of non-zero elements in the index matrix. If the number is less than 7, it is considered that there is occlusion during detection. When three consecutive "0" elements appear while traversing the array elements, it is considered that this place is blocked. The third "0" element is replaced with "77", which is the index value of the "@" element.

[0034] When S3-2-3 detects occlusion, it skips the fifth element when judging the number of "0" elements, because the license plate character format is "AB·C...C", where A is the abbreviation of the province, B is the region sequence of the province, and C is the character code. There is a gap between AB and C. Therefore, in order to avoid wrong judgment, the judgment of the fifth element is skipped. According to experience, the position of the fifth element in the index matrix is ​​basically between B and C.

[0035] The beneficial effects of the present invention are as follows:

[0036] 1. The present invention combines the yoloV5 algorithm to detect the position of the license plate in the image more quickly and accurately, and can also detect quickly when the license plate is tilted at a large angle.

[0037] 2. After detecting the position of the license plate, the detection result is corrected for posture so that the character spacing is clear and easy to distinguish.

[0038] 3. Added "unknown character - @" to the traditional HyperlPR character library to replace the unrecognizable or obscured characters.

[0039] 4. The original HyperLPR algorithm can only recognize and return complete license plates, but in actual operation, license plates are often stained or blocked. The solution of the present invention can output the recognized characters and replace the unrecognized characters with unknown characters when there are limited recognizable characters, thus maintaining the relative positions of the characters in the license plate. In addition, the present invention can provide strong support in high-speed violation detection or other tasks that require license plate recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 is a flow chart of the steps of the present invention;

[0041] Figure 2 is the flow chart of Section S1;

[0042] Figure 3 is the flow chart of part S2;

[0043] Figure 4 This is the flow chart of the S3 part. DETAILED DESCRIPTION

[0044] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making a clearer and more definite definition of the protection scope of the present invention.

[0045] Example 1

[0046] A license plate recognition method based on yolov5 and HyperLPR includes the following steps:

[0047] S1: Use yolov5 detection method to obtain the coordinate information of the license plate area in the image;

[0048] S2: Perform posture correction on the S1 detection result to make the character spacing clear and easy to distinguish;

[0049] S3: Perform character recognition on the result of S2 and return the character recognition result.

[0050] In this embodiment, step S1 specifically includes the following sub-steps:

[0051] S1-1 collects image information containing vehicle license plates, and collects data for different situations, including front complete vehicle license plate images, side complete vehicle license plate images, front partially blocked vehicle license plate images, and side partially blocked vehicle license plate images;

[0052] S1-2 uses LabelImg to annotate the collected data and assign different labels according to different data types, where the front complete license plate is marked as FC, the front occlusion is marked as FO, the side complete is marked as SC, and the side occlusion is marked as SO;

[0053] After obtaining the labeled data, S1-3 uses YOLOV5 to train the data to obtain a model, which can quickly detect the position and posture of the vehicle license plate in the image.

[0054] The step S2 specifically comprises the following sub-steps:

[0055] After S2-1 obtains the vehicle license plate image, it cuts out the license plate area in the image;

[0056] S2-2 After obtaining the license plate area image, the area is binarized, and then the license plate contour is made clearer through the erosion and dilation strategy. After obtaining the contour information, the Hough transform is used to obtain the straight line inclination angle of the license plate edge contour in the image;

[0057] After obtaining the inclination angle of the straight line, S2-3 scales the image and then rotates the image to keep the license plate in a horizontal posture.

[0058] The step S3 specifically comprises the following sub-steps:

[0059] After acquiring the horizontal posture image, S3-1 uses the HyperLPR method to detect characters and obtain the index matrix of the character library. The dimension of the index matrix is ​​1*20;

[0060] After obtaining the index matrix, S3-2 counts the number of non-zero elements in the index matrix, determines whether there is occlusion, and processes the occlusion situation accordingly.

[0061] Example 2

[0062] In the above embodiment, it can also be implemented by the following scheme:

[0063] Wherein step S1-3 in Example 1 specifically comprises the following sub-steps:

[0064] S1-3-1 When training the detection model, the Focus structure is used as the benchmark network for the input data image, and the high-resolution image is divided into multiple low-resolution images to extract finer features. CSPDarknet53 is used as the Backbone network to extract image features, reduce repeated gradient learning, and improve the inference speed;

[0065] S1-3-2 uses PANet (Path Aggregation Network) as Neck. Through top-down path enhancement and bottom-up feature fusion, it retains more underlying features and realizes the fusion and utilization of multi-scale features.

[0066] S1-3-3 As vehicle license plates may be in different postures and angles, the Head part adopts the Anchor-Free method. It does not need to rely on pre-designed anchor frames, but directly learns the boundary information of the license plate area from the data, reducing dependence on hyperparameters and being able to cope with more complex scenarios.

[0067] The step S2-2 in Example 1 specifically includes the following sub-steps:

[0068] S2-2-1 performs binarization processing on the license plate area image, and the binarization threshold is the mean value of all pixel values ​​in the image;

[0069] S2-2-2 Erosion and dilation strategy, which relies on the erosion strategy to eliminate the influence of white noise generated after binarization processing, and relies on the dilation strategy to restore the boundary information eroded by the erosion strategy. After erosion and dilation, more obvious boundary information can be obtained;

[0070] S2-2-3 uses Hough transform to obtain the boundary line information and the angle between the line and the horizontal direction.

[0071] The step S3-1 in Example 1 specifically includes the following sub-steps:

[0072] S3-1-1 performs segmentation detection on the license plate area, segmenting it into 20 areas, detecting each area separately, and summarizing the detection results into a 1*20 matrix, namely the index matrix, where the elements in the matrix are 0-76;

[0073] S3-1-2 expands the character library. In the 77-character library of HyperLPR, a masking character "@" is added to represent the masked character. During character recognition, this character is used to replace the masked character, so that the number of non-zero elements in the index matrix can reach 7.

[0074] The step S3-2 in Example 1 specifically includes the following sub-steps:

[0075] S3-2-1 determines the number of non-zero elements in the index matrix. If the number is equal to 7, it is considered that there is no occlusion during detection, and the detection result is directly returned;

[0076] S3-2-2 determines the number of non-zero elements in the index matrix. If the number is less than 7, it is considered that there is occlusion during detection. When three consecutive "0" elements appear while traversing the array elements, it is considered that this place is blocked. The third "0" element is replaced with "77", which is the index value of the "@" element.

[0077] When S3-2-3 detects occlusion, it skips the fifth element when judging the number of "0" elements, because the license plate character format is "AB·C...C", where A is the abbreviation of the province, B is the region sequence of the province, and C is the character code. There is a gap between AB and C. Therefore, in order to avoid wrong judgment, the judgment of the fifth element is skipped. According to experience, the position of the fifth element in the index matrix is ​​basically between B and C.

[0078] The present invention is combined with the yoloV5 algorithm, and can detect the position of the license plate in the image more quickly and accurately, even when the license plate is tilted at a large angle. After the position of the license plate is detected, the detection result is posture-corrected to make the character spacing obvious and easy to distinguish. In the traditional HyperlPR character library, "unknown characters-@" are added to replace the unrecognizable or obscured characters; the original HyperLPR algorithm can only recognize and return complete license plates, but in actual operation, license plates are often stained and obscured. The solution of the present invention can output the recognized characters in the case of limited recognizable characters, and replace the unrecognized characters with unknown characters, thereby maintaining the relative positions of the characters in the license plate.

[0079] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A license plate recognition method based on yolov5 and HyperLPR, characterized in that: The steps include: S1: Use yolov5 detection method to obtain the coordinate information of the license plate area in the image; S2: Perform posture correction on the S1 detection result to make the character spacing clear and easy to distinguish; S3: Perform character recognition on the result of S2 and return the character recognition result.

2. The license plate recognition method based on yolov5 and HyperLPR according to claim 1, characterized in that: The step S1 specifically comprises the following sub-steps: S1-1 collects image information containing vehicle license plates, and collects data for different situations, including front complete vehicle license plate images, side complete vehicle license plate images, front partially blocked vehicle license plate images, and side partially blocked vehicle license plate images; S1-2 uses LabelImg to annotate the collected data and assign different labels according to different data types, where the front complete license plate is marked as FC, the front occlusion is marked as FO, the side complete is marked as SC, and the side occlusion is marked as SO; After obtaining the labeled data, S1-3 uses YOLOV5 to train the data to obtain a model, which can quickly detect the position and posture of the vehicle license plate in the image.

3. The license plate recognition method based on yolov5 and HyperLPR according to claim 1, characterized in that: The step S2 specifically comprises the following sub-steps: After S2-1 obtains the vehicle license plate image, it cuts out the license plate area in the image; S2-2 After obtaining the license plate area image, the area is binarized, and then the license plate contour is made clearer through the erosion and dilation strategy. After obtaining the contour information, the Hough transform is used to obtain the straight line inclination angle of the license plate edge contour in the image; After obtaining the inclination angle of the straight line, S2-3 scales the image and then rotates the image to keep the license plate in a horizontal posture.

4. The license plate recognition method based on yolov5 and HyperLPR according to claim 1, characterized in that: The step S3 specifically comprises the following sub-steps: After acquiring the horizontal posture image, S3-1 uses the HyperLPR method to detect characters and obtain the index matrix of the character library. The dimension of the index matrix is ​​1*20; After obtaining the index matrix, S3-2 counts the number of non-zero elements in the index matrix, determines whether there is occlusion, and processes the occlusion situation accordingly.

5. The license plate recognition method based on yolov5 and HyperLPR according to claim 2 is characterized in that: The step S1-3 specifically comprises the following sub-steps: S1-3-1 When training the detection model, the Focus structure is used as the benchmark network for the input data image, and the high-resolution image is divided into multiple low-resolution images to extract finer features. CSPDarknet53 is used as the Backbone network to extract image features, reduce repeated gradient learning, and improve the inference speed; S1-3-2 uses PANet (Path Aggregation Network) as Neck. Through top-down path enhancement and bottom-up feature fusion, it retains more underlying features and realizes the fusion and utilization of multi-scale features. S1-3-3 As vehicle license plates may be in different postures and angles, the Head part adopts the Anchor-Free method. It does not need to rely on pre-designed anchor frames, but directly learns the boundary information of the license plate area from the data, reducing dependence on hyperparameters and being able to cope with more complex scenarios.

6. The license plate recognition method based on yolov5 and HyperLPR according to claim 3 is characterized in that: The step S2-2 specifically comprises the following sub-steps: S2-2-1 performs binarization processing on the license plate area image, and the binarization threshold is the mean value of all pixel values ​​in the image; S2-2-2 Erosion and dilation strategy, which relies on the erosion strategy to eliminate the influence of white noise generated after binarization processing, and relies on the dilation strategy to restore the boundary information eroded by the erosion strategy. After erosion and dilation, more obvious boundary information can be obtained; S2-2-3 uses Hough transform to obtain the boundary line information and the angle between the line and the horizontal direction.

7. The license plate recognition method based on yolov5 and HyperLPR according to claim 4 is characterized in that: The step S3-1 specifically includes the following sub-steps: S3-1-1 performs segmentation detection on the license plate area, segmenting it into 20 areas, detecting each area separately, and summarizing the detection results into a 1*20 matrix, namely the index matrix, where the elements in the matrix are 0-76; S3-1-2 expands the character library. In the 77 character library of HyperLPR, a masking character "@" is added to represent the masked character. During character recognition, this character is used to replace the masked character, so that the number of non-zero elements in the index matrix can reach 7.

8. The license plate recognition method based on yolov5 and HyperLPR according to claim 4 is characterized in that: The step S3-2 specifically includes the following sub-steps: S3-2-1 determines the number of non-zero elements in the index matrix. If the number is equal to 7, it is considered that there is no occlusion during detection, and the detection result is directly returned; S3-2-2 determines the number of non-zero elements in the index matrix. If the number is less than 7, it is considered that there is occlusion during detection. When three consecutive "0" elements appear while traversing the array elements, it is considered that this place is occluded. The third "0" element is replaced with "77", which is the index value of the "@" element. When S3-2-3 detects occlusion, it skips the fifth element when judging the number of "0" elements, because the license plate character format is "AB·C...C", where A is the abbreviation of the province, B is the region sequence of the province, and C is the character code. There is a gap between AB and C. Therefore, in order to avoid wrong judgment, the judgment of the fifth element is skipped. According to experience, the position of the fifth element in the index matrix is ​​basically between B and C.