A method, system and device for filtering two-dimensional codes
By performing gradient feature screening, positioning graphic feature screening and position detection graphic screening on the QR code candidate code area, the problem of too many candidate code areas being too long has been solved, and more efficient QR code recognition is achieved.
Patent Information
- Application Number
- CN202211476497.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-23
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2042-11-23
AI Technical Summary
During the QR code detection process, too many candidate code areas lead to too long QR code recognition time, affecting production efficiency.
Through gradient feature filtering, positioning graph feature filtering and position detection graph filtering, the candidate code areas in the QR code area are filtered out, and the final candidate code area is selected for identification.
It effectively reduces the number of candidate code areas, shortens the recognition time, and improves the efficiency of QR code recognition.
Smart Images

Figure CN115719076B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of two-dimensional codes, and particularly to a method, system, and device for filtering two-dimensional codes. Background Art
[0002] During the detection of two-dimensional codes, the code area of the two-dimensional code may be blurred due to objective reasons. In order to successfully identify the two-dimensional code when the code area is blurred, one can start from improving the robustness of the algorithm and set multiple candidate code areas on the two-dimensional code area for scanning.
[0003] When the number of candidate code areas is relatively large, when the scanning device scans the two-dimensional code, it needs to identify multiple candidate code areas, resulting in too long an identification time and affecting production efficiency. Summary of the Invention
[0004] This application provides a method, system, and device for filtering two-dimensional codes to solve the problem that the excessive number of candidate code areas leads to too long a two-dimensional code identification time and affects production efficiency.
[0005] In a first aspect, this application provides a method for filtering two-dimensional codes, including:
[0006] Scanning a target two-dimensional code to obtain candidate code areas of the target two-dimensional code;
[0007] According to the characteristics of the candidate code areas, performing feature screening on the candidate code areas to filter out interference code areas in the candidate code areas; the feature screening includes gradient feature screening, positioning pattern feature screening, and position detection pattern screening;
[0008] According to the results of the feature screening, selecting the position detection patterns to form final candidate code areas.
[0009] Further, the step of performing gradient feature screening on the candidate code areas includes:
[0010] Extracting pixel points in the candidate code areas;
[0011] Calculating the gradient directions of the pixel points and statistically analyzing the gradient directions to obtain several gradient main directions;
[0012] Judging whether the several gradient main directions are orthogonal. If the several gradient main directions are not orthogonal, determining that the code area is an interference code area.
[0013] Further, the step of performing positioning pattern feature screening on the candidate code areas includes:
[0014] According to the positioning pattern design rules, screening out positioning pattern areas in the candidate code areas;
[0015] Perform interference detection on the positioning graphic area to obtain detection features; the detection features include the number of edge points of the positioning graphic area and the distance between adjacent edge points of the positioning graphic area;
[0016] Determine whether the detection features meet the standards. If the detection features do not meet the standards, determine that the candidate code area is an interference code area.
[0017] Further, the step of determining whether the detection features meet the standards and determining that the candidate code area is an interference code area if the detection features do not meet the standards includes:
[0018] Obtain the number of edge points of the positioning graphic area and the distance between any two edge points;
[0019] If the number of edge points is less than the edge point threshold;
[0020] And / or, if the distance between any two edge points is greater than the first edge point distance threshold, determine that the candidate code area is an interference code area.
[0021] Further, the step of determining whether the detection features meet the standards and determining that the candidate code area is an interference code area if the detection features do not meet the standards further includes:
[0022] If the number of edge points is greater than the edge point threshold, obtain the distance between the adjacent edge points;
[0023] When the distance between the adjacent edge points is greater than the second edge point distance threshold, save the adjacent edge points as pixel segments; the pixel segments include black pixel segments and white pixel segments;
[0024] If the variance and / or standard deviation of the pixel segments meet the standards, determine that the candidate code area is a non-interference code area.
[0025] Further, the step of performing position detection graphic feature screening on the candidate code area includes:
[0026] According to the design rules of the position detection graphic, screen out the position detection graphic in the candidate code area; the position detection graphic includes a first center point; the first center point is the central symmetry point of the position detection graphic;
[0027] Generate a second center point according to the first center point;
[0028] If the first center point and / or the second center point do not meet the standards, determine that the candidate code area is an interference code area.
[0029] Further, the step of generating a second center point according to the first center point includes:
[0030] Generate a first affine rectangle based on the first center point;
[0031] Generate a second affine rectangle and a second center point based on the first affine rectangle.
[0032] Furthermore, if the first center point and / or the second center point do not meet the standards, the steps for determining that the candidate code area is an interference code area include:
[0033] Respectively determine the validity of the first center point and the second center point, and respectively record the number of invalid center points for the first center point and the second center point;
[0034] Sum the number of invalid points of the first center point and the number of invalid points of the second center point to obtain the final number of invalid points;
[0035] If the final number of invalid points is greater than the threshold, determine that the candidate code area is an interference area.
[0036] In a second aspect, the present application provides a two-dimensional code filtering system, including: an image acquisition module, an image processing module, and a control module;
[0037] The image acquisition module is used to scan a target two-dimensional code to obtain a candidate code area of the target two-dimensional code;
[0038] The image processing module is used to perform feature screening on the candidate code area according to the characteristics of the candidate code area to filter out the interference code areas in the candidate code area; the feature screening includes gradient feature screening, positioning pattern feature screening, and position detection pattern screening;
[0039] The control module is used to select the position detection patterns to form a final candidate code area according to the results of the feature screening.
[0040] In a third aspect, the present application provides a two-dimensional code filtering device, including:
[0041] An image acquisition device;
[0042] A controller, configured to:
[0043] Control the image acquisition device to scan a target two-dimensional code to obtain a candidate code area of the target two-dimensional code;
[0044] Perform feature screening on the candidate code area according to the characteristics of the candidate code area to filter out the interference code areas in the candidate code area; the feature screening includes gradient feature screening, positioning pattern feature screening, and position detection pattern screening;
[0045] Select the position detection patterns to form a final candidate code area according to the results of the feature screening.
[0046] As can be seen from the above technology, the present application provides a QR code filtering method, system and device. During the process of identifying a QR code, redundant candidate code areas in the two-dimensional code area are filtered through gradient feature screening, positioning graphic feature screening, and position detection graphic screening. Gradient feature screening is performed on candidate code areas with strong contrast, rich edges, and orthogonal characteristics of the main edge gradient direction to filter out candidate code areas that are not easily recognizable due to damage or distortion. Positioning graphic feature screening is performed according to the positioning rules during the design of the QR code to filter out candidate code areas with deviations in the positioning graphics caused by blurring. Position detection graphic screening is used to screen out the position detection graphics that make up the final candidate code area. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions of the present application, the following will briefly introduce the drawings required in the embodiments. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0048] Figure 1 Schematic diagram of the steps of the QR code filtering method provided by the embodiment of the present application;
[0049] Figure 2 Schematic diagram of the actual application of the QR code filtering provided by the embodiment of the present application;
[0050] Figure 3 Schematic diagram of the steps of screening candidate code areas according to gradient features provided by the embodiment of the present application;
[0051] Figure 4 Schematic diagram of the steps of screening candidate code areas according to positioning graphic features provided by the embodiment of the present application;
[0052] Figure 5 Schematic diagram of the steps of screening candidate code areas according to the edge point features of the positioning graphics provided by the embodiment of the present application;
[0053] Figure 6 Schematic diagram of placing a caliper to detect the edge points of the positioning graphics provided by the embodiment of the present application;
[0054] Figure 7 Schematic diagram of the position detection graphics provided by the embodiment of the present application;
[0055] Figure 8 Schematic diagram of the distribution of position center points provided by the embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0056] Embodiments will be described in detail below, and examples thereof are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following examples do not represent all embodiments consistent with the present application. They are merely examples of systems and methods consistent with some aspects of the present application detailed in the claims.
[0057] In the applications of QR codes in life and production, there may be some situations where the QR codes are damaged or partially unclear. In order to complete the recognition even in abnormal situations of QR codes, we can start from improving the robustness of the QR code recognition algorithm. That is, when designing a QR code, multiple candidate code areas are set within the QR code area for scanning. When the scanning device scans, it can scan multiple candidate code areas to obtain valid candidate code areas. However, in actual applications, due to the setting of multiple candidate code areas, when the scanning device recognizes the QR code, it needs to process multiple candidate code areas, and the simultaneous recognition of multiple candidate code areas takes too long, affecting the user experience and production efficiency. Therefore, it is necessary to filter out redundant candidate code areas when scanning the QR code to improve the recognition efficiency.
[0058] In view of the above problems, as Figure 1 shown, the present application provides a QR code filtering method,
[0059] S101: Scan the target QR code to obtain the candidate code areas of the target QR code.
[0060] The target QR code can be scanned through a QR code scanning device, and the candidate code areas of the target QR code can be obtained during the scanning. The QR code scanning device can be an industrial camera used to obtain product information on the factory production line, a handheld scanning device used in a courier station, or a mobile terminal device similar to a smart phone.
[0061] In some embodiments, when a user scans a merchant payment QR code, the user aims the mobile phone camera at the payment QR code. After the valid candidate code areas in the payment QR code are completely obtained through the camera, it is prompted that the scanning is completed and the information related to the payment QR code is displayed. The user can complete the payment according to the displayed content.
[0062] When the complete code area image of the payment QR code is obtained by the camera, the controller parses the valid candidate code areas and further parses the relevant information corresponding to the payment QR code based on the valid candidate code areas, and then displays it on the display device. In another case, due to the existence of candidate code areas, it is not necessarily required that the complete code area image of the payment QR code be completely obtained by the camera. The controller can screen out the valid candidate code areas and identify the relevant information when parsing the code area image obtained by the camera.
[0063] It can be seen that when scanning the target QR code, it is only necessary to ensure that the controller can parse the candidate code area detected by the camera, that is, the candidate code area detected by the camera is a valid code area, and the relevant information of the target QR code can be obtained. However, in actual applications, in order to ensure that the QR code can be recognized, the complete target QR code image is still obtained through the camera, and the controller completes further parsing. Therefore, the controller processes multiple candidate code areas simultaneously, consuming a lot of time. In order to save time, it is necessary to filter the candidate code areas in a timely manner.
[0064] S102: According to the characteristics of the candidate code area, perform feature screening on the candidate code area to filter out the interference code areas in the candidate code area.
[0065] The feature screening includes gradient feature screening, positioning pattern screening, and position detection pattern screening.
[0066] The QR code forms a specific geometric pattern through the distribution of black and white pixels and is displayed on the plane according to a certain rule. It can store information such as Chinese characters, data, and pictures. Therefore, the code area of the QR code has the characteristics of strong contrast, rich edges, and the main direction of the edge gradient being orthogonal. According to this characteristic, the gradient feature screening method can be used first to perform a preliminary screening on the candidate code area.
[0067] Gradient screening can screen out significantly abnormal candidate code areas. However, multiple candidate code areas are set to avoid the inability to recognize due to abnormal QR code display. Therefore, in most cases, the abnormal candidate code areas that can be screened by gradient screening are in the minority, and further screening of the candidate code areas is still required.
[0068] There are usually also positioning patterns in the QR code. One type is the positioning pattern in the horizontal direction, and the other type is the positioning pattern in the vertical direction. The positioning pattern is composed of pixel points where black and white pixels alternate with each other. The design of the positioning pattern involves the size of the position detection pattern that makes up the final candidate code area and can affect key factors such as the length and width of the position detection pattern. Therefore, compared with gradient screening, the filtering degree of positioning pattern feature screening is higher. The positioning pattern can judge the validity of the candidate code area from aspects such as its constituent edge points and the distance between edge points.
[0069] The position detection pattern is used to form the final candidate code area. Therefore, the candidate code areas that have undergone gradient feature screening and positioning pattern feature screening still need to detect the position detection pattern. On the basis that the position detection pattern is valid, the final candidate code area formed is valid.
[0070] The position detection patterns form the final candidate code area. In the international standard, the aspect ratio of the length to the width of the candidate code area is specified as 1:1. Therefore, the aspect ratio of the length to the width of the candidate code area can be calculated first to preliminarily determine whether the candidate code area meets the international standard. After meeting the international standard, it can be further determined whether the position detection patterns are valid. Specifically, it can be determined by judging the black-and-white pixel area ratio of the position detection patterns.
[0071] S103: According to the result of the feature screening, select the position detection patterns to form the final candidate code area.
[0072] After the validity of the position detection patterns is judged, it can be confirmed that the final candidate code area is composed of the position patterns that pass the validity judgment, and the controller analyzes the final candidate code area to obtain the relevant information of the target two-dimensional code.
[0073] As Figure 2 shown, in some embodiments, when the washing machine fails, the user scans the two-dimensional code printed on the washing machine to obtain repair information and fault solutions. The user obtains the complete two-dimensional code through the mobile phone camera, and the mobile phone controller obtains the complete two-dimensional code image transmitted by the camera, and obtains the final candidate code area through gradient screening - positioning pattern feature screening - position detection pattern screening, and analyzes the fault solution according to the final candidate code area and presents it to the user through the mobile phone display screen.
[0074] Conventional controllers analyze multiple candidate code areas when analyzing a complete two-dimensional code image. After the analysis, it is also necessary to perform accuracy judgment, matching degree comparison and other links on the analysis results corresponding to multiple candidate code areas to obtain the optimal candidate code area analysis result. However, the content provided in the above embodiments first screens the candidate code areas to improve the quality of the candidate code areas, and then analyzes the results, eliminating the process of analyzing multiple candidate code areas and comparing the analysis results, thereby improving the two-dimensional code recognition efficiency.
[0075] In the above embodiments, as Figure 3 shown, the steps of gradient feature screening include:
[0076] Extract the pixel points in the candidate code area.
[0077] The candidate code area is composed of a number of black-and-white pixel points, and the pixel composition of the final candidate code area must be distributed according to a preset rule. By setting the black-and-white pixel distribution, the black-and-white pixel segments can be set accordingly. Therefore, the direction of the gradient of each pixel can be used to screen whether the black-and-white pixel points are set according to the preset rule. Therefore, it is necessary to first extract all the pixel points in the candidate code area and perform subsequent calculations.
[0078] Calculate the gradient direction of the pixel points and count the gradient directions to obtain a number of gradient main directions.
[0079] Determine whether the several gradient principal directions are orthogonal. If the several gradient principal directions are not orthogonal, determine that the code area is an interference code area.
[0080] The gradient direction is closely related to the distribution of black and white pixels and can reflect the distribution of black and white pixels in a specific direction. Therefore, by statistically analyzing two gradient principal directions in the candidate code area and then determining whether the principal directions are orthogonal, it is possible to effectively determine whether the black and white pixels in the candidate code area are distributed according to a preset rule. When the two gradient principal directions meet the condition of approximate orthogonality, the candidate code area is determined to be a valid candidate code area; when they do not meet the condition of approximate orthogonality, the candidate code area is determined to be an interference code area.
[0081] Such as Figure 4 and Figure 5 shown, after performing gradient feature screening on the candidate code area, it is also necessary to perform positioning pattern feature screening on the candidate code area, and the steps include:
[0082] According to the positioning pattern design rules, screen out the positioning pattern area in the candidate code area;
[0083] Perform interference detection on the positioning pattern area to obtain detection features; the detection features include the number of edge points in the positioning pattern area and the distance between adjacent edge points in the positioning pattern area;
[0084] Determine whether the detection features meet the standards. If the detection features do not meet the standards, determine that the candidate code area is an interference code area.
[0085] The positioning pattern area plays a certain role in limiting the overall area of the two-dimensional code, and also has a certain limiting effect on the length, width, and area of the position detection pattern. Therefore, there is an intersection part between the positioning pattern and the position detection pattern, and the intersection part is the edge part of the positioning pattern. The edge part is composed of several edge points. Therefore, the intersection module of the positioning pattern and the position pattern is the starting and ending positions of the positioning pattern. In addition, since the positioning pattern is composed of equally spaced black and white modules, performing interference detection on the positioning pattern, the obtained detection features are the features of the edge points.
[0086] The number of edge points will change according to the two-dimensional code design rules. Therefore, different determination methods are also required for different numbers of edge points. There is usually a threshold for the number of edge points. In the case where the number of edge points is less than the edge point threshold, determine whether the detection features meet the standards. If the detection features do not meet the standards, the steps for determining that the candidate code area is an interference code area include:
[0087] Obtain the number of edge points in the positioning pattern area and the distance between any two edge points;
[0088] If the number of the edge points is less than the edge point threshold;
[0089] and / or, the distance between any two edge points is greater than the first edge point distance threshold, then it is determined that the candidate code area is an interference code area.
[0090] Such as Figure 6 As shown, in some embodiments, the controller places a caliper in the positioning graphic area of the candidate code area to detect edge points, for detecting the number of edge points and the distance between edge points. After obtaining the number of edge points by detecting the edge points, the controller detects that the number of edge points is lower than the edge point threshold, and determines that the current candidate code area is a case where the number of edge points is small. And further select a second edge point threshold to judge the number of edge points. If it is detected that the edge points of the current candidate code area are still less than the second edge point threshold, then it is determined that the current candidate code area is an interference area.
[0091] In some other embodiments, the controller detects that the number of edge points is greater than the second edge point threshold, so the length between the edge points is further judged. After obtaining the length between any two edge points, if it is detected that the lengths of any two edge points all meet the standards, then it is determined that the current candidate code area is valid. And further perform the position detection graphic screening.
[0092] In a situation similar to the above embodiments, the number of edge points may also be greater than the edge point threshold. In the case where the number of edge points is greater than the edge point threshold, it is judged whether the detection feature meets the standards. If the detection feature does not meet the standards, the steps for determining that the candidate code area is an interference code area include:
[0093] If the number of the edge points is greater than the edge point threshold, then obtain the distance between the adjacent edge points;
[0094] When the distance between the adjacent edge points is greater than the second edge point distance threshold, save the adjacent edge points as pixel segments; the pixel segments include black pixel segments and white pixel segments;
[0095] If the variance and / or standard deviation of the pixel segments meet the standards, then it is determined that the candidate code area is a non-interference code area.
[0096] When the number of edge points is greater than the edge point threshold, there are some differences in the distance determination conditions between edge points and the above embodiments. It is necessary to calculate the distance between adjacent edge points one by one instead of judging the distance between any two edge points. A threshold can also be set for the distance length between adjacent edge points to facilitate comparison and judgment by the controller. In the embodiments of the present application, the distance length threshold between adjacent edge points is set to 1 / 2 of the size of one pixel point module. When the distance length between adjacent edge points is greater than the length threshold, the controller determines that the pixel segment where it is located is a valid pixel segment. After determining the black and white pixel segments, statistics need to be saved. Calculate the variance and standard deviation of the pixel segment to optimize the candidate code area.
[0097] On the basis of obtaining the number of edge points, the positioning pattern can also be feature-screened by calculating the number of pixel point modules. The mean value obtained by dividing the length of the positioning pattern by the length of the pixel point module should be the theoretical value of the number of pixel point modules. When the theoretical value and the actual value differ greatly, it is considered that the positioning pattern is invalid, and the corresponding candidate code area is also an interference area.
[0098] The final candidate code area is composed of the position detection pattern. Therefore, finally, it is necessary to make an effective judgment on the position detection pattern. The final candidate code area needs to be composed of valid position detection patterns to be more conducive to the analysis of the controller, and the accuracy and matching degree between the relevant information obtained from the final candidate code area and the true information are the highest. The steps for feature-screening the position detection pattern of the candidate code area include:
[0099] According to the design rules of the position detection pattern, screen out the position detection pattern in the candidate code area; the position detection pattern includes a first center point; the first center point is the central symmetry point of the position detection pattern;
[0100] Generate a second center point according to the first center point;
[0101] If the first center point and / or the second center point does not meet the standard, it is determined that the candidate code area is an interference code area.
[0102] The first center point is the central symmetry point in the position detection pattern, and the second center point is the central symmetry point of the affine rectangle generated according to the affine rectangle corresponding to the position detection pattern. The steps for generating the second center point according to the first center point include:
[0103] Generate a first affine rectangle according to the first center point;
[0104] Generate a second affine rectangle and a second center point according to the first affine rectangle.
[0105] A coordinate system can be established based on the position detection patterns at each position. Therefore, the affine rectangle corresponding to the position detection pattern can be calculated through the coordinates of the first center point and the size of the pixel point module. As Figure 7 shown, the length ratio of the position detection pattern area in the QR code is 1:1:3:1:1. Therefore, the black and white pixel area ratio is 33:16 or 16:33. When calculating the first affine rectangle based on the coordinates, only 7 times the module size needs to be used as the length of the position detection pattern to calculate the length of the second affine rectangle.
[0106] As Figure 8 shown, the length and width of the second affine rectangle can also be restricted by the 3 first affine rectangles corresponding to the 3 position detection patterns, and then the second affine rectangle and the second center point can be calculated. Therefore, the first affine rectangle can be understood as a rectangle generated based on the position detection pattern, and the second affine rectangle is generated through the length and width of the first affine rectangle. That is, the second affine rectangle can be approximately understood as also corresponding to a position detection pattern, and its central symmetry point is the second center point.
[0107] Since the first center point and the second center point can be understood as corresponding to their respective position detection patterns, the validity judgment of the position detection pattern can represent the valid judgment results of the first center point and the second center point. The steps of screening the candidate code area according to the judgment results of the first center point and the second center point include:
[0108] Respectively judge the validity of the first center point and the second center point, and respectively record the number of invalid center points of the first center point and the second center point;
[0109] Sum the invalid number of the first center point and the invalid number of the second center point to obtain the final invalid number;
[0110] If the final invalid number is greater than the threshold, it is determined that the candidate code area is an interference area.
[0111] After establishing the coordinate system with the position detection pattern and the first center point, the coordinates of the second center point can be confirmed by the 3 center points in the 3 position detection patterns. Judging whether the first center point and the second center point are valid, that is, judging whether the position detection patterns corresponding to the first center point and the second center point are valid, which can be achieved through their black and white pixel area ratio.
[0112] In some embodiments, the QR code is mainly black. According to the design ratio of the position detection pattern, the number of black and white pixel modules should be 33:16, and the theoretical area ratio is 2.06. In actual detection, the threshold range can be set according to the theoretical area ratio. Therefore, when the controller detects the black and white area ratio of each position detection pattern, if the area ratio meets the threshold range, it is determined that the position detection pattern is valid, that is, the first center point is valid.
[0113] The method for determining whether the second center point is valid is also to judge the validity of the position detection pattern according to the pixel area. In this embodiment, if the proportion of the black pixel area in the position detection pattern where the second center point is located exceeds 0.85 or is less than 0.15 of the entire affine rectangle, it is determined that the position detection pattern is invalid, and the corresponding second center point is also invalid.
[0114] When judging the pixel area, not only should we consider whether a single position detection pattern is valid, but since the final candidate code area needs to be composed of 3 position detection patterns, we also need to consider whether the position detection patterns are valid as a whole. That is, it is also necessary to compare the black and white pixel area ratios of the 3 position detection patterns. If the area ratios of each of them vary greatly, it is determined that the candidate code area is an interference area and is filtered out.
[0115] In addition, combining the design rules of the position detection pattern and the pixel distribution in the central area of each position detection pattern can also judge the validity of the position detection pattern. In some embodiments, when the module size in the central area of the position detection pattern is greater than 8 pixel modules, if the white pixel area is less than 0.7, it is determined that the first center point corresponding to the position detection pattern is invalid. In other embodiments, when the module size in the central area of the position detection pattern is less than 8 pixel modules, if the proportion of the white pixel area is less than 0.6, it is determined that the first center point corresponding to the position detection pattern is invalid.
[0116] By the methods for judging the validity of the first center point and the second center point described in the above embodiments, the number of invalid first center points and second center points in the current candidate code area can be obtained. In the embodiments of the present application, when the number of invalid first center points and second center points exceeds 2, it is determined that the current candidate code area is invalid and filtering processing is performed.
[0117] The present application also provides a QR code filtering system, including: an image acquisition module, an image processing module, and a control module;
[0118] The image acquisition module is used to scan the target QR code to obtain the candidate code area of the target QR code;
[0119] The image processing module is used to perform feature screening on the candidate code areas according to the features of the candidate code areas, so as to filter out the interfering code areas in the candidate code areas; the feature screening includes gradient feature screening, positioning pattern feature screening, and position detection pattern screening;
[0120] The control module is used to select the position detection patterns to form the final candidate code areas according to the results of the feature screening.
[0121] This application also provides a two-dimensional code filtering device, including: an image acquisition device and a controller;
[0122] Wherein, the controller is configured to:
[0123] Control the image acquisition device to scan the target two-dimensional code to obtain the candidate code areas of the target two-dimensional code;
[0124] Perform feature screening on the candidate code areas according to the features of the candidate code areas, so as to filter out the interfering code areas in the candidate code areas; the feature screening includes gradient feature screening, positioning pattern feature screening, and position detection pattern screening;
[0125] Select the position detection patterns to form the final candidate code areas according to the results of the feature screening.
[0126] As can be seen from the above technology, this application provides a two-dimensional code filtering method, system and device. During the process of identifying a two-dimensional code, the redundant candidate code areas in the two-dimensional code area are filtered out through gradient feature screening, positioning pattern feature screening, and position detection pattern screening. The gradient feature screening is performed on the candidate code areas with strong contrast, rich edges and orthogonal characteristics of the main edge gradient direction, so as to filter out the candidate code areas that are not easily recognized due to damage or distortion. The positioning pattern feature screening is performed according to the positioning rules during the design of the two-dimensional code, so as to filter out the candidate code areas with deviation of the positioning pattern caused by blurring. The position detection pattern screening is used to screen out the position detection patterns that make up the final candidate code areas.
[0127] For the similar parts between the embodiments provided in this application, reference can be made to each other. The specific implementation manners provided above are only several examples under the general concept of this application, and do not constitute a limitation on the protection scope of this application. For those skilled in the art, any other implementation manners extended based on the solution of this application without creative efforts belong to the protection scope of this application.
Claims
1. A method for filtering two-dimensional codes, characterized in that, it includes: Scanning the target two-dimensional code to obtain the candidate code area of the target two-dimensional code; According to the characteristics of the candidate code area, performing feature screening on the candidate code area to filter out the interference code area in the candidate code area; The feature screening includes gradient feature screening, positioning pattern feature screening, and position detection pattern screening; According to the result of the feature screening, selecting the position detection patterns to form the final candidate code area; The step of performing gradient feature screening on the candidate code area includes: Extracting the pixel points in the candidate code area; Calculating the gradient direction of the pixel points and statistically analyzing the gradient direction to obtain several main gradient directions; Judging whether the several main gradient directions are orthogonal. If the several main gradient directions are not orthogonal, determining that the code area is an interference code area; The step of performing positioning pattern feature screening on the candidate code area includes: According to the positioning pattern design rules, screening out the positioning pattern area in the candidate code area; Performing interference detection on the positioning pattern area to obtain detection features; the detection features include the number of edge points in the positioning pattern area and the distance between adjacent edge points in the positioning pattern area; Judging whether the detection features meet the standards. If the detection features do not meet the standards, determining that the candidate code area is an interference code area; The step of performing position detection pattern feature screening on the candidate code area includes: According to the design rules of the position detection pattern, screening out the position detection pattern in the candidate code area; the position detection pattern includes a first center point; the first center point is the central symmetry point of the position detection pattern; Generating a second center point according to the first center point; If the first center point, and / or, the second center point does not meet the standards, determining that the candidate code area is an interference code area.
2. The method according to claim 1, characterized in that, The step of judging whether the detection features meet the standards. If the detection features do not meet the standards, determining that the candidate code area is an interference code area includes: Obtaining the number of edge points in the positioning pattern area and the distance between any two edge points; If the number of edge points is less than the edge point threshold; and / or, if the distance between any two edge points is greater than the first edge point distance threshold, determining that the candidate code area is an interference code area.
3. The method according to claim 2, characterized in that, The step of judging whether the detection features meet the standards. If the detection features do not meet the standards, determining that the candidate code area is an interference code area further includes: If the number of edge points is greater than the edge point threshold, obtaining the distance between adjacent edge points; When the distance between adjacent edge points is greater than the second edge point distance threshold, saving the adjacent edge points as pixel segments; the pixel segments include black pixel segments and white pixel segments; If the variance, and / or, standard deviation of the pixel segments meet the standards, determining that the candidate code area is a non-interference code area.
4. The method according to claim 1, characterized in that, The step of generating a second center point according to the first center point includes: Generating a first affine rectangle according to the first center point; Generate a second affine rectangle and a second center point according to the first affine rectangle.
5. The method according to claim 1, wherein, if the first center point and / or the second center point do not meet the standard, the steps of determining that the candidate code area is an interference code area include: respectively determine the validity of the first center point and the second center point, and respectively record the number of invalid center points of the first center point and the second center point; sum the invalid number of the first center point and the invalid number of the second center point to obtain a final invalid number; if the final invalid number is greater than the threshold, determine that the candidate code area is an interference area.
6. A two-dimensional code filtering system, wherein, comprising: an image acquisition module, an image processing module and a control module; the image acquisition module is used to scan a target two-dimensional code to obtain a candidate code area of the target two-dimensional code; the image processing module is used to perform feature screening on the candidate code area according to the characteristics of the candidate code area to filter out the interference code area in the candidate code area; the feature screening includes gradient feature screening, positioning pattern feature screening and position detection pattern screening; the control module is used to select the position detection patterns to form a final candidate code area according to the result of the feature screening; the image processing module is further used for: extracting pixel points in the candidate code area; calculating the gradient direction of the pixel points and statistically analyzing the gradient direction to obtain a plurality of gradient main directions; judging whether the plurality of gradient main directions are orthogonal, and if the plurality of gradient main directions are not orthogonal, determining that the code area is an interference code area; screening out a positioning pattern area in the candidate code area according to the positioning pattern design rule; performing interference detection on the positioning pattern area to obtain detection features; the detection features include the number of edge points of the positioning pattern area and the distance between adjacent edge points of the positioning pattern area; judging whether the detection features meet the standard, and if the detection features do not meet the standard, determining that the candidate code area is an interference code area; screening out the position detection pattern in the candidate code area according to the design rule of the position detection pattern; the position detection pattern includes a first center point; the first center point is the central symmetry point of the position detection pattern; generate a second center point according to the first center point; if the first center point and / or the second center point do not meet the standard, determine that the candidate code area is an interference code area.
7. A two-dimensional code filtering device, wherein, comprising: an image acquisition device; a controller configured to: control the image acquisition device to scan a target two-dimensional code to obtain a candidate code area of the target two-dimensional code; perform feature screening on the candidate code area according to the characteristics of the candidate code area to filter out the interference code area in the candidate code area; the feature screening includes gradient feature screening, positioning pattern feature screening and position detection pattern screening; select the position detection patterns to form a final candidate code area according to the result of the feature screening; the controller is further configured to: extract pixel points in the candidate code area; Calculate the gradient direction of the pixel point and count the gradient direction to obtain several gradient main directions; Determine whether the several gradient main directions are orthogonal. If the several gradient main directions are not orthogonal, determine that the code area is an interference code area; According to the positioning pattern design rules, screen out the positioning pattern area from the candidate code areas; Perform interference detection on the positioning pattern area to obtain detection features; the detection features include the number of edge points of the positioning pattern area and the distance between adjacent edge points of the positioning pattern area; Determine whether the detection features meet the standards. If the detection features do not meet the standards, determine that the candidate code area is an interference code area; According to the design rules of the position detection pattern, screen out the position detection pattern from the candidate code areas; The position detection pattern includes a first center point; The first center point is the central symmetry point of the position detection pattern; Generate a second center point according to the first center point; If the first center point and / or the second center point do not meet the standards, determine that the candidate code area is an interference code area.
Citation Information
Patent Citations
2D code positioning method and system
CN106485183A
Two-dimensional code image processing method and device, storage medium and electronic equipment
CN115358252A