A label processing method, device and computer readable storage medium
By calculating and correcting the similarity of the label recognition results, the problem of low OCR recognition accuracy is solved, and the accuracy of the label recognition results is improved.
Patent Information
- Application Number
- CN202111258007.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-27
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2041-10-27
AI Technical Summary
In the prior art, OCR recognition accuracy is not high, resulting in inaccurate label recognition results, and it is necessary to improve the accuracy of character recognition results.
By traversing all tags of the appliance to which the tag is to be identified, the tag to be identified is recognized is recognized using optical character recognition OCR to identify the tag, obtain the similarity between the character string and the recognition result, and determine the output of the tag based on the maximum similarity, thereby correcting the character recognition result of the OCR.
The correction of OCR character recognition results is achieved, and the accuracy of label recognition results is improved.
Smart Images

Figure CN114022660B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to information processing technology, and more particularly to a label processing method, device and computer-readable storage medium. Background Art
[0002] Electric power booster stations and substations have high voltage and high risk factors, and often require regular inspections. However, due to the large number of equipment, instruments, and meter labels, manual copying often results in misreading and omissions. Therefore, automatic label recognition and automatic meter reading have been widely used.
[0003] In the prior art, optical character recognition (OCR) is usually used to recognize the label to obtain output content.
[0004] However, the OCR recognition accuracy is not high, so how to improve the accuracy of character recognition results is an urgent problem to be solved. Summary of the invention
[0005] The present application provides a label processing method, device and computer-readable storage medium, which can correct the character recognition results of OCR, thereby improving the accuracy of label recognition results.
[0006] The present application provides a label processing method, including:
[0007] Traversing all labels of the electrical appliance to which the label to be identified belongs to obtain a character string corresponding to each label, and using optical character recognition (OCR) to identify the label to be identified to obtain an identification result;
[0008] For each traversed character string, respectively obtain the similarity between the character string and the recognition result;
[0009] The output of the tag to be identified is determined according to the character string corresponding to the maximum similarity obtained and the recognition result.
[0010] Compared with the related art, the label processing method provided in the present application performs similarity calculation on the traversed character string and the recognition result obtained by OCR recognition, and then determines the output of the label according to the calculation result, thereby realizing the correction of the OCR character recognition result, thereby improving the accuracy of the label recognition result.
[0011] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by implementing the present application. Other advantages of the present application can be realized and obtained by the schemes described in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The accompanying drawings are used to provide an understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0013] Figure 1 A flowchart of a label processing method provided in an embodiment of the present application;
[0014] Figure 2 A flowchart of another label processing method provided in an embodiment of the present application;
[0015] Figure 3 A schematic diagram of a process for creating character mapping data provided in an embodiment of the present application;
[0016] Figure 4 A schematic diagram of a process for calculating similarity probability provided in an embodiment of the present application. DETAILED DESCRIPTION
[0017] This paper provides a label processing method, such as Figure 1 As shown, including:
[0018] Step 101, traverse all labels of the electrical appliance to which the label to be identified belongs to obtain a character string corresponding to each label, and use optical character recognition (OCR) to identify the label to be identified to obtain a recognition result.
[0019] Step 102: for each traversed character string, obtain the similarity between the character string and the recognition result.
[0020] Step 103: Determine the output of the tag to be identified according to the character string corresponding to the maximum similarity obtained and the recognition result.
[0021] The label processing method provided in the embodiment of the present application performs similarity calculation on the traversed character string and the recognition result obtained by OCR recognition, and then determines the output of the label based on the calculation result, thereby achieving correction of the OCR character recognition result, thereby improving the accuracy of the label recognition result.
[0022] In an exemplary embodiment, obtaining the similarity between the character string and the recognition result includes:
[0023] First, character codes of the character string and the recognition result are obtained according to the number of occurrences and positions of each character in the character string and the number of occurrences and positions of each character in the recognition result.
[0024] Secondly, the similarity between the character string and the recognition result is obtained according to the character codes of the character string and the recognition result.
[0025] In an exemplary embodiment, obtaining the character codes of the character string and the recognition result according to the number of occurrences and positions of each character in the character string and the number of occurrences and positions of each character in the recognition result, respectively, includes:
[0026] First, an array having the same number of elements as the length of the character string and an array having the same number of elements as the length of the recognition result are created respectively; wherein each element in the array is a first value.
[0027] Secondly, according to the traversed string and the position where each character appears in the recognition result, the elements at the corresponding positions of the corresponding arrays are modified to second numerical values, so as to obtain a binary array as the character encoding of each character in the string and the recognition result; wherein, for a traversed string or a character that appears multiple times in the recognition result, multiple character encodings are merged into one character encoding.
[0028] Finally, the character codes of all characters in the character string are used as the character code of the character string, and the character codes of all characters in the recognition result are used as the character code of the recognition result.
[0029] In an exemplary embodiment, the first value may be 0, and the second value may be 1. For example, in the label 'current voltage', there are two positions
[1000] and
[0010] for the voltage, so
[1000] and
[0010] are combined to obtain
[1010] .
[0030] In an exemplary embodiment, obtaining the similarity between the character string and the recognition result according to the character codes of the character string and the recognition result includes:
[0031] First, the character matching degree and the position matching degree of the character string and the recognition result are obtained according to the character codes of the character string and the recognition result.
[0032] Secondly, the similarity between the character string and the recognition result is obtained according to the character matching degree and the position matching degree.
[0033] In an exemplary embodiment, assuming that the traversed label is: "electronic charge", the corresponding character code is: electricity
[1010] , sub
[0100] , quantity
[0001] , and the recognition result obtained by OCR is: "electronic current, the corresponding character code is: electricity
[1010] , sub
[0100] , flow
[0000] , then the similarity between the two is to use the traversed character code: electricity
[1010] and the character code obtained by OCR: electricity
[1010] to perform computer position matching, use the traversed character code: sub
[0100] and the character code obtained by OCR: sub
[0100] to perform computer position matching, use the traversed character code: quantity
[0001] and the character code obtained by OCR: flow
[0000] to perform computer position matching, and then obtain the character matching degree and position matching degree, and finally obtain the similarity between the two.
[0034] In an exemplary embodiment, obtaining the character matching degree of the character string and the recognition result according to the character codes of the character string and the recognition result includes:
[0035] First, the number of second numerical values in the character codes of the character string and the recognition result is obtained.
[0036] Secondly, the ratio of the minimum value to the maximum value of the two obtained values is calculated to obtain the character matching degree between the character string and the recognition result.
[0037] In an exemplary embodiment, obtaining the position matching degree of the character string and the recognition result according to the character codes of the character string and the recognition result includes:
[0038] The sum of the products of the character code of the character string and the character code of the recognition result is calculated to obtain the position matching degree of the character string and the recognition result.
[0039] In an exemplary embodiment, determining the output of the tag to be identified according to the character string corresponding to the maximum similarity obtained and the recognition result includes:
[0040] First, when the obtained similarities have two identical maximum values, the recognition result is used as the output of the tag to be recognized.
[0041] Secondly, when there are no two identical maximum values of the obtained similarities, the character string corresponding to the maximum similarity is used as the output of the label to be identified.
[0042] This paper also provides a label processing method, such as Figure 2 As shown, including:
[0043] Step 201, create an electrical cabinet tag mapping.
[0044] Create a dictionary mapping data structure of the text labels of each electrical cabinet for each electrical equipment label that needs to be detected. For example, electrical cabinet 001: ["electrical switch", "current switch"].
[0045] Step 202: Create a tag score dictionary.
[0046] Create a dictionary data structure to store the predicted scores for each label character.
[0047] Step 203, traverse each tag of the current electrical cabinet.
[0048] Step 204: input the OCR text recognition result.
[0049] After OCR detects the text position and infers the text content of the current electrical cabinet, it will make a predicted output for the current electrical instrument label.
[0050] Step 205: Create character mapping data.
[0051] The output result of step 204 and each tag traversed in step 203 are used to create character mapping data respectively, so as to describe the data structure of the characters.
[0052] Step 206, calculating the similarity probability.
[0053] The similarity probability is calculated for the results respectively generated in step 205, that is, the similarity probability score between the OCR text recognition result and the currently traversed label is predicted.
[0054] Step 207: store the current label and probability score into the label score dictionary.
[0055] The result calculated in step 206 is stored in a dictionary data structure, where the dictionary key is the text label currently traversed in step 203 and the value is the similarity probability score output in step 206 .
[0056] Step 208, sort the tag score dictionary in descending order of value.
[0057] The probability scores of the text labels obtained in step 207 are sorted in descending order.
[0058] Step 209: Check whether the first and second values after sorting are the same.
[0059] It is determined whether the scores sorted in step 208 have two identical maximum values.
[0060] If yes, execute step 204 to input the OCR text recognition result. No matching operation is performed on the result of step 204.
[0061] If not, execute step 210 to output the label of the first value. Output the label corresponding to the first maximum probability value in step 209 as the label of the detection instrument.
[0062] In one illustrative example, Figure 2 The specific steps of creating character mapping data in the corresponding embodiment are as follows: Figure 3 As shown, including:
[0063] Step 301, input label text.
[0064] The label obtained in step 201 and the OCR text obtained in step 204 are input.
[0065] Step 302, calculate the length of the label text.
[0066] The label length and OCR text length obtained in step 301 are calculated respectively.
[0067] Step 303: Create a character encoding data format.
[0068] Here you need to create a dictionary data format for a single character to store the conversion code for each character.
[0069] Step 304, traverse each character of the label text.
[0070] Each character of the tag in step 301 is parsed.
[0071] Step 305: Check whether it is the last character of the label text.
[0072] The determination step 304 traverses whether the current position is the last character of the tag.
[0073] If yes, execute step 311 to output the character encoding mapping data of the label text, and then exit the loop and terminate directly.
[0074] If not, execute step 306 to create an all-0 matrix of the label character length.
[0075] Create a matrix of all 0s based on the obtained label length.
[0076] Step 307, modify the current character position of the all-0 matrix to 1.
[0077] The character position in step 304 is obtained, and the matrix value created in step 306 corresponding to the position is modified to 1.
[0078] Step 308, determining whether the current character already exists in the character encoding mapping.
[0079] If yes, execute step 309 to perform a union operation on the current character, the character code, and the matrix of the character code mapping, and continue to execute step 310.
[0080] If not, execute step 310 to store the current character and matrix in the character encoding map.
[0081] Perform a matrix union operation on the matrix of the current character and the corresponding character matrix in step 303.
[0082] Step 311, output the character encoding mapping data of the label text.
[0083] In one illustrative example, Figure 2 The specific steps of calculating the similarity probability in the corresponding embodiment are as follows: Figure 4 As shown, including:
[0084] Step 401, read the character mapping dictionary of the current tag.
[0085] Step 402, read the character mapping dictionary for OCR text recognition.
[0086] Step 403, creating character matching probability and position matching probability variables.
[0087] The variables created are mainly used to describe the probability of character matching quantity accuracy and character matching position accuracy probability.
[0088] Step 404, traverse each character in the character mapping dictionary.
[0089] The characters in step 401 and step 402 are traversed.
[0090] Step 405, determining whether the character recognized by OCR is equal to the current label character.
[0091] Determine whether the character in step 402 is the same as the character in step 401.
[0092] If not, step 410 is executed to output the quantity accuracy probability as 0.
[0093] A value of 0 is stored in step 403. The character currently being traversed by the OCR is not in the result obtained by reading in step 401, so the probability of the quantity accuracy is 0, and the probability of the position accuracy is 0.
[0094] If yes, execute step 406 to read the matrix of OCR recognized characters and the matrix of current label characters.
[0095] The character matrices corresponding to the characters in step 402 and step 401 are read respectively.
[0096] Step 407, calculating the number of non-zero values in the OCR recognition character matrix and the current label character matrix.
[0097] The number of non-zero values in the matrix is obtained in step 406 .
[0098] Step 408, calculating the probability of the number of tag matches.
[0099] The probability is calculated as: min(num_ocr, num_label) / max(num_ocr, num_label), where num_ocr is the number of non-zero values in the OCR recognition character matrix in step S607, and num_label is the number of non-zero values in the current label character matrix in step 407. The minimum value of num_ocr and num_label is divided by the maximum value.
[0100] Step 409, determining whether the length of the OCR recognized character matrix is equal to the length of the current label character matrix.
[0101] If not, step 410 is executed to output the position accuracy probability as 0.
[0102] A value of 0 is stored in step 403, indicating that the quantity is detected at this time, but the position is not correctly matched.
[0103] If yes, execute step 411 to calculate the product of the OCR recognition character matrix and the current label character matrix.
[0104] Step 412: output the sum of the quantity matching probability and the position matching probability.
[0105] The sum of the quantity matching probability and the position matching probability in step 403 is output.
[0106] The present invention also provides a label processing device, characterized in that it includes a memory and a processor, wherein the memory stores a computer program, and when the computer program on the memory is executed by the processor, the following steps are performed:
[0107] All labels of the electrical appliance to which the label to be identified belongs are traversed to obtain a character string corresponding to each label, and the label to be identified is identified by using optical character recognition (OCR) to obtain an identification result.
[0108] For each traversed character string, the similarity between the character string and the recognition result is obtained respectively.
[0109] The output of the tag to be identified is determined according to the character string corresponding to the maximum similarity obtained and the recognition result.
[0110] In an exemplary embodiment, when the computer program on the memory is executed by the processor, the following steps are specifically performed:
[0111] The character codes of the character string and the recognition result are obtained according to the number of occurrences and position of each character in the character string and the number of occurrences and position of each character in the recognition result.
[0112] The similarity between the character string and the recognition result is obtained according to the character codes of the character string and the recognition result.
[0113] In an exemplary embodiment, when the computer program on the memory is executed by the processor, the following steps are further specifically performed:
[0114] In an exemplary embodiment, an array having the same number of elements as the length of the character string and an array having the same number of elements as the length of the recognition result are created respectively; wherein each element in the array is a first numerical value.
[0115] According to the traversed string and the position where each character appears in the recognition result, the elements at the corresponding positions of the corresponding arrays are modified to second numerical values, so as to obtain a binary array as the character encoding of each character in the string and the recognition result; wherein, for a traversed string or a character that appears multiple times in the recognition result, multiple character encodings are merged into one character encoding.
[0116] The character codes of all characters in the character string are used as the character code of the character string, and the character codes of all characters in the recognition result are used as the character code of the recognition result.
[0117] In an exemplary embodiment, when the computer program on the memory is executed by the processor, the following steps are further specifically performed:
[0118] The character matching degree and the position matching degree of the character string and the recognition result are obtained according to the character codes of the character string and the recognition result.
[0119] The similarity between the character string and the recognition result is obtained according to the character matching degree and the position matching degree.
[0120] In an exemplary embodiment, when the computer program on the memory is executed by the processor, the following steps are further specifically performed:
[0121] The number of second numerical values in the character codes of the character string and the recognition result is obtained.
[0122] The ratio of the minimum value to the maximum value of the two obtained values is calculated to obtain the character matching degree between the character string and the recognition result.
[0123] In an exemplary embodiment, when the computer program on the memory is executed by the processor, the following steps are further specifically performed:
[0124] The sum of the products of the character code of the character string and the character code of the recognition result is calculated to obtain the position matching degree of the character string and the recognition result.
[0125] In an exemplary embodiment, when the computer program on the memory is executed by the processor, the following steps are further specifically performed:
[0126] When the obtained similarities have two identical maximum values, the recognition result is used as the output of the tag to be recognized.
[0127] When there are no two identical maximum values of the obtained similarities, the character string corresponding to the maximum similarity is output as the label to be identified.
[0128] The label processing device provided in the embodiment of the present application performs similarity calculation on the traversed character string and the recognition result obtained by using OCR recognition, and then determines the output of the label based on the calculation result, thereby realizing the correction of the OCR character recognition result, thereby improving the accuracy of the label recognition result.
[0129] This article also provides a computer-readable storage medium, on which computer-executable commands are stored, and the computer-executable commands are used to execute the steps described in any of the above-mentioned label processing methods.
[0130] The present application describes multiple embodiments, but the description is exemplary rather than restrictive, and it is obvious to those skilled in the art that there may be more embodiments and implementations within the scope of the embodiments described in the present application. Although many possible feature combinations are shown in the drawings and discussed in the specific embodiments, many other combinations of the disclosed features are also possible. Unless specifically limited, any feature or element of any embodiment may be used in combination with any other feature or element in any other embodiment, or may replace any other feature or element in any other embodiment.
[0131] The present application includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The embodiments, features and elements disclosed in the present application may also be combined with any conventional features or elements to form a unique invention scheme defined by the claims. Any features or elements of any embodiment may also be combined with features or elements from other invention schemes to form another unique invention scheme defined by the claims. Therefore, it should be understood that any feature shown and / or discussed in the present application may be implemented individually or in any appropriate combination. Therefore, except for the limitations made according to the attached claims and their equivalents, the embodiments are not subject to other restrictions. In addition, various modifications and changes may be made within the scope of protection of the attached claims.
[0132] In addition, when describing representative embodiments, the specification may have presented the method and / or process as a specific sequence of steps. However, to the extent that the method or process does not rely on the specific order of the steps described herein, the method or process should not be limited to the steps of the specific order described. As will be understood by those of ordinary skill in the art, other sequences of steps are also possible. Therefore, the specific sequence of the steps set forth in the specification should not be interpreted as a limitation to the claims. In addition, the claims for the method and / or process should not be limited to the steps of performing them in the order written, and those skilled in the art can easily understand that these sequences can be changed and still remain within the spirit and scope of the embodiments of the present application.
[0133] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
Claims
1. A label processing method, characterized in that: include: Traversing all labels of the electrical appliance to which the label to be identified belongs to obtain a character string corresponding to each label, and using optical character recognition (OCR) to identify the label to be identified to obtain an identification result; For each traversed character string, respectively obtain the similarity between the character string and the recognition result; Determine the output of the tag to be identified according to the character string corresponding to the maximum similarity obtained and the recognition result; Obtaining the similarity between the character string and the recognition result includes: Obtaining character codes of the character string and the recognition result according to the number of occurrences and positions of each character in the character string and the number of occurrences and positions of each character in the recognition result; Obtaining the similarity between the character string and the recognition result according to the character codes of the character string and the recognition result; Obtaining character codes of the character string and the recognition result according to the number of occurrences and positions of each character in the character string and the number of occurrences and positions of each character in the recognition result, respectively, includes: Create an array whose number of elements is the same as the length of the character string and an array whose number of elements is the same as the length of the recognition result respectively; wherein each element in the array is a first value; According to the traversed string and the position where each character appears in the recognition result, the elements at the corresponding positions of the corresponding arrays are respectively modified to second values, and a binary array is obtained as the character code of each character in the string and the recognition result; wherein, for a traversed string or a character that appears multiple times in the recognition result, multiple character codes are merged into one character code; The character codes of all characters in the character string are used as the character code of the character string, and the character codes of all characters in the recognition result are used as the character code of the recognition result.
2. The method according to claim 1, characterized in that Obtaining the similarity between the character string and the recognition result according to the character codes of the character string and the recognition result, including: Obtaining a character matching degree and a position matching degree between the character string and the recognition result according to the character codes of the character string and the recognition result; The similarity between the character string and the recognition result is obtained according to the character matching degree and the position matching degree.
3. The method according to claim 2, characterized in that Obtaining a character matching degree between the character string and the recognition result according to the character codes of the character string and the recognition result includes: Obtain the number of second numerical values in the character codes of the character string and the recognition result; The ratio of the minimum value to the maximum value of the two obtained values is calculated to obtain the character matching degree between the character string and the recognition result.
4. The method according to claim 2, characterized in that: Obtaining the position matching degree of the character string and the recognition result according to the character codes of the character string and the recognition result includes: The sum of the products of the character code of the character string and the character code of the recognition result is calculated to obtain the position matching degree of the character string and the recognition result.
5. The method according to claim 1, characterized in that Determining the output of the tag to be identified according to the character string corresponding to the maximum similarity obtained and the recognition result, including: When the obtained similarities have two identical maximum values, the recognition result is used as the output of the tag to be recognized; When there are no two identical maximum values of the obtained similarities, the character string corresponding to the maximum similarity is output as the label to be identified.
6. A label processing device, characterized in that: The system comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program in the memory is executed by the processor, the following steps are performed: Traversing all labels of the electrical appliance to which the label to be identified belongs to obtain a character string corresponding to each label, and using optical character recognition (OCR) to identify the label to be identified to obtain an identification result; For each traversed character string, respectively obtain the similarity between the character string and the recognition result; Determine the output of the tag to be identified according to the character string corresponding to the maximum similarity obtained and the recognition result; When the computer program in the memory is executed by the processor, the following steps are further performed: Obtaining character codes of the character string and the recognition result according to the number of occurrences and positions of each character in the character string and the number of occurrences and positions of each character in the recognition result; Obtaining the similarity between the character string and the recognition result according to the character codes of the character string and the recognition result; When the computer program in the memory is executed by the processor, the following steps are further performed: Create an array whose number of elements is the same as the length of the character string and an array whose number of elements is the same as the length of the recognition result respectively; wherein each element in the array is a first value; According to the traversed string and the position where each character appears in the recognition result, the elements at the corresponding positions of the corresponding arrays are respectively modified to second values, and a binary array is obtained as the character code of each character in the string and the recognition result; wherein, for a traversed string or a character that appears multiple times in the recognition result, multiple character codes are merged into one character code; The character codes of all characters in the character string are used as the character code of the character string, and the character codes of all characters in the recognition result are used as the character code of the recognition result.
7. A computer-readable storage medium, characterized in that: The storage medium stores computer executable commands, and the computer executable commands are used to execute the steps described in any one of claims 1 to 5.
Citation Information
Patent Citations
Method, device and equipment used for determining similarity information among character string information
CN102184169A
Correction method and apparatus for OCR result
CN107220639A