Ocr recognition result optimization candidate character recommendation method based on stroke comparison

By establishing a character stroke order library and a stroke difference scoring matrix, the problem of the OCR system misjudging similar characters under non-ideal conditions is solved, a structural reference is provided to correct recognition errors, and the accuracy and reliability of character recognition are improved.

CN120612705BActive Publication Date: 2025-10-10CENT SOUTH UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511107167.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-08
Publication Date
2025-10-10
Estimated Expiration
2045-08-08

AI Technical Summary

Technical Problem

Existing OCR systems are prone to misjudging similar characters during the character recognition process, especially under non-ideal conditions such as blurred characters, deformed fonts, or handwritten input. They also lack a structural review mechanism for recognition results, leading to recognition errors.

Method used

By establishing a character stroke order library and a stroke difference scoring matrix, the stroke structure difference between the OCR recognition results and other characters is calculated, and structurally explainable candidate characters are output, providing structural references to correct potential errors.

Benefits of technology

It realizes the difference analysis of OCR recognition results at the stroke structure level, identifies suspected misrecognized characters and provides structural anomaly annotations, providing a clear basis for subsequent proofreading or replacement, and improving recognition accuracy and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120612705B_ABST
    Figure CN120612705B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of character image recognition processing, and specifically discloses an OCR recognition result optimization candidate character recommendation method based on stroke comparison, which can analyze the differences of the OCR recognition result at the stroke structure level by establishing a stroke difference scoring mechanism, determine whether it matches the standard character structure, identify the suspected misrecognized characters and mark the structural abnormalities, provide clear basis for subsequent correction or replacement, and output multiple candidate characters closest to the recognition result structure according to the stroke structure similarity when performing difference analysis, and provide difference degree scores as a reference. The candidate character set and its structure similarity score can be used as the input basis for artificial correction, OCR system post-processing or automatic error correction module, and provide structural reference basis for subsequent review, examination and automatic error correction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of character image recognition processing, and specifically discloses a method for recommending candidate characters based on optimized OCR recognition results based on stroke comparison. Background Art

[0002] Currently, OCR systems are widely used in scenarios such as bill recognition, file digitization, and document processing. Mainstream methods rely on deep learning models such as convolutional neural networks (CNNs), recurrent neural networks (RNNs), and transformers to implement end-to-end text recognition processes. These systems achieve high accuracy when recognizing standard fonts or high-quality images.

[0003] Although current OCR systems can achieve high recognition accuracy under conditions of standard fonts and clear images, in real application environments, such as when there are many characters with similar structures (such as "白" and "百", "口" and "日") or characters with similar strokes, recognition results often show errors.

[0004] Especially under non-ideal conditions such as blurred character images, deformed fonts, and handwritten input, existing OCR systems are prone to misjudging similar characters, and the recognition system itself usually lacks a structural review mechanism for the recognition results, and cannot effectively judge or correct potential errors.

[0005] The present invention provides a method for recommending candidate characters based on stroke comparison and optimization of OCR recognition results, so as to solve the above problems. Summary of the Invention

[0006] The purpose of the present invention is to compare and analyze the stroke structure level of single-word characters output by OCR recognition with a character stroke order library, calculate the difference between the recognition result and other characters, and output several candidate characters with the closest stroke order structure, so as to provide the OCR system with structurally interpretable judgment basis and candidate replacement suggestions.

[0007] To achieve the above objectives, the basic solution of the present invention provides a method for optimizing candidate character recommendation based on OCR recognition results based on stroke comparison, comprising the following steps:

[0008] Step A1: establishing a character stroke order library, which stores stroke sequence information of all standard characters arranged in ascending order, and each stroke sequence information includes a stroke code corresponding to a stroke;

[0009] Step A2: establishing a stroke difference scoring matrix for evaluating the degree of structural difference between any two strokes;

[0010] Step A3: receiving the single character result recognized by OCR as an input character, matching and obtaining the stroke sequence of the input character with the stroke order number from the character stroke order library;

[0011] Step A4: Filter and obtain candidate characters from the character stroke order library according to the stroke order number range to form a candidate character set;

[0012] Step A5: Compare the input character with the candidate characters in sequence, calculate the stroke difference based on the stroke difference scoring matrix to obtain a comparison score, and store the comparison score corresponding to the candidate character in the candidate character set;

[0013] Step A6: Sort the candidate characters in the candidate character set in ascending order according to the comparison scores, retain and output the first N_candidate items, and output a set of each retained candidate character and its comparison score.

[0014] Further, in step A1, the stroke sequence information stored in the character stroke library StrokeLib is represented as: {character c:[s1,s2,...,s k ]},s k Indicates the k-th stroke order of a character, where k = 1, 2, .... The stroke codes in the stroke sequence information of each standard character c are interpreted as follows:

[0015] 1=horizontal, 2=vertical, 3=left stroke, 4=right stroke, 5=falling stroke, 0=empty stroke;

[0016] Among them, empty strokes are used for insertion / deletion structure scoring.

[0017] Furthermore, in step A2, the expression of the stroke difference score matrix StrokeDiffMatrix is ​​as follows:

[0018] ;

[0019] Where StrokeDiffMatrix[i][j] represents the structural difference between the i-th stroke and the j-th stroke, and its value range is [0,1]. A larger value indicates a more obvious difference, and a smaller value indicates a closer structure. The value range of i and j is {0,1,2,3,4,5}, corresponding to the stroke code in the stroke sequence information of each character.

[0020] Further, in step A4, the candidate character set includes character set 1 of all standard characters in the character stroke order library whose number of strokes is the same as the number of strokes of the input character, and character set 3 of all standard characters in the character stroke order library whose number of strokes is one more than the number of strokes of the input character. When the number of strokes of the input character is greater than 1, the candidate character set also includes character set 2 of all standard characters in the character stroke order library whose number of strokes is one less than the number of strokes of the input character.

[0021] Further, in step A5, the process of comparing the input character with the candidate characters in sequence includes comparing the input character with the candidate characters in character set one and character set three in the candidate character set in sequence. When the number of strokes of the input character is greater than 1, it also includes comparing the input character with the candidate characters in character set two in the candidate character set.

[0022] Furthermore, the comparison process of the input character with the candidate characters of the character set 1 in the candidate character set is as follows:

[0023] For each candidate character c w ∈ character set 1, get its stroke sequence S_c=[t1,t2,...,t z ];

[0024] Initialize the difference count diff_count=0 and the comparison score score=0.0;

[0025] Bit-by-bit comparison S_ocr=[s1,s2,...,s k ] and S_c=[t1,t2,...,t z ], where S_ocr is the stroke sequence with the number of strokes of the input character matched from the character stroke order library, k=1,2,..., z=1,2,...;

[0026] If s k With t z If they are not the same, then diff_count+=1 and score w +=StrokeDiffMatrix[s k ][t z ], StrokeDiffMatrix[s k ][t z ] indicates the sth k Strokes and t z The difference in the structure of the strokes, if diff_count≤1, then (c w ,score w ) is added to the candidate character set CandidateSet, and CandidateSet.append((c w ,scorew ))).

[0027] Further, the comparison process between the input character and the candidate characters in the character set three is as follows:

[0028] For each position y∈[0,n-1] in the stroke sequence S_ocr of the input character, delete the y-th stroke s y Construct the deletion variant S_del y , record the deleted stroke s y , and add (S_del y , s y ) to the deletion set, where n represents the length of the stroke sequence, n=len(S_ocr);

[0029] For all candidate characters c w-1 ∈ the character set three, if its stroke sequence is identical to any deletion variant S_del y , record the score score w-1 =StrokeDiffMatrix[s y ][0], and add (c w-1 , score w-1 ) to the candidate character set CandidateSet, resulting in CandidateSet.append((c w-1 , score w-1 )).

[0030] Further, the comparison process between the input character and the candidate characters in the character set three is as follows:

[0031] For each position r∈[0,n] in the stroke sequence S_ocr of the input character and the corresponding stroke code x, x∈{1,2,3,4,5}, insert x in S_ocr at the corresponding position to obtain S_ins r , and add (S_ins r , x) to the insertion set;

[0032] For all candidate characters c w+1 ∈ the character set three, if its stroke sequence is identical to any S_ins r , record the score score w+1 =StrokeDiffMatrix[0][x], and add (c w+1 , score w+1 ) to the candidate character set CandidateSet, resulting in CandidateSet.append((c w+1 , score w+1 )).

[0033] The principle and effect of this solution are:

[0034] 1. Compared with the existing technology, the present invention can perform difference analysis on the OCR recognition results at the stroke structure level to determine whether they match the standard character structure, thereby identifying suspected misrecognized characters and marking structural anomalies, providing a clear basis for subsequent proofreading or replacement, and establishing a stroke difference scoring mechanism.

[0035] 2. Compared with existing technologies, this invention outputs multiple candidate characters that are structurally closest to the recognition result based on stroke structure similarity, and provides a difference score as a reference. The candidate character set and its structural similarity score can be used as input for manual proofreading, OCR system post-processing, or automatic error correction modules, providing a structural reference for subsequent review, inspection, and automatic error correction. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0037] Figure 1 A flowchart of a method for optimizing candidate character recommendation based on OCR recognition results based on stroke comparison proposed in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0038] In order to further illustrate the technical means and effects adopted by the present invention to achieve the predetermined purpose of the invention, the specific implementation methods, structures, features and effects of the present invention are described in detail below in conjunction with the accompanying drawings and preferred embodiments.

[0039] The candidate character recommendation method is optimized based on the OCR recognition results of stroke comparison, and the implementation is as follows: Figure 1 As shown, the following steps are included:

[0040] Step A1: Establish a character stroke order library. The character stroke order library stores stroke sequence information of all standard characters arranged in ascending order. Each stroke sequence information includes a stroke code representing a stroke.

[0041] In this embodiment, the character stroke order library StrokeLib stores the stroke sequence information of all standard characters, and the type of the character stroke order library is Dict[str, List[int]].

[0042] The stroke sequence information stored in the character stroke library StrokeLib is represented as: {character c:[s1,s2,...,sk ]},s k Indicates the kth stroke order of a character, where k = 1, 2, ..., where each standard character c includes a plurality of stroke sequence information arranged in ascending order, and each stroke sequence information contains a stroke code for representing a stroke. The stroke codes in the stroke sequence information of each standard character are interpreted as follows:

[0043] 1 = horizontal stroke, 2 = vertical stroke, 3 = left-falling stroke, 4 = right-falling stroke, 5 = right-falling stroke, 0 = empty stroke. The empty stroke is used for insertion / deletion structure scoring.

[0044] Step A2: Establish a stroke difference score matrix for evaluating the degree of structural difference between any two strokes.

[0045] In this embodiment, the expression of the stroke difference score matrix StrokeDiffMatrix is ​​as follows:

[0046] ;

[0047] Where StrokeDiffMatrix[i][j] represents the structural difference between the i-th and j-th strokes, with a value range of [0,1]. Larger values ​​indicate more significant differences, while smaller values ​​indicate closer structures. The values ​​of i and j both range from {0,1,2,3,4,5}, corresponding to the stroke codes in the stroke sequence information of each character.

[0048] The following is an example of calculating the stroke difference score:

[0049] In the process of calculating the stroke difference, when the third stroke of an input character is identified as "horizontal", that is, the stroke code is 1, and the third stroke of the candidate character is identified as "falling", that is, the stroke code is 3, the comparison score of the structural difference under the same stroke sequence is 0.4, that is, StrokeDiffMatrix[1][3]=0.4.

[0050] During the calculation of the stroke difference, when it is recognized that the candidate character has one more "折" inserted than an input character, that is, the stroke code is 5, the comparison score of the difference of the inserted structure is 0.9, that is, StrokeDiffMatrix[0][5]=0.9 (the difference between the empty stroke and the 折).

[0051] Step A3: Receive the single character result recognized by OCR as the input character C_ocr, match and obtain the stroke sequence with the number of strokes of the input character C_ocr from the character stroke library StrokeLib, and record it as S_ocr=[s1,s2,...,s k], the number of strokes is denoted as n = len(S_ocr).

[0052] Step A4: According to the range of the number of strokes, filter and obtain candidate character set from the character stroke library, the candidate character set includes: all standard characters with the same number of strokes as the input character in the character stroke library, all standard characters with one less number of strokes than the input character in the character stroke library, and all standard characters with one more number of strokes than the input character in the character stroke library.

[0053] Specifically, the candidate character set CandidateSet = [] includes: P n , P n-1 , and P n+1 .

[0054] P n : includes all standard characters with the same number of strokes as S_ocr in the character stroke library StrokeLib;

[0055] P n-1 : includes all standard characters with n-1 strokes in the character stroke library StrokeLib, when n = 1, ignore the character set two;

[0056] P n+1 : includes all standard characters with n+1 strokes in the character stroke library StrokeLib.

[0057] Step A5: Compare the input character with the candidate characters in the character set one, the character set two and the character set three in the candidate character set in turn, calculate the stroke difference degree based on the stroke difference degree scoring matrix to obtain the comparison score, and store the comparison score corresponding to the candidate character to the candidate character set.

[0058] Specifically, it includes the following steps:

[0059] Step A501: Perform equal-length stroke structure comparison with 1 stroke difference allowed.

[0060] For each candidate character c w ∈P n , obtain its stroke sequence S_c = [t1, t2,..., t z ].

[0061] Initialize the difference count diff_count = 0 and the comparison score score = 0.0.

[0062] Compare S_ocr = [s1, s2,..., s k] and S_c=[t1,t2,...,t z ], where S_ocr is the stroke sequence of the input character.

[0063] If s k With t z If they are not the same, then diff_count+=1 and score w +=StrokeDiffMatrix[s k ][t z ], if diff_count≤1, then (c w ,score w ) is added to the candidate character set CandidateSet, and CandidateSet.append((c w ,score w )).

[0064] And, when n>1 exists, go to step A502, and when n=1 exists, go to step A503.

[0065] Step A502: one-stroke structure matching.

[0066] For each position y∈[0,n-1] in the stroke sequence S_ocr of the input character, delete the y-th stroke s y Construct the deletion variant S_del y , record the deleted strokes s y , and (S_del y ,s y ) to the delete collection.

[0067] For all candidate characters c w-1 ∈P n-1 , if its sequence is equal to any deletion variant S_del y , then remember the score w-1 =StrokeDiffMatrix[s y ][0], and in (c w-1 ,score w-1 ) is added to the candidate character set CandidateSet and then the process goes to step A503 to obtain CandidateSet.append((c w-1 ,score w-1 )).

[0068] Step A503: One more stroke structure matching.

[0069] For each position r∈[0,n] in the stroke sequence S_ocr of the input character and the corresponding stroke code x,

[0070] x∈{1,2,3,4,5}, insert x into the corresponding position in S_ocr to get S_ins r , and (S_ins r ,x) is added to the insertion set;

[0071] For all candidate characters c w+1 ∈P n+1 , if its pen sequence is the same as any S_ins r If they are completely consistent, remember to score w+1 =StrokeDiffMatrix[0][x], and in (c w+1 ,score w+1 ) is added to the candidate character set CandidateSet and then the process goes to step A6 to obtain CandidateSet.append((c w+1 ,score w+1 )).

[0072] Step A6: Sort the candidate characters in the candidate character set CandidateSet in ascending order by comparison score, retain and output the top N_candidate items, and output the set of comparison scores of each retained candidate character and the degree of difference in their stroke structure with the input character. The expression is: TopCandidates = [(c1, score1), (c2, score2), ...], where each item is: (candidate character, comparison score). Lower comparison scores indicate closer structures. The characters are sorted in ascending order and are of type List[Tuple[str, int]].

[0073] The present invention can perform difference analysis on the OCR recognition results at the stroke structure level to determine whether they match the standard character structure, thereby identifying suspected misrecognized characters and marking structural anomalies, providing a clear basis for subsequent proofreading or replacement, and establishing a stroke difference scoring mechanism.

[0074] Based on stroke structure similarity, the present invention outputs multiple candidate characters that are structurally closest to the recognition result and provides a difference score as a reference. The candidate character set and its structural similarity score can be used as input for manual proofreading, OCR system post-processing, or automatic error correction modules, providing a structural reference for subsequent review, inspection, and automatic error correction.

[0075] The above description is merely a preferred embodiment of the present invention and does not constitute any form of limitation to the present invention. Although the present invention has been disclosed as a preferred embodiment as above, it is not intended to limit the present invention. Any person skilled in the art can make some changes or modifications to equivalent embodiments using the technical contents disclosed above without departing from the scope of the technical solution of the present invention. However, any indirect modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention are still within the scope of the technical solution of the present invention.

Claims

1. A method for optimizing candidate character recommendation based on OCR recognition results based on stroke comparison, characterized in that: The steps include: Step A1: establishing a character stroke order library, which stores stroke sequence information of all standard characters arranged in ascending order, and each stroke sequence information includes a stroke code corresponding to a stroke; Step A2: establishing a stroke difference scoring matrix for evaluating the degree of structural difference between any two strokes; Step A3: receiving the single character result recognized by OCR as an input character, matching and obtaining the stroke sequence of the input character with the stroke order number from the character stroke order library; Step A4: Filter and obtain candidate characters from the character stroke order library according to the stroke order number range to form a candidate character set; Step A5: Compare the input character with the candidate characters in sequence, calculate the stroke difference based on the stroke difference scoring matrix to obtain a comparison score, and store the comparison score corresponding to the candidate character in the candidate character set; Step A6: Sort the candidate characters in the candidate character set in ascending order according to the comparison scores, retain and output the first N_candidate items, and output a set of each retained candidate character and its comparison score; In step A1, the stroke sequence information stored in the character stroke library StrokeLib is represented as: {character c:[s1,s2,...,s k ]},s k Indicates the k-th stroke order of a character, where k = 1, 2, .... The stroke codes in the stroke sequence information of each standard character c are interpreted as follows: 1=horizontal, 2=vertical, 3=left stroke, 4=right stroke, 5=falling stroke, 0=empty stroke; Among them, empty strokes are used for insertion / deletion structure scoring; In step A2, the expression of the stroke difference score matrix StrokeDiffMatrix is ​​as follows: ; Where StrokeDiffMatrix[i][j] represents the structural difference between the i-th stroke and the j-th stroke, and its value range is [0,1]. A larger value indicates a more obvious difference, and a smaller value indicates a closer structure. The value range of i and j is {0,1,2,3,4,5}, corresponding to the stroke code in the stroke sequence information of each character. In step A4, the candidate character set includes character set 1 of all standard characters in the character stroke order library whose number of strokes is the same as the number of strokes of the input character, and character set 3 of all standard characters in the character stroke order library whose number of strokes is one more than the number of strokes of the input character. When the number of strokes of the input character is greater than 1, the candidate character set also includes character set 2 of all standard characters in the character stroke order library whose number of strokes is one less than the number of strokes of the input character.

2. The method for recommending candidate characters based on stroke comparison and optimizing OCR recognition results according to claim 1, characterized in that: In step A5, the process of comparing the input character with the candidate characters in sequence includes comparing the input character with the candidate characters in character set one and character set three in the candidate character set in sequence. When the number of strokes of the input character is greater than 1, it also includes comparing the input character with the candidate characters in character set two in the candidate character set.

3. The method for recommending candidate characters based on stroke comparison and optimizing OCR recognition results according to claim 2, characterized in that: The comparison process of the input character with the candidate characters of character set 1 in the candidate character set is as follows: For each candidate character c w ∈ character set 1, get its stroke sequence S_c=[t1,t2,...,t z ]; Initialize the difference count diff_count=0 and the comparison score score=0.0; Bit-by-bit comparison S_ocr=[s1,s2,...,s k ] and S_c=[t1,t2,...,t z ], where S_ocr is the stroke sequence with the number of strokes of the input character matched from the character stroke order library, k=1,2,..., z=1,2,...; If s k With t z If they are not the same, then diff_count+=1 and score w +=StrokeDiffMatrix[s k ][t z ], StrokeDiffMatrix[s k ][t z ] indicates the sth k Strokes and t z The difference in the structure of the strokes, if diff_count≤1, then (c w ,score w ) is added to the candidate character set CandidateSet, and CandidateSet.append((c w ,score w )).

4. The method for recommending candidate characters based on stroke comparison and optimizing OCR recognition results according to claim 3, characterized in that: The comparison process of the input character and the candidate characters of the character set 2 in the candidate character set is as follows: For each position y∈[0,n-1] in the stroke sequence S_ocr of the input character, delete the y-th stroke s y Construct the deletion variant S_del y , record the deleted strokes s y , and (S_del y ,s y ) is added to the deletion set, where n represents the length of the pen sequence column, n=len(S_ocr); For all candidate characters c w-1 ∈ character set 2, if its stroke sequence is equal to any deletion variant S_del y , then remember the score w-1 =StrokeDiffMatrix[s y ][0], and (c w-1 ,score w-1 ) is added to the candidate character set CandidateSet, and CandidateSet.append((c w-1 ,score w-1 )).

5. The method for recommending candidate characters based on stroke comparison and optimizing OCR recognition results according to claim 4, characterized in that: The comparison process of the input character and the candidate characters of character set 3 in the candidate character set is as follows: For each position r∈[0,n] in the stroke sequence S_ocr of the input character and the corresponding stroke code x, x∈{1,2,3,4,5}, insert x into the corresponding position in S_ocr to get S_ins r , and (S_ins r ,x) is added to the insertion set; For all candidate characters c w+1 ∈ character set three, if its stroke sequence is the same as any S_ins r If they are completely consistent, remember to score w+1 =StrokeDiffMatrix[0][x], and (c w+1 ,score w+1 ) is added to the candidate character set CandidateSet, and CandidateSet.append((c w+1 ,score w+1 )).

Citation Information

Patent Citations

  • Method and device for hand writing identification using character structural information for post treatment

    CN101149805A

  • Writing information evaluation method and device, electronic equipment and storage medium

    CN115346223A