A Character Recognition Method Based on Character Contour
By extracting the outline components of characters to generate identification codes, the problem of poor recognition of handwriting and ancient books in the existing technology is solved, and efficient recognition of characters is achieved.
Patent Information
- Application Number
- CN202211103708.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-09
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2042-09-09
AI Technical Summary
Existing technologies have difficulty in effectively recognizing characters in certain types of documents, such as handwritten documents and ancient books, especially due to the poor recognition effect caused by unstable fonts, tilted and deformed characters.
By extracting multiple contour components of a character, generating overall and local identification codes, and using the character recognition library for matching and recognition, the effects of character tilt, rotation, and stretching are eliminated.
It achieves efficient recognition of special types of documents such as handwriting and ancient books, and improves recognition accuracy and effect.
Smart Images

Figure CN116311264B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text recognition, and in particular to a character recognition method based on character contours. Background Art
[0002] Character recognition is a technology that uses computer technology to automatically identify characters. Generally speaking, character recognition generally includes several parts, such as the collection of text information, analysis and processing of information, and classification and discrimination of information.
[0003] In the prior art, there are technologies that recognize text in images based on image recognition methods, such as optical character recognition (OCR). This type of technology usually performs a series of image processing on printed characters, and then recognizes each character through a corresponding recognition algorithm to extract specific text. However, in the actual implementation process, the inventors found that this type of technical solution can often only achieve a good recognition effect on printed characters. For specific types of documents, such as handwritten documents, ancient books, letters, etc., due to the fact that such documents have unstable fonts and large deviations from printed fonts, scanning and photography cause different degrees of tilt and deformation of each character, unclear and missing handwriting due to age, and character differences caused by different handwriting strokes, they cannot be well recognized. Summary of the Invention
[0004] In view of the above problems existing in the prior art, a character recognition method based on character contours is provided.
[0005] The specific technical solutions are as follows:
[0006] A character recognition method based on character contours, comprising:
[0007] Step S1: extracting multiple contour components of a character to be recognized along a specific direction, and generating an overall identification code based on all the contour components;
[0008] Step S2: using a pre-generated character recognition library and the overall identification code to identify the character to be identified, and determining whether the character to be identified can be identified;
[0009] If so, output the recognition result and then end the recognition process;
[0010] If not, go to step S3;
[0011] Step S3: segmenting the character to be recognized, and extracting the contour components of each contour segment of the segmented character to be recognized, so as to generate a local recognition code corresponding to the contour segment;
[0012] Step S4: using the character recognition library and the local recognition code to recognize the character to be recognized, and then outputting the recognition result.
[0013] Preferably, the step S1 includes:
[0014] Step S11: selecting an origin in the outline of the character to be recognized, and acquiring each point on the outline from the origin along the specific direction;
[0015] Step S12: grouping the contours, and obtaining a pattern shape composed of points in each group along the specific direction as a component of the contour;
[0016] Step S13: generating an identification bit corresponding to each of the contour components according to the type of the contour components, and generating the overall identification code according to the order of the identification bit and the contour components.
[0017] Preferably, before step S1, the method for constructing the character recognition library includes:
[0018] Step S01: obtaining a sample character, extracting a plurality of contour components of the sample character along the specific direction, and generating the overall identification code according to the contour components;
[0019] Step S02: segmenting the sample character, obtaining the contour components of each contour segment of the segmented sample character, and generating the local identification code according to the contour components;
[0020] Step S03: annotating the sample characters to generate an annotation result, and generating the character recognition library according to the annotation result, the overall recognition code and the local recognition code.
[0021] Preferably, step S2 includes:
[0022] Step S21: using the character recognition library to match the overall identification code to determine whether a first matching result exists;
[0023] If yes, go to step S22;
[0024] If not, go to step S3;
[0025] Step S22: outputting the second matching result as the recognition result, and then ending the recognition process.
[0026] Preferably, step S3 includes:
[0027] Step S31: obtaining the center point of the character to be recognized, and dividing the character to be recognized into equal parts based on the center point to generate a plurality of contour segments;
[0028] Step S32: respectively obtaining the pattern shape of each contour segment as the contour component of the contour segment;
[0029] Step S33: Generate an identification bit corresponding to each of the contour components according to the type of the contour components, and generate the local identification code corresponding to the contour segment according to the order of the identification bit and the contour components.
[0030] Preferably, in step S31, the method for generating the center point is:
[0031] The position coordinates of each pixel of the character to be recognized are obtained, and the average of all the position coordinates is calculated to obtain an average position, and the average position is used as the center point.
[0032] Preferably, step S4 includes:
[0033] Step S41: matching the local identification code with the character recognition library to determine whether a second matching result exists;
[0034] If yes, go to step S42:
[0035] If not, output a matching failure result;
[0036] Step S42: output the second matching result as the recognition result.
[0037] Preferably, when the step S4 outputs the matching failure result, the identification method further includes:
[0038] Step A5: Obtaining a pixel ratio of the character to be recognized in a background image, and a pixel ratio of each contour segment in the segmented background image, and generating a ratio identification code according to the pixel ratios;
[0039] Step A6: using the character recognition library and the proportional recognition code to recognize the character to be recognized, and then outputting the recognition result.
[0040] Preferably, before step S1, the method further includes:
[0041] The sample characters are segmented to obtain pixel ratios of the sample characters in the background image and pixel ratios of each contour segment in the segmented background image.
[0042] Preferably, the step S4 comprises: using the character recognition library and the local recognition code to recognize the character to be recognized, and determining whether the character to be recognized can be recognized;
[0043] When the character to be recognized can be recognized, outputting the sample character corresponding to the character to be recognized as the recognition result;
[0044] When the character to be recognized cannot be recognized, a recognition result indicating recognition failure is output.
[0045] Preferably, the recognition result indicating recognition failure includes:
[0046] A first failure result indicating that there is no similar sample character;
[0047] and, a second failure result indicating that there are a plurality of sample characters having similar confidence levels;
[0048] When step S4 outputs a recognition result indicating recognition failure, the character recognition method further includes:
[0049] Step B5: Obtaining the recognition result indicating recognition failure, and determining the type of the recognition result;
[0050] When the recognition result is the first failure result, go to step C6;
[0051] When the recognition result is the second failure result, go to step D6;
[0052] Step C6: generating a first character sample corresponding to the character to be recognized in the character recognition library, and marking the first sample character;
[0053] Step D6: generating a second character sample corresponding to the character to be recognized in the character recognition library, and marking the second sample character.
[0054] Preferably, step C6 comprises:
[0055] Step C61: adding the character to be recognized to the character recognition library;
[0056] Step C62: recording the overall representation code, the partial representation code, the complete character image, and the partial character image associated with the character to be recognized to construct the first character sample;
[0057] Step C63: labeling the first character sample.
[0058] Preferably, step D6 includes:
[0059] Step D61: adding the character to be recognized to the character recognition library;
[0060] Step D62: Recording the overall representation code, the partial representation code, the sample characters with similar confidence levels, the complete character image, and the partial character image associated with the character to be recognized to construct the second character sample;
[0061] Step D63: labeling the second character sample.
[0062] A verification code construction method, comprising:
[0063] Step E1: extracting multiple contour components of an initial character along a specific direction, and generating a sample code based on all the contour components;
[0064] The outline components include pattern shapes of various parts of the outline of the initial character;
[0065] Step E2: randomly generating an adjustment parameter, and generating a verification code character corresponding to the initial character according to the adjustment parameter and the sample code.
[0066] The above technical solution has the following advantages or beneficial effects: by obtaining the contour components of the character and generating an identification code according to the shape changes of the character contour, an effective description of the character contour shape is achieved, so that a more accurate match can be made according to the character recognition library, and the same recognition effect can be achieved for tilted, rotated, and stretched fonts, which facilitates the recognition of various types of paper documents. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] The embodiments of the present invention will be described more fully with reference to the accompanying drawings, which are provided for illustration and description only and are not intended to limit the scope of the present invention.
[0068] Figure 1 is an overall schematic diagram of an embodiment of the present invention;
[0069] Figure 2 Schematic diagram of the outline components in an embodiment of the present invention;
[0070] Figure 3 This is a schematic diagram of the sub-steps of step S1 in an embodiment of the present invention;
[0071] Figure 4 A schematic diagram of the steps for establishing a character recognition library in an embodiment of the present invention;
[0072] Figure 5 This is a schematic diagram of the sub-steps of step S2 in an embodiment of the present invention;
[0073] Figure 6This is a schematic diagram of sub-steps of step S3 in an embodiment of the present invention;
[0074] Figure 7 Schematic diagram of character segmentation in an embodiment of the present invention;
[0075] Figure 8 This is a schematic diagram of sub-steps of step S4 in an embodiment of the present invention;
[0076] Figure 9 Schematic diagram of steps A5 and A6 in an embodiment of the present invention;
[0077] Figure 10 This is a schematic diagram of step B5 in an embodiment of the present invention;
[0078] Figure 11 This is a schematic diagram of sub-steps of step C6 in an embodiment of the present invention;
[0079] Figure 12 This is a schematic diagram of sub-steps of step D6 in an embodiment of the present invention;
[0080] Figure 13 Schematic diagram of a verification code construction method in an embodiment of the present invention. DETAILED DESCRIPTION
[0081] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.
[0082] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0083] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, but they are not intended to limit the present invention.
[0084] The present invention comprises:
[0085] A character recognition method based on character contours, such as Figure 1 Shown, including:
[0086] Step S1: extracting multiple contour components of the character to be recognized along a specific direction, and generating an overall identification code based on all the contour components;
[0087] Step S2: using a pre-generated character recognition library and the overall identification code to identify the character to be identified, and determining whether the character to be identified can be identified;
[0088] If so, output the recognition result and then end the recognition process;
[0089] If not, go to step S3;
[0090] Step S3: segmenting the character to be recognized, and extracting contour components of each contour segment of the segmented character to be recognized, so as to generate a local recognition code corresponding to the contour segment;
[0091] Step S4: Recognize the character to be recognized using the character recognition library and the local recognition code, and then output the recognition result.
[0092] Specifically, in response to the problem in the prior art that recognition algorithms cannot effectively identify specific types of files, this embodiment extracts the contour components of the characters to be identified, and then generates an overall identification code and a local identification code to describe the shape of the characters, so that the character recognition library can match according to the contour shape of the characters without being affected by the stretching, tilting, and rotation of the characters, thereby achieving better recognition effects for special fonts.
[0093] As an optional embodiment, before step S1, the document to be identified is photographed to obtain a document image, which is then binarized and cropped to generate single-character images. Each single-character image contains a single character to be identified and a background image. The binarization method used to generate the single-character image in black and white is conventional. This image binarization process can achieve better contour extraction results.
[0094] In the implementation process, for single text images, since they have a large contrast with the background color, they can be generated by a relatively simple image processing method. Figure 2 The character contour is shown. For the character contour, its various contour components can be extracted in sequence along a fixed direction, such as clockwise or counterclockwise, such as acute angle-straight line-right angle-straight line, etc. Each contour component is pre-corresponded to an identification bit, such as "straight line" corresponds to 0x01, "right angle" corresponds to 0x02, etc., and then an overall recognition code corresponding to the character contour is generated according to each contour component. The overall recognition code is used to characterize the shape of the entire character, thereby eliminating the impact of scaling and deformation of fonts in handwritten documents and ancient books on recognition. After testing, this method has a good recognition effect on Chinese characters, numbers, etc.
[0095] In a preferred embodiment, Figure 3 As shown, step S1 includes:
[0096] Step S11: Select an origin point in the outline of the character to be recognized, and obtain each point on the outline from the origin point along a specific direction;
[0097] Step S12: grouping the contours, and obtaining the pattern shapes composed of the points in each group along a specific direction as contour components;
[0098] Step S13: Generate an identification bit corresponding to each contour component according to the type of the contour component, and generate an overall identification code according to the sequence of the identification bit and the contour components.
[0099] Specifically, in order to address the problem that the recognition algorithms in the prior art are unable to recognize characters in special types of files, this embodiment traverses the contours of the characters to be recognized, extracts the pattern shapes composed of multiple points in each group of contours in turn, and recognizes the pattern shapes, thereby generating an overall recognition code that can represent the character contour shape, avoiding the problem in the prior art that it is difficult to recognize specific types of characters based on image recognition.
[0100] In a preferred embodiment, Figure 4 As shown, before step S1, the method for constructing a character recognition library includes:
[0101] Step S01: obtaining a sample character, extracting multiple contour components of the sample character along a specific direction, and generating an overall identification code based on the contour components;
[0102] Step S02: Segmenting the sample character, obtaining contour components of each contour segment of the segmented sample character, and generating a local identification code based on the contour components;
[0103] Step S03: labeling the sample characters to generate labeling results, and generating a character recognition library according to the labeling results, the overall recognition code and the local recognition code.
[0104] Specifically, in order to address the problem in the prior art that character images are directly used as training sets for artificial intelligence programs, which makes it impossible to effectively identify deformed characters, this embodiment labels sample characters and extracts their contour components to generate overall identification codes and local identification codes respectively, thereby achieving re-representation of the character and excluding information such as the length and direction of the character, thereby facilitating direct identification based on the contour shape of the character in the subsequent matching process, thereby improving the recognition accuracy.
[0105] In a preferred embodiment, Figure 5 As shown, step S2 includes:
[0106] Step S21: using a character recognition library to match the entire identification code and determine whether a first matching result exists;
[0107] If yes, go to step S22;
[0108] If not, go to step S3;
[0109] Step S22: Output the first matching result as the recognition result, and then end the recognition process.
[0110] Specifically, in order to address the problem of poor recognition effect on specific types of characters in the existing technology, this embodiment adopts the overall recognition code for matching in advance, and then adopts the local recognition code for local matching when the matching is unsuccessful, thereby achieving better recognition effect and recognition efficiency for characters.
[0111] In practice, the matching process in step S21 may be to use the overall recognition code to search the character recognition library to obtain consistent search results. Alternatively, a correlation method may be used to determine the correlation between the overall recognition code and the overall recognition code preset in the character recognition code. When the confidence level is higher than a threshold, the result is considered a match, and the corresponding sample character is obtained to complete the recognition process.
[0112] In a preferred embodiment, Figure 6 As shown, step S3 includes:
[0113] Step S31: obtaining the center point of the character to be recognized, and dividing the character to be recognized into equal parts based on the center point to generate multiple contour segments;
[0114] Step S32: respectively obtaining the pattern shape of each contour segment as a contour component of the contour segment;
[0115] Step S33: Generate an identification bit corresponding to each contour component according to the type of the contour component, and generate a local identification code corresponding to the contour segment according to the order of the identification bit and the contour components.
[0116] Specifically, to address the inability of existing technologies to effectively recognize special types of documents, this embodiment extracts the center point of the character to be recognized and divides it into equal parts, thereby dividing the outline of the character to be recognized into multiple contour segments. Multiple local identification codes are then generated to represent these contour segments. Because characters in handwritten text and ancient texts often exhibit certain distortions in specific areas, which can reduce the overall recognition rate, setting local identification codes for local character recognition can effectively improve the recognition rate.
[0117] During the implementation process, if Figure 7 As shown in the figure, to achieve better character recognition, the character can be divided equally from its center point, generating multiple contour segments for local recognition. The number of equal segments can be selected based on the actual font sample. For example, for specific handwritten characters with significant distortion, the number of equal segments can be appropriately increased to improve recognition rate.
[0118] In a preferred embodiment, in step S31, the method for generating the center point is:
[0119] The position coordinates of each pixel of the character to be recognized are obtained, and the average of all the position coordinates is calculated to obtain an average position, and the average position is used as the center point.
[0120] In a preferred embodiment, Figure 8 As shown, step S4 includes:
[0121] Step S41: using a character recognition library to match the local identification code and determine whether there is a second matching result;
[0122] If yes, go to step S42:
[0123] If not, output a matching failure result;
[0124] Step S42: Output the second matching result as the recognition result.
[0125] Specifically, to address the problem that some handwritten characters have a large distortion amplitude, and thus the recognition efficiency of using continuous overall recognition codes is low, this embodiment uses local recognition codes that represent each contour interval of the character to be recognized to perform matching, thereby achieving a higher recognition rate for characters with a large distortion amplitude.
[0126] In the implementation process, the above matching process is a whole match or a separate match. For example, in one embodiment, multiple partial identification codes are combined into a complete identification code, and then a circular match is performed to select the corresponding interval from the character recognition library.
[0127] In a preferred embodiment, Figure 9 As shown, when step S4 outputs a matching failure result, the identification method further includes:
[0128] Step A5: Obtaining the pixel ratio of the character to be recognized in a background image and the pixel ratio of each contour segment in the segmented background image, and generating a proportional identification code according to the pixel ratio;
[0129] Step A6: Recognize the character to be recognized using the character recognition library and the proportional recognition code, and then output the recognition result.
[0130] In this embodiment, before step S1, the following steps are further included:
[0131] The sample characters are segmented to obtain the pixel ratio of the sample characters in the background image and the pixel ratio of each contour segment in the segmented background image.
[0132] Specifically, in response to the problem of low recognition rate for specific types of characters in the existing technology, this embodiment further obtains the pixel ratio of each part after the character is divided into equal parts, thereby generating a proportional identification code based on the black and white ratio of each part, thereby achieving effective recognition of difficult-to-recognize characters based on their ratio in the image area, thereby improving the recognition rate of characters.
[0133] During implementation, the pixel ratio generation process involves two steps. First, the number of pixels of the character to be identified and the number of pixels of the background image are pre-determined, and the pixel ratio of the entire character to be identified within the background image is calculated. Simultaneously, based on the segmentation results, the pixel ratio of each contour segment after filling within the segmented background image is obtained, thereby generating multiple pixel ratios representing the character in the segmented image. These pixel ratios are combined to form a proportional identification code, thereby enabling character recognition.
[0134] In a preferred embodiment, the types of contour components include: sharp angles, acute angles, arcs, and inner angles.
[0135] In a preferred embodiment, step S4 includes: using a character recognition library and a local recognition code to recognize the character to be recognized, and determining whether the character to be recognized can be recognized;
[0136] When the character to be recognized can be recognized, a sample character corresponding to the character to be recognized is output as a recognition result;
[0137] When the character to be recognized cannot be recognized, a recognition result indicating recognition failure is output.
[0138] Specifically, in the above determination process, "capable of recognizing the character to be recognized" means that a sample character corresponding to the character to be recognized can be obtained using the character recognition library and the local recognition code, and there is only one such sample character. During the recognition process, however, there may be multiple sample characters with similar confidence levels, or no corresponding sample character can be obtained. In such cases, the recognition result is output as a failure.
[0139] In a preferred embodiment, the recognition result indicating recognition failure includes:
[0140] A first failure result indicating that there is no similar sample character;
[0141] and, a second failure result indicating that there are multiple sample characters with similar confidence levels;
[0142] Then when step S4 outputs the recognition result indicating recognition failure, Figure 10 As shown, the character recognition method further includes:
[0143] Step B5: Obtaining a recognition result indicating recognition failure and determining the type of the recognition result;
[0144] When the recognition result is the first failure result, go to step C6;
[0145] When the recognition result is the second failure result, go to step D6;
[0146] Step C6: generating a first character sample corresponding to the character to be recognized in the character recognition library, and marking the first sample character;
[0147] Step D6: Generate a second character sample corresponding to the character to be recognized in the character recognition library, and mark the second sample character.
[0148] Specifically, in order to achieve a better update effect on the character recognition library, in this embodiment, two situations that may occur when recognition fails are selected, namely, it is impossible to obtain sample characters similar to the character to be recognized, or multiple sample characters with similar confidence levels are obtained, and different character samples are generated for these two situations respectively, and then labeled, thereby achieving a better update effect on the character recognition library, so as to improve the accuracy of recognizing the character to be recognized in the next recognition process.
[0149] In a preferred embodiment, Figure 11 As shown, step C6 includes:
[0150] Step C61: Add characters to be recognized in the character recognition library;
[0151] Step C62: Recording the overall representation code, partial representation code, complete character image, and partial character image associated with the character to be recognized to construct a first character sample;
[0152] Step C63: Label the first character sample.
[0153] Specifically, in response to the failure situation where a sample character similar to the character to be recognized cannot be obtained, this embodiment generates a new font corresponding to the character to be recognized in the character recognition library, and associates information related to the character to be recognized, including the overall representation code, local representation code, complete character image and local character image, with the newly generated font, thereby generating a first character sample to achieve better labeling efficiency, and by recording the information such as the overall representation code, local representation code, complete character image and local character image, the character can obtain better recognition accuracy in the next recognition process.
[0154] In a preferred embodiment, step D6 includes:
[0155] Step D61: Add characters to be recognized in the character recognition library;
[0156] Step D62: Recording the overall representation code, partial representation code, sample characters with similar confidence levels, complete character images, and partial character images associated with the character to be recognized to construct a second character sample;
[0157] Step D63: Label the second character sample.
[0158] Specifically, in response to the failure of obtaining multiple sample characters with similar confidence levels, this embodiment generates a new font corresponding to the character to be recognized in the character recognition library, and associates the information related to the character to be recognized, including the overall representation code, local representation code, complete character image and local character image, with the newly generated font, thereby generating a second character sample to achieve better annotation efficiency, and by recording the overall representation code, local representation code, complete character image and local character image information, the character can obtain better recognition accuracy in the next recognition process. At the same time, by adding multiple sample characters with similar confidence levels to the second character sample for annotation, the specificity of the character relative to the sample characters that are easily misjudged can be improved in the next recognition process, thereby reducing the possibility of recognition errors.
[0159] A verification code construction method, such as Figure 13 Shown, including:
[0160] Step E1: extracting multiple contour components of an initial character along a specific direction, and generating a sample code based on all the contour components;
[0161] The outline components include pattern shapes of various parts of the outline of the initial character;
[0162] Step E2: randomly generate an adjustment parameter, and generate a verification code character corresponding to the initial character according to the adjustment parameter and the sample code.
[0163] Specifically, the above-mentioned technical solution of re-encoding characters based on contour components can also be used in the process of generating verification codes. Specifically, in order to achieve better protection against automatic recognition software, it is necessary to deform the normal characters, that is, the original characters, so that the automatic recognition software cannot distinguish them.
[0164] In order to achieve this technical effect, in this embodiment, the sample code is extracted from the initial character, and then the initial character is re-encoded. During the re-encoding process, only the contour components of the outer contour of the initial character are retained, including sharp angles, acute angles, arcs, inner angles, etc., while the length, angle, direction and other information of the initial character are removed. Among them, the adjustment parameters of step E2 are the length, angle and other information of each segment of the verification code character, which are randomly generated and spliced in a segment-by-segment combination with the sample code, thereby realizing the fuzzy processing of the information and constructing the deformed verification code character. Since the overall contour components of the verification code character are consistent with the initial character, it does not affect normal recognition, but its pattern is deformed relative to the initial character, which makes it difficult for the automatic recognition software to distinguish, thereby achieving a better protection effect.
[0165] During implementation, the initial characters are characters obtained based on a standard character library, including Chinese characters, numbers, letters, and the like. The contour components are contour components extracted based on the initial characters in the above-mentioned scheme, and their specific extraction process can refer to other embodiments of the present invention. The sample code is a code corresponding to the pattern shapes represented by all contour components, wherein a plurality of identification bits are provided, each corresponding to a pattern shape of a section constituting the font contour. The adjustment parameters are a plurality of adjustment parameters corresponding to each contour component, including information such as length, angle, and direction.
[0166] The beneficial effects of the present invention are as follows: by obtaining the contour components of the character and generating an identification code according to the shape changes of the character contour, an effective representation of the character contour shape is achieved, so that a more accurate match can be made according to the character recognition library, and the same recognition effect can be achieved for tilted, rotated, and stretched fonts, which facilitates the recognition of various types of paper documents.
[0167] The above are only preferred embodiments of the present invention and do not limit the implementation mode and protection scope of the present invention. For those skilled in the art, it should be aware that all solutions obtained by equivalent substitutions and obvious changes made using the description and illustrations of the present invention should be included in the protection scope of the present invention.
Claims
1. A character recognition method based on character outline, characterized in that: include: Step S1: extracting multiple contour components of a character to be recognized along a specific direction, and generating an overall identification code based on all the contour components; The specific direction is the clockwise direction or the counterclockwise direction of the outline of the character to be recognized; The contour component is a local contour shape of the character to be recognized with length, direction and angle removed; Step S2: using a pre-generated character recognition library and the overall identification code to identify the character to be identified, and determining whether the character to be identified can be identified; If so, output the recognition result and then end the recognition process; If not, go to step S3; Step S3: segmenting the character to be recognized, and extracting the contour components of each contour segment of the segmented character to be recognized, so as to generate a local recognition code corresponding to the contour segment; The step S3 comprises: Step S31: obtaining the center point of the character to be recognized, and dividing the character to be recognized into equal parts based on the center point to generate a plurality of contour segments; Step S32: respectively obtaining the pattern shape of each contour segment as the contour component of the contour segment; Step S33: generating an identification bit corresponding to each contour component according to the type of the contour component, and generating the local identification code corresponding to the contour segment according to the order of the identification bit and the contour components; Step S4: using the character recognition library and the local recognition code to recognize the character to be recognized, and then outputting the recognition result.
2. The character recognition method according to claim 1, wherein: The step S1 comprises: Step S11: selecting an origin in the outline of the character to be recognized, and acquiring each point on the outline from the origin along the specific direction; Step S12: grouping the contours, and obtaining a pattern shape composed of points in each group along the specific direction as a component of the contour; Step S13: generating an identification bit corresponding to each of the contour components according to the type of the contour components, and generating the overall identification code according to the order of the identification bit and the contour components.
3. The character recognition method according to claim 1, wherein: Before step S1, the method for constructing the character recognition library includes: Step S01: obtaining a sample character, extracting a plurality of contour components of the sample character along the specific direction, and generating the overall identification code according to the contour components; Step S02: segmenting the sample character, obtaining the contour components of each contour segment of the segmented sample character, and generating the local identification code according to the contour components; Step S03: annotating the sample characters to generate an annotation result, and generating the character recognition library according to the annotation result, the overall identification code and the local identification code.
4. The character recognition method according to claim 1, wherein: The step S2 comprises: Step S21: using the character recognition library to match the overall identification code and determine whether a first matching result exists; If yes, go to step S22; If not, go to step S3; Step S22: outputting the first matching result as the recognition result, and then ending the recognition process.
5. The character recognition method according to claim 1, wherein: In step S31, the method for generating the center point is: A rectangular coordinate system is established for the character to be recognized, and then the position coordinates of each pixel of the character to be recognized are obtained, and all the position coordinates are averaged to obtain an average position, and the average position is used as the center point.
6. The character recognition method according to claim 2, wherein: The step S4 comprises: Step S41: matching the local identification code with the character recognition library to determine whether a second matching result exists; If yes, go to step S42: If not, output a matching failure result; Step S42: output the second matching result as the recognition result.
7. The character recognition method according to claim 6, wherein: When the step S4 outputs the matching failure result, the character recognition method further includes: Step A5: Obtaining a pixel ratio of the character to be recognized in a background image, and a pixel ratio of each contour segment in the segmented background image, and generating a ratio identification code according to the pixel ratios; Step A6: using the character recognition library and the proportional recognition code to recognize the character to be recognized, and then outputting the recognition result.
8. The character recognition method according to claim 7, wherein: Before step S1, the method further includes: The sample characters are segmented to obtain pixel ratios of the sample characters in the background image and pixel ratios of each contour segment in the segmented background image.
9. The character recognition method according to claim 3, wherein: The step S4 includes: using the character recognition library and the local recognition code to recognize the character to be recognized, and determining whether the character to be recognized can be recognized; When the character to be recognized can be recognized, outputting the sample character corresponding to the character to be recognized as the recognition result; When the character to be recognized cannot be recognized, a recognition result indicating recognition failure is output.
10. The character recognition method according to claim 9, wherein: The recognition result indicating recognition failure includes: A first failure result indicating that there is no similar sample character; and, a second failure result indicating that there are a plurality of sample characters having similar confidence levels; When step S4 outputs a recognition result indicating recognition failure, the character recognition method further includes: Step B5: Obtaining the recognition result indicating recognition failure, and determining the type of the recognition result; When the recognition result is the first failure result, go to step C6; When the recognition result is the second failure result, go to step D6; Step C6: generating a first character sample corresponding to the character to be recognized in the character recognition library, and marking the first character sample; Step D6: generating a second character sample corresponding to the character to be recognized in the character recognition library, and marking the second character sample; The step C6 comprises: Step C61: adding the character to be recognized to the character recognition library; Step C62: recording the overall identification code, the partial identification code, the complete character image, and the partial character image associated with the character to be recognized to construct the first character sample; Step C63: labeling the first character sample; The step D6 comprises: Step D61: adding the character to be recognized to the character recognition library; Step D62: Recording the overall identification code, the partial identification code, the sample characters with similar confidence levels, the complete character image, and the partial character image associated with the character to be recognized, to construct the second character sample; Step D63: labeling the second character sample.
11. A verification code construction method, characterized in that: include: Step E1: extracting multiple contour components of an initial character along a specific direction, and generating a sample code based on all the contour components; The sample code is constructed based on the generation process of the overall identification code and the local identification code according to any one of claims 1 to 10; The outline components include pattern shapes of various parts of the outline of the initial character; Step E2: randomly generating an adjustment parameter, and generating a verification code character corresponding to the initial character according to the adjustment parameter and the sample code; The adjustment parameters include the length, angle and direction assigned to each segment of the verification code character.
Citation Information
Patent Citations
Character identification method and relevant device
CN102831416A
Image character morphing animation generating method
CN103810739A