A verification code picture recognition method, device and equipment and storage medium
By binarizing, clustering, and cutting verification code images and combining them with recognition models, the problem of low machine recognition efficiency of verification code images in the existing technology is solved, and more efficient and accurate verification code recognition is achieved.
Patent Information
- Application Number
- CN202111263901.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-27
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2041-10-27
AI Technical Summary
In the prior art, the machine recognition efficiency of verification code images is not high, especially it is difficult to accurately judge overlapping characters, which affects the recognition efficiency and accuracy of users.
The image to be recognized is binarized and clustered to separate the valid character areas. The single and contiguous character areas are determined by combining the preset character attribute set, and the contiguous character areas are cut according to the preset cutting rules. Finally, the pre-trained recognition model is used for recognition.
It improves the accuracy and efficiency of verification code recognition, assists users in entering verification codes correctly, and enhances the user experience.
Smart Images

Figure CN114067324B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure belongs to the technical field of verification code, and particularly relates to a verification code picture recognition method and device, equipment and a storage medium. BACKGROUND
[0002] The verification code picture technology is part of modern network security technology. For example, in the scenarios of user login and sensitive information query, the program will require the user to input the verification code to verify whether it is a human operation.
[0003] With the development of image recognition technology, it is not difficult to recognize pictures of simple arranged numbers and letters. In some existing technologies, the characters in the image are distorted, rotated, overlapped, and often have interference lines and interference points to increase the difficulty of user recognition. However, images with too much difficulty are not conducive to user recognition (for example, due to character color change and character deformation), which goes against the original intention of verifying human operation through verification code, and brings great trouble to the user. Therefore, the user's efficiency and accuracy in recognizing the verification code can be improved through automatic recognition technology. The efficiency of machine recognition of the verification code image in the prior art is not high, and it is difficult to accurately judge the overlapped characters. Therefore, how to improve the accuracy of automatic recognition of the verification code has become a technical problem to be solved. SUMMARY
[0004] In view of the above problems of the prior art, the purpose of the present disclosure is to provide a verification code picture recognition method, device, equipment and storage medium, which can improve the accuracy of automatic recognition of the verification code picture.
[0005] In order to solve the above technical problems, the specific technical solutions of the present disclosure are as follows:
[0006] In one aspect, the present disclosure provides a verification code picture recognition method, which comprises:
[0007] The to-be-recognized picture is subjected to binarization processing to obtain picture effective pixel points;
[0008] The effective pixel points are subjected to clustering processing to obtain mutually separated effective character regions;
[0009] According to the effective character regions and a preset character attribute set, a single character region and a connected character region in all effective character regions are determined, and the preset character attribute set comprises preset attribute features of all characters;
[0010] According to the connected character region, a plurality of effective characters are obtained through a preset cutting rule;
[0011] According to the single character corresponding to the single character region and the plurality of valid characters in the connected character region, and in combination with a pre-trained recognition model, an identification result of the picture to be identified is obtained.
[0012] Further, the preset attribute features include character height, character width, and character pixel point number.
[0013] The single character region and the connected character region in the plurality of valid character regions are determined according to the valid character region and a preset character attribute set.
[0014] The following steps are performed for each valid character region:
[0015] Character features in the valid character region are obtained.
[0016] It is determined whether the character features in the valid character region fall within the range of the preset attribute features in the preset character attribute set.
[0017] If yes, the valid character region is determined as a single character region.
[0018] If no, the valid character region is determined as a connected character region.
[0019] Further, the determination of whether the character features in the valid character region fall within the range of the preset attribute features in the preset character attribute set further includes:
[0020] It is determined whether the width of the valid character region exceeds the maximum value of the character width in the preset character attribute set.
[0021] If yes, the valid character region is determined as a connected character region.
[0022] If no, it is determined whether the ratio of the width and the height of the valid character region exceeds the maximum value of the ratio of the character width and the character height of the single character in the preset character attribute set.
[0023] If the ratio of the width and the height of the valid character region exceeds the maximum value of the ratio of the character width and the character height of the single character in the preset character attribute set, the valid character region is determined as a connected character region.
[0024] If the ratio of the width and the height of the valid character region does not exceed the maximum value of the ratio of the character width and the character height of the single character in the preset character attribute set, the valid character region is determined as a single character region.
[0025] Further, if the ratio of the width and the height of the effective character region does not exceed the maximum value of the ratio of the character width and the character height of the single character in the preset character attribute set, the effective character region is determined as a single character region, and further comprising:
[0026] whether the number of pixel points in the effective character region exceeds the maximum value of the number of pixel points of the single character in the preset character attribute set;
[0027] If the number of pixel points in the effective character region exceeds the maximum value of the number of pixel points of the single character in the preset character attribute set, the effective character region is determined as a single character region.
[0028] If the number of pixel points in the effective character region does not exceed the maximum value of the number of pixel points of the single character in the preset character attribute set, the effective character region is determined as a single character region.
[0029] Further, the plurality of effective characters are obtained from the connected character region according to a preset cutting rule, comprising:
[0030] For each connected character region, the following steps are performed:
[0031] According to the vertical projection method, the number of pixel points of the connected character region in a preset unit interval in the horizontal direction is sequentially counted;
[0032] According to the change trend of the number of pixel points of the connected character region in the preset unit interval in the horizontal direction, a candidate cutting point of the connected character region is determined;
[0033] When the candidate cutting point is one, the candidate cutting point is taken as a target cutting point;
[0034] When the candidate cutting point is multiple, a plurality of character features of candidate regions obtained by the multiple candidate cutting points are obtained, and a target cutting point is screened from the multiple candidate cutting points by combining the plurality of character features with a preset screening rule;
[0035] According to the target cutting point, the connected character region is cut to obtain a plurality of effective characters after cutting.
[0036] Further, according to the vertical projection method, the number of pixel points of the connected character region in a preset unit interval in the horizontal direction is sequentially counted, comprising:
[0037] A minimum character width is determined from the preset character attribute set, and the minimum character width is taken as the initial width of a specified window, the specified window including a fixed end and a moving end;
[0038] placing a fixed end of the specified window at one side of the ligature character region and placing a moving end of the specified window at the other side of the ligature character region with the initial width;
[0039] moving the moving end of the specified window by a preset unit interval towards the side away from the fixed end in sequence;
[0040] obtaining the number of pixel points of the ligature character region within the moving range of the moving end.
[0041] Further, the determining of the candidate cutting point of the ligature character region according to the change trend of the number of pixel points of the ligature character region within the preset unit interval in the horizontal direction comprises:
[0042] generating a change curve of the number of pixel points according to the number of pixel points of the ligature character region within the preset unit interval in the horizontal direction;
[0043] calculating a pixel point change slope in the change curve according to the change curve;
[0044] determining a position where the pixel point change slope exceeds a preset value as the candidate cutting point of the ligature character region.
[0045] Further, the determining of the candidate cutting point of the ligature character region according to the change trend of the number of pixel points of the ligature character region within the preset unit interval in the horizontal direction further comprises:
[0046] generating a change curve of the number of pixel points according to the number of pixel points of the ligature character region within the preset unit interval in the horizontal direction;
[0047] determining a wave peak position and a wave trough position in the change curve according to the change curve;
[0048] determining the wave trough position as the candidate cutting point of the ligature character region.
[0049] Further, when the candidate cutting point is multiple, obtaining multiple character features of candidate regions obtained by the multiple candidate cutting points, and screening a target cutting point from the multiple candidate cutting points by combining the multiple character features with a preset screening rule, comprises:
[0050] determining a cutting position combination for the ligature character region according to the multiple candidate cutting points, each cutting position in the cutting position combination comprising at least one candidate cutting point;
[0051] cutting the ligature character region according to the cutting position combination and the candidate cutting point in each cutting position to obtain multiple candidate regions corresponding to each cutting position;
[0052] counting character features in the plurality of candidate regions corresponding to each cutting position, the character features comprising at least character width and character pixel point number;
[0053] determining, according to the character features, a number of candidate regions corresponding to each cutting position that meet single character features;
[0054] determining a candidate cutting point in the cutting position corresponding to the plurality of candidate regions that meet the maximum number of single character features as a target cutting point.
[0055] Further, the determining, according to the character features, a number of candidate regions corresponding to each cutting position that meet single character features comprises:
[0056] for each cutting position corresponding to the plurality of candidate regions, sequentially performing the following steps:
[0057] determining whether the character pixel point number in the candidate region exceeds the minimum value of the single character pixel point number in the preset character attribute set;
[0058] if yes, then determining whether the character width in the candidate region is between the minimum value and the maximum value of the character width of the single character in the preset character attribute set;
[0059] if the character width in the candidate region is between the minimum value and the maximum value of the character width of the single character in the preset character attribute set, then the candidate region meets single character features;
[0060] determining the number of candidate regions that meet single character features.
[0061] Further, the clustering processing the effective pixel points to obtain mutually separated effective character regions comprises:
[0062] counting the pixel point number of the effective pixel points in the to-be-recognized picture in the vertical direction;
[0063] determining a position with a pixel point number of zero and taking the position as a clustering segmentation point;
[0064] segmenting the effective pixel points in the to-be-recognized picture according to the clustering segmentation point to obtain mutually separated effective character regions.
[0065] On the other hand, the present document also provides a verification code picture recognition device, the device comprising:
[0066] a preprocessing module configured to perform binaryzation processing on a to-be-recognized picture to obtain picture effective pixel points;
[0067] An effective character region generation module is configured to cluster the effective pixels to obtain mutually separated effective character regions.
[0068] A processing module is configured to determine single character regions and connected character regions in all the effective character regions according to the effective character regions and a preset character attribute set, the preset character attribute set including preset attribute features of all characters.
[0069] A cutting module is configured to obtain multiple effective characters by a preset cutting rule according to the connected character regions.
[0070] An identification module is configured to obtain an identification result of the picture to be identified by combining a pre-trained identification model according to single characters corresponding to the single character regions and the multiple effective characters in the connected character regions.
[0071] In another aspect, the present document also provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the method described above when executing the computer program.
[0072] Finally, the present document also provides a computer readable storage medium storing a computer program, the computer program being executable on a processor to implement the method described above.
[0073] By the above technical solution, the verification code picture identification method, device, equipment and storage medium provided by the present document can obtain mutually separated effective character regions by performing binarization processing and clustering processing on the picture to be identified, then determine single character regions and connected character regions in all the effective character regions according to a preset character attribute set, and then obtain multiple effective characters by cutting the connected character regions according to a preset cutting rule, and finally input single characters corresponding to the single character regions and the multiple effective characters obtained by cutting into a pre-trained identification model to obtain an identification result of the picture to be identified. The present document can improve the accuracy of verification code identification by accurately cutting the picture to be identified and combining a machine identification model.
[0074] To make the above and other purposes, features and advantages of the present document more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS
[0075] In order to more clearly illustrate the technical solutions in the embodiments or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, the accompanying drawings in the following description only constitute some embodiments of the present disclosure, and for those skilled in the art, other drawings can be obtained based on these accompanying drawings without creative effort.
[0076] Figure 1 An implementation environment schematic diagram of the method provided by the embodiments is shown;
[0077] Figure 2 A step schematic diagram of the verification code picture recognition method provided by the embodiments is shown;
[0078] Figure 3 An effective character region identification process schematic diagram in the embodiments is shown;
[0079] Figure 4 An effective character region identification process schematic diagram in another embodiment is shown;
[0080] Figure 5 A step schematic diagram of the connected character region cutting in the embodiments is shown;
[0081] Figure 6 A verification code cutting schematic diagram in the embodiments is shown;
[0082] Figure 7 A pixel point number change curve schematic diagram in the embodiments is shown;
[0083] Figure 8 A structure schematic diagram of the verification code picture recognition device provided by the embodiments is shown;
[0084] Figure 9 A computer device structure schematic diagram provided by the embodiments is shown.
[0085] Explanation of the accompanying drawings:
[0086] 10, user;
[0087] 20, service terminal;
[0088] 30, processing device;
[0089] 40, recognition device;
[0090] 100, preprocessing module;
[0091] 200, effective character region generation module;
[0092] 300, processing module;
[0093] 400, cutting module;
[0094] 500, identification module;
[0095] 902, computer device;
[0096] 904, processor;
[0097] 906, memory;
[0098] 908, driving mechanism;
[0099] 910, input / output module;
[0100] 912, input device;
[0101] 914, output device;
[0102] 916, presentation device;
[0103] 918, graphical user interface;
[0104] 920, network interface;
[0105] 922, communication link;
[0106] 924, communication bus. DETAILED DESCRIPTION
[0107] The technical solutions in the embodiments herein will be described clearly and completely below with reference to the drawings in the embodiments herein. Obviously, the described embodiments are only part of the embodiments herein, rather than all the embodiments. Based on the embodiments herein, all the other embodiments obtained by those skilled in the art without creative work fall within the scope of protection herein.
[0108] It should be noted that the terms "first", "second", and the like in the specification and claims herein and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments herein described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, device, product, or apparatus that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products, or apparatuses.
[0109] In the prior art, due to the increase in the difficulty of generating the verification code, the normal identification of the user is affected, and then the normal business processing (such as login verification, payment verification, and the like) of the user is affected, which brings great trouble to the user. Therefore, the efficiency and accuracy of the user in identifying the verification code can be improved by using the automatic identification technology to assist the user in identifying the verification code. In the prior art, the efficiency of machine identification of the verification code image is not high, and it is difficult to accurately judge the overlapping characters.
[0110] To solve the above problems, the embodiments of the present specification provide a verification code picture identification method, which can improve the accuracy of automatic identification of the verification code, and then efficiently assist the user. As shown in Figure 1 The method can include a user 10, a business terminal 20, a processing device 30, and an identification device 40. The business terminal 20, the processing device 30, and the identification device 40 are communicatively connected. The user 10 performs corresponding business through the business terminal 20, which can involve account login or payment business, and needs to input the verification code to verify the authenticity of the user 10 and prevent malicious password cracking, thereby improving the security of data or funds. The processing device 30 obtains the verification code picture appearing on the business terminal 20, performs binarization, clustering, cutting, and the like to obtain multiple effective characters and single identifiable characters, and sends the processed characters to the identification device 40. The identification device 40 stores a pre-trained identification model. By inputting the multiple effective characters and the single identifiable characters into the identification model, the character result of the verification code in the business terminal 20 can be obtained, and the identified characters are sent to the business terminal 20 through the processing device 30. The corresponding result is realized on the display interface of the business terminal 20, thereby facilitating the user to correctly input the verification code. In this paper, the automatic identification of the verification code improves the accuracy of the verification code identification, thereby effectively assisting the user to correctly input the verification code and improving the user experience.
[0111] The identification device 40 can be a server. The server can be a standalone physical server, a server cluster composed of multiple physical servers, or a distributed system. The server can also be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms, and the like basic cloud computing services.
[0112] In an optional embodiment, the functions of the processing device 30 can be implemented in the recognition device 40, that is, the recognition device 40 can implement binarization, clustering, and segmentation processing of the image to be recognized, and push the recognition results directly to the service terminal 20. Specifically, the service terminal 20 and the processing device 30 can include, but are not limited to, electronic devices such as smartphones, desktop computers, tablet computers, laptops, smart speakers, digital assistants, augmented reality (AR) / virtual reality (VR) devices, and smart wearable devices. Optionally, the operating system running on the electronic device can include, but is not limited to, Android, iOS, Linux, Windows, etc.
[0113] In addition, it should be noted that Figure 1 What is shown is only one application environment provided by the present disclosure. In actual applications, other application environments may also be included. For example, the training of a target image segmentation model may also be implemented on the processing device 30 .
[0114] Specifically, the embodiments of this document provide a verification code image recognition method that can improve the accuracy of automatic verification code recognition, thereby improving the assistance effect for users. Figure 2 This is a schematic diagram of the steps of a verification code image recognition method provided in the embodiment of this article. This specification provides the method operation steps described in the embodiment or flowchart, but based on conventional or non-creative labor, more or fewer operation steps may be included. The order of steps listed in the embodiment is only one way of executing the steps among many steps, and does not represent the only execution order. When the actual system or device product is executed, it can be executed in the order or in parallel according to the method shown in the embodiment or the accompanying drawings. Specifically, Figure 2 As shown, the method may include:
[0115] S101: Binarize the image to be identified to obtain valid pixels of the image;
[0116] S102: performing clustering processing on the effective pixel points to obtain mutually separated effective character areas;
[0117] S103: determining a single character region and a connected character region in all valid character regions based on the valid character region and a preset character attribute set, wherein the preset character attribute set includes preset attribute features of all characters;
[0118] S104: obtaining a plurality of valid characters according to a preset cutting rule based on the connected character area;
[0119] S105: obtaining the recognition result of the picture to be recognized according to the single character corresponding to the single character region and the multiple effective characters in the conjoined character region, and combining the pre-trained recognition model.
[0120] In the present disclosure, the picture to be recognized is preprocessed and cut to obtain the separated effective character regions, the single character region and the conjoined character region in the effective character regions are determined by combining the preset character attribute set, the conjoined character region is cut to obtain the multiple effective characters, the single character corresponding to the single character region and the multiple effective characters in the conjoined character region are input into the pre-trained recognition model to obtain the recognition result. In the present disclosure, the conjoined character region is automatically cut, and then the machine learning model is combined to improve the accuracy and reliability of the verification code recognition.
[0121] In the present disclosure, after step S105, the following steps can also be included:
[0122] The recognition result is sent to the service terminal to display the recognition result, so that the user can input the corresponding verification code according to the displayed recognition result, thereby improving the accuracy of the user's verification code input.
[0123] The binarization process of the picture to be recognized can be understood as the preprocessing of the picture to be recognized. The specific steps can be as follows: the picture is subjected to gray processing to obtain a gray image of the picture. For example, each pixel point in the picture to be recognized is traversed, and the gray value corresponding to the pixel point is calculated by combining the pixel values of three channels R, G and B and a corresponding operation formula, thereby obtaining the gray image of the picture. The operation formula is set according to the actual situation, for example, Gray = R*0.299 + G*0.587 + B*0.114. After obtaining the gray image, each pixel point in the gray image is subjected to binarization processing by setting a gray threshold. The pixel value of the pixel point exceeding the gray threshold is re-assigned to 255, and the pixel value of the pixel point not exceeding the gray threshold is re-assigned to 0. The gray threshold can also be set according to the actual situation, for example, it can be determined by the OTSU algorithm.
[0124] It can be understood that the effective pixel point is a pixel point whose pixel value is 255 after reassignment, that is, a pixel point having actual meaning and capable of representing a real character feature. However, during the generation of the verification code, interference lines or interference points can also be generated at other positions of the image. In order to improve the reliability of character recognition in the effective character region, the effective character region can also be subjected to noise reduction processing to remove interference pixel points therefrom, such as interference pixel points determined by an 8-neighborhood noise reduction algorithm, and then the interference pixel points are removed. The 8-neighborhood noise reduction algorithm is a common technical means for interference point recognition, and the specific recognition process is not limited in the embodiments of the present specification.
[0125] In the embodiments of the present specification, the clustering processing of the effective pixel points to obtain the mutually separated effective character regions comprises:
[0126] Counting the number of pixel points of the effective pixel points in the to-be-recognized image in the vertical direction;
[0127] Determining a position at which the number of pixel points is zero, and taking the position as a clustering segmentation point;
[0128] According to the clustering segmentation point, the effective pixel points in the to-be-recognized image are segmented to obtain the mutually separated effective character regions.
[0129] Specifically, one pixel point size can be taken as a statistical interval, and the number of pixel points of the effective pixel points in each pixel point size in the horizontal direction is counted, that is, the number of pixel points of the effective pixel points in the vertical direction is counted by vertical projection. The position at which the number of pixel points is zero indicates that the effective pixel points are segmented into two independent regions at the position. In this way, the positions at which the number of pixel points is zero are sequentially determined, and the effective pixel points can be segmented into mutually separated different effective character regions.
[0130] In the embodiments of the present specification, the preset character attribute set comprises preset attribute features of all standard characters; wherein the preset characters can be all standard characters appearing, such as 0-9, A-Z. In some other embodiments, Chinese characters can also be included, which can be Chinese characters commonly used in verification codes or randomly extracted Chinese characters of a preset number, such as 100, 500, 1000, etc. The preset attribute features are attribute features of corresponding characters, such as character height, character width, and character pixel point number. In some other embodiments, other attribute features can also be included, such as character perimeter and character area, which are not limited in the embodiments of the present specification.
[0131] It should be noted that the preset character attribute set is the attribute feature of the standard character, different fonts have different attribute features, as an option, Times New Roman font can be selected, of course, the selected font is used on the basis of obtaining the relevant copyright, and the preset character attribute set can be adapted to the verification code recognition process in various scenes.
[0132] In the embodiments of the present specification, as shown in Figure 3 The determining of the single character region and the connected character region in the all effective character regions according to the effective character region and the preset character attribute set comprises:
[0133] The following steps are performed for each effective character region:
[0134] S201: Obtain the character feature in the effective character region;
[0135] S202: Determine whether the character feature in the effective character region falls within the range of the preset attribute feature in the preset character attribute set;
[0136] S203: If yes, the effective character region is determined as a single character region;
[0137] S204: If no, the effective character region is determined as a connected character region.
[0138] It can be understood that, on the basis of dividing different effective character regions, since the characters in the verification code picture can be deformed, twisted, and rotated, the attribute feature of a single character and the attribute feature of a standard character are also difficult to be completely consistent, and therefore, by analyzing whether the character feature in each effective character region falls within the range of the preset character attribute feature in the preset character attribute set, it can be coarsely determined whether the effective character region is a single character region or a connected character region.
[0139] As an option, the determination of whether the character feature in the effective character region falls within the range of the preset attribute feature in the preset character attribute set further comprises:
[0140] Determining whether the width of the effective character region exceeds the maximum value of the character width in the preset character attribute set;
[0141] If yes, the effective character region is determined as a connected character region;
[0142] If no, it is determined whether the ratio of the width and the height of the effective character region exceeds the maximum value of the ratio of the character width and the character height of a single character in the preset character attribute set;
[0143] if the ratio of the width and the height of the effective character region exceeds the maximum value of the ratio of the character width and the character height of the single character in the preset character attribute set, the effective character region is determined as a conglutination character region;
[0144] if the ratio of the width and the height of the effective character region does not exceed the maximum value of the ratio of the character width and the character height of the single character in the preset character attribute set, the effective character region is determined as a single character region.
[0145] It can be understood that, in this paper, whether the size of the effective character region is within the range of the standard character size is judged by the size of the effective character region, and the conglutination character region can be a character region formed by overlapping characters. Generally, the verification code will not appear completely overlapping (i.e. 100%), otherwise it will greatly affect the user's identification. In the case of partial overlap, the width of the overlapped character will be significantly larger, thus exceeding the maximum value of the standard character width. Therefore, by analyzing the width of the effective character region, it can be determined whether it belongs to the conglutination character region. Further, in some character regions with large overlap, the width of the character may not exceed the maximum value of the standard character width. In the overlapped character, the width / height value will also increase when the width increases. Therefore, the width / height value can also be used to determine whether it belongs to the conglutination character region.
[0146] In further embodiments, due to the existence of distortion, deformation and rotation in the characters of the verification code, it is difficult to directly distinguish single character regions and conglutination character regions by the width of the character and the ratio of the character width and the character height. As an option, if the ratio of the width and the height of the effective character region does not exceed the maximum value of the ratio of the character width and the character height of the single character in the preset character attribute set, the effective character region is determined as a single character region, further comprising:
[0147] determining whether the number of pixel points in the effective character region exceeds the maximum value of the number of pixel points of the single character in the preset character attribute set;
[0148] if the number of pixel points in the effective character region exceeds the maximum value of the number of pixel points of the single character in the preset character attribute set, the effective character region is determined as a conglutination character region;
[0149] if the number of pixel points in the effective character region does not exceed the maximum value of the number of pixel points of the single character in the preset character attribute set, the effective character region is determined as a single character region.
[0150] It can be understood that taking the number of pixel points as a further judgment condition of a single character can effectively avoid the situation of character size change caused by character deformation and distortion, and can further improve the reliability and accuracy of single character judgment. For example, when the character is distorted, its width will change. When the width after distortion exceeds the maximum value of the standard character width, the valid character area cannot be identified by the values of the character width and the character width / height. When the character is distorted, only the shape changes, and the number of pixel points of the character itself does not change or changes very little. Therefore, the number of pixel points of the character can be used to further identify the valid character area.
[0151] As shown in an example of the valid character area recognition in the embodiments of the present specification, Figure 4 may include the following steps:
[0152] Step 1.1: Obtain character features in the valid character area. In this step, the character features include character width, character height, and character pixel point number;
[0153] Step 1.2: Determine whether the character width of the valid character area exceeds the maximum value of the single character width. In this step, if yes, go to step 1.3, if no, go to step 1.6, wherein the maximum value of the single character width can be the maximum value of all widths in the standard character;
[0154] Step 1.3: Determine whether the character width / height ratio of the valid character area exceeds the maximum value of the single character width / height ratio. In this step, if yes, go to step 1.4, if no, go to step 1.6, wherein the maximum value of the single character width / height ratio can be the maximum value of all width / height ratios in the standard character;
[0155] Step 1.4: Determine whether the character pixel point number of the valid character area exceeds the maximum value of the single character pixel point number. In this step, if yes, go to step 1.5, if no, go to step 1.6, wherein the maximum value of the single character pixel point number is the maximum value of all pixel point numbers in the standard character;
[0156] Step 1.5: Determine the valid character area as a single character area;
[0157] Step 1.6: Determine the valid character area as a connected character area.
[0158] The above steps can achieve efficient recognition of the type of the valid character area. First, the size features of the valid character area are used as the recognition condition, and then the pixel point features of the valid character area are used for further recognition, which can reliably determine the type of the valid character area.
[0159] In the embodiments of the present specification, asFigure 5 As shown, the plurality of effective characters are obtained by preset cutting rules according to the conjoined character region, including:
[0160] The following steps are performed for each conjoined character region:
[0161] S301: The number of pixel points of the conjoined character region in a preset unit interval in the horizontal direction is counted in sequence according to the vertical projection method;
[0162] S302: The candidate cutting point of the conjoined character region is determined according to the change trend of the number of pixel points of the conjoined character region in the preset unit interval in the horizontal direction;
[0163] S303: When the candidate cutting point is one, the candidate cutting point is taken as the target cutting point;
[0164] S304: When the candidate cutting point is multiple, the character features of the candidate regions obtained by the multiple candidate cutting points are obtained, and the target cutting point is screened from the multiple candidate cutting points by combining the multiple character features with the preset screening rule;
[0165] S305: The conjoined character region is cut according to the target cutting point, and the plurality of effective characters after cutting are obtained.
[0166] It can be understood that when the effective character region is a single character region, it does not need to be segmented, and when the effective character region is a conjoined character region, the conjoined character region needs to be cut to obtain the plurality of effective characters contained therein. The preset unit interval can be a pixel point interval, so that the number of pixel points of the conjoined character region in the horizontal direction can be obtained in sequence, and the change trend of the number of pixel points is used to determine the candidate cutting point, which can improve the efficiency of determining the candidate cutting point.
[0167] When the candidate cutting point is one, it means that the conjoined character region is formed by the overlap of two characters, so there is a cutting position, and the position (i.e. the candidate cutting point) is determined as the target cutting point.
[0168] When the candidate cutting point is multiple, it may mean that the conjoined character region is formed by the overlap of more than two characters, or the character appears distorted and overlapped, etc. In the embodiments of the present specification, only the case of the conjoined character region formed by the overlap of more than two characters is considered, so as to facilitate judging whether the candidate cutting point is determined as the target cutting point by the character region after cutting.
[0169] In the embodiments of the present specification, the pixel point number of the coalesced character region in a preset unit interval in the horizontal direction is sequentially counted according to the vertical projection method, including:
[0170] A minimum character width is determined from the preset character attribute set, and the minimum character width is taken as an initial width of a specified window, the specified window including a fixed end and a moving end;
[0171] The fixed end of the specified window is placed on one side of the coalesced character region, and the moving end of the specified window is placed on the other side of the coalesced character region with the initial width;
[0172] The moving end is sequentially moved by a preset unit interval away from the fixed end;
[0173] The pixel point number of the coalesced character region in the moving range of the moving end is obtained.
[0174] Exemplarily, the character width of "I or i" is the minimum character width, and the character width is taken as the initial width of the specified window. The initial width of the specified window can be understood as the minimum window for recognizing characters. When the initial width is less than the minimum character width, the valid character cannot be recognized. By setting the specified window, the efficiency of valid character recognition can be improved, and the speed of verification code recognition is improved.
[0175] As shown in Figure 6 , the coalesced character region formed after the three characters "A", "B" and "C" overlap, and the window composed of x0 and x1 is the initial position of the specified window, wherein x0 is the fixed end of the specified window, and x1 is the moving end of the specified window. The specified window is set on the left side of the coalesced character region, x1 is sequentially moved to the right by a preset unit interval, and the total number of pixel points in the preset unit interval in the vertical direction is counted. In this way, multiple pixel point numbers can be obtained by sequentially moving multiple times, until the moving end moves to the rightmost side of the coalesced character region. Of course, the specified window can also be set on the rightmost side of the coalesced character region, so that the moving end moves to the left to obtain the pixel point number in each preset unit interval.
[0176] On the basis of obtaining the pixel point numbers at different positions, the candidate cutting points of the coalesced character region can also be determined by the change trend of the pixel point numbers. As an option, the following steps can be included:
[0177] According to the pixel point number of the coalesced character region in a preset unit interval in the horizontal direction, a change curve of the pixel point number is generated;
[0178] According to the change curve, the pixel point change slope in the change curve is calculated and obtained;
[0179] The position where the pixel point change slope exceeds a preset value is determined as a candidate cutting point of the adhered character area.
[0180] It can be understood that for a single character, the number of pixels in the horizontal direction (i.e., the number of pixels in the vertical direction of the character is counted sequentially from the horizontal direction) has a basically consistent change trend, that is, the pixels rarely undergo a large mutation. When characters overlap, the number of pixels in the overlapping area will change significantly relative to the previous position, so on the continuous change curve, it will cause the curve at the beginning of the overlap to suddenly rise. Therefore, the candidate cutting point can be determined by the slope of the curve change. The preset value can be set according to actual conditions, such as 2, 5, etc., and is not limited in the embodiments of this specification.
[0181] It should be noted that determining candidate cutting points by the slope of the curve change is a method with a higher success rate. However, for some special characters, the curve change rate of the number of pixels of a single character may exceed the preset value. This situation is not within the scope of this specification.
[0182] In some other embodiments, in addition to determining the candidate cutting point by the slope, the following methods can also be used to determine the candidate cutting point:
[0183] generating a change curve of the number of pixels according to the number of pixels in a preset unit interval in the horizontal direction of the adhesion character area;
[0184] According to the change curve, determining the peak position and the trough position of the change curve;
[0185] The trough position is determined as a candidate cutting point of the connected character area.
[0186] It can be understood that judging the candidate cutting points by the trough position can effectively combine the change characteristics of the number of pixel points after the characters overlap and the curve change trend. After the characters overlap, the overlapping part must be at the trough position, such as Figure 7 As shown in the figure, it is a curve showing the change of the number of pixel points. It can be seen that there are two trough positions at positions m and n, so m and n can be used as candidate cutting points. This paper can find the candidate cutting points visually and intuitively, thereby improving the efficiency and reliability of determining the candidate cutting points.
[0187] In the embodiment of the present specification, when there are multiple candidate cutting points, multiple character features of the candidate area obtained from the multiple candidate cutting points are obtained, and the target cutting point is screened out from the multiple candidate cutting points by combining the multiple character features with preset screening rules, including:
[0188] determining a cutting position combination for the conjoined character region according to the plurality of candidate cutting points, each cutting position in the cutting position combination comprising at least one candidate cutting point;
[0189] cutting the conjoined character region according to the cutting position combination and the candidate cutting points in each cutting position to obtain a plurality of candidate regions corresponding to each cutting position;
[0190] counting character features in the plurality of candidate regions corresponding to each cutting position, the character features comprising at least character width and character pixel point number;
[0191] determining a number of candidate regions corresponding to each cutting position that meet single character features according to the character features;
[0192] determining the candidate cutting points in the cutting position corresponding to the plurality of candidate regions that meet the maximum number of single character features as target cutting points.
[0193] It can be understood that different cutting positions correspond to different candidate cutting point combinations, so that the cutting position combination can be obtained, and then the cutting position with the best cutting effect is selected from the cutting position combination, and the candidate cutting point corresponding to the best cutting position is taken as the target cutting point, wherein the cutting effect is the best, that is, the single character region obtained by cutting is the most, and an example is shown in FIG. 8. Figure 7 As shown in the figure, two candidate cutting points a and b are determined through the above steps, so that three cutting positions a, b and a and b are formed, and a cutting position combination composed of three cutting positions is obtained. Three different candidate region combinations can be obtained through the three cutting positions. The cutting position corresponding to the candidate region combination with the maximum number of single character features is taken as the target cutting position, and correspondingly, the candidate cutting points in the target cutting position are taken as the target cutting points. Through the combination of different candidate cutting points, the points that can effectively divide the conjoined character region can be quickly determined, so that the problem of too much or too little cutting is avoided.
[0194] In a further embodiment, the determining of the number of candidate regions corresponding to each cutting position that meet single character features according to the character features comprises:
[0195] for each cutting position corresponding to the plurality of candidate regions, the following steps are performed in sequence:
[0196] determining whether the number of character pixel points in the candidate region exceeds the minimum value of the number of single character pixel points in the preset character attribute set;
[0197] If yes, it is determined whether the character width in the candidate region is between the minimum and maximum of the character width of a single character in the preset character attribute set;
[0198] If the character width in the candidate region is between the minimum and maximum of the character width of a single character in the preset character attribute set, the candidate region meets the single character feature;
[0199] The number of candidate regions meeting the single character feature is determined.
[0200] It can be understood that, by extracting the character features such as the character width and the number of character pixels in each candidate region, and then comparing the character features with the features of the standard character, it is determined whether the candidate region meets the single character feature. Since the cut candidate region may also be distorted, rotated, or even partially overlapped, the character features of the candidate region are difficult to be consistent with the character features of the standard character. In this paper, the character features of the candidate region are compared with the range of the character features of the standard character, which can greatly identify the type of the candidate region, thereby improving the reliability of identifying the type of the candidate region.
[0201] It should be noted that, in the embodiments of the present specification, the number of pixels and the character width can be used to determine whether the candidate region meets the single character feature. In some other embodiments, other judgment conditions or standards can also be used, which are not limited in the embodiments of the present specification.
[0202] In the embodiments of the present specification, the pre-trained recognition model can be obtained by the following steps:
[0203] Step 2.1: Obtain training set data, which includes pre-labeled verification code pictures. As an option, the training set data can be obtained by a verification code generation program;
[0204] Step 2.2: Preprocess the training set data to obtain a plurality of valid characters corresponding to each verification code picture.
[0205] Step 2.3: Input the plurality of valid characters corresponding to each verification code picture into an initial training model to obtain a prediction result.
[0206] Step 2.4: According to the preset result and the annotation result of the verification code picture, the initial training model is trained to obtain a recognition model for the verification code picture.
[0207] The model training process can quickly obtain the recognition model for the verification code picture. The model training process is a conventional training process. The recognition model can be a convolutional neural network (CNN) model. In some other embodiments, other machine learning models can also be used, which are not limited in the embodiments of the present specification.
[0208] The preprocessing of the verification code picture in step 2.2 can include the following steps.
[0209] Step 2.2.1: binarizing the verification code picture in the training set data to obtain valid pixel points of the picture.
[0210] Step 2.2.2: clustering the valid pixel points to obtain mutually separated valid character regions.
[0211] Step 2.2.3: determining single character regions and connected character regions in all valid character regions according to the valid character regions and a preset character attribute set, wherein the preset character attribute set includes preset attribute features of all characters.
[0212] Step 2.2.4: obtaining multiple valid characters from the connected character regions according to the connected character regions and a preset cutting rule.
[0213] Step 2.2.5: determining single characters corresponding to the single character regions and the multiple valid characters in the connected character regions as multiple valid characters corresponding to the verification code picture.
[0214] It can be understood that the preprocessing process of the training set data and the processing process of the to-be-recognized picture in the recognition process are consistent, which can quickly and efficiently determine the valid characters in the verification code picture, thereby improving the speed and accuracy of subsequent model training.
[0215] Based on the same inventive concept, the embodiments of the present specification also provide a verification code picture recognition device, as shown in Figure 8 The device includes:
[0216] The preprocessing module 100 is configured to binarize the to-be-recognized picture to obtain valid pixel points of the picture.
[0217] The valid character region generation module 200 is configured to cluster the valid pixel points to obtain mutually separated valid character regions.
[0218] The processing module 300 is configured to determine single character regions and connected character regions in all valid character regions according to the valid character regions and a preset character attribute set, wherein the preset character attribute set includes preset attribute features of all characters.
[0219] A cutting module 400 is configured to obtain a plurality of valid characters according to a preset cutting rule based on the connected character area;
[0220] The recognition module 500 is used to obtain a recognition result of the image to be recognized based on the single character corresponding to the single character area and the multiple valid characters in the contiguous character area in combination with a pre-trained recognition model.
[0221] The beneficial effects achieved by the above-mentioned device are consistent with the beneficial effects achieved by the above-mentioned method, and are not described in detail in the embodiments of this specification.
[0222] like Figure 9 As shown, a computer device provided in an embodiment of this document is shown. The apparatus herein may be a computer device in this embodiment, executing the method described above. The computer device 902 may include one or more processors 904, such as one or more central processing units (CPUs), each of which may implement one or more hardware threads. The computer device 902 may also include any memory 906 for storing any type of information, such as code, settings, data, etc. For example, without limitation, the memory 906 may include any one or more combinations of the following: any type of RAM, any type of ROM, a flash memory device, a hard disk, an optical disk, etc. More generally, any memory may use any technology to store information. Furthermore, any memory may provide volatile or non-volatile retention of information. Furthermore, any memory may represent a fixed or removable component of the computer device 902. In one embodiment, when the processor 904 executes associated instructions stored in any memory or combination of memories, the computer device 902 may perform any operation of the associated instructions. The computer device 902 also includes one or more drive mechanisms 908, such as a hard disk drive mechanism, an optical disk drive mechanism, etc., for interacting with any memory.
[0223] The computer device 902 may also include an input / output module 910 (I / O) for receiving various inputs (via input devices 912) and providing various outputs (via output devices 914). A specific output mechanism may include a presentation device 916 and an associated graphical user interface (GUI) 918. In other embodiments, the input / output module 910 (I / O), input devices 912, and output devices 914 may not be included, and the computer device 902 may simply be a computer device in a network. The computer device 902 may also include one or more network interfaces 920 for exchanging data with other devices via one or more communication links 922. One or more communication buses 924 couple the components described above together.
[0224] The communication links 922 can be implemented in any manner, such as through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication links 922 can include any combination of hardwired links, wireless links, routers, gateway functionality, name servers, etc., governed by any protocol or combination of protocols.
[0225] Corresponding to the method in Figures 2-5 The embodiments herein also provide a computer-readable storage medium, having stored thereon a computer program, which, when executed by a processor, performs the steps of the above-mentioned method.
[0226] The embodiments herein also provide a computer-readable instruction, wherein the program in the computer-readable instruction, when executed by a processor, causes the processor to perform the method as shown in Figures 2 to 5
[0227] It should be understood that the size of the sequence number of the above-mentioned procedures in the various embodiments herein does not mean the order of execution, and the execution order of the procedures should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments herein.
[0228] It should also be understood that in the embodiments herein, the term "and / or" is only a description of the association relationship of the associated objects, which means that there can be three relationships. For example, A and / or B can represent the following three cases: A exists alone, A and B exist together, and B exists alone. In addition, the character " / " in this paper generally represents that the front and rear associated objects are in an "or" relationship.
[0229] Those skilled in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in the above description in general terms. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this paper.
[0230] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-mentioned system, device and unit can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.
[0231] In several embodiments provided herein, it should be understood that the disclosed system, apparatus and method can be implemented in other manners. For example, the apparatus embodiments described above are merely schematic. For example, the division of the units is only a logical function division. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections can be indirect couplings or communication connections through some interfaces, devices or units, and can be in electric, mechanical or other form.
[0232] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e. may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiments provided herein.
[0233] In addition, each functional unit in each embodiment herein can be integrated into a processing unit, or each unit can be physically present separately, or two or more units can be integrated into one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0234] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on this understanding, the technical solutions herein, essentially or the part of the prior art that contributes to the technical solutions, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment herein. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0235] The specific embodiments are applied herein to describe the principles and implementation manners of the embodiments herein. The above description of the embodiments is only for the purpose of helping to understand the methods and their core ideas; meanwhile, for those skilled in the art, according to the ideas herein, the specific implementation manners and application ranges can be changed; and in view of the above, the content of the specification should not be understood as limiting the embodiments herein.
Claims
1. A verification code image recognition method, characterized in that: The method comprises: Binarize the image to be identified to obtain valid pixels of the image; Clustering the valid pixels to obtain mutually separated valid character regions includes: counting the number of valid pixels in the image to be identified in a vertical direction; determining a position where the number of pixels is zero, and using the position as a cluster segmentation point; and segmenting the valid pixels in the image to be identified based on the cluster segmentation point to obtain mutually separated valid character regions. Determining a single character area and a contiguous character area in all valid character areas based on the valid character area and a preset character attribute set, wherein the preset character attribute set includes preset attribute features of all characters; the preset attribute features include character height, character width, and number of character pixels; According to the connected character area, a plurality of valid characters are obtained by using a preset cutting rule; Obtaining a recognition result of the image to be recognized based on the single character corresponding to the single character area and the multiple valid characters in the contiguous character area, in combination with a pre-trained recognition model; The preset cutting rules include: Perform the following steps for each glue character area: According to the vertical projection method, the number of pixels in the preset unit interval in the horizontal direction of the adhesion character area is counted in sequence; Determining candidate cutting points of the adhered character area according to a change trend of the number of pixels within a preset unit interval in the horizontal direction of the adhered character area; When there is only one candidate cutting point, the candidate cutting point is used as the target cutting point; When there are multiple candidate cutting points, multiple character features of the candidate area obtained from the multiple candidate cutting points are obtained, and a target cutting point is screened out from the multiple candidate cutting points by combining the multiple character features with preset screening rules, including: determining a cutting position combination for the contiguous character area based on the multiple candidate cutting points, each cutting position in the cutting position combination including at least one candidate cutting point; According to the cutting position combination and the candidate cutting points in each cutting position, the connected character area is cut to obtain a plurality of candidate areas corresponding to each cutting position; Counting the character features in the multiple candidate areas corresponding to each cutting position, wherein the character features include at least the character width and the number of character pixels; According to the character feature, determining the number of candidate regions corresponding to each cutting position that meet the single character feature; Determine the candidate cutting point among the cutting positions corresponding to the plurality of candidate regions that meet the largest number of single character features as the target cutting point; According to the target cutting point, the contiguous character area is cut to obtain a plurality of valid characters after cutting.
2. The method according to claim 1, characterized in that The determining of the single character area and the contiguous character area in all valid character areas according to the valid character area and the preset character attribute set includes: Perform the following steps for each valid character area: Acquire character features in the valid character area; Determining whether the character feature in the valid character area falls within the range of the preset attribute features in the preset character attribute set; If so, determining the valid character area as a single character area; If not, the valid character area is determined as a glued character area.
3. The method according to claim 2, characterized in that The step of determining whether the character features in the valid character area fall within the range of the preset attribute features in the preset character attribute set further comprises: Determine whether the width of the valid character area exceeds the maximum character width in the preset character attribute set; If so, the valid character area is determined as a glued character area; If not, determining whether the ratio of the width to the height of the valid character area exceeds the maximum value of the ratio of the character width to the character height of a single character in the preset character attribute set; If the ratio of the width to the height of the valid character area exceeds the maximum value of the ratio of the character width to the character height of a single character in the preset character attribute set, the valid character area is determined as a contiguous character area; If the ratio of the width to the height of the valid character area does not exceed the maximum value of the ratio of the character width to the character height of a single character in the preset character attribute set, the valid character area is determined to be a single character area.
4. The method according to claim 3, characterized in that If the ratio of the width to the height of the valid character area does not exceed the maximum value of the ratio of the character width to the character height of a single character in the preset character attribute set, determining the valid character area as a single character area further includes: Determining whether the number of pixels in the valid character area exceeds the maximum number of pixels of a single character in the preset character attribute set; If the number of pixels in the valid character area exceeds the maximum number of pixels of a single character in the preset character attribute set, the valid character area is determined as a contiguous character area; If the number of pixels in the valid character area does not exceed the maximum number of pixels of a single character in the preset character attribute set, the valid character area is determined to be a single character area.
5. The method according to claim 1, wherein The method of sequentially counting the number of pixels in a preset unit interval in the horizontal direction of the adhesion character area according to the vertical projection method includes: Determining a minimum character width from the preset character attribute set, and using the minimum character width as an initial width of a designated window, the designated window including a fixed end and a mobile end; placing the fixed end of the designated window on one side of the sticky character area, and placing the movable end of the designated window on the other side of the sticky character area with the initial width; Moving the mobile end sequentially toward a side away from the fixed end by a preset unit interval; The number of pixels in the sticky character area within the moving range of the mobile terminal is obtained.
6. The method according to claim 1, characterized in that The determining of the candidate cutting points of the adhered character area according to a change trend of the number of pixels within a preset unit interval in the horizontal direction of the adhered character area includes: generating a change curve of the number of pixels according to the number of pixels in a preset unit interval in the horizontal direction of the adhesion character area; According to the change curve, calculating and obtaining the change slope of the pixel points in the change curve; The position where the pixel point change slope exceeds a preset value is determined as a candidate cutting point of the adhered character area.
7. The method according to claim 1, characterized in that The step of determining the candidate cutting points of the adhered character region according to a change trend of the number of pixels within a preset unit interval in the horizontal direction of the adhered character region further includes: generating a change curve of the number of pixels according to the number of pixels in a preset unit interval in the horizontal direction of the adhesion character area; According to the change curve, determining the peak position and the trough position of the change curve; The trough position is determined as a candidate cutting point of the connected character area.
8. The method according to claim 1, characterized in that The step of determining the number of candidate regions corresponding to each cutting position that meet the single character feature based on the character feature includes: For each candidate region corresponding to a cutting position, the following steps are performed in sequence: Determining whether the number of character pixels in the candidate area exceeds the minimum number of single character pixels in the preset character attribute set; If yes, continue to determine whether the character width in the candidate area is between the minimum value and the maximum value of the character width of a single character in the preset character attribute set; If the character width in the candidate area is between the minimum and maximum values of the character width of a single character in the preset character attribute set, then the candidate area meets the single character feature; Determine the number of candidate regions that meet the characteristics of a single character.
9. A verification code image recognition device, characterized in that: The device comprises: The pre-processing module is used to perform binarization processing on the image to be identified to obtain the effective pixel points of the image; The valid character region generation module is configured to cluster the valid pixels to obtain mutually separated valid character regions, comprising: counting the number of valid pixels in the image to be identified in the vertical direction; determining a position where the number of pixels is zero, and using the position as a cluster segmentation point; and segmenting the valid pixels in the image to be identified based on the cluster segmentation point to obtain mutually separated valid character regions. a processing module, configured to determine, based on the valid character area and a preset character attribute set, a single character area and a contiguous character area in all valid character areas, wherein the preset character attribute set includes preset attribute features of all characters; the preset attribute features include character height, character width, and number of character pixels; A cutting module, configured to obtain a plurality of valid characters according to a preset cutting rule based on the connected character area; a recognition module, configured to obtain a recognition result of the image to be recognized based on the single character corresponding to the single character area and the multiple valid characters in the contiguous character area, in combination with a pre-trained recognition model; The preset cutting rules include: Perform the following steps for each glue character area: According to the vertical projection method, the number of pixels in the preset unit interval in the horizontal direction of the adhesion character area is counted in sequence; Determining candidate cutting points of the adhered character area according to a change trend of the number of pixels within a preset unit interval in the horizontal direction of the adhered character area; When there is only one candidate cutting point, the candidate cutting point is used as the target cutting point; When there are multiple candidate cutting points, multiple character features of the candidate area obtained from the multiple candidate cutting points are obtained, and a target cutting point is screened out from the multiple candidate cutting points by combining the multiple character features with preset screening rules, including: determining a cutting position combination for the contiguous character area based on the multiple candidate cutting points, each cutting position in the cutting position combination including at least one candidate cutting point; According to the cutting position combination and the candidate cutting points in each cutting position, the connected character area is cut to obtain a plurality of candidate areas corresponding to each cutting position; Counting the character features in the multiple candidate areas corresponding to each cutting position, wherein the character features include at least the character width and the number of character pixels; According to the character feature, determining the number of candidate regions corresponding to each cutting position that meet the single character feature; Determine the candidate cutting point among the cutting positions corresponding to the plurality of candidate regions that meet the largest number of single character features as the target cutting point; According to the target cutting point, the contiguous character area is cut to obtain a plurality of valid characters after cutting.
10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Verification method and device based on handwritten character recognition
CN106951832A
Verification code identification method and device, terminal and storage medium
CN109919160A