A Chinese character sequential selection verification code recognition method and computer readable storage medium
By using a mutation point intelligent extraction algorithm and OCR technology to identify Chinese character regions, the problem of background interference in the sequential selection of Chinese characters in the verification code is solved, thereby improving the accuracy of verification code recognition and supporting enterprise digital transformation.
Patent Information
- Application Number
- CN202411639221.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-11-18
AI Technical Summary
Existing technologies struggle to effectively recognize Chinese characters when clicking on verification codes sequentially, especially due to background interference leading to low OCR recognition accuracy, which affects the success rate of verification code recognition.
The algorithm for intelligent extraction of mutation points is used to extract Chinese character regions from CAPTCHA images. Chinese characters are then recognized using OCR technology. The coordinates of the Chinese characters and the click order are obtained by combining the edge point set P2, thus avoiding the stack overflow problem.
It improves the recognition accuracy of Chinese characters sequentially selected in the verification code, enhances the success rate of verification code recognition, and helps enterprises with digital transformation.
Smart Images

Figure CN119152517B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of verification code recognition, and in particular to a verification code recognition method for selecting Chinese characters in sequence and a computer-readable storage medium. Background Art
[0002] Verification codes usually contain images composed of numbers and letters. Currently, there are three main types of verification codes on the market: character verification codes, slider verification codes, and Chinese character click verification codes. Among them, the Chinese character click verification code requires first finding the text from the picture, and then clicking the corresponding Chinese characters in turn according to the prompts. This operation is not difficult for people; but it is very difficult to let the computer automatically find the area where the text is located from a picture, and then click the corresponding Chinese characters according to the prompts. In this regard, the current mainstream approach is to solve this problem by identifying the area where the Chinese characters are located through the YOLO algorithm (target detection algorithm), but the regional Chinese characters of this method are easily interfered by the background, and the OCR recognition accuracy of Chinese characters is low, resulting in a low success rate of verification code recognition. Summary of the invention
[0003] The purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art and provide a method for recognizing verification codes by clicking on Chinese characters in sequence. The method can find out the characters that need to be clicked in sequence and has no background interference. The accuracy of character recognition can be greatly improved through OCR technology, thereby improving the accuracy of verification code recognition.
[0004] The purpose of the present invention is achieved through the following technical solutions:
[0005] A method for recognizing a verification code by selecting Chinese characters in sequence, comprising the following steps in sequence:
[0006] S1. Read the verification code image, and extract the area where each Chinese character in the verification code image is located and the image of each Chinese character by using the variation point intelligent extraction algorithm; the variation point is a local variation in the unified order in the plane composition, and a different factor that stands out in the whole, that is, the Chinese character in the verification code image;
[0007] The variation point intelligent extraction algorithm performs the following operations:
[0008] (1) First, read all pixel information of the verification code image;
[0009] (2) Then traverse all the pixels of the verification code image in turn: if the transparent channel value of pixel T is 0, continue to traverse the next pixel, otherwise create a new set of pseudo-continuous points of similar colors Points, and then execute step (3);
[0010] (3) Find all pixels within a certain range of pixels from pixel T whose transparent channel values are not 0 and whose hue value difference with pixel T is less than a preset value. The resulting pixel set is defined as set P1, which is used to store the coordinate information and color information of the pixel points.
[0011] 1) If the number of set P1 is 0, execute step (4); otherwise, remove the coordinate information in set P1 to obtain set P1', add all the pixels in set P1' to the set Points of similar-color pseudo-continuous points, and set the transparent channel value of the pixel in the verification code image where the point set Points is located to 0;
[0012] 2) Extract the outermost edge point set P2 of the point set Points, and then search for all pixels whose transparent channel values are not 0 and whose difference with the hue value of the pixel point T is less than a preset value within a certain range of pixels from each pixel of the point set P2. The formed pixel point set is defined as set P1, which is used to store the coordinate information and color information of the pixel points; then execute step 1);
[0013] (4) Remove duplicates from the pseudo-continuous point set Points of similar colors to obtain a new point set Points, and then add the new point set Points to each similar color region set L1;
[0014] (5) Traverse all similar color pseudo-continuous point sets Points in set L1. If the number of pixels in the similar color pseudo-continuous point set Points is less than the number of pixels occupied by a verification code Chinese character, or the width and height of the similar color pseudo-continuous point set Points are greater than the width and height of a verification code Chinese character, then the similar color pseudo-continuous point set Points is the background pixel set. The similar color pseudo-continuous point set Points is deleted from set L1 to form set L1'.
[0015] (6) Redraw a picture Picture1 with the same length and width as the verification code picture, and set the color of all pixels to white; then traverse all the similar color pseudo-continuous point sets Points in the set L1', redraw all the pixels in the similar color pseudo-continuous point sets Points on the picture Picture1 according to their colors, and extract the area where each Chinese character in the verification code picture is located under the white background;
[0016] S2. According to the area where each Chinese character is located under the white background, the coordinates of each Chinese character and the order of clicking are obtained.
[0017] In step 2), the edge point set P2 is obtained by:
[0018] The point set Points is grouped according to the Y axis, and all points with the maximum value of X and the minimum value of X in each group are obtained and saved to the edge point set P2;
[0019] The point set Points is grouped according to the X-axis, and all points with the maximum Y value and the minimum Y value of each group are obtained and saved to the edge point set P2;
[0020] The edge point set P2 is deduplicated to obtain the final edge point set P2.
[0021] The individual characters corresponding to the Chinese characters are saved as pictures with a white background, and then the characters at each variation point are recognized through OCR to determine whether the recognized characters are in the string of Chinese characters clicked in sequence: if so, the middle point of the position where the point is located is saved, otherwise it is determined whether the next recognized character is in the string of Chinese characters clicked in sequence; after traversing and matching all the variation point characters, if there is still a character that needs to be clicked that does not match the one recognized by OCR, then the middle point of the position where the variation point is located is considered to be the position of the character that needs to be clicked; if the final result shows that there are 2 or more characters that do not match the one recognized by OCR, then the recognition fails.
[0022] At the same time, the present invention provides:
[0023] A server comprises a processor and a memory, wherein the memory stores at least one program, and the program is loaded and executed by the processor to implement the above-mentioned Chinese character sequential selection verification code recognition method.
[0024] A computer-readable storage medium stores at least one program, which is loaded and executed by a processor to implement the above-mentioned Chinese character sequential selection verification code recognition method.
[0025] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0026] 1. The present invention can greatly improve the recognition accuracy of this type of verification code, empower business processes, and help enterprises to carry out digital transformation.
[0027] 2. Conventional recursive color similarity query results in stack overflow due to too many recursion times. The intelligent extraction algorithm of variation points of the present invention can avoid the stack overflow problem. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 The present invention is a flowchart of the method for recognizing verification codes by sequentially selecting Chinese characters.
[0029] Figure 2 This is an example of a verification code image.
[0030] Figure 3 It is a flowchart of the intelligent extraction algorithm for mutation points.
[0031] Figure 4 It is a schematic diagram for extracting pseudo-continuous points of similar colors (there can be a certain number of discontinuous pixel points in the middle).
[0032] Figure 5 It is a schematic diagram of the result obtained by redrawing all the points in Points on Picture1 according to their colors.
[0033] Figure 6 It is a schematic diagram of the edge point set P2. Specific implementation mode
[0034] The present invention will be further described in detail below in conjunction with embodiments and the accompanying drawings, but the implementation modes of the present invention are not limited thereto.
[0035] For the verification code recognition of Chinese characters by sequential point selection, the background is complex and random, the positions of each Chinese character do not intersect, the colors of each Chinese character can be different, and the Chinese characters appear randomly at any position on the background picture, and each Chinese character also has a different inclination, such as Figure 1 A method for recognizing verification codes of Chinese characters by sequential point selection includes the following steps in sequence:
[0036] One, Figure 2 The characters (Dou, Tan, Hua) in the verification code picture in are mutation points in the whole picture (mutation points are local mutations that appear in the unified order of plane composition and are different factors that stand out in the whole). After reading the information of each pixel point of the picture, the areas where each character is located are extracted through the intelligent extraction algorithm for mutation points (Algorithm 1), and then the coordinates and click order for sequential clicking are obtained through the intelligent matching algorithm for characters (Algorithm 2).
[0037] Two, as Figure 3 Apply the intelligent extraction algorithm for mutation points (Algorithm 1) to intelligently extract the area where the character is located and the separate picture of the character.
[0038] 1. Read the information of all pixel points of the picture. The coordinates of the upper left corner of the picture are (0, 0), the X-axis increases in the right direction, and the Y-axis increases in the downward direction.
[0039] 2. Traverse all pixel points of the verification code picture in sequence. Obtain the values of A (alpha channel), R (red), G (green), B (blue), and H (hue) of this pixel point. If the A value is 0 (0 represents transparent and 255 represents opaque), continue to execute the second step; otherwise, create a set Points of pseudo-continuous points of similar colors, and then execute the next operation.
[0040] 3. Find the pixel point set P1 (storing coordinates X, Y and color information) within a certain distance from the pixel point (set according to the discontinuous interval size of the pixels occupied by the Chinese characters, generally 9) whose A value is not 0 and has similar colors (the difference in H value between two pixels is less than 5). If the number of set P1 is 0, proceed to the next step. Otherwise, remove the duplicates from the set P1 by using the coordinates X and Y to obtain a new P1, add all the points in P1 to the Points set, and set the A value corresponding to each point on the image to 0 (indicating that the point has been extracted by other similar colors and will not be judged later), and then extract the outermost edge point set P2 of the point set through the edge intelligent extraction algorithm (Algorithm 3), and then traverse the point set P2 in sequence to execute the third step.
[0041] 4. The set of similar color pseudo-continuous points Points (which contains all the similar color pseudo-continuous points such as Figure 3 , 0 is the starting point, 1 is all pseudo-continuous points with similar colors to pixel 0) are removed and added to the similar color region set L1. If all pixels of the verification code image have been traversed, the next step is performed, otherwise, the second step is continued to find Figure 2 Pseudo continuous similar color pixels of all pixels in .
[0042] 5. Through a large number of manual samples, we found the width W and height H of the pixels occupied by the Chinese characters (variation points) of this point-selected verification code. The number of pixels occupied by Chinese character 1 is N (the number of pixels occupied by Chinese character 1 is the least among all Chinese characters, so characters with a number of pixels less than N are not Chinese characters).
[0043] 6. The obtained similar color region set L1 stores all the pseudo-continuous point set information of each color in a region. Traverse all the Points in the set L1. If the number of Points is less than N or the width of the Points is greater than W or the height is greater than H, then the Points are the background point set and are directly deleted from L1.
[0044] 7. We re-draw a picture Picture1 with the same length and width as the verification code, and set the color of all pixels to white. Then we traverse all Points in the set L1 and re-draw all the points in Points on Picture1 according to their colors. The result is as follows Figure 5 .
[0045] 3. Apply the text intelligent matching algorithm (Algorithm 2) to obtain the coordinates of the clicks in sequence.
[0046] Will Figure 4The individual characters corresponding to the Chinese characters are saved as images with a white background, and then the characters at each variation point are recognized through OCR to determine whether the recognized characters are in the Chinese character string that is clicked in sequence. If so, the middle point of the position where the point is located is saved. After traversing and matching all the variation point characters, if there is still a character that needs to be clicked that does not match the OCR recognized one, then we regard the middle point of the variation point as the position of the character that needs to be clicked.
[0047] 4. Apply the edge intelligent extraction algorithm (Algorithm 3) to extract all the outermost edge points of the point set.
[0048] 1. Take the point set Points and group them according to the Y axis, get all the points with the largest X value in each group and save them in the point set PT.
[0049] 2. Take the point set Points and group them according to the Y axis, get all the points with the smallest X value in each group and save them in the point set PT.
[0050] 3. Take the point set Points and group them according to the X-axis, get all the points with the largest Y value in each group and save them in the point set PT.
[0051] 4. Take the point set Points and group them according to the X-axis, get all the points with the smallest Y value in each group and save them in the point set PT.
[0052] 5. After removing duplicates from the point set PT, a new point set PT is obtained.
[0053] Figure 6 In the , the colored points are the point set, and the points with numbers on the grid are all the edge points of the point set, which are also the points in our point set PT.
[0054] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.
Claims
1. A method for recognizing verification codes by selecting Chinese characters in sequence, characterized in that: The steps include the following sequence: S1. Read the verification code image, and extract the area where each Chinese character in the verification code image is located and the image of each Chinese character by using the variation point intelligent extraction algorithm; the variation point is a local variation in the unified order in the plane composition, and a different factor that stands out in the whole, that is, the Chinese character in the verification code image; The variation point intelligent extraction algorithm performs the following operations: (1) First, read all pixel information of the verification code image; (2) Then traverse all the pixels of the verification code image in turn: if the transparent channel value of pixel T is 0, continue to traverse the next pixel, otherwise create a new set of pseudo-continuous points of similar colors Points, and then execute step (3); (3) Find all pixels within a certain range of pixels from pixel T whose transparent channel values are not 0 and whose hue value difference with pixel T is less than a preset value. The resulting pixel set is defined as set P1, which is used to store the coordinate information and color information of the pixel points. 1) If the number of set P1 is 0, execute step (4); otherwise, remove the coordinate information in set P1 to obtain set P1', add all the pixels in set P1' to the set Points of similar-color pseudo-continuous points, and set the transparent channel value of the pixel in the verification code image where the point set Points is located to 0; 2) Extract the outermost edge point set P2 of the point set Points, and then search for all pixels whose transparent channel values are not 0 and whose difference with the hue value of the pixel point T is less than a preset value within a certain range of pixels from each pixel of the point set P2. The formed pixel point set is defined as set P1, which is used to store the coordinate information and color information of the pixel points; then execute step 1); The edge point set P2 is obtained in the following way: The point set Points is grouped according to the Y axis, and all points with the maximum value of X and the minimum value of X in each group are obtained and saved to the edge point set P2; The point set Points is grouped according to the X-axis, and all points with the maximum Y value and the minimum Y value of each group are obtained and saved to the edge point set P2; The edge point set P2 is deduplicated to obtain the final edge point set P2; (4) Remove duplicates from the pseudo-continuous point set Points of similar colors to obtain a new point set Points, and then add the new point set Points to each similar color region set L1; (5) Traverse all similar color pseudo-continuous point sets Points in set L1. If the number of pixels in the similar color pseudo-continuous point set Points is less than the number of pixels occupied by a verification code Chinese character, or the width and height of the similar color pseudo-continuous point set Points are greater than the width and height of a verification code Chinese character, then the similar color pseudo-continuous point set Points is the background pixel set. The similar color pseudo-continuous point set Points is deleted from set L1 to form set L1'. (6) Redraw a picture Picture1 with the same length and width as the verification code picture, and set the color of all pixels to white; then traverse all the similar color pseudo-continuous point sets Points in the set L1', redraw all the pixels in the similar color pseudo-continuous point sets Points on the picture Picture1 according to their colors, and extract the area where each Chinese character in the verification code picture is located under the white background; S2. According to the area where each Chinese character is located under the white background, the coordinates of each Chinese character and the order of clicking are obtained.
2. According to the method for recognizing Chinese characters by clicking on verification codes in sequence according to claim 1, it is characterized in that: The individual characters corresponding to the Chinese characters are saved as pictures with a white background, and then the characters at each variation point are recognized through OCR to determine whether the recognized characters are in the string of Chinese characters clicked in sequence: if so, the middle point of the position where the variation point is located is saved, otherwise it is determined whether the next recognized character is in the string of Chinese characters clicked in sequence; after traversing and matching all the variation point characters, if there is still a character that needs to be clicked that does not match the one recognized by OCR, then the middle point of the position where the variation point is located is considered to be the position of the character that needs to be clicked; if the final result shows that there are 2 or more characters that do not match the one recognized by OCR, then the recognition fails.
3. A server, comprising a processor and a memory, characterized in that: At least one program is stored in the memory, and the program is loaded and executed by the processor to implement the Chinese character sequential selection verification code recognition method described in any one of claims 1 or 2.
4. A computer-readable storage medium, wherein at least one program is stored in the storage medium, characterized in that: The program is loaded and executed by a processor to implement the Chinese character sequential selection verification code recognition method described in any one of claims 1 or 2.
Citation Information
Patent Citations
Click verification code identification method and device, and user terminal
CN108182437A
Graphical verification code recognition method and device, computer equipment and storage medium
CN112035821A