WO2019237549A1 - 验证码识别方法、装置、计算机设备及存储介质 - Google Patents

验证码识别方法、装置、计算机设备及存储介质 Download PDF

Info

Publication number
WO2019237549A1
WO2019237549A1 PCT/CN2018/106400 CN2018106400W WO2019237549A1 WO 2019237549 A1 WO2019237549 A1 WO 2019237549A1 CN 2018106400 W CN2018106400 W CN 2018106400W WO 2019237549 A1 WO2019237549 A1 WO 2019237549A1
Authority
WO
WIPO (PCT)
Prior art keywords
verification code
picture
character
recognition result
code picture
Prior art date
Application number
PCT/CN2018/106400
Other languages
English (en)
French (fr)
Inventor
蔡俊
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2019237549A1 publication Critical patent/WO2019237549A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/30Authentication, i.e. establishing the identity or authorisation of security principals
    • G06F21/31User authentication
    • G06F21/36User authentication by graphic or iconic representation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/23Clustering techniques
    • G06F18/232Non-hierarchical techniques
    • G06F18/2321Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions
    • G06F18/23213Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions with fixed number of clusters, e.g. K-means clustering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4038Image mosaicing, e.g. composing plane images from plane sub-images
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/26Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
    • G06V10/267Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion by performing operations on regions, e.g. growing, shrinking or watersheds
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/30Noise filtering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/14Image acquisition
    • G06V30/148Segmentation of character regions
    • G06V30/153Segmentation of character regions using recognition of characters or words
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition

Definitions

  • the present application relates to the field of finance, and in particular, to a method, a device, a computer device, and a storage medium for identifying a verification code.
  • the website has set some resource information that requires an account password to log in to browse, and at the same time set an account password
  • a verification code picture is also set on the basis of login.
  • the original content of the verification code in the verification code picture does not need to be changed to the time required to manually enter the verification code content in the verification code picture Information, resulting in low efficiency in obtaining resource information.
  • a verification code identification method includes: obtaining a verification code picture to be identified on a target website; performing recognition processing on the verification code picture to be identified based on Tesseract to obtain a recognition result corresponding to the verification code picture to be identified, wherein Tesseract Is an optical character recognition tool; judging whether the recognition result is a formula; if the recognition result is a formula, filling a calculation result corresponding to the recognition result into an input box corresponding to the verification code picture to be recognized; if If the recognition result is a non-calculation formula, then the recognition result is filled in an input box corresponding to the verification code picture to be recognized.
  • a verification code recognition device includes: a recognition processing module for recognizing the verification code picture to be identified based on Tesseract to obtain a recognition result corresponding to the verification code picture to be identified, wherein Tesseract is an optical character A recognition tool; a judgment module for determining whether the recognition result is a formula; a first filling module for filling the calculation result corresponding to the recognition result into the verification to be recognized if the recognition result is a formula An input box corresponding to the code picture; a second filling module, configured to fill the recognition result into the input box corresponding to the verification code picture to be recognized if the recognition result is a non-calculation formula;
  • a computer device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and the processor implements the verification code identification method when the processor executes the computer-readable instructions A step of.
  • One or more non-volatile readable storage media storing computer-readable instructions, which when executed by one or more processors, cause the one or more processors to execute the verification code Identify method steps.
  • FIG. 1 is a schematic diagram of an application environment of a verification code identification method according to an embodiment of the present application
  • FIG. 2 is a flowchart of a verification code identification method according to an embodiment of the present application.
  • step S20 is a flowchart of step S20 in the verification code identification method according to an embodiment of the present application.
  • step S30 is a flowchart of step S30 in the verification code identification method according to an embodiment of the present application.
  • FIG. 5 is a flowchart of preprocessing a verification code picture to be identified in a verification code identification method according to an embodiment of the present application
  • FIG. 6 is a picture to be identified that is not processed by the interference line in the verification code identification method according to an embodiment of the present application.
  • FIG. 7 is a picture to be identified in the verification code identification method according to an embodiment of the present application, which has been processed without interference lines;
  • FIG. 8 is a binarization diagram without denoising processing in the verification code identification method according to an embodiment of the present application.
  • FIG. 9 is a picture of a verification code to be identified in the verification code identification method according to an embodiment of the present application.
  • FIG. 10 is a flowchart for identifying each to-be-identified verification code picture on each target website in the verification code identification method according to an embodiment of the present application;
  • FIG. 11 is a schematic diagram of a verification code identification device according to an embodiment of the present application.
  • FIG. 12 is a schematic diagram of a computer device according to an embodiment of the present application.
  • the server obtains the to-be-recognized verification code picture on the client's target website, and the server performs recognition processing on the to-be-recognized verification code picture based on Tesseract to obtain the recognition result corresponding to the to-be-recognized verification code picture.
  • the server determines whether the recognition result is an expression. If the result is a formula, the server fills the calculation result corresponding to the recognition result into the input box corresponding to the verification code picture. If the recognition result is not a formula, the server fills the recognition result into the input box corresponding to the verification code picture.
  • the computer device may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices.
  • the server can be implemented by an independent server or a server cluster composed of multiple servers.
  • a verification code identification method is provided.
  • the verification code identification method is applied in the financial industry.
  • the method is applied to the server in FIG. 1 as an example for description, and includes the following steps. :
  • the target website refers to a website corresponding to the resource information to be obtained.
  • the target website is successfully logged in, and the path information of the verification code picture to be identified is obtained, and then, the verification code picture to be identified is extracted on the target website according to the path information of the verification code picture.
  • Tesseract is a widely used open source OCR tool.
  • OCR full name of English is Optical Character Recognition
  • Chinese name is Optical Character Recognition, which means that electronic equipment checks characters printed on paper, determines its shape by detecting dark and light patterns, and then uses character recognition to translate the shape into computer text. process.
  • the recognition code image to be identified on the target website is processed to obtain the recognition result corresponding to the picture to be identified.
  • the expression refers to an expression containing an equal sign "##
  • the recognition result corresponding to the verification code picture to be identified on the target website is an equation
  • the calculation result corresponding to the recognition result is filled into an input box corresponding to the verification code picture to be identified.
  • step S40 In order to better understand step S40, an example is described below, and the specific expression is as follows:
  • the target website is the official website of China Railway Freight
  • the picture of the verification code to be identified is the page picture of the truck number and ticket number of the cargo
  • the recognition result corresponding to the verification code picture to be identified on the target website is a non-calculation formula
  • the recognition result is filled into an input box corresponding to the verification code picture to be identified.
  • step S20 is specifically performing recognition processing on the Tesseract verification code picture to obtain a recognition result corresponding to the verification code picture. It includes the following steps:
  • S201 Segment the to-be-identified verification code picture by using the vertical projection method to obtain each sub- verification code picture;
  • the vertical projection method refers to a method in which the number of stroke pixels of a binarized character pattern is counted in the vertical direction, and the boundary of the character is determined by detecting the troughs on the vertical projection graph obtained.
  • the sub verification code picture refers to a verification code sub picture corresponding to each character obtained after each character on the verification code picture to be identified is segmented.
  • a vertical projection method is used to segment the to-be-recognized verification code picture on the target website to obtain each sub- verification code picture.
  • step S201 In order to better understand step S201, an example is described below, and the specific expression is as follows:
  • the target website is the official website of Jiangsu Online Vehicle Administration Institute
  • the image of the verification code to be identified is the picture of the license plate "Su E.UK722”
  • the vertical projection method is used to segment the picture of "Su E.UK722” to obtain "E", "U”, “K”, “7”, "2", and "2" pictures.
  • S202 Normalize the size of each sub-CAPTCHA image according to a preset size specification to obtain each standardized sub-CAPTCHA image;
  • the size normalization refers to the size of a single character on a verification code picture is reduced to the same size.
  • the preset size can be 6cm * 10cm. cm, the Chinese name for centimeters, refers to a unit of length.
  • the specific content of the preset size specification can be set according to the actual application, and there is no limitation here.
  • the sub captcha pictures are subjected to size normalization according to a preset size specification to obtain each standardized sub captcha picture.
  • S203 Recognize each normalized sub-CAPTCHA picture based on Tesseract, and obtain each verification code content information corresponding to each normalized sub-CAPTCHA picture;
  • the verification code content information refers to specific character information on the sub verification code picture.
  • each normalized sub-CAPTCHA image is identified, and content information of each CAPTCHA corresponding to each normalized sub-CAPTCHA image is obtained.
  • S204 splicing the content information of each captcha in order from left to right before segmentation of the captcha picture to obtain the recognition result corresponding to the captcha picture to be identified, and the recognition result includes more than one character;
  • the content information of each verification code is spliced in the order from left to right before segmentation of the verification code picture on the target website to obtain the recognition result corresponding to the verification code picture.
  • the recognition result includes more than one character.
  • the captcha picture is segmented by using a vertical projection method to obtain each sub captcha picture, and then each sub captcha picture is subjected to size normalization processing to obtain each normalized Sub captcha pictures.
  • each standardized captcha picture is identified based on Tesseract to obtain each captcha content information.
  • each captcha content information is spliced to obtain the recognition result.
  • the vertical projection method accurately divides the captcha picture into each sub captcha picture, and then normalizes the sub captcha pictures with different sizes to obtain a standardized sub captcha picture that is easy to identify and read.
  • Tesseract continuously optimized the recognition accuracy to identify the CAPTCHA content information of the standardized sub-CAPTCHA image.
  • CAPTCHA content information was stitched to obtain the required recognition results, thereby improving recognition.
  • the accuracy of the captcha picture was improved.
  • step S30 is specifically determining whether the identification result is a calculation formula. It includes the following steps:
  • S301 arrange each character in the recognition result from left to right, and push each character in the recognition result to the stack in left to right order;
  • the stack is a linear table that is restricted to perform insert or delete operations only at the end of the table. It is a data structure that stores data according to the principle of first-in, first-out, and the data that is entered first is pushed to the bottom of the stack, and finally The data is on the top of the stack. When data needs to be read, the data is popped from the top of the stack.
  • the characters in the recognition result are arranged in order from left to right, and then the characters in the recognition result are pushed into the stack in order from left to right.
  • S302 Arrange the characters in the stack in order from the stack to get the first character out of the stack as the current character.
  • one of the characters in the stack that is the first to be popped from the stack is arranged in the order of the pop-out order as the current character.
  • the operation symbol database is exclusively used to store all operation symbols.
  • the operation symbol can be a logical operation symbol or an expression symbol.
  • the operation symbol database is used to query whether the current character exists. If it exists, the query result of the current character as an operation symbol is obtained; if it does not exist, the query result of the character type of the current character is a non-operation symbol.
  • S304 Determine the character type of the query result according to the query result, where the character type includes an operator type and a non-operator type;
  • the character type includes an operator type and a non-operator type.
  • the character type of the current character is determined as the operator type, and the current character is stored in the target operation symbol database.
  • the character type of the current character is determined as the non-operator type.
  • the character type of the query result is an operator type
  • a preset original value of the operation symbol is obtained as the current quantity.
  • the query result is stored in a standby database so that it can be extracted when needed.
  • the preset original value of the arithmetic symbol can be 0 or 1, etc.
  • the specific content of the preset original value of the arithmetic symbol can be set according to the actual application, which is not limited here.
  • the current character is the last popped character among the characters arranged in the popped order
  • all characters in the target operation symbol database are extracted, and then it is determined whether the number of operation symbols is greater than Or equal to the sum of the original value of the preset arithmetic symbol and the number 2, and whether there is an equal sign character among all the characters in the target arithmetic symbol database.
  • the recognition result is determined as Formula.
  • the recognition is determined.
  • the result is a non-calculus.
  • the current character is not the last popped character among the characters arranged in the order of popping, then the next popped character among the characters arranged in the order of popping is obtained as the current character and returned Go to step S303.
  • step S301 step S302, step S303, step S304, step S305, step S306, step S307, step S308, step S309, step S310, and step S311, an example will be described below, and the specific expression is as follows:
  • each character in the recognition result is pushed onto the stack in order from the left to the right of the recognition result, and the first character that is popped out of the stack is obtained as the current character.
  • the operation symbol query method is adopted. Query the current character to get the query result, and then determine the character type of the query result based on the query result. If the character type of the query result is an operator type, obtain the preset original value of the operation symbol as the current quantity, and use the current quantity Add it to the number 1 to get the quantity result. Finally, determine whether the current character is the last popped character. If so, determine whether the quantity result is greater than or equal to the sum of the original value of the preset arithmetic symbol and the number 2, and the character type.
  • step S303 determines whether the current verification code content information can be accurately distinguished as a calculation formula or a non-calculation formula, thereby improving the accuracy of the verification code identification.
  • the verification code identification method is applied in the financial industry. As shown in FIG. 5, before step S20, the verification code identification method further includes the following steps:
  • the depth-first search algorithm refers to that in an HTML file, when a hyperlink is selected, the linked HTML file will perform a depth-first search, that is, the rest of the search will be performed. You must first search for a single chain in its entirety before the result of the hyperlink. Depth-first search follows the hyperlink on the HTML file until it cannot be further deepened, then returns to a certain HTML file, and then continues to select other hyperlink graph algorithms in the HTML file.
  • HTML files are descriptive text consisting of HTML commands.
  • An HTML command is an instruction composed of HTML.
  • HTML which stands for HyperTextMark-upLanguage, refers to Hypertext Markup Language.
  • the DFS algorithm is used to perform interference removal processing on the pictures to be identified on the target website to obtain the pictures to be identified after the interference is removed.
  • step S61 In order to better understand step S61, an example is described below, and the specific expression is as follows:
  • FIG. 6 is a to-be-recognized picture processed without interference lines
  • FIG. 7 is a to-be-recognized picture processed without interference lines
  • FIG. 6 is obtained by removing interference lines based on DFS.
  • S62 Perform conversion processing on the de-interference verification code picture to obtain a grayscale picture according to a preset conversion method
  • a grayscale picture refers to a picture in which white and black are divided into several levels according to a logarithmic relationship.
  • the RGB color mode is a color standard in the industry. It is obtained by changing the three color channels of R, G, and B and superimposing them on each other. Among them, R represents red and G represents Green, B stands for green. According to a preset conversion method, a calculation formula can be used to convert an RGB color mode picture into a grayscale picture.
  • GREY (R + G + B) / 3, where R, G, and B are the values of the three color channels of the pixel, respectively.
  • GREY Is the gray value corresponding to the pixel, where the gray value range is between 0-255.
  • the specific content of the preset conversion method can be set according to the actual application, and there is no limitation here.
  • each pixel point of the RGB color pattern verification code image to be identified after the interference removal line is sequentially read, and the R, G, and B values of the pixel point are obtained.
  • S63 The clustering algorithm is used to binarize the grayscale image to obtain a binary image
  • the K-means algorithm is a clustering algorithm.
  • This clustering algorithm is one of the data mining algorithms. It refers to clustering around k points in space, and classifies the objects closest to them. An algorithm that iteratively updates the values of each cluster center until the best clustering result is obtained.
  • the binarization process refers to a process in which the gray value of a pixel point on an image is set to 0 or 255, that is, the entire image presents a clear black and white effect.
  • the K-means algorithm is used to calculate the optimal preset threshold, and then the background color and characters of the grayscale image are distinguished.
  • the grayscale value of each pixel on the grayscale image If the gray value is greater than the best preset threshold, the gray value of the pixel is set to 255; if the gray value is less than or equal to the best preset threshold, the gray value of the pixel is Set it to 0, and finally get the binary image.
  • S64 Denoise the binary image by using the flood filling algorithm to obtain the denoised verification code image
  • the FloodFill algorithm also known as the flood fill algorithm, refers to painting all adjacent points of a point with the color of the point and filling it until all the points in the area are filled.
  • Algorithm. Denoising refers to the process of removing noise or noise from a binary image.
  • a FloodFill algorithm is used to perform denoising processing on the binarized picture to obtain a denoised picture to be identified with a verification code.
  • step S90 an example is described below, and the specific expression is as follows:
  • FIG. 8 is a binary image without denoising
  • FIG. 9 is a picture of a verification code to be identified after denoising
  • the FloodFill algorithm is used to perform denoising on FIG. 8 to obtain FIG. 9.
  • the DFS algorithm using a recursive processing method is used to comprehensively remove the interference line processing to obtain a verification code image without remaining interference lines.
  • the FloodFill algorithm using the full-fill method removes all noise from the binarized picture to obtain a completely clean verification code picture, which can avoid misreading the verification code picture due to interference, thereby improving the accuracy of the verification code recognition. .
  • step S10 is specifically obtaining a verification code map to be identified on the target website.
  • the steps include: S101: Obtain each to-be-identified verification code picture on each target website;
  • each verification code picture to be identified is acquired, and then each of the verification code pictures to be identified is extracted from each target website according to the path information of each verification code picture.
  • the verification code identification method further includes the following steps: S65: Determine a verification code picture to be identified among each verification code picture to be identified as the current verification code picture;
  • one of the verification code pictures to be identified on each target website is the current verification code picture.
  • Step S20 is specifically: S201: Perform recognition processing on the current captcha picture based on Tesseract to obtain a recognition result corresponding to the current captcha picture;
  • the current verification code picture is identified based on Tesseract to obtain a recognition result corresponding to the current verification code picture.
  • step S40 the calculation result corresponding to the recognition result is filled into the input box corresponding to the verification code picture to be identified, or in step S50, the recognition result is filled into the input box corresponding to the verification code picture to be identified, the verification code identification method.
  • the method further includes the following steps: S66: Determine an unidentified verification code picture among the verification code pictures to be identified as the current verification code picture, and return to step S201 until each verification code picture to be identified is processed and obtained. Corresponding recognition results;
  • an unidentified verification code picture among the verification code pictures to be identified is determined as the current verification code picture, and the process returns to step S201 until each verification code picture to be identified is identified and a corresponding recognition result is obtained. .
  • each to-be-identified verification code picture on each target website it is determined that one of the to-be-identified verification code pictures is the current verification code picture. Then, based on Tesseract, the current verification code picture is identified to obtain the verification code content information. Next, it is determined whether the verification code content information is an expression. If it is an expression, the calculation result is entered in the input box. If it is not an expression, then Fill in the verification code content information into the input box. Finally, determine the unrecognized verification code picture as the current verification code picture, and return to step S201, until each verification code picture to be identified is identified and processed, and corresponding identification is obtained.
  • each verification code picture on each website corresponding to the resource information that needs to be acquired can be identified in sequence, and there is no need to spend a lot of time to manually enter each verification code content information of each website one by one, thereby improving the acquisition of resource information s efficiency.
  • a verification code identification device corresponds to the verification code identification method in the above embodiment in a one-to-one correspondence.
  • the verification code identification device includes an acquisition module 701, an identification processing module 702, a judgment module 703, a first filling module 704, a second filling module 705, a removing module 706, a conversion module 707, and binarization.
  • the detailed description of each function module is as follows:
  • An obtaining module 701, configured to obtain a picture of a verification code to be identified on a target website
  • the recognition processing module 702 is configured to perform recognition processing on the to-be-recognized verification code picture based on Tesseract to obtain the recognition result corresponding to the to-be-recognized verification code picture, wherein Tesseract is an optical character recognition tool;
  • a judging module 703, configured to judge whether the recognition result is a formula
  • a first filling module 704 configured to fill a calculation result corresponding to the recognition result into an input box corresponding to a picture of a verification code to be recognized if the recognition result is a formula
  • a second filling module 705, configured to fill the recognition result into an input box corresponding to the verification code picture to be recognized if the recognition result is a non-calculation formula
  • a removal module 706, configured to use a depth-first search algorithm to remove interference lines from the to-be-identified verification code picture to obtain the to-be-identified verification code picture after de-interference;
  • a conversion module 707 configured to perform conversion processing on the interference-free to-be-identified verification code picture according to a preset conversion method to obtain a grayscale picture
  • a binarization processing module 708, configured to perform a binarization process on the grayscale image by using a clustering algorithm to obtain a binary image
  • a denoising processing module 709 configured to perform denoising processing on the binarized picture by using a flood filling algorithm to obtain a denoised picture of a verification code to be identified;
  • a first determining module 710 configured to determine a verification code picture to be identified among the verification code pictures to be identified as a current verification code picture
  • the second determining module 711 is configured to determine an unidentified verification code picture among the verification code pictures to be identified as the current verification code picture, and return to execute the identification processing on the current verification code picture based on Tesseract to obtain the current verification code. The step of recognizing the results corresponding to the pictures until each verification code picture to be identified is identified and processed and a corresponding recognition result is obtained.
  • the obtaining module 701 is specifically: a third extraction sub-module 7011, configured to obtain each verification code picture to be identified on each target website;
  • the recognition processing module 702 is specifically: a second discrimination submodule 7025, configured to perform recognition processing on the current captcha picture based on Tesseract to obtain a recognition result corresponding to the current captcha picture;
  • the identification processing module 702 includes:
  • a segmentation submodule 7021 configured to segment the identification verification code picture by using a vertical projection method to obtain each sub verification code picture
  • a normalization sub-module 7022 configured to perform size normalization processing on each sub-CAPTCHA image according to a preset size specification to obtain each normalized sub-CAPTCHA image;
  • a first discrimination sub-module 7023 configured to identify each normalized sub-CAPTCHA picture based on Tesseract, and obtain content information of each CAPTCHA corresponding to each normalized sub-CAPTCHA picture;
  • the splicing sub-module 7024 is configured to splice the content information of each captcha in the order from left to right before the captcha picture segmentation to obtain the recognition result corresponding to the captcha picture to be recognized, and the recognition result includes more than one character.
  • judgment module 703 includes:
  • a push-in sub-module 7031 configured to arrange each character in the recognition result from left to right, and push each character in the recognition result to the stack in left to right order;
  • a first extraction sub-module 7032 configured to obtain the first character from the stack that is the first character out of the stack as the current character according to the order of the stack;
  • a query submodule 7033 configured to query the current character by using an operation symbol query method to obtain a query result
  • a first broken stator module 7034 configured to determine the character type of the query result according to the query result, where the character type includes an operator type and a non-operator type;
  • a second extraction submodule 7035 configured to obtain a preset original value of an operation symbol as the current quantity if the character type of the query result is an operator type
  • An operator sub-module 7036 configured to perform an arithmetic addition operation on the current quantity and the number 1 to obtain the quantity result
  • the first determination sub-module 7037 is used to determine whether the current character is the last one of the characters in the characters arranged in the order of pop-out. If yes, the second determination sub-module 7038 is triggered; if not, the third determination sub-module is triggered. Extraction sub-module 7039;
  • the second determination sub-module 7038 is used to determine whether the quantity result is greater than or equal to the sum of the preset original value of the operation symbol and the number 2, and whether there is an equal sign in all characters whose character type is the operator type, and if so, trigger the first
  • the third extraction sub-module 7039 is configured to obtain the next pop-out character among the characters arranged in the order of pop-out as the current character, obtain the number of results as the current number, and trigger the query sub-module 7033;
  • a second broken stator module 70310 configured to determine a recognition result as a formula
  • the third broken stator module 70311 is configured to determine that the recognition result is a non-calculation formula.
  • Each module in the verification code identification device can be implemented in whole or in part by software, hardware, and a combination thereof.
  • the above-mentioned modules may be embedded in the hardware in or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
  • a computer device is provided.
  • the computer device may be a server, and its internal structure diagram may be as shown in FIG. 12.
  • the computer device includes a processor, a memory, a network interface, and a database connected through a system bus.
  • the processor of the computer device is used to provide computing and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, computer-readable instructions, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer-readable instructions in a non-volatile storage medium.
  • the database of the computer equipment is used to store pictures or data information involved in the verification code identification method.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer-readable instructions are executed by a processor to implement a verification code identification method.
  • a computer device including a memory, a processor, and computer-readable instructions stored on the memory and executable on the processor.
  • the processor implements the verification code of the foregoing embodiment when the processor executes the computer-readable instructions.
  • the steps of the identification method are, for example, steps S10 to S50 shown in FIG. 2.
  • the functions of each module / unit of the verification code identification device in the foregoing embodiment are implemented, for example, the functions of modules 701 to 711 shown in FIG. 11. To avoid repetition, we will not repeat them here.
  • a computer-readable storage medium is provided, the one or more non-volatile storage mediums storing computer-readable instructions, and the computer-readable instructions are executed by one or more processors.
  • the verification code identification method in the foregoing method embodiment is implemented, or the one or more non-volatile readable storage media storing the computer-readable instructions store the computer-readable instructions
  • the function of each module / unit in the verification code identification device in the foregoing device embodiment is implemented when one or more processors execute a computer-readable instruction. To avoid repetition, we will not repeat them here.
  • Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory can include random access memory (RAM) or external cache memory.
  • RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Data Mining & Analysis (AREA)
  • Multimedia (AREA)
  • Computer Security & Cryptography (AREA)
  • General Engineering & Computer Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Probability & Statistics with Applications (AREA)
  • Artificial Intelligence (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Character Discrimination (AREA)

Abstract

一种验证码识别方法、装置、计算机设备及存储介质,所述方法包括:通过获取目标网站上的待识别验证码图片,基于Tesseract对验证码图片进行识别处理,得到识别结果,然后,判断识别结果是否为算式,若是,则将计算结果填入输入框,若否,则将识别结果填入输入框,通过基于Tesseract对验证码图片进行识别,得到验证码内容信息,并当该验证码内容信息为算式时,自动计算出计算结果,将该计算结果或非算式的验证码内容信息填入验证码图片对应的输入框,从而当在目标网站上获取目标资源信息时,不需要花费时间由人工输入目标网站的验证码内容信息,进而提高了获取资源信息的效率。

Description

验证码识别方法、装置、计算机设备及存储介质
本申请以2018年06月11日提交的申请号为201810595668.3,名称为“验证码识别方法、装置、计算机设备及存储介质”的中国发明专利申请为基础,并要求其优先权。
技术领域
本申请涉及金融领域,尤其涉及一种验证码识别方法、装置、计算机设备及存储介质。
背景技术
在信息时代的今天,资源信息对于每个公司都起着至关重要的作用。
由于互联网给人们带来了极大的便捷性,公司的人员常常通过网络到网站上获取资源信息,网站为了保证访问质量,设置了有些资源信息需要账号密码登录后才能浏览,同时在设置账号密码登录的基础上也设置了验证码图片。但是,当用户通过账号密码登录网站获取该网站上的这些资源信息时,由原来不需要输入验证码图片中的验证码内容信息变成了需要花费时间由人工输入验证码图片中的验证码内容信息,从而导致获取资源信息的效率低。
发明内容
基于此,有必要针对上述技术问题,提供一种可以提高获取资源信息的效率的验证码识别方法、装置、计算机设备及存储介质。
一种验证码识别方法,包括:获取目标网站上的待识别验证码图片;基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果,其中,Tesseract为一款光学字符识别工具;判断所述识别结果是否为算式;若所述识别结果为算式,则将所述识别结果对应的计算结果填入所述待识别验证码图片对应的输入框;若所述识别结果为非算式,则将所述识别结果填入所述待识别验证码图片对应的输入框。
一种验证码识别装置,包括:识别处理模块,用于基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果,其中,Tesseract为一款光学字符识别工具;判断模块,用于判断所述识别结果是否为算式;第一填入模块,用于若所述识别结果为算式,则将所述识别结果对应的计算结果填入所述待识别验证码图片对应的输入框;第二填入模块,用于若所述识别结果为非算式,则将所述识别结果填入所述待识别验证码图片对应的输入框。
一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现上述验证码识别方法的步骤。
一个或多个存储有计算机可读指令的非易失性可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行所述验证码识别方法的步骤。
本申请的一个或多个实施例的细节在下面的的附图和描述中提出,本申请的其他特征和优点将从说明书、附图以及权力要求变得明显。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本申请一实施例中验证码识别方法的一应用环境示意图;
图2是本申请一实施例中验证码识别方法的一流程图;
图3是本申请一实施例中验证码识别方法中步骤S20的一流程图;
图4是本申请一实施例中验证码识别方法中步骤S30的一流程图;
图5是本申请一实施例中验证码识别方法中对待识别验证码图片进行预处理的一流程图;
图6是本申请一实施例中验证码识别方法中未去干扰线处理的待识别图片;
图7是本申请一实施例中验证码识别方法中已去干扰线处理的待识别图片;
图8是本申请一实施例中验证码识别方法中未做去噪处理的二值化图;
图9是本申请一实施例中验证码识别方法中已做去噪后的待识别验证码图片;
图10是本申请一实施例中验证码识别方法中对各个目标网站上的各个待识别验证码图片进行识别的一流程图;
图11是本申请一实施例中验证码识别装置的一示意图;
图12是本申请一实施例中计算机设备的一示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。本申请提供的验证码识别方法,可应用在如图1的应用环境中,其中,计算机设备通过网络与服务器进行通信。服务端获取客户端的目标网站上的待识别验证码图片,服务端基于Tesseract对待识别验证码图片进行识别处理,得到待识别验证码图片对应的识别结果,服务端判断识别结果是否为算式,若识别结果为算式,则服务端将识别结果对应的计算结果填入待识别验证码图片对应的输入框,若识别结果为非算式,则服务端将识别结果填入待识别验证码图片对应的输入框。其中,计算机设备可以但不限于各种个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备。服务器可以用独立的服务器或者是多个服务器组成的服务器集群来实现。
在一实施例中,如图2所示,提供一种验证码识别方法,该验证码识别方法应用在金融行业中,以该方法应用在图1中的服务端为例进行说明,包括如下步骤:
S10:获取目标网站上的待识别验证码图片;
在本实施例中,目标网站是指需要获取的资源信息对应的网站。
具体地,首先,成功登录目标网站,并获取待识别验证码图片的路径信息,然后,根据待识别验证码图片的路径信息,在目标网站上提取该待识别验证码图片。
S20:基于Tesseract对待识别验证码图片进行识别处理,得到待识别验证码图片对应的识别结果;
在本实施例中,Tesseract,是一款被广泛使用的开源OCR工具。OCR,英文全称为 Optical Character Recognition,中文名为光学字符识别,是指电子设备检查纸上打印的字符,通过检测暗、亮的模式确定其形状,然后用字符识别方法将形状翻译成计算机文字的过程。
具体地,基于Tesseract对目标网站上的待识别验证码图片进行识别处理,得到待识别验证码图片对应的识别结果。
需要说明的是,待识别验证码图片与识别结果记录着一一对应的关系。
S30:判断识别结果是否为算式;
在本实施例中,算式是指含有等号“=”的式子。
具体地,判断目标网站上的待识别验证码图片对应的识别结果是否为算式。
S40:若识别结果为算式,则将识别结果对应的计算结果填入待识别验证码图片对应的输入框;
具体地,若目标网站上的待识别验证码图片对应的识别结果为算式,则将该识别结果对应的计算结果填入待识别验证码图片对应的输入框。
需要说明的是,待识别验证码图片与输入框记录着一一对应的关系。
为了更好地理解步骤S40,下面通过一个例子进行说明,具体表述如下:
例如,假设目标网站为中国铁路货运官网,待识别验证码图片为查询货物的车号和货票号的页面图片,该待识别验证码图片对应的识别结果为“36+21=”,则,确定中国铁路货运官网上的该待识别验证码图片对应的“36+21=”,则将“36+21=”对应的“57”填入车号输入框。
S50:若识别结果为非算式,则将识别结果填入待识别验证码图片对应的输入框。
具体地,若目标网站上的待识别验证码图片对应的识别结果为非算式,则将该识别结果填入待识别验证码图片对应的输入框。
在图2对应的实施例中,首先,通过获取需要获取的资源信息对应的网站上的验证码图片,基于Tesseract对该验证码图片进行识别处理,得到识别结果,然后,判断识别结果是否为算式,若是,则将该识别结果对应的计算结果填入输入框,若否,则将识别结果填入输入框,通过基于Tesseract对目标资源信息对应的目标网站上的验证码图片进行识别,得到验证码内容信息,并且当该验证码内容信息为算式时,自动计算出该验证码内容信息对应的计算结果,然后,将该计算结果或非算式的验证码内容信息填入验证码图片对应的输入框,从而当在目标网站上获取目标资源信息时,不需要花费时间由人工输入目标网站的验证码内容信息,进而提高了获取资源信息的效率。
在一实施例中,该验证码识别方法应用在金融行业中,如图3所示,步骤S20具体为基于Tesseract对待识别验证码图片进行识别处理,得到待识别验证码图片对应的识别结果。具体包括如下步骤:
S201:采用垂直投影法对待识别验证码图片进行分割,得到各个子验证码图片;
在本实施例中,垂直投影法,是指二值化的字符图形的笔画像素个数进行垂直方向上的统计,通过检测得到的垂直投影图上的波谷来确定字符的边界的方法。子验证码图片是指待识别验证码图片上各个字符被分割后,得到的各个字符对应的验证码子图片。
具体地,采用垂直投影法对目标网站上的待识别验证码图片进行分割,得到各个子验证码图片。
为了更好地理解步骤S201,下面通过一个例子进行说明,具体表述如下:
例如,假设目标网站为江苏网上车管所官网,待识别验证码图片为车牌“苏E.UK722”图片,则采用垂直投影法,将“苏E.UK722”图片进行分割,得到“苏”、“E”、“U”、“K”、“7”、“2”和“2”图片。
S202:按照预设的尺寸规格将各个子验证码图片进行尺寸归一处理,得到各个规格化后的子验证码图片;
在本实施例中,尺寸归一,是指将验证码图片上的单个字符的尺寸进行归为同一个尺 寸。预设的尺寸规格可以为6cm*10cm。cm,中文名为厘米,是指一种长度单位。预设的尺寸规格的具体内容,可以根据实际应用进行设定,此处不做限制。
具体地,按照预设的尺寸规格将各个子验证码图片进行尺寸归一处理,得到各个规格化后的子验证码图片。
S203:基于Tesseract对各个规格化后的子验证码图片进行识别,得到各个规格化后的子验证码图片对应的各个验证码内容信息;
在本实施例中,验证码内容信息是指子验证码图片上的具体字符信息。
具体地,基于Tesseract对各个规格化后的子验证码图片进行识别,得到各个规格化后的子验证码图片对应的各个验证码内容信息。
需要说明的是,规格化后的子验证码图片与验证码内容信息记录着一一对应关系。
S204:按照验证码图片分割前的由左到右的顺序将各个验证码内容信息进行拼接,得到待识别验证码图片对应的识别结果,识别结果包括一个以上字符;
具体地,按照目标网站上的待识别验证码图片分割前的由左到右的顺序将各个验证码内容信息进行拼接,得到该待识别验证码图片对应的识别结果。
需要说明的是,识别结果包括一个以上的字符。
在图3对应的实施例中,首先,通过采用垂直投影法对验证码图片进行分割,得到各个子验证码图片,然后,将各个子验证码图片进行尺寸归一处理,得到各个规格化后的子验证码图片,接下来,基于Tesseract对各个规格化后的子验证码图片进行识别,得到各个验证码内容信息,最后,将各个验证码内容信息进行拼接,得到识别结果,通过采用定位精准的垂直投影法准确地将验证码图片准确地分割成各个子验证码图片,然后,将尺寸不齐的子验证码图片进行尺寸归一,得到便于识别读取的规格化后的子验证码图片,接下来,基于许多机器学习算法不断优化识别精准度的Tesseract识别出规格化后的子验证码图片的验证码内容信息,最后,将各个验证码内容信息拼接得到需要的识别结果,从而提高了识别验证码图片的精准度。
在一实施例中,该验证码识别方法应用在金融行业中,如图4所示,步骤S30具体为判断识别结果是否为算式。具体包括如下步骤:
S301:按照识别结果中的各个字符从左到右顺序排列,并将识别结果中的各个字符按照从左到右顺序排列顺序压入栈;
在本实施例中,栈,是限定仅在表尾进行插入或删除操作的线性表,是一种数据结构,它按照后进先出的原则存储数据,先进入的数据被压入栈底,最后的数据在栈顶,需要读数据的时候从栈顶开始弹出数据。
具体地,首先,按照识别结果中的各个字符从左到右顺序排列,然后,将识别结果中的各个字符按照从左到右顺序排列顺序压入栈中。
S302:按照出栈先后顺序排列从栈中获取各个字符中的最先出栈的一个字符作为当前字符;
具体地,按照出栈先后顺序排列从栈中获取各个字符中的最先出栈的一个字符作为当前字符。
S303:采用运算符号查询方法对当前字符进行查询,得到查询结果;
在本实施例中,运算符号数据库专门用于存储着所有的运算符号。运算符号可以为逻辑运算符号或算式符号。
具体地,在运算符号数据库中查询当前字符是否存在,若存在,则得到该当前字符为运算符号的查询结果;若不存在,则得到该当前字符的字符类型为非运算符号的查询结果。
S304:根据查询结果,确定查询结果的字符类型,其中,字符类型包括运算符类型和非运算符类型;
在本实施例中,字符类型包括运算符类型和非运算符类型。
具体地,若当前字符为运算符号,则将该当前字符的字符类型确定为运算符类型,并将该当前字符存储到目标运算符号数据库中。
若当前字符为非运算符号,则将该当前字符的字符类型确定为非运算符类型。
S305:若查询结果的字符类型为运算符类型,则获取预设的运算符号原始值作为当前数量;
具体地,若查询结果的字符类型为运算符类型,则获取预设的运算符号原始值作为当前数量。
若查询结果的字符类型为非运算符类型,则将该查询结果存储到备用数据库,以便需要用到时进行提取。
需要说明的是,预设的运算符号原始值可以为0或1等,预设的运算符号原始值的具体内容,可以根据实际应用进行设定,此处不做限制。
S306:将当前数量与数字1进行算术相加运算,得到数量结果;
具体地,将当前数量与数字1进行算术相加运算,得到数量结果。
S307:判断当前字符是否为按照出栈先后顺序排列的各个字符中的最后出栈的一个字符;
具体地,判断当前字符是否为按照出栈先后顺序排列的各个字符中的最后出栈的一个字符。
S308:若当前字符是为按照出栈先后顺序排列的各个字符中的最后出栈的一个字符,则判断数量结果是否大于或等于预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中是否存在等号;
具体地,若该当前字符是为按照出栈先后顺序排列的各个字符中的最后出栈的一个字符,则首先,提取目标运算符号数据库中的所有的字符,然后,判断运算符号数量值是否大于或等于预设的运算符号原始值与数字2的和,并且目标运算符号数据库中的所有的字符中是否存在有等号字符。
S309:若数量结果大于或等于所述预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中存在等号,则确定识别结果为算式;
具体地,若计算得到的数量结果大于或等于所述预设的运算符号原始值与数字2的和,并且查询结果的字符类型为运算符类型的所有字符中存在等号,则确定识别结果为算式。
S310:若数量结果不大于或不等于所述预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中不存在等号,则确定识别结果为非算式;
具体地,若计算得到的数量结果不大于或不等于所述预设的运算符号原始值与数字2的和,并且查询结果的字符类型为运算符类型的所有字符中不存在等号则确定识别结果为非算式。
S311:若当前字符不是为按照出栈先后顺序排列的各个字符中的最后出栈的一个字符,则获取按照出栈先后顺序排列的各个字符中的下一个出栈的字符作为当前字符,获取数量结果作为当前数量,返回执行采用运算符号查询方法对当前字符进行查询,得到查询结果的步骤;
具体地,若当前字符不是为按照出栈先后顺序排列的各个字符中的最后出栈的一个字符,则获取按照出栈先后顺序排列的各个字符中的下一个出栈的字符作为当前字符,返回执行步骤S303。
为了更好地理解步骤S301、步骤S302、步骤S303、步骤S304、步骤S305、步骤S306、步骤S307、步骤S308、步骤S309、步骤S310和步骤S311,下面通过一个例子进行说明,具体表述如下:
例如,假设识别结果为“9+7=”,目标运算符号数据库为第一MYSQL数据库,运 算符号数据库为第二MYSQL数据库,预设的运算符号原始值为0,则,按照“9+7=”由左到右顺序将“9”、“+”、“7”和“=”压入栈,获取“=”作为当前字符,确定“=”在第二MYSQL数据库中存在,确定“=”为运算符号,并将“=”记录为运算符类型,并将“=”存储到第一MYSQL数据库中,同时获取0作为当前数量,将0与数字1进行算术相加运算,得到1,接下来,判断当前字符是否为“9”,若是,则提取第一MYSQL数据库中的“+”和“=”,确定4是大于0与数字2的和,且“9”、“+”、“7”和“=”是存在等号,则确定“9+7=”为算式,若“=”不是“9”,则获取“7”作为当前字符,返回执行步骤S303。
在图4对应的实施例中,首先,通过按照识别结果的由左到右顺序排列的将识别结果中的各个字符压入栈,获取最先出栈的字符作为当前字符,采用运算符号查询方法对当前字符进行查询,得到查询结果,然后,根据查询结果,确定查询结果的字符类型,若查询结果的字符类型为运算符类型,则获取预设的运算符号原始值作为当前数量,将当前数量与数字1进行相加,得到数量结果,最后,判断当前字符是否为最后出栈的字符,若是,则判断数量结果是否大于或等于预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中是否存在等号,若是,则确定识别结果为算式,若否,则确定识别结果为非算式,若当前字符不是最后出栈的字符,则获取按下一个出栈的字符作为当前字符,获取数量结果作为当前数量,返回执行采用运算符号查询方法对当前字符进行查询,得到查询结果的步骤,通过栈先入后出的特性,能够保证有序地查询各个字符在运算符号数据库中是否存在,当存在时,则将数量结果加1,接着,判断该字符是否为最后出栈的字符,若是最后出栈的字符,则判断数量结果是否大于或等于预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中是否存在有等号,若是,确定当前验证码内容信息为算式,若否,确定当前验证码内容信息为非算式,若不是最后出栈的字符,则继续获取下一个出栈的字符作为当前字符,获取数量结果作为当前数量,返回执行步骤S303,从而能够准确地分辨出当前验证码内容信息是算式还是非算式,进而提高了验证码识别的准确性。
在一实施例中,该验证码识别方法应用在金融行业中,如图5所示,在步骤S20之前,该验证码识别方法还包括如下步骤:
S61:采用深度优先搜索算法对待识别验证码图片进行去除干扰线处理,得到去干扰后的待识别验证码图片;
在本实施例中,深度优先搜索算法,英文名称为Depth First Search算法,是指在一个HTML文件中,当一个超链被选择后,被链接的HTML文件将执行深度优先搜索,即在搜索其余的超链结果之前必须先完整地搜索单独的一条链。深度优先搜索沿着HTML文件上的超链走到不能再深入为止,然后返回到某一个HTML文件,再继续选择该HTML文件中的其他超链图算法。HTML文件是由HTML命令组成的描述性文本。HTML命令是指由HTML构成的指令。HTML,全称为HyperTextMark-upLanguage,是指超文本标记语言。
具体地,采用DFS算法对目标网站上的待识别图片进行去干扰处理,得到去干扰后的待识别验证码图片。
为了更好地理解步骤S61,下面通过一个例子进行说明,具体表述如下:
例如,假设图6为未去干扰线处理的待识别图片,图7为已去干扰线处理的待识别图片,基于DFS对图6进行去除干扰线,得到图7。
S62:按照预设的转换方式将去干扰后的待识别验证码图片进行转换处理,得到灰度图片;
在本实施例中,灰度图片是指把白色与黑色之间按对数关系分为若干等级的图片。RGB颜色模式是工业界的一种颜色标准,是通过对R、G和B三个颜色通道的变化及它们相互之间的叠加来得到各式各样的颜色,其中,R代表红色,G代表绿色,B代表绿色。 按照预设的转换方式可以为采用计算公式将RGB颜色模式图片转换成灰度图片。
需要说明的是,RGB颜色模式图片转换成灰度图片的计算公式为:GREY=(R+G+B)/3,其中R、G、B分别是像素点的三个颜色通道的值,GREY为该像素点对应的灰度值,其中,灰度值范围为0-255之间。按照预设的转换方式的具体内容,可以根据实际应用进行设定,此处不做限制。
具体地,通过公式GREY=(R+G+B)/3,依次读取去干扰线后的待识别RGB颜色模式图验证码图片每个像素点,获取该像素点的R、G、B值,取R、G、B三者的平均值作为新图片对应像素点的灰度值,得到灰度图片。
S63:采用聚类算法对灰度图片进行二值化处理,得到二值化图片;
在本实施例中,K-means算法,是一种聚类算法,该聚类算法是数据挖掘算法之一,是指以空间中k个点为中心进行聚类,对最靠近他们的对象归类,通过迭代的方法,逐次更新各聚类中心的值,直至得到最好的聚类结果的算法。二值化处理,是指就是将图像上的像素点的灰度值设置为0或255,也就是将整个图像呈现出明显的黑白效果的处理过程。
具体地,首先,采用K-means算法计算得到最佳预设的阈值,然后,将灰度图片的背景颜色和字符区分开来,接下来,对于灰度图片上每个像素点的灰度值,若灰度值大于最佳预设的阈值,则将该像素点的灰度值都设置为255,若灰度值小于等于最佳预设的阈值,则将该像素点的灰度值都设置为0,最后,得到二值化图片。
S64:采用洪水填充算法对二值化图片进行去噪处理,得到去噪后的待识别验证码图片;
在本实施例中,FloodFill算法,又叫洪水填充算法,是指把一个点的所有相邻的点都涂上该点的颜色,一直填充下去,直到这个区域内所有的点都被填充完为止的算法。去噪是指对二值化图片进行去除噪音或噪点的过程。
具体地,采用FloodFill算法对二值化图片进行去噪处理,得到去噪后的待识别验证码图片。
为了更好地理解步骤S90,下面通过一个例子进行说明,具体表述如下:
例如,假设图8为未做去噪处理的二值化图,图9为已做去噪后的待识别验证码图片,则采用FloodFill算法对图8进行去噪处理,得到图9。
在图5对应的实施例中,首先,通过采用递归处理方式的DFS算法对待识别验证码图片进行全面地去除干扰线处理,得到不残留干扰线的待识别验证码图片,然后,通过转换公式GREY=(R+G+B)/3将彩色的待识别验证码图片进行转换为黑白灰度图片,接下来,采用包含机器学习方法的聚类K-means算法计算出最佳预设的阈值,将灰度值大于最佳预设的阈值的像素点设为255,将灰度值小于等于最佳预设的阈值的像素点设为0,得到亮暗明显的二值化图片,再接下来,采用全填充方式的FloodFill算法将二值化图片上全部的噪点除去,得到完全干净的待识别验证码图片,从而可以避免因干扰而误读验证码图片,进而提高了验证码识别的精准度。
在一实施例中,该验证码识别方法应用在金融行业中,如图10所示,步骤S10具体为获取目标网站上的待识别验证码图。包括的步骤具体为:S101:获取各个目标网站上的各个待识别验证码图片;
具体地,首先,获取各个待识别验证码图片的路径信息,然后,根据各个待识别验证码图片的路径信息,在各个目标网站上提取各个该待识别验证码图片。
在步骤S20之前,该验证码识别方法还包括如下步骤:S65:确定各个待识别的验证码图片中的一张待识别的验证码图片为当前验证码图片;
具体地,确定各个目标网站上的各个待识别的验证码图片中的一张待识别的验证码图片为当前验证码图片。
步骤S20具体为:S201:基于Tesseract对当前验证码图片进行识别处理,得到当前 验证码图片对应的识别结果;
具体地,基于Tesseract对当前验证码图片进行识别处理,得到当前验证码图片对应的识别结果。
在步骤S40中,即将识别结果对应的计算结果填入待识别验证码图片对应的输入框,或者步骤S50中,即将识别结果填入待识别验证码图片对应的输入框之后,该验证码识别方法还包括如下步骤:S66:将各个待识别验证码图片中的一个未识别的待识别验证码图片确定为当前验证码图片,返回执行步骤S201,直到各个待识别验证码图片均被识别处理并得到对应的识别结果;
具体地,将各个待识别验证码图片中的一个未识别的待识别验证码图片确定为当前验证码图片,返回执行步骤S201,直到各个待识别验证码图片均被识别处理并得到对应的识别结果。
在图10对应的实施例中,首先,通过获取各个目标网站上的各个待识别验证码图片,确定各个待识别的验证码图片中的其中一张待识别的验证码图片为当前验证码图片,然后,基于Tesseract对当前验证码图片进行识别处理,得到验证码内容信息,接下来,判断该验证码内容信息是否为算式,若为算式,则计算结果填入输入框,若为非算式,则将该验证码内容信息填入输入框,最后,将未识别的待识别验证码图片确定为当前验证码图片,返回执行步骤S201,直到各个待识别验证码图片均被识别处理并得到对应的识别结果,从而能够依次对所需要获取的资源信息对应的各个网站上的各个验证码图片进行识别,不需要花费大量的时间由人工逐个输入各个网站的各个验证码内容信息,进而提高了获取资源信息的效率。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
在一实施例中,提供一种验证码识别装置,该验证码识别装置与上述实施例中验证码识别方法一一对应。如图11所示,该验证码识别装置包括获取模块701、识别处理模块702、判断模块703、第一填入模块704、第二填入模块705、去除模块706、转换模块707、二值化处理模块708、去噪处理模块709、第一确定模块710和第二确定模块711。各功能模块详细说明如下:
获取模块701,用于获取目标网站上的待识别验证码图片;
识别处理模块702,用于基于Tesseract对待识别验证码图片进行识别处理,得到待识别验证码图片对应的识别结果,其中,Tesseract为一款光学字符识别工具;
判断模块703,用于判断识别结果是否为算式;
第一填入模块704,用于若识别结果为算式,则将识别结果对应的计算结果填入待识别验证码图片对应的输入框;
第二填入模块705,用于若识别结果为非算式,则将识别结果填入待识别验证码图片对应的输入框;
去除模块706,用于采用深度优先搜索算法对待识别验证码图片进行去除干扰线处理,得到去干扰后的待识别验证码图片;
转换模块707,用于按照预设的转换方式将去干扰后的待识别验证码图片进行转换处理,得到灰度图片;
二值化处理模块708,用于采用聚类算法对灰度图片进行二值化处理,得到二值化图片;
去噪处理模块709,用于采用洪水填充算法对二值化图片进行去噪处理,得到去噪后的待识别验证码图片;
第一确定模块710,用于确定各个待识别的验证码图片中的一张待识别的验证码图片为当前验证码图片;
第二确定模块711,用于将各个待识别验证码图片中的一个未识别的待识别验证码图片确定为当前验证码图片,返回执行基于Tesseract对当前验证码图片进行识别处理,得到当前验证码图片对应的识别结果的步骤,直到各个待识别验证码图片均被识别处理并得到对应的识别结果。
进一步地,获取模块701具体为:第三提取子模块7011,用于获取各个目标网站上的各个待识别验证码图片;
进一步地,识别处理模块702具体为:第二辨别子模块7025,用于基于Tesseract对当前验证码图片进行识别处理,得到当前验证码图片对应的识别结果;
进一步地,识别处理模块702包括:
分割子模块7021,用于采用垂直投影法对待识别验证码图片进行分割,得到各个子验证码图片;
归一子模块7022,用于按照预设的尺寸规格将各个子验证码图片进行尺寸归一处理,得到各个规格化后的子验证码图片;
第一辨别子模块7023,用于基于Tesseract对各个规格化后的子验证码图片进行识别,得到各个规格化后的子验证码图片对应的各个验证码内容信息;
拼接子模块7024,用于按照验证码图片分割前的由左到右的顺序将各个验证码内容信息进行拼接,得到待识别验证码图片对应的识别结果,识别结果包括一个以上字符。
进一步地,判断模块703包括:
压入子模块7031,用于按照识别结果中的各个字符从左到右顺序排列,并将识别结果中的各个字符按照从左到右顺序排列顺序压入栈;
第一提取子模块7032,用于按照出栈先后顺序排列从栈中获取各个字符中的最先出栈的一个字符作为当前字符;
查询子模块7033,用于采用运算符号查询方法对当前字符进行查询,得到查询结果;
第一断定子模块7034,用于根据查询结果,确定查询结果的字符类型,其中,字符类型包括运算符类型和非运算符类型;
第二提取子模块7035,用于若查询结果的字符类型为运算符类型,则获取预设的运算符号原始值作为当前数量;
运算子模块7036,用于将当前数量与数字1进行算术相加运算,得到数量结果;
第一判别子模块7037,用于判断当前字符是否为按照出栈先后顺序排列的各个字符中的最后出栈的一个字符,若是,则触发第二判别子模块7038,若否,则触发第三提取子模块7039;
第二判别子模块7038,用于判断数量结果是否大于或等于预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中是否存在等号,若是,则触发第二断定子模块70310,若否,则触发第三断定子模块70311;
第三提取子模块7039,用于获取按照出栈先后顺序排列的各个字符中的下一个出栈的字符作为当前字符,获取数量结果作为当前数量,并触发查询子模块7033;
第二断定子模块70310,用于确定识别结果为算式;
第三断定子模块70311,用于确定识别结果为非算式。
关于验证码识别装置的具体限定可以参见上文中对于验证码识别方法的限定,在此不再赘述。上述验证码识别装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
在一个实施例中,提供了一种计算机设备,该计算机设备可以是服务器,其内部结构图可以如图12所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储 器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储验证码识别方法涉及到的图片或数据信息等。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现一种验证码识别方法。
在一个实施例中,提供了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机可读指令,处理器执行计算机可读指令时实现上述实施例验证码识别方法的步骤,例如图2所示的步骤S10至步骤S50。或者,处理器执行计算机可读指令时实现上述实施例中验证码识别装置的各模块/单元的功能,例如图11所示模块701至模块711的功能。为避免重复,这里不再赘述。
在一个实施例中,提供了一种计算机可读存储介质,该一个或多个存储有计算机可读指令的非易失性可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行计算机可读指令时实现上述方法实施例中验证码识别方法,或者,该一个或多个存储有计算机可读指令的非易失性可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行计算机可读指令时实现上述装置实施例中验证码识别装置中各模块/单元的功能。为避免重复,这里不再赘述。本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。

Claims (20)

  1. 一种验证码识别方法,其特征在于,所述验证码识别方法包括:
    获取目标网站上的待识别验证码图片;
    基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果,其中,Tesseract为一款光学字符识别工具;
    判断所述识别结果是否为算式;
    若所述识别结果为算式,则将所述识别结果对应的计算结果填入所述待识别验证码图片对应的输入框;
    若所述识别结果为非算式,则将所述识别结果填入所述待识别验证码图片对应的输入框。
  2. 如权利要求1所述的验证码识别方法,其特征在于,所述基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果包括:
    采用垂直投影法对所述待识别验证码图片进行分割,得到各个子验证码图片;
    按照预设的尺寸规格将各个所述子验证码图片进行尺寸归一处理,得到各个规格化后的子验证码图片;
    基于Tesseract对各个所述规格化后的子验证码图片进行识别,得到各个所述规格化后的子验证码图片对应的各个验证码内容信息;
    按照所述验证码图片分割前的由左到右的顺序将各个所述验证码内容信息进行拼接,得到所述待识别验证码图片对应的识别结果,所述识别结果包括一个以上字符。
  3. 如权利要求1所述的验证码识别方法,其特征在于,所述判断所述识别结果是否为算式包括:
    按照所述识别结果中的各个字符从左到右顺序排列,并将所述识别结果中的各个字符按照从左到右顺序排列顺序压入栈;
    按照出栈先后顺序排列从栈中获取所述各个字符中的最先出栈的一个字符作为当前字符;
    采用运算符号查询方法对所述当前字符进行查询,得到查询结果;
    根据所述查询结果,确定所述查询结果的字符类型,其中,所述字符类型包括运算符类型和非运算符类型;
    若所述查询结果的字符类型为所述运算符类型,则获取预设的运算符号原始值作为当前数量;
    将所述当前数量与数字1进行算术相加运算,得到数量结果;
    判断所述当前字符是否为按照出栈先后顺序排列的所述各个字符中的最后出栈的一个字符,若所述当前字符是按照出栈先后顺序排列的所述各个字符中的最后出栈的一个字符,则判断所述数量结果是否大于或等于所述预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中是否存在等号;
    若所述数量结果大于或等于所述预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中存在等号,则确定所述识别结果为算式,若所述数量结果不大于或不等于所述预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中不存在等号,则确定所述识别结果为非算式;
    若所述当前字符不是按照出栈先后顺序排列的所述各个字符中的最后出栈的一个字符,则获取按照出栈先后顺序排列的所述各个字符中的下一个出栈的字符作为当前字符,获取所述数量结果作为所述当前数量,返回执行所述采用运算符号查询方法对所述当前字符进行查询,得到查询结果的步骤。
  4. 如权利要求1所述的验证码识别方法,其特征在于,在所述基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果之前,所述验证码识别方法还包括:
    采用深度优先搜索算法对所述待识别验证码图片进行去除干扰线处理,得到去干扰后的待识别验证码图片;
    按照预设的转换方式将所述去干扰后的待识别验证码图片进行转换处理,得到灰度图片;
    采用聚类算法对所述灰度图片进行二值化处理,得到二值化图片;
    采用洪水填充算法对所述二值化图片进行去噪处理,得到去噪后的待识别验证码图片。
  5. 如权利要求1至4中任一项所述的验证码识别方法,其特征在于,所述获取目标网站上的待识别验证码图具体为:获取各个目标网站上的各个待识别验证码图片;
    在所述基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果之前,所述验证码识别方法还包括:确定所述各个待识别的验证码图片中的一张待识别的验证码图片为当前验证码图片;
    所述基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果具体为:基于Tesseract对所述当前验证码图片进行识别处理,得到所述当前验证码图片对应的识别结果;
    在将所述识别结果对应的计算结果填入所述验证码图片对应的输入框,或者将所述识别结果填入所述验证码图片对应的输入框之后,所述验证码识别方法还包括:将所述各个待识别验证码图片中的一个未识别的待识别验证码图片确定为当前验证码图片,返回执行所述基于Tesseract对所述当前验证码图片进行识别处理,得到所述当前验证码图片对应的识别结果的步骤,直到所述各个待识别验证码图片均被识别处理并得到对应的识别结果。
  6. 一种验证码识别装置,其特征在于,所述验证码识别装置包括:
    获取模块,用于获取目标网站上的待识别验证码图片;
    识别处理模块,用于基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果,其中,Tesseract为一款光学字符识别工具;
    判断模块,用于判断所述识别结果是否为算式;
    第一填入模块,用于若所述识别结果为算式,则将所述识别结果对应的计算结果填入所述待识别验证码图片对应的输入框;
    第二填入模块,用于若所述识别结果为非算式,则将所述识别结果填入所述待识别验证码图片对应的输入框。
  7. 如权利要求6所述的验证码识别装置,其特征在于,所述识别处理模块包括:
    分割子模块,用于采用垂直投影法对所述待识别验证码图片进行分割,得到各个子验证码图片;
    归一子模块,用于按照预设的尺寸规格将各个所述子验证码图片进行尺寸归一处理,得到各个规格化后的子验证码图片;
    第一辨别子模块,用于基于Tesseract对各个所述规格化后的子验证码图片进行识别,得到各个所述规格化后的子验证码图片对应的各个验证码内容信息;
    拼接子模块,用于按照所述验证码图片分割前的由左到右的顺序将各个所述验证码内容信息进行拼接,得到所述待识别验证码图片对应的识别结果,所述识别结果包括一个以上字符。
  8. 如权利要求6所述的验证码识别装置,其特征在于,所述判断模块包括:
    压入子模块,用于按照所述识别结果中的各个字符从左到右顺序排列,并将所述识别结果中的各个字符按照从左到右顺序排列顺序压入栈;
    第一提取子模块,用于按照出栈先后顺序排列从栈中获取所述各个字符中的最先出栈的一个字符作为当前字符;
    查询子模块,用于采用运算符号查询方法对所述当前字符进行查询,得到查询结果;
    第一断定子模块,用于根据所述查询结果,确定所述查询结果的字符类型,其中,所述字符类型包括运算符类型和非运算符类型;
    第二提取子模块,用于若所述查询结果的字符类型为所述运算符类型,则获取预设的运算符号原始值作为当前数量;
    运算子模块,用于将所述当前数量与数字1进行算术相加运算,得到数量结果;
    第一判别子模块,用于判断所述当前字符是否为按照出栈先后顺序排列的所述各个字符中的最后出栈的一个字符,若是,则触发第二判别子模块,若否,则触发第三提取子模块;
    第二判别子模块,用于判断所述数量结果是否大于或等于所述预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中是否存在等号,若是,则触发第二断定子模块,若否,则触发第三断定子模块;
    第三提取子模块,用于获取按照出栈先后顺序排列的各个字符中的下一个出栈的字符作为当前字符,获取数量结果作为当前数量,并触发查询子模块;
    第二断定子模块,用于确定所述识别结果为算式;
    第三断定子模块,用于确定所述识别结果为非算式。
  9. 如权利要求6所述的验证码识别装置,其特征在于,所述验证码识别装置还包括:
    去除模块,用于采用深度优先搜索算法对所述待识别验证码图片进行去除干扰线处理,得到去干扰后的待识别验证码图片;
    转换模块,用于按照预设的转换方式将所述去干扰后的待识别验证码图片进行转换处理,得到灰度图片;
    二值化处理模块,用于采用聚类算法对所述灰度图片进行二值化处理,得到二值化图片;
    去噪处理模块,用于采用洪水填充算法对所述二值化图片进行去噪处理,得到去噪后的待识别验证码图片。
  10. 如权利要求6至9中任一项所述的验证码识别装置,其特征在于,所述获取模块包括第三提取子模块,用于获取各个目标网站上的各个待识别验证码图片,所述验证码识别装置还包括:
    第一确定模块,用于确定所述各个待识别的验证码图片中的一张待识别的验证码图片为当前验证码图片;
    所述识别处理模块包括第二辨别子模块,用于基于Tesseract对所述当前验证码图片进行识别处理,得到所述当前验证码图片对应的识别结果;
    第二确定模块,用于将所述各个待识别验证码图片中的一个未识别的待识别验证码图片确定为当前验证码图片,返回执行所述基于Tesseract对所述当前验证码图片进行识别处理,得到所述当前验证码图片对应的识别结果的步骤,直到所述各个待识别验证码图片均被识别处理并得到对应的识别结果。
  11. 一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如下步骤:
    获取目标网站上的待识别验证码图片;
    基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果,其中,Tesseract为一款光学字符识别工具;
    判断所述识别结果是否为算式;
    若所述识别结果为算式,则将所述识别结果对应的计算结果填入所述待识别验证码图片对应的输入框;
    若所述识别结果为非算式,则将所述识别结果填入所述待识别验证码图片对应的输入框。
  12. 如权利要求11所述的计算机设备,其特征在于,所述基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果包括:
    采用垂直投影法对所述待识别验证码图片进行分割,得到各个子验证码图片;
    按照预设的尺寸规格将各个所述子验证码图片进行尺寸归一处理,得到各个规格化后的子验证码图片;
    基于Tesseract对各个所述规格化后的子验证码图片进行识别,得到各个所述规格化后的子验证码图片对应的各个验证码内容信息;
    按照所述验证码图片分割前的由左到右的顺序将各个所述验证码内容信息进行拼接,得到所述待识别验证码图片对应的识别结果,所述识别结果包括一个以上字符。
  13. 如权利要求11所述的计算机设备,其特征在于,所述判断所述识别结果是否为算式包括:
    按照所述识别结果中的各个字符从左到右顺序排列,并将所述识别结果中的各个字符按照从左到右顺序排列顺序压入栈;
    按照出栈先后顺序排列从栈中获取所述各个字符中的最先出栈的一个字符作为当前字符;
    采用运算符号查询方法对所述当前字符进行查询,得到查询结果;
    根据所述查询结果,确定所述查询结果的字符类型,其中,所述字符类型包括运算符类型和非运算符类型;
    若所述查询结果的字符类型为所述运算符类型,则获取预设的运算符号原始值作为当前数量;
    将所述当前数量与数字1进行算术相加运算,得到数量结果;
    判断所述当前字符是否为按照出栈先后顺序排列的所述各个字符中的最后出栈的一个字符,若所述当前字符是按照出栈先后顺序排列的所述各个字符中的最后出栈的一个字符,则判断所述数量结果是否大于或等于所述预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中是否存在等号;
    若所述数量结果大于或等于所述预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中存在等号,则确定所述识别结果为算式,若所述数量结果不大于或不等于所述预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中不存在等号,则确定所述识别结果为非算式;
    若所述当前字符不是按照出栈先后顺序排列的所述各个字符中的最后出栈的一个字符,则获取按照出栈先后顺序排列的所述各个字符中的下一个出栈的字符作为当前字符,获取所述数量结果作为所述当前数量,返回执行所述采用运算符号查询方法对所述当前字符进行查询,得到查询结果的步骤。
  14. 如权利要求11所述的计算机设备,其特征在于,在所述基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果之前,所述处理器执行所述计算机可读指令时还实现如下步骤:
    采用深度优先搜索算法对所述待识别验证码图片进行去除干扰线处理,得到去干扰后的待识别验证码图片;
    按照预设的转换方式将所述去干扰后的待识别验证码图片进行转换处理,得到灰度图片;
    采用聚类算法对所述灰度图片进行二值化处理,得到二值化图片;
    采用洪水填充算法对所述二值化图片进行去噪处理,得到去噪后的待识别验证码图片。
  15. 如权利要求11至14中任一项所述的计算机设备,其特征在于,所述获取目标网站上的待识别验证码图具体为:获取各个目标网站上的各个待识别验证码图片;
    在所述基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果之前,所述处理器执行所述计算机可读指令时还实现如下步骤:
    确定所述各个待识别的验证码图片中的一张待识别的验证码图片为当前验证码图片;
    所述基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果具体为:基于Tesseract对所述当前验证码图片进行识别处理,得到所述当前验证码图片对应的识别结果;
    在将所述识别结果对应的计算结果填入所述验证码图片对应的输入框,或者将所述识别结果填入所述验证码图片对应的输入框之后,所述处理器执行所述计算机可读指令时还实现如下步骤:将所述各个待识别验证码图片中的一个未识别的待识别验证码图片确定为当前验证码图片,返回执行所述基于Tesseract对所述当前验证码图片进行识别处理,得到所述当前验证码图片对应的识别结果的步骤,直到所述各个待识别验证码图片均被识别处理并得到对应的识别结果。
  16. 一个或多个存储有计算机可读指令的非易失性可读存储介质,其特征在于,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行如下步骤:
    获取目标网站上的待识别验证码图片;
    基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果,其中,Tesseract为一款光学字符识别工具;
    判断所述识别结果是否为算式;
    若所述识别结果为算式,则将所述识别结果对应的计算结果填入所述待识别验证码图片对应的输入框;
    若所述识别结果为非算式,则将所述识别结果填入所述待识别验证码图片对应的输入框。
  17. 如权利要求16所述的非易失性可读存储介质,其特征在于,所述基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果包括:
    采用垂直投影法对所述待识别验证码图片进行分割,得到各个子验证码图片;
    按照预设的尺寸规格将各个所述子验证码图片进行尺寸归一处理,得到各个规格化后的子验证码图片;
    基于Tesseract对各个所述规格化后的子验证码图片进行识别,得到各个所述规格化后的子验证码图片对应的各个验证码内容信息;
    按照所述验证码图片分割前的由左到右的顺序将各个所述验证码内容信息进行拼接,得到所述待识别验证码图片对应的识别结果,所述识别结果包括一个以上字符。
  18. 如权利要求16所述的非易失性可读存储介质,其特征在于,所述判断所述识别结果是否为算式包括:
    按照所述识别结果中的各个字符从左到右顺序排列,并将所述识别结果中的各个字符按照从左到右顺序排列顺序压入栈;
    按照出栈先后顺序排列从栈中获取所述各个字符中的最先出栈的一个字符作为当前字符;
    采用运算符号查询方法对所述当前字符进行查询,得到查询结果;
    根据所述查询结果,确定所述查询结果的字符类型,其中,所述字符类型包括运算符类型和非运算符类型;
    若所述查询结果的字符类型为所述运算符类型,则获取预设的运算符号原始值作为当前数量;
    将所述当前数量与数字1进行算术相加运算,得到数量结果;
    判断所述当前字符是否为按照出栈先后顺序排列的所述各个字符中的最后出栈的一个字符,若所述当前字符是按照出栈先后顺序排列的所述各个字符中的最后出栈的一个字符,则判断所述数量结果是否大于或等于所述预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中是否存在等号;
    若所述数量结果大于或等于所述预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中存在等号,则确定所述识别结果为算式,若所述数量结果不大于或不等于所述预设的运算符号原始值与数字2的和,且字符类型为运算符类型的所有字符中不存在等号,则确定所述识别结果为非算式;
    若所述当前字符不是按照出栈先后顺序排列的所述各个字符中的最后出栈的一个字符,则获取按照出栈先后顺序排列的所述各个字符中的下一个出栈的字符作为当前字符,获取所述数量结果作为所述当前数量,返回执行所述采用运算符号查询方法对所述当前字符进行查询,得到查询结果的步骤。
  19. 如权利要求16所述的非易失性可读存储介质,其特征在于,在所述基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果之前,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器还执行如下步骤:
    采用深度优先搜索算法对所述待识别验证码图片进行去除干扰线处理,得到去干扰后的待识别验证码图片;
    按照预设的转换方式将所述去干扰后的待识别验证码图片进行转换处理,得到灰度图片;
    采用聚类算法对所述灰度图片进行二值化处理,得到二值化图片;
    采用洪水填充算法对所述二值化图片进行去噪处理,得到去噪后的待识别验证码图片。
  20. 如权利要求16至19中任一项所述的非易失性可读存储介质,其特征在于,所述获取目标网站上的待识别验证码图具体为:获取各个目标网站上的各个待识别验证码图片;
    在所述基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果之前,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器还执行如下步骤:确定所述各个待识别的验证码图片中的一张待识别的验证码图片为当前验证码图片;
    所述基于Tesseract对所述待识别验证码图片进行识别处理,得到所述待识别验证码图片对应的识别结果具体为:基于Tesseract对所述当前验证码图片进行识别处理,得到所述当前验证码图片对应的识别结果;
    在将所述识别结果对应的计算结果填入所述验证码图片对应的输入框,或者将所述识别结果填入所述验证码图片对应的输入框之后,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器还执行如下步骤:将所述各个待识别验证码图片中的一个未识别的待识别验证码图片确定为当前验证码图片,返回执行所述基于Tesseract对所述当前验证码图片进行识别处理,得到所述当前验证码图片对应的识别结果的步骤,直到所述各个待识别验证码图片均被识别处理并得到对应的识别结果。
PCT/CN2018/106400 2018-06-11 2018-09-19 验证码识别方法、装置、计算机设备及存储介质 WO2019237549A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810595668.3 2018-06-11
CN201810595668.3A CN109086591A (zh) 2018-06-11 2018-06-11 验证码识别方法、装置、计算机设备及存储介质

Publications (1)

Publication Number Publication Date
WO2019237549A1 true WO2019237549A1 (zh) 2019-12-19

Family

ID=64839903

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/106400 WO2019237549A1 (zh) 2018-06-11 2018-09-19 验证码识别方法、装置、计算机设备及存储介质

Country Status (2)

Country Link
CN (1) CN109086591A (zh)
WO (1) WO2019237549A1 (zh)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111476528A (zh) * 2020-04-27 2020-07-31 上海东普信息科技有限公司 基于快递出库的数据处理方法、装置、设备及存储介质
CN111611988A (zh) * 2020-05-22 2020-09-01 上海携程商务有限公司 图片验证码识别方法及装置、电子设备和计算机可读介质
CN111652130A (zh) * 2020-06-02 2020-09-11 上海语识信息技术有限公司 一种非特定字体的数字、符号和字母组的识别方法
CN111666737A (zh) * 2020-06-04 2020-09-15 广州博高信息科技有限公司 区域图书馆多编码规则兼容处理方法、装置、设备及介质
CN111753845A (zh) * 2020-06-30 2020-10-09 北京来也网络科技有限公司 基于ai的验证码图片识别方法、装置、设备及存储介质
CN111881810A (zh) * 2020-07-23 2020-11-03 前海人寿保险股份有限公司 基于ocr的证件识别方法、装置、终端和存储介质
CN112270325A (zh) * 2020-11-09 2021-01-26 携程旅游网络技术(上海)有限公司 字符验证码识别模型训练方法、识别方法、系统、设备及介质
CN112487394A (zh) * 2020-11-30 2021-03-12 携程旅游网络技术(上海)有限公司 图形推理验证码识别方法、系统、设备及介质
CN112686266A (zh) * 2021-01-11 2021-04-20 安徽希施玛数据科技有限公司 一种验证码识别方法及装置
CN115150186A (zh) * 2022-07-27 2022-10-04 张瑜 验证码校验方法、系统、电子设备及存储介质

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111163082B (zh) * 2019-12-27 2022-03-25 咪咕文化科技有限公司 一种验证码的生成、验证方法、电子设备及存储介质
CN112948801A (zh) * 2021-03-05 2021-06-11 上海臣星软件技术有限公司 验证码输入的方法、装置、设备及计算机存储介质
CN115208704B (zh) * 2022-09-16 2023-01-13 欣诚信息技术有限公司 一种身份认证系统及政法服务应用系统
CN115712887B (zh) * 2023-01-09 2023-04-28 成方金融科技有限公司 图片验证码识别方法、装置、电子设备及存储介质
CN116186674A (zh) * 2023-02-21 2023-05-30 宿迁乐享知途网络科技有限公司 一种高对抗性人机交互验证方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104462930A (zh) * 2014-11-18 2015-03-25 百度在线网络技术(北京)有限公司 验证码生成方法和装置
CN105681344A (zh) * 2016-03-11 2016-06-15 广东亿迅科技有限公司 一种验证码识别系统及方法
CN105763319A (zh) * 2016-02-02 2016-07-13 南京云创大数据科技股份有限公司 一种随机多态验证码生成方法
US20170006182A1 (en) * 2015-07-01 2017-01-05 Dmitri Marinkin Method for protecting the authenticity of an object, item, document, packaging and/or a label from imitation, forgery and theft
CN106570159A (zh) * 2016-11-07 2017-04-19 国家电网公司 供应商投标文件资质信息审核系统及方法

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473531A (zh) * 2013-09-04 2013-12-25 上海索广电子有限公司 一种基于铭牌数字识别的数字图像识别纠错方法
CN106650398B (zh) * 2017-01-03 2023-04-14 深圳博十强志科技有限公司 移动平台的验证码识别系统及识别方法
CN106886996A (zh) * 2017-02-10 2017-06-23 九次方大数据信息集团有限公司 基于数学运算验证码图像的分割方法和装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104462930A (zh) * 2014-11-18 2015-03-25 百度在线网络技术(北京)有限公司 验证码生成方法和装置
US20170006182A1 (en) * 2015-07-01 2017-01-05 Dmitri Marinkin Method for protecting the authenticity of an object, item, document, packaging and/or a label from imitation, forgery and theft
CN105763319A (zh) * 2016-02-02 2016-07-13 南京云创大数据科技股份有限公司 一种随机多态验证码生成方法
CN105681344A (zh) * 2016-03-11 2016-06-15 广东亿迅科技有限公司 一种验证码识别系统及方法
CN106570159A (zh) * 2016-11-07 2017-04-19 国家电网公司 供应商投标文件资质信息审核系统及方法

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111476528A (zh) * 2020-04-27 2020-07-31 上海东普信息科技有限公司 基于快递出库的数据处理方法、装置、设备及存储介质
CN111476528B (zh) * 2020-04-27 2023-07-11 上海东普信息科技有限公司 基于快递出库的数据处理方法、装置、设备及存储介质
CN111611988A (zh) * 2020-05-22 2020-09-01 上海携程商务有限公司 图片验证码识别方法及装置、电子设备和计算机可读介质
CN111652130A (zh) * 2020-06-02 2020-09-11 上海语识信息技术有限公司 一种非特定字体的数字、符号和字母组的识别方法
CN111652130B (zh) * 2020-06-02 2023-09-15 上海语识信息技术有限公司 一种非特定字体的数字、符号和字母组的识别方法
CN111666737B (zh) * 2020-06-04 2023-04-25 广州博高信息科技有限公司 区域图书馆多编码规则兼容处理方法、装置、设备及介质
CN111666737A (zh) * 2020-06-04 2020-09-15 广州博高信息科技有限公司 区域图书馆多编码规则兼容处理方法、装置、设备及介质
CN111753845A (zh) * 2020-06-30 2020-10-09 北京来也网络科技有限公司 基于ai的验证码图片识别方法、装置、设备及存储介质
CN111881810A (zh) * 2020-07-23 2020-11-03 前海人寿保险股份有限公司 基于ocr的证件识别方法、装置、终端和存储介质
CN111881810B (zh) * 2020-07-23 2024-03-29 前海人寿保险股份有限公司 基于ocr的证件识别方法、装置、终端和存储介质
CN112270325A (zh) * 2020-11-09 2021-01-26 携程旅游网络技术(上海)有限公司 字符验证码识别模型训练方法、识别方法、系统、设备及介质
CN112270325B (zh) * 2020-11-09 2024-05-24 携程旅游网络技术(上海)有限公司 字符验证码识别模型训练方法、识别方法、系统、设备及介质
CN112487394A (zh) * 2020-11-30 2021-03-12 携程旅游网络技术(上海)有限公司 图形推理验证码识别方法、系统、设备及介质
CN112686266A (zh) * 2021-01-11 2021-04-20 安徽希施玛数据科技有限公司 一种验证码识别方法及装置
CN115150186A (zh) * 2022-07-27 2022-10-04 张瑜 验证码校验方法、系统、电子设备及存储介质

Also Published As

Publication number Publication date
CN109086591A (zh) 2018-12-25

Similar Documents

Publication Publication Date Title
WO2019237549A1 (zh) 验证码识别方法、装置、计算机设备及存储介质
US10706320B2 (en) Determining a document type of a digital document
AU2020200251B2 (en) Label and field identification without optical character recognition (OCR)
US11302109B2 (en) Range and/or polarity-based thresholding for improved data extraction
US10866997B2 (en) Determining functional and descriptive elements of application images for intelligent screen automation
EP3117369B1 (en) Detecting and extracting image document components to create flow document
US10817741B2 (en) Word segmentation system, method and device
US20200074169A1 (en) System And Method For Extracting Structured Information From Image Documents
US9626555B2 (en) Content-based document image classification
US11106891B2 (en) Automated signature extraction and verification
US9659213B2 (en) System and method for efficient recognition of handwritten characters in documents
CN111340037B (zh) 文本版面分析方法、装置、计算机设备和存储介质
CN113011144A (zh) 表单信息的获取方法、装置和服务器
CN112232336A (zh) 一种证件识别方法、装置、设备及存储介质
CN111209865A (zh) 文件内容提取方法、装置、电子设备及存储介质
CN113673528B (zh) 文本处理方法、装置、电子设备和可读存储介质
EP4244761A1 (en) Fraud detection via automated handwriting clustering
CN114140649A (zh) 票据分类方法、票据分类装置、电子设备和存储介质
US10769429B2 (en) Method and system for extracting text from an engineering drawing
CN114120305B (zh) 文本分类模型的训练方法、文本内容的识别方法及装置
US20180225508A1 (en) Detecting document objects
CN111753836A (zh) 文字识别方法、装置、计算机可读介质及电子设备
US11899704B2 (en) Systems and methods for extracting, digitizing, and using engineering drawing data
CN115082938A (zh) 一种文本识别方法、存储介质及设备
CN117197798A (zh) 发票的信息提取方法、装置、设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18922237

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 19.03.2021)

122 Ep: pct application non-entry in european phase

Ref document number: 18922237

Country of ref document: EP

Kind code of ref document: A1