Differential verification code identification method and system, storage medium and electronic equipment

By obtaining and calculating the texture characteristics and external rectangle differences of the differential verification code, we automatically identify the target elements in the differential verification code, solving the problems of low recognition efficiency and waste of computing resources in the existing technology, and achieving efficient differential verification code Identify.

CN119227043APending Publication Date: 2024-12-31SUZHOU CHUANGLUTIANXIA INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411065258.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

In the prior art, due to the subtle differences in the identification of differential verification codes, a large number of manual marking of texture features is required, resulting in low recognition efficiency and a large amount of computing resources.

Method used

By obtaining the texture characteristics of the difference verification code, positioning the external rectangle of the element based on the texture features, and calculating the difference between the external rectangles, automatically identifying the target element with the greatest difference, and using an unsupervised method to calculate the element positioning and difference degree to avoid dependence A large number of manual markings.

Benefits of technology

Automatically identify subtle differences between elements in complex verification codes, save computing resources, and improve the recognition efficiency of differential verification codes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119227043A_ABST
    Figure CN119227043A_ABST
Patent Text Reader

Abstract

The invention discloses a difference verification code identification method and system, a storage medium and electronic equipment, and relates to the technical field of computer vision. The method comprises the following steps: obtaining texture features of a to-be-identified difference verification code; based on the texture features of the difference verification code, positioning a bounding rectangle of each element; and calculating the difference degree between the enclosing rectangles, and determining the element corresponding to the enclosing rectangle with the maximum difference degree as a target element. By implementing the technical scheme provided by the invention, the computing power resource can be saved, and the identification efficiency of the difference verification code is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer vision technology, and in particular to a method, system, storage medium and electronic device for recognizing a difference verification code. Background Art

[0002] With the rapid development of Internet technology, network security issues have become increasingly prominent. In many online applications and services, in order to prevent malicious software from automatically performing large-scale registration, login or data crawling, various verification code mechanisms are usually used to distinguish between human users and computer programs. Difference verification codes are widely used as an alternative. Difference verification codes are image verification codes that distinguish differences in details. It requires users to select the target element with the largest difference in the difference verification code to prove that the user is a human. This type of verification code increases the difficulty of robot recognition.

[0003] When the prior art recognizes and processes difference verification codes, since the differences in the difference verification codes are subtle, it is necessary to manually annotate the detailed texture features of the difference verification codes in large quantities, and then train the recognition model through a machine learning algorithm. Due to the large amount of annotation of texture features, the recognition model trained by this method requires a large amount of computing power resources when applied, resulting in low recognition efficiency of the difference verification codes. Summary of the invention

[0004] The present application provides a method, system, storage medium and electronic device for recognizing a difference verification code, which can save computing resources and improve the recognition efficiency of the difference verification code.

[0005] In a first aspect, the present application provides a method for identifying a difference verification code, the method comprising: Obtaining texture features of the difference verification code to be identified; Based on the texture features of the difference verification code, locating the circumscribed rectangle of each of the elements; The difference between the bounding rectangles is calculated, and the element corresponding to the bounding rectangle with the largest difference is determined as the target element.

[0006] By adopting the above technical solution, by obtaining the texture features of the difference verification code, locating the bounding rectangle of each element based on the texture features, and calculating the difference between each bounding rectangle, the element corresponding to the bounding rectangle with the largest difference is determined as the target element, so that the target element with the largest difference from other elements in the difference verification code can be automatically identified, and the automatic identification of the subtle differences between elements in the complex verification code is realized. Compared with the prior art, the algorithms such as the location detection and difference calculation of the elements in the present application are all performed in an unsupervised manner, and there is no need to rely on a large amount of manual annotation to identify the subtle differences of the elements in the difference verification code, thereby saving computing resources during identification and improving the recognition efficiency of the difference verification code.

[0007] Optionally, obtaining the texture feature of the difference verification code to be identified includes: Obtaining a difference verification code to be identified, and converting the difference verification code into a single-channel grayscale image; Performing edge detection on the grayscale image to obtain an edge image; Based on the morphological algorithm, the edge image is subjected to denoising and corrosion and expansion operations successively to obtain a morphological change image; The texture features of the difference verification code are determined in the morphological change graph.

[0008] By adopting the above technical scheme, the texture features of the difference verification code are extracted by combining grayscale image, edge detection and morphological algorithm. Grayscale conversion reduces color interference, edge detection can highlight the element outline, morphological opening denoising can eliminate small noise in the edge image, and morphological expansion can further enhance the texture features. Compared with directly processing the original color image, the accuracy and reliability of subsequent judgment of element position and subtle differences based on texture features are improved.

[0009] Optionally, locating the bounding rectangle of each element based on the texture feature of the difference verification code includes: Detecting the outer contour of each element in the texture features in the difference verification code to obtain a contour group corresponding to each element; Generate an initial circumscribed rectangle corresponding to each of the elements based on each of the contour line groups; A bounding rectangle that meets a preset element area condition is selected from each of the initial bounding rectangles.

[0010] By adopting the above technical scheme, the outer contour lines of each element are detected on the feature map using the extracted difference verification code texture features, and the initial circumscribed rectangle is generated from the contour lines of each element. Then, the element is screened according to the preset area conditions of the element, such as size, aspect ratio, etc., so that the area where each element is located can be accurately located. The visual texture features of the elements are fully utilized, and the image processing algorithms of contour detection and area screening are used to realize the automatic positioning of verification code elements based on non-manual labeling methods. Compared with the manual calibration of the areas of each element, this technical means performs automated analysis and screening, thereby improving the positioning efficiency.

[0011] Optionally, selecting a bounding rectangle that meets a preset element area condition from each of the initial bounding rectangles includes: Obtain the aspect ratio and the total number of pixels corresponding to each of the initial circumscribed rectangles; Determining whether the aspect ratio is within a preset aspect ratio range and whether the pixel sum is less than a pixel sum threshold; The initial bounding rectangle whose aspect ratio is within a preset aspect ratio range and whose pixel sum is less than a pixel sum threshold is used as a first bounding rectangle; The number of first circumscribed rectangles is obtained, and based on the number of the first circumscribed rectangles and the number of the elements in the difference verification code, a circumscribed rectangle corresponding to each of the elements is determined.

[0012] By adopting the above technical scheme, the visual features of the difference verification code elements are fully utilized, the preset conditions of the aspect ratio range and the pixel sum threshold are proposed, and the bounding rectangles that meet the characteristics of the verification code elements are screened out. Combined with the number of pre-screening results and the number of verification code elements, the bounding rectangle corresponding to each element can be automatically determined, and the quantitative feature judgment and screening of the initial bounding rectangle are realized, thereby improving the accuracy of element area positioning. Compared with directly obtaining the initial bounding rectangle, the automatic filtering and calibration process makes element positioning more accurate and reliable.

[0013] Optionally, the determining, based on the number of the first bounding rectangles and the number of the elements in the difference verification code, a bounding rectangle corresponding to each element includes: Determining whether the number of the first circumscribed rectangles is consistent with the number of the elements; If the number of the first circumscribed rectangles is consistent with the number of elements, each first circumscribed rectangle is determined to be a circumscribed rectangle corresponding to each of the elements.

[0014] By adopting the above technical solution, it is determined whether the number of bounding rectangles of the previous screening results is consistent with the number of elements. If they are consistent, the bounding rectangle corresponding to the element is directly determined, thereby achieving the technical effect of accurately locating the verification code elements based on prior information and feature analysis. Compared with the existing technology, the number of bounding rectangles obtained by the previous screening is used to determine whether it is consistent with the actual number of verification code elements. If they are consistent, the element area can be directly determined.

[0015] Optionally, the method further includes: If the number of the first circumscribed rectangles is inconsistent with the number of elements, determining a plurality of characteristic key points in the difference verification code; The number of the elements is used as the number of clusters, and each of the characteristic key points is clustered, and a second circumscribed rectangle corresponding to each clustering result is calculated, and each of the second circumscribed rectangles is used as a circumscribed rectangle corresponding to each of the elements.

[0016] By adopting the above technical solution, if the number of circumscribed rectangles is inconsistent with the number of elements, the feature point detection and clustering method is used to obtain the circumscribed rectangular area corresponding to the element, and the element is located by an image analysis method that detects feature points and clusters them. The combination of the two positioning methods improves the accuracy and reliability of positioning.

[0017] Optionally, the calculating the difference between the bounding rectangles and determining the element corresponding to the bounding rectangle with the largest difference as the target element includes: Determine the standard element after filtering each of the circumscribed rectangles; Calculating the difference between each of the standard elements, and constructing a difference matrix based on each of the difference; The difference matrix is ​​summed up row by row to obtain a column vector, and the maximum element corresponding to the column vector is used as the target element with the maximum difference.

[0018] By adopting the above technical scheme, by determining the standard elements, calculating the differences between the elements to construct a difference matrix, and selecting the element with the largest difference as the difference target element, the technical effect of judging the difference target of the verification code based on the difference comparison is achieved. Compared with the existing technology, after locating each element, the standard element is determined, that is, the background noise is filtered out, and then the difference between these standard elements is calculated to construct a difference matrix. Based on the comparison of the matrix column vectors, the target element with the largest difference, that is, the element with the largest difference from other elements, is judged, thereby improving the accuracy of difference recognition.

[0019] In a second aspect of the present application, a system for identifying a difference verification code is provided, the system comprising: A texture acquisition module, used to acquire texture features of the difference verification code to be identified; A target positioning module, used for positioning the circumscribed rectangle of each element based on the texture features of the difference verification code; The difference recognition module is used to calculate the difference between the bounding rectangles and determine the element corresponding to the bounding rectangle with the largest difference as the target element.

[0020] In a third aspect of the present application, a computer storage medium is provided, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the above method steps.

[0021] In a fourth aspect of the present application, an electronic device is provided, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.

[0022] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: By obtaining the texture features of the difference verification code, locating the bounding rectangle of each element based on the texture features, and calculating the difference between the bounding rectangles, the element corresponding to the bounding rectangle with the largest difference is determined as the target element, so that the target element with the largest difference from other elements in the difference verification code can be automatically identified, thereby realizing automatic recognition of subtle differences between elements in complex verification codes. The algorithms for element positioning detection and difference calculation in the present application are all performed in an unsupervised manner. Compared with the prior art, it avoids relying on a large amount of manual annotation to identify subtle differences between elements in the difference verification code, thereby further saving computing power resources during recognition and improving the recognition efficiency of difference verification codes. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 It is a flowchart of a method for identifying a difference verification code provided in an embodiment of the present application; Figure 2 This is an example diagram of a difference verification code provided in an embodiment of the present application; Figure 3 It is a module schematic diagram of a difference verification code recognition system provided in an embodiment of the present application; Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.

[0024] Description of reference numerals: 400, electronic device; 401, processor; 402, communication bus; 403, user interface; 404, network interface; 405, memory. DETAILED DESCRIPTION

[0025] In order to enable technicians in this field to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.

[0026] In the description of the embodiments of the present application, words such as "for example" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "for example" or "for example" is intended to present related concepts in a specific way.

[0027] In the description of the embodiments of the present application, the term "plurality" means two or more. For example, a plurality of systems means two or more systems, and a plurality of screen terminals means two or more screen terminals. In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. The terms "comprising", "including", "having" and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0028] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments.

[0029] Please refer to Figure 1 , a flowchart of a method for identifying differential verification codes is specifically proposed. This method can be implemented relying on a computer program, can be implemented relying on a single-chip microcomputer, or can run on a differential verification code identification system. This computer program can be integrated in a computer device or can run as an independent tool application. Specifically, this method includes steps 10 to 30, and the above steps are as follows: Step 10: Obtain the texture features of the differential verification code to be identified.

[0030] Among them, in the embodiments of the present application, the differential verification code refers to an image containing elements such as text, numbers, and graphics with multiple different shapes, colors, and distortion degrees. These elements are placed in a complex background, and there are certain differences and changes between the elements.

[0031] Please refer to Figure 2 , which is an example diagram of a differential verification code provided by the embodiments of the present application. This differential verification code includes four elements, which are the Chinese character "墟". Among them, there are differences in aspects such as the font form of the lower left corner element and the remaining three elements. The lower left corner element is used as the target element with the largest difference. It should be noted that this differential verification code is only an example diagram, and in other scenarios, this differential verification code can also be composed of other elements such as text, numbers, and graphics.

[0032] In the embodiments of the present application, the texture features refer to visual features used to describe and represent the surface structure of the elements in the differential verification code. These texture features can reflect the texture information of the elements, including attributes such as the pixel change rate, directionality, and thickness of the element surface.

[0033] Specifically, to identify the difference click verification code, it is necessary to extract texture features from the original input image first, because the difference between the difference target and other targets is usually reflected in the texture details, such as the subtle differences in local areas such as fonts and lines. It is difficult to directly analyze the original image, and extracting texture features can highlight the unique texture characteristics of the difference target, which is conducive to subsequent detection and classification. First, the input color difference verification code is converted from RGB image to grayscale image, only grayscale information is retained and color information is removed, simplifying subsequent processing. Then edge detection is performed on the grayscale image, and the edge map of the image is obtained using the Canny operator. Edge detection can extract important texture features such as contour lines in the image. In order to further remove noise and enhance texture, the edge map is morphologically opened to remove small noise points, and an enhanced morphological change map is obtained. The texture features of the difference verification code can be determined in the morphological change map, and key texture features are automatically and efficiently extracted from complex difference verification codes, laying the foundation for subsequent unsupervised target detection and classification.

[0034] Based on the above embodiment, as an optional embodiment, the step of obtaining the texture feature of the difference verification code to be identified may further include the following steps: Step 101: Obtain a difference verification code to be identified, and convert the difference verification code into a single-channel grayscale image.

[0035] Specifically, obtain the difference verification code to be identified, which is usually a color image, including three RGB color channels. However, for subsequent image processing, the color image is too complex, and the information of different color channels often interferes with the effect of image processing. Therefore, it is necessary to convert the difference verification code into a single-channel grayscale image. Only retaining grayscale information and removing redundant color information makes image processing more efficient and will not be affected by color interference. The process of converting the difference verification code into a single-channel grayscale image can be: first obtain the input color difference verification code, set it as an RGB three-channel image, recorded as input_img. Then according to the specified color space conversion formula, input_img is converted from RGB space to grayscale space to obtain a single-channel grayscale image gray_img, and the color space conversion formula can be: gray=(0.299 * R +0.587 * G + 0.114 * B). Where R, G, and B represent the pixel values ​​of input_img in the three color channels of RGB respectively. Through the above formula, each pixel of the color image can be mapped to a grayscale value, thus obtaining a single-channel grayscale image gray_img.

[0036] Step 102: Perform edge detection on the grayscale image to obtain an edge map.

[0037] Specifically, since the difference between the difference target and other targets is mainly reflected in the texture details, such as the subtle differences in local areas such as the outline of the font and lines, edge detection can efficiently extract important texture features such as the contour lines in the image, laying the foundation for the subsequent identification of the difference target. First, select a suitable edge detection operator, commonly used ones are Canny, Sobel, Prewitt, etc. Among them, the Canny operator is used to perform edge detection on gray_img in the embodiment of the present application, which can effectively detect edges with low noise and good continuity. The Canny operator uses a Gaussian filter to smooth the image to eliminate noise, then calculates the amplitude and direction of the image gradient, then performs non-maximum suppression on the gradient amplitude, and finally detects and connects the edges through a dual threshold algorithm. After being processed by the Canny operator, the original grayscale image gray_img is converted into an edge image that only retains the edge contour lines.

[0038] Step 103: Based on the morphological algorithm, the edge image is subjected to denoising and corrosion and dilation operations to obtain a morphological change image.

[0039] After edge detection to obtain the edge map, although the texture contour line features of the target area in the image have been extracted, some noises, such as small dots or holes, often remain in the edge map, which will interfere with subsequent target detection and classification. Therefore, it is necessary to further denoise the edge map. At the same time, in order to enhance the contour features and make the contour lines of the target area thicker and more significant, an expansion operation is also required. The embodiment of the present application adopts a method based on a morphological opening algorithm, which successively corrodes, expands and denoises the edge map to obtain a morphological change map.

[0040] Specifically, denoising is performed based on the edge map of the morphological opening algorithm. The effect of the opening operation is to eliminate small objects on the boundary, fill small holes in the window, smooth the outline of the object without significantly changing the area. In the opening operation, the corrosion operation is first performed to remove small objects and small protrusions on the edge, and then the expansion operation is performed to restore the shape of the eroded object but the small hole is still retained. The opening operation is equivalent to a noise cleaner, which is used to remove small objects caused by noise and particles. The convolution kernel used in the opening operation can be selected according to the actual situation, such as a 3x3 rectangular structure element. Although the small noise is removed, the contour lines will become slightly thinner. Therefore, it is necessary to further perform an expansion operation on the denoised image to make the contour lines thicker. The expansion operation can expand the edge outward by several pixels and thicken the contour. After the opening operation of first corrosion and then expansion, the morphological change map of the texture line significance can be finally obtained.

[0041] Step 104: Determine the texture features of the difference verification code in the morphological change graph.

[0042] Specifically, the morphological change map is corrected and cut, the image area is limited to the region of interest ROI, and the irrelevant area at the edge of the image is removed. Then, the image in the ROI is scanned to extract independent connected areas. Each connected area can be regarded as an independent texture feature. In the process of extracting connected areas, some morphological operations and filtering are required, such as using opening operations to remove small noise areas, and using area thresholds to remove areas that are too large or too small. For each extracted valid connected area, its area, rectangular frame coordinates, centroid coordinates and other feature parameters can be calculated and recorded as the description information of the texture feature. Finally, a texture feature set consisting of N connected area texture features can be obtained, and each texture feature has corresponding description parameters such as area and coordinates.

[0043] Step 20: Based on the texture features of the difference verification code, locate the bounding rectangle of each element.

[0044] Among them, the circumscribed rectangle in the embodiment of the present application refers to a geometric feature parameter used to describe the connected area of ​​the extracted texture features. The circumscribed rectangle refers to the smallest rectangular frame that can completely surround the connected area, which can be determined by the coordinate values ​​of the two points in the upper left corner and the lower right corner of the rectangular frame.

[0045] Specifically, the findContours function in OpenCV is used to perform contour detection on the texture features in the difference verification code. The detection mode is set to detect only the external contour line, that is, the outermost contour line of each connected domain. In the findContours function, the contour approximation method CHAIN_APPROX_SIMPLE is used. The approximation method only retains the key points of the contour, but does not store all points. It can greatly reduce the required storage space and improve the calculation efficiency. All contour lines detected by the findContours function are stored in a vector contours to obtain multiple contour line groups. Traverse each contour line group, for the current contour line, call the boundingRect function of OpenCV, pass in the contour line as a parameter, and obtain the circumscribed rectangle of the contour line. According to the return value of the boundingRect function, record the coordinates of the upper left corner and lower right corner of the current bounding rectangle (x, y, w, h), where (x, y) is the coordinate of the upper left corner, and (x+w, y+h) is the coordinate of the lower right corner. Since there are some noise contours with too small or too large areas, filtering is required. The area and total pixel value of the current bounding rectangle can be screened to filter out the bounding rectangles that do not meet the preset element area conditions, thereby obtaining the bounding rectangles of each element.

[0046] Based on the above embodiment, as an optional embodiment, the step of locating the bounding rectangle of each element based on the texture feature of the difference verification code may further include the following steps: Step 201: Detect the outer contour of each element in the texture features in the difference verification code to obtain a contour group corresponding to each element.

[0047] Specifically, the texture features of the difference verification code are obtained and stored in a texture feature set. Each texture feature corresponds to a connected area and describes the geometric properties of the area. To locate and identify each individual element (character or graphic) in the verification code, it is necessary to further extract the outer contour lines corresponding to each element based on these texture features, and determine the specific area of ​​the element based on these contour lines. Contour lines can well describe and segment independent target objects in the image. For the difference verification code, characters and graphic elements are separated by contour edge lines. If the outermost contour lines corresponding to each element can be accurately extracted, each independent element area can be located and segmented according to these contour lines. Specifically, you can call the findContours function in OpenCV to perform contour detection, set the detection mode to RETR_EXTERNAL, and only detect external contours, that is, the outermost closed contour of each connected area. All contours detected by findContours are stored in a vector contours. In findContours, set the contour approximation method to CHAIN_APPROX_SIMPLE to only retain the key points of the contour, reduce storage space, and improve efficiency. All contours detected by findContours are stored in a vector contours, each contour is a vector element, and a contour group consisting of N vector elements can be obtained, each element corresponds to the outermost contour of an independent element in the difference verification code.

[0048] Step 202: Generate an initial circumscribed rectangle corresponding to each element based on each contour line group.

[0049] Specifically, after obtaining the contour line group corresponding to all elements (characters or graphics) in the difference verification code, each of which describes the outermost closed contour of an element. Although these contour lines can be used to intercept the corresponding element area on the original image, the contour line itself is a point sequence, which is relatively complicated to describe. It is necessary to approximate the element area corresponding to each contour line with a simple geometric shape. For any contour line group, traverse each contour line in the contour line group. For the current contour line, call the boundingRect function of OpenCV, which can calculate the minimum bounding rectangle based on the contour line. BoundingRect returns the coordinates (x, y, w, h) of the upper left corner and the lower right corner of the bounding rectangle, where (x, y) is the coordinate of the upper left corner, (x+w, y+h) is the coordinate of the lower right corner, w and h are the width and height of the rectangle respectively, and the (x, y, w, h) coordinates of the rectangle can constitute the initial bounding rectangle corresponding to the element.

[0050] Step 203: Filter out the bounding rectangles that meet the preset element area conditions from the initial bounding rectangles.

[0051] Specifically, due to some noise and errors in the process of contour extraction and bounding rectangle generation, some initial bounding rectangles may correspond to some background areas that are too large or too small, rather than the real target element areas. In order to eliminate these false detection areas as much as possible and improve the accuracy of the final segmentation and recognition, it is necessary to further screen these initial bounding rectangles. The preset element area condition in the embodiment of the present application refers to the aspect ratio range and pixel sum threshold of the standard bounding rectangle, that is, it is necessary to screen out the bounding rectangles within the preset aspect ratio range and below the pixel sum threshold in each initial bounding rectangle. Eliminating these obviously abnormal bounding rectangles in advance can effectively prevent some errors from being passed to the subsequent classification and recognition links, thereby improving the overall recognition accuracy.

[0052] Based on the above embodiment, as an optional embodiment, the step of selecting the bounding rectangles that meet the preset element area conditions from the initial bounding rectangles may further include the following steps: Step 2031: Obtain the aspect ratio and the total number of pixels corresponding to each initial circumscribed rectangle.

[0053] Specifically, the aspect ratio is obtained because the aspect ratio of common elements such as numbers and letters is relatively fixed within a certain range. The total number of pixels is obtained because the total number of foreground pixels contained in a rectangular frame can reflect the actual occupied area of ​​the target element to a certain extent. For each initial circumscribed rectangle, calculate its aspect ratio: max(w, h) / min(w, h), where max(w, h) takes the maximum value of the width and height, and min(w, h) takes the minimum value of the width and height. Traverse each pixel point in the initial circumscribed rectangle and accumulate the pixel sum.

[0054] Step 2032: Determine whether the aspect ratio is within a preset aspect ratio range and whether the pixel sum is less than a pixel sum threshold.

[0055] Specifically, due to the influence of image noise or other interference, some falsely detected bounding rectangles may correspond to some obviously abnormal aspect ratios or pixel sums, such as being too long or too narrow, too large or too small in area, etc., and it is necessary to pre-set an aspect ratio range. In the embodiment of the present application, the preset aspect ratio range is between 0.5 and 2, and the pixel sum threshold is 800 pixels. It is determined one by one whether the aspect ratio corresponding to each initial bounding rectangle is within the preset aspect ratio range, and whether the pixel sum is less than the pixel sum threshold.

[0056] Step 2033: taking an initial bounding rectangle whose aspect ratio is within a preset aspect ratio range and whose pixel sum is less than a pixel sum threshold as a first bounding rectangle.

[0057] Specifically, an initial bounding rectangle whose aspect ratio is within a preset aspect ratio range and whose pixel sum is less than a pixel sum threshold is used as a first bounding rectangle, and the first bounding rectangle is a bounding rectangle that meets a preset element region condition.

[0058] Step 2034: Obtain the number of first circumscribed rectangles, and determine the circumscribed rectangle corresponding to each element based on the number of first circumscribed rectangles and the number of each element in the difference verification code.

[0059] Specifically, after obtaining the first circumscribed rectangles that have met the preset element area conditions, these first circumscribed rectangles may correspond to the target element area in the difference verification code. Generally, the number of first circumscribed rectangles should be exactly the same as the number of elements in the difference verification code, but due to possible omissions, incomplete segmentation, etc., there may be a difference in quantity between the two. Therefore, it is necessary to first determine whether the number of first circumscribed rectangles is consistent with the number of elements. For example, in the embodiment of the present application, the number of elements is 4, that is, there are 4 Chinese characters or four graphics and other elements in the difference verification code.

[0060] If the number of first bounding rectangles is consistent with the number of elements, each first bounding rectangle is determined to be the bounding rectangle corresponding to each element, indicating that the bounding rectangles of all elements have been successfully obtained and no additional processing is required. If the number of first bounding rectangles is inconsistent with the number of elements, it is likely caused by omissions, inaccurate positioning, etc., so other strategies need to be introduced to ensure that all target element areas can be covered. For example, the number of first bounding rectangles is 3, which is inconsistent with the number of elements in the difference verification code, which is 4. Then the ORB algorithm is used for feature key point detection. The ORB (OrientedFAST and Rotated BRIEF) algorithm is a computationally efficient and robust feature point detection and description operator, which includes a key point detector and a description with directional information. In setting the ORB parameters, the embodiment of the present application sets pyramidlevels to 5, which can capture feature points at different scales; edgeThreshold is set to 15, which can filter out noise points in weak edge areas; patchSize is set to 5, which can extract enough local features, and the others are calculated according to the default values ​​to obtain multiple feature key points. The distribution of the detected key points kpoints is usually disordered and difficult to directly correspond to the target element. The number of elements is 4 as the number of clusters, and the kmeans algorithm is used to cluster each feature key point. For each cluster, the bounding rectangle of all key points is calculated as the second bounding rectangle, and each second bounding rectangle is used as the bounding rectangle corresponding to each element.

[0061] Step 30: Calculate the difference between the bounding rectangles, and determine the element corresponding to the bounding rectangle with the largest difference as the target element.

[0062] In the embodiment of the present application, the target element refers to the character or symbol element contained in the special bounding rectangle that is the least similar to other elements.

[0063] Specifically, determine the standard elements after filtering each circumscribed rectangle, then calculate the differences between the standard elements based on the matchTemplate method of OpenCV, and construct a difference matrix based on the differences; sum each row of the difference matrix to obtain a column vector, and take the largest column vector in the column vector as the target element with the largest difference.

[0064] Based on the above embodiment, as an optional embodiment, the step of calculating the difference between the bounding rectangles and determining the element corresponding to the bounding rectangle with the largest difference as the target element may further include the following steps: Step 301: Determine the standard element after filtering each circumscribed rectangle.

[0065] Specifically, since the image obtained after edge detection and morphological operations is a binary image, it is only necessary to filter out the valid elements in each circumscribed rectangle as the standard elements, that is, to obtain the standard elements after filtering the aspect ratio or the number of pixels of the area after findContours or clustering.

[0066] Step 302: Calculate the differences between the standard elements, and construct a difference matrix based on the differences.

[0067] Specifically, after obtaining high-quality standard elements, it is necessary to calculate the difference between them so as to subsequently determine the most dissimilar special target element, that is, the one with the largest difference. Figure 2 The four regions in the figure are used as an example to describe the algorithm. In actual situations, there can be any region, and this algorithm is applicable. First, a 4x4 difference matrix needs to be initialized to store the difference values ​​between standard elements. Using two nested loops, the first standard element is selected as the template image, and the difference between the template image and all other standard elements is calculated. The matchTemplate function of OpenCV is used, and TM_SQDIFF_NORMED is selected as the matching mode. The closer the difference value returned by this mode is to 0, the more similar the two elements are, and vice versa. The greater the difference. Since the size of each standard element may be different, it is necessary to paste the search and matching circumscribed rectangle onto a larger base plate in advance as the image to be searched, and ensure that its size is greater than or equal to the template image size to avoid matching failure, and can cover the entire area of ​​the template image, thereby ensuring the reliability of the difference calculation. And when calculating the difference, in order to suppress redundancy and noise interference in the calculation process, only the outline of the text or graphic is matched during matching, that is, the template binary image itself is used as a mask parameter to match the template to calculate the difference. That is, when calculating the difference, the binary image is passed in as a mask parameter, and the system will only calculate the difference in the foreground area of ​​the template image, thereby avoiding the interference of background noise and improving the calculation accuracy. The calculated differences are sequentially stored in the initialized difference matrix to obtain the difference matrix.

[0068] Step 303: sum the difference matrix row by row to obtain a column vector, and use the maximum element corresponding to the column vector as the target element with the maximum difference.

[0069] Specifically, in the difference matrix array, array ijRepresents the difference between the i-th and j-th standard elements. Sum each row in the difference matrix to get a column vector, whose dimension is the same as the number of rows in the difference matrix. According to vector theory, each component of the vector reflects the "cumulative difference" between the i-th standard element and all other standard elements. Usually, since most standard elements belong to the same category, the difference between them will be small, so a small cumulative value will appear in the column vector. For elements that are obviously different from other elements, since their similarity with all elements is small, that is, the difference is large, the value in the corresponding column vector must be the largest value, so you only need to find the maximum value in the column vector and record its index idx to directly determine the target element.

[0070] See also Figure 3 , is a module diagram of a difference verification code recognition system provided in an embodiment of the present application. The difference verification code recognition system may include: a texture acquisition module, a target positioning module and a difference recognition module, wherein: A texture acquisition module, used to acquire texture features of the difference verification code to be identified; A target positioning module, used for positioning the circumscribed rectangle of each element based on the texture features of the difference verification code; The difference recognition module is used to calculate the difference between the bounding rectangles and determine the element corresponding to the bounding rectangle with the largest difference as the target element.

[0071] Optionally, the texture acquisition module is also used to obtain the difference verification code to be identified, convert the difference verification code into a single-channel grayscale image; perform edge detection on the grayscale image to obtain an edge map; perform denoising and dilation operations on the edge map based on a morphological algorithm to obtain a morphological change map; determine the texture features of the difference verification code in the morphological change map.

[0072] Optionally, the target positioning module is also used to detect the outer contour line of each element in the texture features in the difference verification code to obtain a contour line group corresponding to each element; generate an initial circumscribed rectangle corresponding to each element based on each contour line group; and screen out a circumscribed rectangle that meets a preset element area condition from each initial circumscribed rectangle.

[0073] Optionally, the target positioning module is also used to obtain the aspect ratio and the total pixel value corresponding to each of the initial bounding rectangles; determine whether the aspect ratio is within a preset aspect ratio range, and whether the total pixel value is less than a pixel total threshold; use the initial bounding rectangle whose aspect ratio is within the preset aspect ratio range and whose total pixel value is less than a pixel total threshold as the first bounding rectangle; obtain the number of first bounding rectangles, and determine the bounding rectangle corresponding to each element based on the number of the first bounding rectangles and the number of each element in the difference verification code.

[0074] Optionally, the target positioning module is also used to determine whether the number of the first circumscribed rectangles is consistent with the number of the elements; if the number of the first circumscribed rectangles is consistent with the number of elements, then each first circumscribed rectangle is determined to be the circumscribed rectangle corresponding to each element; if the number of the first circumscribed rectangles is inconsistent with the number of elements, then multiple feature key points are determined in the difference verification code; the number of elements is used as the number of clusters, and each feature key point is clustered, and the second circumscribed rectangle corresponding to each clustering result is calculated, and each second circumscribed rectangle is used as the circumscribed rectangle corresponding to each element.

[0075] Optionally, the difference identification module is also used to determine the standard elements after filtering each of the circumscribed rectangles; calculate the difference between each of the standard elements, and construct a difference matrix based on each of the differences; sum the difference matrix row by row to obtain a column vector, and take the maximum element corresponding to the column vector as the target element with the largest difference.

[0076] Optionally, the difference identification module is further used to binarize the difference verification code to obtain a binarized image; filter the pixel points of each circumscribed rectangle based on the binarized image to obtain standard elements in each circumscribed rectangle after filtering.

[0077] It should be noted that: when the system provided in the above embodiment realizes its functions, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the system and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0078] An embodiment of the present application also provides a computer storage medium, which can store multiple instructions. The instructions are suitable for being loaded by a processor and executing a method for identifying a difference verification code of the above embodiment. The specific execution process can be found in the specific description of the above embodiment, which will not be repeated here.

[0079] Please refer to Figure 4 The application also discloses an electronic device. Figure 4 The electronic device 400 may include: at least one processor 401 , at least one network interface 404 , a user interface 403 , a memory 405 , and at least one communication bus 402 .

[0080] The communication bus 402 is used to realize the connection and communication between these components.

[0081] The user interface 403 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 403 may also include a standard wired interface and a wireless interface.

[0082] The network interface 404 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0083] Among them, the processor 401 may include one or more processing cores. The processor 401 uses various interfaces and lines to connect various parts in the entire server, and executes various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 405, and calling data stored in the memory 405. Optionally, the processor 401 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 401 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 401, and it can be implemented separately through a chip.

[0084] Among them, the memory 405 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 405 includes a non-transitory computer-readable storage medium. The memory 405 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 405 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 405 may optionally also be at least one storage device located away from the aforementioned processor 401. Refer to Figure 4 , the memory 405 as a computer storage medium may include an operating system, a network communication module, a user interface module and an application program for a method for identifying a difference verification code.

[0085] exist Figure 4 In the electronic device 400 shown, the user interface 403 is mainly used to provide an input interface for the user and obtain the data input by the user; and the processor 401 can be used to call an application for identifying a difference verification code stored in the memory 405, and when executed by one or more processors 401, the electronic device 400 executes one or more of the methods described in the above embodiments. It should be noted that for the aforementioned method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for the present application.

[0086] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0087] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

[0088] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0089] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0090] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: various media that can store program codes, such as USB flash drives, mobile hard drives, magnetic disks or optical disks.

[0091] The above is only an exemplary embodiment of the present disclosure and cannot be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the disclosure of the specification and the truth of practice, those skilled in the art will easily think of other embodiments of the present disclosure.

[0092] This application is intended to cover any variation, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the art not described in the present disclosure. The description and examples are to be regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.

Claims

1. A method for identifying a difference verification code, characterized in that: include: Obtaining texture features of the difference verification code to be identified; Based on the texture features of the difference verification code, locating the circumscribed rectangle of each of the elements; The difference between the bounding rectangles is calculated, and the element corresponding to the bounding rectangle with the largest difference is determined as the target element.

2. The method for identifying a difference verification code according to claim 1, characterized in that: The step of obtaining the texture feature of the difference verification code to be identified includes: Obtaining a difference verification code to be identified, and converting the difference verification code into a single-channel grayscale image; Performing edge detection on the grayscale image to obtain an edge image; Based on the morphological algorithm, the edge image is subjected to denoising and corrosion and expansion operations successively to obtain a morphological change image; The texture features of the difference verification code are determined in the morphological change graph.

3. The method for identifying a difference verification code according to claim 1, characterized in that: The locating the bounding rectangle of each element based on the texture feature of the difference verification code includes: Detecting the outer contour of each element in the texture features in the difference verification code to obtain a contour group corresponding to each element; Generate an initial circumscribed rectangle corresponding to each of the elements based on each of the contour line groups; A bounding rectangle that meets a preset element area condition is selected from each of the initial bounding rectangles.

4. The method for identifying a difference verification code according to claim 3, characterized in that: Screening out a bounding rectangle that meets a preset element area condition from each of the initial bounding rectangles includes: Obtain the aspect ratio and the total number of pixels corresponding to each of the initial circumscribed rectangles; Determining whether the aspect ratio is within a preset aspect ratio range and whether the pixel sum is less than a pixel sum threshold; The initial bounding rectangle whose aspect ratio is within a preset aspect ratio range and whose pixel sum is less than a pixel sum threshold is used as a first bounding rectangle; The number of first circumscribed rectangles is obtained, and based on the number of the first circumscribed rectangles and the number of the elements in the difference verification code, a circumscribed rectangle corresponding to each of the elements is determined.

5. The method for identifying a difference verification code according to claim 4, characterized in that: The determining, based on the number of the first bounding rectangles and the number of the elements in the difference verification code, a bounding rectangle corresponding to each element includes: Determining whether the number of the first circumscribed rectangles is consistent with the number of the elements; If the number of the first circumscribed rectangles is consistent with the number of elements, each first circumscribed rectangle is determined to be a circumscribed rectangle corresponding to each of the elements.

6. The method for identifying a difference verification code according to claim 5, characterized in that: The method further comprises: If the number of the first circumscribed rectangles is inconsistent with the number of elements, determining a plurality of characteristic key points in the difference verification code; The number of the elements is used as the number of clusters, and each of the characteristic key points is clustered, and a second circumscribed rectangle corresponding to each clustering result is calculated, and each of the second circumscribed rectangles is used as a circumscribed rectangle corresponding to each of the elements.

7. The method for identifying a difference verification code according to claim 1, characterized in that: The calculating the difference between the bounding rectangles and determining the element corresponding to the bounding rectangle with the largest difference as the target element includes: Determine the standard element after filtering each of the circumscribed rectangles; Calculating the difference between each of the standard elements, and constructing a difference matrix based on each of the difference; The difference matrix is ​​summed up row by row to obtain a column vector, and the maximum element corresponding to the column vector is used as the target element with the maximum difference.

8. A system for identifying a difference verification code, characterized in that: The system comprises: A texture acquisition module, used to acquire texture features of the difference verification code to be identified; A target positioning module, used for positioning the circumscribed rectangle of each element based on the texture features of the difference verification code; The difference recognition module is used to calculate the difference between the bounding rectangles and determine the element corresponding to the bounding rectangle with the largest difference as the target element.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method according to any one of claims 1 to 7.

10. An electronic device, characterized in that: It includes a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes the method as described in any one of claims 1-7.