Optical character recognition method and device, electronic equipment and storage medium

CN118038475BActive Publication Date: 2026-10-30成方金融科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410045367.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-11
Publication Date
2026-10-30
Estimated Expiration
2044-01-11

AI Technical Summary

Technical Problem

[0005]本发明提供一种光学字符识别方法、装置、电子设备及存储介质,用以解决现有技术中某些表格、票据的版式经常会因为工作需要发生变化,此时原本训练的模型很难快速适应新的版式得到比较良好的效果,从而降低了光学字符识别的识别准确率的缺陷

Benefits of technology

[0053]本发明提供的光学字符识别方法、装置、电子设备及存储介质,基于语义得分、距离得分,以及字符串合并得分,确定邻接检测区域对的合并指标,基于合并指标对邻接检测区域对进行合并,得到目标邻接检测区域,最后,基于目标邻接检测区域,确定待识别图像的光学字符识别结果,一方面,综合了语义得分、距离得分和字符串合并得分三个层面的合并指标,对光学字符识别结果进行进一步优化,获得更加准确的检测区域和识别结果;另一方面,可以适应多变的待识别图像版面,即使没有大量训练样本也可以得到效果不错的识别结果;并且,计算简单快速,相较于使用大量训练样本更新图像类网络,本发明实施例的处理方法仅仅增加了一两个语言模型,对计算速度的影响不大,且进一步提高了光学字符识别的识别准确率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118038475B_ABST
    Figure CN118038475B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of optical character recognition, and provides an optical character recognition method and device, electronic equipment and a storage medium. The method comprises the following steps: recognizing an image to obtain an initial recognition result; performing a loop process until a preset condition is met; the loop process comprises the following steps: in the case that text in a text detection region in the initial recognition result is not a same phrase or a same short sentence, splitting the text to obtain a split recognition result; determining a pair of adjacent detection regions in the split recognition result; matching a preset phrase table with the text of the pair of adjacent regions to obtain a semantic score; determining a distance score based on a region distance between regions and adjacent regions; determining a string merging score based on a string length; determining a merging index based on the semantic score, the distance score and the string merging score; merging the pair of adjacent detection regions based on the merging index to obtain a target adjacent detection region; and determining a recognition result based on the target adjacent detection region, so that the accuracy of the recognition result is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of optical character recognition technology, and in particular to an optical character recognition method, apparatus, electronic device and storage medium. Background Technology

[0002] OCR (Optical Character Recognition) refers to the process by which electronic devices (such as scanners or digital cameras) examine characters printed on paper and then use character recognition methods to translate the shapes into computer text. OCR technology is widely used in applications such as ID card recognition, ticket recognition, and license plate recognition.

[0003] Current OCR technology primarily employs deep learning methods, and its main technical approaches can be broadly categorized into end-to-end algorithms and two-stage algorithms. Two-stage algorithms divide text detection and recognition in OCR technology into two steps, which are completed sequentially. End-to-end algorithms, on the other hand, directly output the recognition result from the input image.

[0004] In the past, in numerous practical applications, obtaining a good OCR model in a vertical field often required annotating and training a large number of vertical images. However, in many scenarios, acquiring and annotating a large number of vertical images is very difficult. For example, the layout of certain tables and invoices often changes due to work requirements. In such cases, the originally trained model struggles to quickly adapt to the new layout and achieve good results, thus reducing the recognition accuracy of optical character recognition. Summary of the Invention

[0005] This invention provides an optical character recognition method, apparatus, electronic device, and storage medium to address the shortcomings of existing technologies where the layout of certain forms and documents often changes due to work requirements. In such cases, the originally trained model struggles to quickly adapt to the new layout and achieve good results, thereby reducing the accuracy of optical character recognition.

[0006] This invention provides an optical character recognition method, comprising:

[0007] Acquire the image to be identified, and identify the image to be identified to obtain the initial recognition result of the image to be identified;

[0008] The loop process continues until a preset condition is met; the loop process includes:

[0009] If the text within the text detection area in the initial recognition result is not the same phrase or the same short sentence, the text is split to obtain a split recognition result;

[0010] Based on the initial identification result and the split identification result, an unsplit identification result is determined, and adjacent detection region pairs in the split identification result and the unsplit identification result are determined;

[0011] In the presence of a preset phrase list, the preset phrase list is matched with the text of the adjacent detection region pair to obtain the semantic score of the adjacent detection region pair.

[0012] In the absence of the preset phrase table, or in the case where the semantic score of the adjacent detection region pair is 0, it is determined whether the text of the adjacent detection region pair is the same phrase or the same short sentence, and the confidence score of the text of the adjacent detection region pair being the same phrase or the same short sentence is obtained. The confidence score is used as the semantic score of the adjacent detection region pair.

[0013] Determine the region distance between the center detection region of the adjacent detection region pair and the adjacent detection regions of the detection region, and determine the distance score of the adjacent detection region pair based on the region distance;

[0014] Determine the string length of each detection region in the adjacent detection region pair, and determine the string merging score of the adjacent detection region pair based on the string length;

[0015] Based on the semantic score, the distance score, and the string merging score, a merging index for the adjacent detection region pairs is determined. The adjacent detection region pairs are then merged based on the merging index to obtain a target adjacent detection region. The preset condition is that the obtained target adjacent detection region remains unchanged.

[0016] Based on the target adjacency detection region, the optical character recognition result of the image to be recognized is determined.

[0017] According to an optical character recognition method provided by the present invention, the step of determining the string length of each detection region in the adjacent detection region pair, and determining the string merging score of the adjacent detection region pair based on the string length, includes:

[0018] Determine the length of the first string in the middle detection area of ​​the adjacent detection area, and the length of the second string in the middle detection area of ​​the other detection area of ​​the adjacent detection area;

[0019] Determine the minimum and maximum string lengths among the first string length and the second string length;

[0020] Based on the minimum string length and the maximum string length, the string merging score of the adjacent detection region pair is determined.

[0021] According to an optical character recognition method provided by the present invention, determining the distance score of the adjacent detection region pair based on the region distance includes:

[0022] If the distance between the regions is greater than a first preset threshold, the distance score of the adjacent detection region pair is determined to be a second preset value;

[0023] If the distance between the regions is less than or equal to the first preset threshold, the total length of the adjacent detection region pair is determined, and the distance score of the adjacent detection region pair is determined based on the total length and the distance between the regions.

[0024] According to an optical character recognition method provided by the present invention, the step of matching the preset phrase list with the text of the adjacent detection region pair to obtain the semantic score of the adjacent detection region pair includes:

[0025] The text of the adjacent detection regions is merged to obtain the merged text and the length of the merged text;

[0026] The preset phrase list is matched with the merged text, and if the length of a phrase in the preset phrase list is greater than the length of the merged text, and the preset phrase list contains the merged text, the semantic score of the adjacent detection region pair is determined to be a third preset value.

[0027] If the preset phrase table does not contain the merged text, the semantic score of the adjacent detection region pair is determined to be the fourth preset value.

[0028] According to an optical character recognition method provided by the present invention, when the preset phrase table does not contain the merged text, the method further includes determining the semantic score of the adjacent detection region pair as a fourth preset value, and then further comprising:

[0029] Determine whether the merged texts are the same phrase or the same short sentence, and obtain the confidence score that the merged texts are the same phrase or the same short sentence;

[0030] The semantic score of the adjacent detection region pair is determined based on the confidence score.

[0031] According to an optical character recognition method provided by the present invention, determining the adjacent detection region pairs in the split recognition result and the unsplit recognition result includes:

[0032] Based on the split identification results and the categories of the detected regions in the unsplit identification results, the adjacent detection regions of the detected regions are determined;

[0033] The detection region and the adjacent detection region are merged to obtain the adjacent detection region pair.

[0034] According to an optical character recognition method provided by the present invention, the categories of the detection regions in the split recognition result and the unsplit recognition result include a first detection region, a second detection region, and a third detection region;

[0035] The step of determining the adjacent detection regions of the detection region based on the category of the detection region in the split identification result and the unsplit identification result includes:

[0036] When the category of the detection area is the first detection area, the adjacent detection areas of the first detection area are determined to be the detection area below and the detection area to the right of the first detection area.

[0037] When the category of the detection area is the second detection area, the adjacent detection area of ​​the second detection area is determined as the right detection area of ​​the second detection area;

[0038] If the category of the detection area is the third detection area, the adjacent detection area of ​​the third detection area is determined as the detection area below the third detection area.

[0039] The present invention also provides an optical character recognition device, comprising:

[0040] The recognition unit is used to acquire the image to be recognized and to recognize the image to obtain the initial recognition result of the image to be recognized;

[0041] An execution unit is used to execute a loop process until a preset condition is met; the loop process includes:

[0042] If the text within the text detection area in the initial recognition result is not the same phrase or the same short sentence, the text is split to obtain a split recognition result.

[0043] Based on the initial identification result and the split identification result, an unsplit identification result is determined, and adjacent detection region pairs in the split identification result and the unsplit identification result are determined;

[0044] In the presence of a preset phrase list, the preset phrase list is matched with the text of the adjacent detection region pair to obtain the semantic score of the adjacent detection region pair.

[0045] In the absence of the preset phrase table, or in the case where the semantic score of the adjacent detection region pair is 0, it is determined whether the text of the adjacent detection region pair is the same phrase or the same short sentence, and the confidence score of the text of the adjacent detection region pair being the same phrase or the same short sentence is obtained. The confidence score is used as the semantic score of the adjacent detection region pair.

[0046] Determine the region distance between the center detection region of the adjacent detection region pair and the adjacent detection regions of the detection region, and determine the distance score of the adjacent detection region pair based on the region distance;

[0047] Determine the string length of each detection region in the adjacent detection region pair, and determine the string merging score of the adjacent detection region pair based on the string length;

[0048] Based on the semantic score, the distance score, and the string merging score, a merging index for the adjacent detection region pairs is determined. The adjacent detection region pairs are then merged based on the merging index to obtain a target adjacent detection region. The preset condition is that the obtained target adjacent detection region remains unchanged.

[0049] The optical character recognition result determination unit is used to determine the optical character recognition result of the image to be recognized based on the target adjacent detection area.

[0050] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the optical character recognition method as described above.

[0051] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the optical character recognition method as described above.

[0052] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the optical character recognition method as described above.

[0053] The optical character recognition method, apparatus, electronic device, and storage medium provided by this invention determine the merging index of adjacent detection region pairs based on semantic score, distance score, and string merging score. The adjacent detection region pairs are then merged based on the merging index to obtain the target adjacent detection region. Finally, the optical character recognition result of the image to be recognized is determined based on the target adjacent detection region. On the one hand, it integrates the merging indexes from three levels—semantic score, distance score, and string merging score—to further optimize the optical character recognition result, obtaining more accurate detection regions and recognition results. On the other hand, it can adapt to varying image layouts and achieve good recognition results even without a large number of training samples. Furthermore, the calculation is simple and fast. Compared to updating image-based networks using a large number of training samples, the processing method of this invention only adds one or two language models, having little impact on computational speed, and further improves the recognition accuracy of optical characters. Attached Figure Description

[0054] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0055] Figure 1 This is one of the flowcharts illustrating the optical character recognition method provided by the present invention;

[0056] Figure 2 This is a schematic diagram illustrating the text segmentation within the detection area provided by the present invention;

[0057] Figure 3 This is a schematic diagram of merging adjacent detection region pairs based on merging indicators provided by the present invention;

[0058] Figure 4 This is a flowchart illustrating step 410 provided by the present invention;

[0059] Figure 5 This is the second flowchart illustrating the optical character recognition method provided by the present invention;

[0060] Figure 6 This is a schematic diagram of the structure of the optical character recognition device provided by the present invention;

[0061] Figure 7 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0062] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0063] The terms “first,” “second,” and “third,” etc., used in the specification and claims of this invention are used to distinguish similar objects and are not used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and that the objects distinguished by “first,” “second,” and “third,” etc., are generally of the same class.

[0064] This invention provides an optical character recognition method. Figure 1 This is one of the flowcharts illustrating the optical character recognition method provided by the present invention, such as... Figure 1 As shown, the method includes:

[0065] Step 110: Obtain the image to be identified and identify the image to be identified to obtain the initial identification result of the image to be identified.

[0066] Specifically, an image to be identified can be acquired. Here, the image to be identified is the image that needs to be recognized. It can be pre-acquired by an image acquisition device, captured in real time, or downloaded or scanned from the Internet. This embodiment of the invention does not specifically limit this.

[0067] After obtaining the image to be recognized, it can be recognized to obtain the initial recognition result.

[0068] Here, various OCR detection and recognition networks can be used to recognize the image to be recognized. These networks can be end-to-end recognition networks or two-stage recognition networks. This embodiment of the invention does not specifically limit the types of OCR detection and recognition networks used.

[0069] Here, the initial recognition results may include the coordinates of the text detection regions in the image to be recognized and the text content of each detection region.

[0070] Step 120: Execute a loop process until a preset condition is met; the loop process includes:

[0071] If the text within the text detection area in the initial recognition result is not the same phrase or the same short sentence, the text is split to obtain a split recognition result;

[0072] Based on the initial identification result and the split identification result, an unsplit identification result is determined, and adjacent detection region pairs in the split identification result and the unsplit identification result are determined;

[0073] In the presence of a preset phrase list, the preset phrase list is matched with the text of the adjacent detection region pair to obtain the semantic score of the adjacent detection region pair.

[0074] In the absence of the preset phrase table, or in the case where the semantic score of the adjacent detection region pair is 0, it is determined whether the text of the adjacent detection region pair is the same phrase or the same short sentence, and the confidence score of the text of the adjacent detection region pair being the same phrase or the same short sentence is obtained. The confidence score is used as the semantic score of the adjacent detection region pair.

[0075] Determine the region distance between the center detection region of the adjacent detection region pair and the adjacent detection regions of the detection region, and determine the distance score of the adjacent detection region pair based on the region distance;

[0076] Determine the string length of each detection region in the adjacent detection region pair, and determine the string merging score of the adjacent detection region pair based on the string length;

[0077] Based on the semantic score, the distance score, and the string merging score, a merging index for the adjacent detection region pairs is determined. The adjacent detection region pairs are then merged based on the merging index to obtain a target adjacent detection region. The preset condition is that the obtained target adjacent detection region remains unchanged.

[0078] Specifically, the loop process is executed until a preset condition is met. The loop process includes:

[0079] The text can be split into segments to obtain the split recognition result when the text within the text detection area in the initial recognition result is not the same phrase or the same short sentence.

[0080] Here, for a string S of length N within the detection region... N Various models, such as sequence labeling models, MLM (Masked Language Model), or NSP (Next Sentence Prediction) models, can be used to semantically determine whether the sentences are the same and output each sentence of length M. i A collection of phrases

[0081] The detection region is divided equally along its longer side, based on the number of characters in each phrase, thus enabling the semantic-based splitting of a single detection region into multiple detection regions. For example, given a detection box with a longer side L... N After being split, it becomes

[0082] Figure 2 This is a schematic diagram illustrating the text segmentation within the detection area provided by the present invention, such as... Figure 2 As shown, "Name, Address, Number" is split into "Name", "Address", and "Number", thus splitting the intervals between different sentences or phrases.

[0083] After obtaining the split recognition result, the unsplit recognition result can be determined based on the initial recognition result and the split recognition result. Here, the unsplit recognition result is the recognition result in the initial recognition result excluding the split recognition result.

[0084] It also identifies adjacent detection region pairs in the split and unsplit identification results, where each adjacent detection region pair includes the detection region and the detection region adjacent to the detection region.

[0085] Here, the detection area can be divided into three categories: horizontal T, vertical D, and single-character C.

[0086] If there is only one single character or word (in English) in the detection area, then the detection area is classified as Class C.

[0087] If there is more than one single character or word in the detection area and the horizontal length of the text area is greater than the vertical length, then the detection area is classified as class T.

[0088] If there is more than one single character or word in the detection area and the vertical length of the text area is greater than the horizontal length, then the detection area is classified as Class D.

[0089] In this embodiment of the invention, adjacent detection region pairs are constructed based on reading habits, and each detection region Ri is traversed. Here, reading habits are from left to right and from top to bottom.

[0090] After identifying adjacent detection region pairs in the segmentation and recognition results, if a preset phrase table exists, the preset phrase table can be matched with the text of the adjacent detection region pairs to obtain the semantic score of the adjacent detection region pairs.

[0091] Here, the preset phrase table is a table composed of some preset phrases. For example, the preset phrase table may include name and serial number, or name, item, amount, or name, item, amount and doctor's employee number, etc. The embodiments of the present invention do not make specific limitations in this regard.

[0092] Here, the semantic score of the adjacent detection region pair reflects the semantic association between the adjacent detection region pairs.

[0093] Understandably, the higher the semantic score of an adjacent detection region pair, the more semantically matched the pairs of detection regions within that pair are, and the more likely the adjacent detection region pairs should be merged; conversely, the lower the semantic score of an adjacent detection region pair, the less semantically matched the pairs of detection regions are, and the less likely the adjacent detection region pairs should be merged.

[0094] Furthermore, in the absence of a pre-defined phrase list, or when the semantic score of the adjacent detection region pair is 0, it is determined whether the text of the adjacent detection region pair is the same phrase or the same short sentence, and the confidence score of the adjacent detection region pair being the same phrase or the same short sentence is obtained. The confidence score is then used as the semantic score of the adjacent detection region pair.

[0095] It can determine the regional distance between the center detection region and the adjacent detection regions of the detection region, and determine the distance score of the adjacent detection region pair based on the regional distance.

[0096] Here, the distance score of adjacent detection region pairs reflects the correlation between adjacent detection region pairs at the distance level.

[0097] Understandably, the higher the distance score of an adjacent detection region pair, the less matched the pairs of detection regions within that pair are at the distance level, and the less likely the adjacent detection region pair should be merged; conversely, the lower the distance score of an adjacent detection region pair, the more matched the pairs of detection regions are at the distance level, and the more likely the adjacent detection region pair should be merged.

[0098] It is possible to determine the string length of each detection region in an adjacent detection region pair, and based on the string length, determine the string merging score of the adjacent detection region pair.

[0099] Here, the string length of one detection region in an adjacent detection region pair can be expressed as length(S). j The string length of another detection region can be represented as length(S). j+1 )express.

[0100] Here, the string merging score of adjacent detection region pairs reflects the degree of string merging of adjacent detection region pairs.

[0101] After obtaining the semantic score, distance score, and string merging score, the merging index for adjacent detection region pairs can be determined based on these scores. Here, the semantic score can be represented by N. score This means that the distance score can be represented by L. score This indicates that the string merging score can be represented by S. score express.

[0102] The formula for determining the merging index CB of adjacent detection region pairs, based on semantic score, distance score, and string merging score, is as follows:

[0103] CB=N score / (1+L score )*alpha^S score

[0104] Where CB represents the merging index of adjacent detection region pairs, and N score L represents the semantic score. score S represents the distance score. score This represents the score for string merging, and alpha represents the preset coefficient.

[0105] Here, alpha can be 0.1 or 5, etc., and the embodiments of the present invention do not specifically limit it.

[0106] Figure 3 This is a schematic diagram of merging adjacent detection region pairs based on merging indices provided by the present invention, as shown below. Figure 3 As shown, after obtaining the merging index, adjacent detection regions can be merged based on the merging index to obtain the target adjacent detection region. The preset condition is that the obtained target adjacent detection region will not change.

[0107] Here, the target adjacent detection region refers to the final adjacent detection region. For example, two adjacent detection regions can be merged when the merging index is greater than the merging threshold Beta.

[0108] Here, the determination of whether adjacent detection regions should be merged based on the merging index can be made using a text detection model, a dictionary table, or a combination of a text detection model and a dictionary table. This embodiment of the invention does not specifically limit this approach.

[0109] Here, the text detection model can be CRAFT (Character Region Awareness for Text Detection), DBNet (Differentiable Binarization Network), or PSENet (Progressive Scale Expansion Network), etc. This embodiment of the invention does not specifically limit it.

[0110] Step 130: Based on the target adjacent detection area, determine the optical character recognition result of the image to be recognized.

[0111] Specifically, after obtaining the target adjacent detection region, the optical character recognition result of the image to be recognized can be determined based on the target adjacent detection region, that is, the OCR result is output based on the target adjacent detection region.

[0112] Understandably, by determining the optical character recognition result of the image to be recognized based on the target's adjacent detection area, the optical character recognition result can be further optimized to obtain a more accurate detection area and recognition result.

[0113] The method provided in this invention determines the merging index of adjacent detection region pairs based on semantic score, distance score, and string merging score. The adjacent detection region pairs are then merged based on the merging index to obtain the target adjacent detection region. Finally, the optical character recognition result of the image to be recognized is determined based on the target adjacent detection region. On the one hand, it integrates the merging indexes from three levels—semantic score, distance score, and string merging score—to further optimize the optical character recognition result, obtaining more accurate detection regions and recognition results. On the other hand, it can adapt to varying image layouts and achieve good recognition results even without a large number of training samples. Furthermore, the calculation is simple and fast. Compared to updating image networks using a large number of training samples, the processing method in this invention only adds one or two language models, having little impact on computational speed, and further improves the recognition accuracy of optical characters.

[0114] Based on the above embodiments, step 120, which involves determining the string length of each detection region in the adjacent detection region pair and determining the string merging score of the adjacent detection region pair based on the string length, includes:

[0115] Step 121: Determine the first string length of the detection region in the adjacent detection region pairing, and the second string length of the other detection region in the adjacent detection region pairing;

[0116] Step 122: Determine the minimum and maximum string lengths among the first string length and the second string length;

[0117] Step 123: Determine the string merging score of the adjacent detection region pair based on the minimum string length and the maximum string length.

[0118] Specifically, the length of the first string in the middle detection region of the adjacent detection region (length(Sj)) and the length of the second string in the middle detection region of the adjacent detection region (length(Sj)) can be determined. j+1 ).

[0119] Then, the minimum and maximum string lengths among the first and second string lengths can be determined. Here, the minimum string length among the first and second string lengths can be determined using min(length(S)). j ),length(S j+1 The maximum string length between the length of the first string and the length of the second string can be represented by max(length(S)). j ),length(S j+1 ))express.

[0120] Finally, after obtaining the minimum and maximum string lengths, the string merging score for adjacent detection region pairs can be determined based on these lengths. This string merging score can be represented by S. score express.

[0121] The formula for determining the string merging score of adjacent detection region pairs based on the minimum and maximum string lengths is as follows:

[0122] S score =[min(length(S)] j ),length(S j+1 ))] / [max(length(S j ),length(S j+1 ))).

[0123] Based on the above embodiments, step 120, determining the distance score of the adjacent detection region pair based on the region distance, includes:

[0124] Step 210: If the distance between the regions is greater than the first preset threshold, determine the distance score of the adjacent detection region pair as the second preset value;

[0125] Step 220: If the area distance is less than or equal to the first preset threshold, determine the total length of the adjacent detection area pair, and determine the distance score of the adjacent detection area pair based on the total length and the area distance.

[0126] Specifically, if the regional distance is greater than a first preset threshold, the distance score of the adjacent detection region pair can be determined as a second preset value.

[0127] Here, the first preset threshold can be 5cm, or it can be 2cm, etc., and the embodiments of the present invention do not specifically limit it.

[0128] Here, the second preset value can be 100, 90, etc., and the embodiments of the present invention do not specifically limit it.

[0129] If the distance between adjacent detection regions is less than or equal to a first preset threshold, the total length of the adjacent detection region pairs is determined. Here, the total length can be represented by Length. j express.

[0130] Here, when the adjacent detection region pair is of type T, the total length of the adjacent detection region pair is the total horizontal length of the adjacent detection region pair; when the adjacent detection region pair is of type D, the total length of the adjacent detection region pair is the total vertical length of the adjacent detection region pair; when the adjacent detection region pair is of type C, the total length of the adjacent detection region pair is determined to be either the total vertical length or the total horizontal length of the adjacent detection region pair, depending on whether the adjacent detection region is to the right or below the detection region.

[0131] For example, when the adjacent detection region pair is of type C and the adjacent detection region is to the right of the detection region, the total length of the adjacent detection region pair is the total horizontal length of the adjacent detection region pair; when the adjacent detection region pair is of type C and the adjacent detection region is below the detection region, the total length of the adjacent detection region pair is the total vertical length of the adjacent detection region pair.

[0132] After determining the total length of adjacent detection region pairs, the distance score of the adjacent detection region pairs can be determined based on the total length and the region distance, as shown in the following formula:

[0133] L score =d j / Length j

[0134] Among them, L score d represents the distance score between adjacent detection region pairs. j Indicates the distance between regions, Length j Indicates the total length.

[0135] The method provided in this embodiment of the invention determines the distance score of adjacent detection region pairs as a second preset value when the region distance is greater than a first preset threshold, and determines the total length of adjacent detection region pairs when the region distance is less than or equal to the first preset threshold. Based on the total length and region distance, the distance score of adjacent detection region pairs is determined. This process also takes into account the influence of the total length of adjacent detection regions on the distance score, thereby improving the accuracy and reliability of determining the distance score of adjacent detection region pairs.

[0136] Based on the above embodiments, step 120, which involves matching the preset phrase list with the text of the adjacent detection region pair to obtain the semantic score of the adjacent detection region pair, includes:

[0137] Step 310: Merge the text of the adjacent detection region pairs to obtain the merged text and the length of the merged text;

[0138] Step 320: Match the preset phrase list with the merged text, and determine the semantic score of the adjacent detection region pair as a third preset value if the length of the phrase in the preset phrase list is greater than the length of the merged text and the preset phrase list contains the merged text.

[0139] Step 330: If the preset phrase table does not contain the merged text, determine the semantic score of the adjacent detection region pair as the fourth preset value.

[0140] Specifically, the text of adjacent detection region pairs can be merged to obtain the merged text and its length. Here, the merged text can be represented by S. j S j+1 express.

[0141] The preset phrase list is matched with the merged text, and the semantic score of the adjacent detection region pair is determined to be the third preset value when the length of the phrase in the preset phrase list is greater than the length of the merged text, and when the preset phrase list contains the merged text.

[0142] For example, for a phrase in the preset phrase list whose length is greater than the merged text S j S j+1 The phrase, if the phrase contains merged text S j S j+1 Then the semantic score N of the adjacent detection region pair score If the value is 1, then if the preset phrase list does not contain merged text, the semantic score of the adjacent detection region pair is determined to be the fourth preset value, which is set to 0 here.

[0143] Based on the above embodiments, step 330 further includes:

[0144] Step 331: Determine whether the merged texts are the same phrase or the same short sentence, and obtain the confidence score that the merged texts are the same phrase or the same short sentence;

[0145] Step 332: Determine the semantic score of the adjacent detection region pair based on the confidence score.

[0146] Specifically, it can be determined whether the merged texts are the same phrase or the same short sentence, and a confidence score can be obtained for whether the merged texts are the same phrase or the same short sentence.

[0147] For example, merged texts with a matching score of 0 from a pre-defined phrase list can be used to calculate S using a Natural Language Processing (NSP) model. j S j+1 Whether it is a phrase or a short sentence, and obtain a confidence score.

[0148] Furthermore, for texts without a pre-defined phrase list, the merged text can also be used to calculate S using a Natural Language Processing (NSP) model. j S j+1 Whether it is a phrase or a short sentence, and obtain a confidence score.

[0149] Understandably, the closer the confidence score is to 1, the greater the likelihood that the merged text will be a phrase or short sentence; the closer the confidence score is to 0, the less likely the merged text will be a phrase or short sentence.

[0150] After obtaining the confidence score, the semantic score of the adjacent detection region pair can be determined based on the confidence score.

[0151] For example, if the confidence score is 0.8, then the semantic score of the adjacent detection region pair is 0.8; and if the confidence score is 0.2, then the semantic score of the adjacent detection region pair is 0.2.

[0152] Based on the above embodiments, step 120, which involves determining the adjacent detection region pairs in the split identification result and the unsplit identification result, includes:

[0153] Step 410: Based on the category of the detection region in the splitting and identification results, determine the adjacent detection regions of the detection region;

[0154] Step 420: Merge the detection area and the adjacent detection area to obtain the adjacent detection area pair.

[0155] Specifically, after obtaining the splitting and identification results, since the adjacent detection regions of the detection region are related to the category of the detection region, the adjacent detection regions of the detection region can be determined based on the category of the detection region in the splitting and identification results and the non-splitting identification results.

[0156] Here, the detection area can be classified into three categories: C, T, and D.

[0157] After determining the adjacent detection regions, the detection regions and adjacent detection regions can be merged to obtain adjacent detection region pairs.

[0158] Based on the above embodiments, the categories of the detection regions in the split identification results and the unsplit identification results include a first detection region, a second detection region, and a third detection region;

[0159] Accordingly, Figure 4 This is a flowchart illustrating step 410 provided by the present invention, as shown below. Figure 4 As shown, step 410 includes:

[0160] When the category of the detection area is the first detection area, the adjacent detection areas of the first detection area are determined to be the detection area below and the detection area to the right of the first detection area;

[0161] When the category of the detection area is the second detection area, the adjacent detection area of ​​the second detection area is determined as the right detection area of ​​the second detection area;

[0162] If the category of the detection area is the third detection area, the adjacent detection area of ​​the third detection area is determined as the detection area below the third detection area.

[0163] Specifically, the categories of the detection regions in the split and unsplit recognition results include the first detection region, the second detection region, and the third detection region. Here, the first detection region is a Class C detection region, the second detection region is a Class T detection region, and the third detection region is a Class D detection region.

[0164] When the detection area is classified as the first detection area, the adjacent detection areas of the first detection area are determined to be the detection area below and the detection area to the right of the first detection area, and the detection area below and the detection area to the right are the detection areas closest to the first detection area.

[0165] When the detection area is classified as the second detection area, the adjacent detection area of ​​the second detection area is determined as the right detection area of ​​the second detection area, and the right detection area is the detection area closest to the second detection area.

[0166] When the detection area is classified as the third detection area, the adjacent detection area of ​​the third detection area is determined as the detection area below the third detection area, and the detection area below is the detection area closest to the third detection area.

[0167] Figure 5 This is the second flowchart illustrating the optical character recognition method provided by this invention, as shown below. Figure 5 As shown, the method includes:

[0168] The first step is to acquire the image to be recognized and then recognize it to obtain the initial recognition result.

[0169] The second step is to execute a loop until a preset condition is met. This loop includes:

[0170] 1. If the text within the text detection area in the initial recognition result is not the same phrase or sentence, the text is split to obtain the split recognition result.

[0171] 2. Based on the initial recognition results and the split recognition results, determine the unsplit recognition results, and identify the adjacent detection region pairs in the split and unsplit recognition results. For example, if the category of the detection region is the first detection region, determine the adjacent detection regions of the first detection region as the detection region below and the detection region to the right of the first detection region;

[0172] When the detection area is classified as the second detection area, the adjacent detection area of ​​the second detection area is determined as the detection area to the right of the second detection area.

[0173] If the detection area is classified as the third detection area, the adjacent detection area of ​​the third detection area is determined as the detection area below the third detection area.

[0174] 3. Merge the detection area and adjacent detection areas to obtain adjacent detection area pairs.

[0175] 4. Merge the text of adjacent detection regions to obtain the merged text and its length;

[0176] The preset phrase list is matched with the merged text, and the semantic score of the adjacent detection region pair is determined to be the third preset value when the length of the phrase in the preset phrase list is greater than the length of the merged text, and when the preset phrase list contains the merged text.

[0177] If the preset phrase list does not contain merged text, the semantic score of the adjacent detection region pair is determined to be the fourth preset value.

[0178] Determine whether the merged texts are the same phrase or the same short sentence, and obtain the confidence score that the merged texts are the same phrase or the same short sentence;

[0179] The semantic score of adjacent detection region pairs is determined based on the confidence score.

[0180] 5. Determine the regional distance between the detection region and the adjacent detection regions of the detection region pair. If the regional distance is greater than the first preset threshold, determine the distance score of the adjacent detection region pair as the second preset value. If the regional distance is less than or equal to the first preset threshold, determine the total length of the adjacent detection region pair, and determine the distance score of the adjacent detection region pair based on the total length and the regional distance.

[0181] 6. Determine the length of the first string in the detection region centered on the adjacent detection region, and the length of the second string in the other detection region centered on the adjacent detection region;

[0182] Determine the minimum and maximum string lengths between the length of the first string and the length of the second string;

[0183] The string merging score for adjacent detection region pairs is determined based on the minimum and maximum string lengths.

[0184] 7. Based on semantic score, distance score, and string merging score, determine the merging index of adjacent detection region pairs, and merge adjacent detection region pairs based on the merging index to obtain the target adjacent detection region; wherein, the preset condition is that the obtained target adjacent detection region will not change.

[0185] The third step is to determine the optical character recognition result of the image to be recognized based on the target adjacent detection area.

[0186] The optical character recognition device provided by the present invention is described below. The optical character recognition device described below can be referred to in correspondence with the optical character recognition method described above.

[0187] Based on any of the above embodiments, the present invention provides an optical character recognition device. Figure 6 This is a schematic diagram of the structure of the optical character recognition device provided by the present invention, as shown below. Figure 6 As shown, the device includes:

[0188] The recognition unit 610 is used to acquire the image to be recognized and to recognize the image to obtain an initial recognition result of the image to be recognized;

[0189] Execution unit 620 is used to execute a loop process until a preset condition is met; the loop process includes:

[0190] If the text within the text detection area in the initial recognition result is not the same phrase or the same short sentence, the text is split to obtain a split recognition result;

[0191] Based on the initial identification result and the split identification result, an unsplit identification result is determined, and adjacent detection region pairs in the split identification result and the unsplit identification result are determined;

[0192] In the presence of a preset phrase list, the preset phrase list is matched with the text of the adjacent detection region pair to obtain the semantic score of the adjacent detection region pair.

[0193] In the absence of the preset phrase table, or in the case where the semantic score of the adjacent detection region pair is 0, it is determined whether the text of the adjacent detection region pair is the same phrase or the same short sentence, and the confidence score of the text of the adjacent detection region pair being the same phrase or the same short sentence is obtained. The confidence score is used as the semantic score of the adjacent detection region pair.

[0194] Determine the region distance between the center detection region of the adjacent detection region pair and the adjacent detection regions of the detection region, and determine the distance score of the adjacent detection region pair based on the region distance;

[0195] Determine the string length of each detection region in the adjacent detection region pair, and determine the string merging score of the adjacent detection region pair based on the string length;

[0196] Based on the semantic score, the distance score, and the string merging score, a merging index for the adjacent detection region pairs is determined. The adjacent detection region pairs are then merged based on the merging index to obtain a target adjacent detection region. The preset condition is that the obtained target adjacent detection region remains unchanged.

[0197] The optical character recognition result determination unit 630 is used to determine the optical character recognition result of the image to be recognized based on the target adjacent detection area.

[0198] The apparatus provided in this invention determines the merging index of adjacent detection region pairs based on semantic score, distance score, and string merging score. It then merges the adjacent detection region pairs based on the merging index to obtain the target adjacent detection region. Finally, based on the target adjacent detection region, it determines the optical character recognition result of the image to be recognized. On the one hand, it integrates the merging indexes from three levels—semantic score, distance score, and string merging score—to further optimize the optical character recognition result, obtaining more accurate detection regions and recognition results. On the other hand, it can adapt to varying image layouts and achieve good recognition results even without a large number of training samples. Furthermore, the calculation is simple and fast. Compared to updating image networks using a large number of training samples, the processing method in this invention only adds one or two language models, having little impact on computational speed, and further improves the recognition accuracy of optical characters.

[0199] Based on any of the above embodiments, the execution unit 620 is specifically used for:

[0200] Determine the length of the first string in the middle detection area of ​​the adjacent detection area, and the length of the second string in the middle detection area of ​​the other detection area of ​​the adjacent detection area;

[0201] Determine the minimum and maximum string lengths among the first string length and the second string length;

[0202] Based on the minimum string length and the maximum string length, the string merging score of the adjacent detection region pair is determined.

[0203] Based on any of the above embodiments, the execution unit 620 is specifically used for:

[0204] If the distance between the regions is greater than a first preset threshold, the distance score of the adjacent detection region pair is determined to be a second preset value;

[0205] If the distance between the regions is less than or equal to the first preset threshold, the total length of the adjacent detection region pair is determined, and the distance score of the adjacent detection region pair is determined based on the total length and the distance between the regions.

[0206] Based on any of the above embodiments, the execution unit 620 specifically includes:

[0207] The text merging unit is used to merge the text of the adjacent detection region pairs to obtain the merged text and the length of the merged text;

[0208] A phrase matching unit is used to match the preset phrase list with the merged text, and determine the semantic score of the adjacent detection region pair as a third preset value when the length of the phrase in the preset phrase list is greater than the length of the merged text, and the preset phrase list contains the merged text.

[0209] A semantic score unit is determined to determine the semantic score of the adjacent detection region pair as a fourth preset value when the preset phrase table does not contain the merged text.

[0210] Based on any of the above embodiments, a confidence score determination unit is further included, wherein the confidence score determination unit is specifically used for:

[0211] Determine whether the merged texts are the same phrase or the same short sentence, and obtain the confidence score that the merged texts are the same phrase or the same short sentence;

[0212] The semantic score of the adjacent detection region pair is determined based on the confidence score.

[0213] Based on any of the above embodiments, the execution unit 620 specifically includes:

[0214] The adjacent detection region determination unit is used to determine the adjacent detection regions of the detection region based on the category of the detection region in the splitting and identification results;

[0215] The merge detection region unit is used to merge the detection region and the adjacent detection region to obtain the adjacent detection region pair.

[0216] Based on any of the above embodiments, the categories of the detection regions in the splitting and identification results include a first detection region, a second detection region, and a third detection region;

[0217] Determine the adjacent detection region unit, specifically used for:

[0218] When the category of the detection area is the first detection area, the adjacent detection areas of the first detection area are determined to be the detection area below and the detection area to the right of the first detection area.

[0219] When the category of the detection area is the second detection area, the adjacent detection area of ​​the second detection area is determined as the right detection area of ​​the second detection area;

[0220] If the category of the detection area is the third detection area, the adjacent detection area of ​​the third detection area is determined as the detection area below the third detection area.

[0221] Figure 7 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 7As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730, and a communication bus 740, wherein the processor 710, the communication interface 720, and the memory 730 communicate with each other through the communication bus 740. The processor 710 can call logical instructions in the memory 730 to execute an optical character recognition method. The method includes: acquiring an image to be recognized and recognizing the image to obtain an initial recognition result; executing a loop process until a preset condition is met; the loop process includes: if the text within the text detection area in the initial recognition result is not the same phrase or sentence, splitting the text to obtain a split recognition result; based on the initial recognition result and the split recognition result, determining an unsplit recognition result, and determining adjacent detection region pairs in the split recognition result and the unsplit recognition result; if a preset phrase table exists, matching the preset phrase table with the text of the adjacent detection region pair to obtain a semantic score for the adjacent detection region pair; if the preset phrase table does not exist, or the semantic score of the adjacent detection region pair is 0, determining the text of the adjacent detection region pair... To determine if the text of the adjacent detection region pair is the same phrase or short sentence, a confidence score is obtained, and this confidence score is used as the semantic score of the adjacent detection region pair. The regional distance between the detection regions in the adjacent detection region pair and their adjacent detection regions is determined, and a distance score is determined based on this regional distance. The string length of each detection region in the adjacent detection region pair is determined, and a string merging score is determined based on this string length. A merging index is determined for the adjacent detection region pair based on the semantic score, the distance score, and the string merging score. The adjacent detection region pair is then merged based on this merging index to obtain a target adjacent detection region. The preset condition is that the obtained target adjacent detection region remains unchanged. Based on the target adjacent detection region, the optical character recognition result of the image to be recognized is determined.

[0222] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0223] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the optical character recognition method provided by the above methods. The method includes: acquiring an image to be recognized and recognizing the image to be recognized to obtain an initial recognition result of the image to be recognized; executing a loop process until a preset condition is met; the loop process includes: if the text in the text detection area of ​​the initial recognition result is not the same phrase or the same short sentence, splitting the text to obtain a split recognition result; based on the initial recognition result and the split recognition result, determining an unsplit recognition result, and determining adjacent detection region pairs in the split recognition result and the unsplit recognition result; if a preset phrase table exists, matching the preset phrase table with the text of the adjacent detection region pair to obtain a semantic score of the adjacent detection region pair; if the preset phrase table does not exist, or if the text in the adjacent detection region pair does not exist, the method executes the optical character recognition method provided by the above methods. When the semantic score of a pair of adjacent detection regions is 0, it is determined whether the text of the pair of adjacent detection regions is the same phrase or the same short sentence, and the confidence score of the pair of adjacent detection regions being the same phrase or the same short sentence is obtained. The confidence score is used as the semantic score of the pair of adjacent detection regions. The regional distance between the detection regions in the pair of adjacent detection regions and the adjacent detection regions of the detection region is determined, and the distance score of the pair of adjacent detection regions is determined based on the regional distance. The string length of each detection region in the pair of adjacent detection regions is determined, and the string merging score of the pair of adjacent detection regions is determined based on the string length. Based on the semantic score, the distance score, and the string merging score, the merging index of the pair of adjacent detection regions is determined, and the pair of adjacent detection regions is merged based on the merging index to obtain the target adjacent detection region. The preset condition is that the obtained target adjacent detection region does not change. Based on the target adjacent detection region, the optical character recognition result of the image to be recognized is determined.

[0224] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the optical character recognition method provided by the methods described above. The method includes: acquiring an image to be recognized and recognizing the image to obtain an initial recognition result; executing a loop process until a preset condition is met; the loop process includes: if the text within the text detection area of ​​the initial recognition result is not the same phrase or the same short sentence, splitting the text to obtain a split recognition result; based on the initial recognition result and the split recognition result, determining an unsplit recognition result, and determining adjacent detection region pairs in the split recognition result and the unsplit recognition result; if a preset phrase table exists, matching the preset phrase table with the text of the adjacent detection region pair to obtain a semantic score for the adjacent detection region pair; if the preset phrase table does not exist, or the semantic score of the adjacent detection region pair is 0. In the case of adjacent detection regions, it is determined whether the text of the adjacent detection region pair is the same phrase or the same short sentence, and the confidence score of the adjacent detection region pair being the same phrase or the same short sentence is obtained. The confidence score is used as the semantic score of the adjacent detection region pair. The regional distance between the detection regions in the adjacent detection region pair and the adjacent detection regions of the detection region is determined, and the distance score of the adjacent detection region pair is determined based on the regional distance. The string length of each detection region in the adjacent detection region pair is determined, and the string merging score of the adjacent detection region pair is determined based on the string length. Based on the semantic score, the distance score, and the string merging score, the merging index of the adjacent detection region pair is determined, and the adjacent detection region pair is merged based on the merging index to obtain the target adjacent detection region. The preset condition is that the obtained target adjacent detection region does not change. Based on the target adjacent detection region, the optical character recognition result of the image to be recognized is determined.

[0225] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0226] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0227] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An optical character recognition method, characterized in that, include: Acquire the image to be identified, and identify the image to be identified to obtain the initial recognition result of the image to be identified; The loop continues until the preset condition is met. The cyclic process includes: If the text within the text detection area in the initial recognition result is not the same phrase or the same short sentence, the text is split to obtain a split recognition result; Based on the initial identification result and the split identification result, an unsplit identification result is determined, and adjacent detection region pairs in the split identification result and the unsplit identification result are determined; In the presence of a preset phrase list, the preset phrase list is matched with the text of the adjacent detection region pair to obtain the semantic score of the adjacent detection region pair. In the absence of the preset phrase table, or in the case where the semantic score of the adjacent detection region pair is 0, it is determined whether the text of the adjacent detection region pair is the same phrase or the same short sentence, and the confidence score of the text of the adjacent detection region pair being the same phrase or the same short sentence is obtained. The confidence score is used as the semantic score of the adjacent detection region pair. Determine the region distance between the center detection region of the adjacent detection region pair and the adjacent detection regions of the detection region, and determine the distance score of the adjacent detection region pair based on the region distance; The string length of each detection region in the adjacent detection region pair is determined, and based on the string length, the string merging score of the adjacent detection region pair is determined; based on the semantic score, the distance score, and the string merging score, the merging index of the adjacent detection region pair is determined, and the adjacent detection region pair is merged based on the merging index to obtain the target adjacent detection region; wherein, the preset condition is that the obtained target adjacent detection region does not change; The formula for the combined index is as follows: CB = N score / (1+L) score *alpha^S score ; Where CB represents the merging index of adjacent detection region pairs, and N score L represents the semantic score. score S represents the distance score. score This represents the score for string merging, where alpha represents the preset coefficient. Based on the target adjacency detection region, the optical character recognition result of the image to be recognized is determined; The step of determining the string length of each detection region in the adjacent detection region pair, and determining the string merging score of the adjacent detection region pair based on the string length, includes: Determine the length of the first string in the middle detection area of ​​the adjacent detection area, and the length of the second string in the middle detection area of ​​the other detection area of ​​the adjacent detection area; Determine the minimum and maximum string lengths among the first string length and the second string length; Based on the minimum string length and the maximum string length, the string merging score of the adjacent detection region pair is determined; The formula for the string merging score is as follows: S score =[min(length(S j ),length(S j+1 ))] / [max(length(S j ),length(S j+1 ))]; Among them, S score This represents the score for string merging, min(length(S)). j ),length(S j+1 )) represents the minimum string length between the length of the first string and the length of the second string, max(length(S) j ),length(S j+1 )) represents the maximum string length between the length of the first string and the length of the second string; The step of determining the distance score of the adjacent detection region pair based on the region distance includes: If the distance between the regions is greater than a first preset threshold, the distance score of the adjacent detection region pair is determined to be a second preset value; If the distance between the regions is less than or equal to the first preset threshold, the total length of the adjacent detection region pair is determined, and the distance score of the adjacent detection region pair is determined based on the total length and the distance between the regions. The formula for the distance score is as follows: L score =d j / Length j ; Among them, L score d represents the distance score between adjacent detection region pairs. j Indicates the distance between regions, Length j Indicates the total length; The step of matching the preset phrase list with the text of the adjacent detection region pair to obtain the semantic score of the adjacent detection region pair includes: The text of the adjacent detection regions is merged to obtain the merged text and the length of the merged text; The preset phrase list is matched with the merged text, and if the length of the phrase in the preset phrase list is greater than or equal to the length of the merged text, and the preset phrase list contains the merged text, the semantic score of the adjacent detection region pair is determined to be a third preset value. If the preset phrase table does not contain the merged text, the semantic score of the adjacent detection region pair is determined to be the fourth preset value.

2. The optical character recognition method according to claim 1, characterized in that, When the preset phrase table does not contain the merged text, the semantic score of the adjacent detection region pair is determined to be a fourth preset value, and then the method further includes: Determine whether the merged texts are the same phrase or the same short sentence, and obtain the confidence score that the merged texts are the same phrase or the same short sentence; The semantic score of the adjacent detection region pair is determined based on the confidence score.

3. The optical character recognition method according to any one of claims 1 to 2, characterized in that, Determining the adjacent detection region pairs in the split identification result and the unsplit identification result includes: Based on the split identification results and the categories of the detected regions in the unsplit identification results, the adjacent detection regions of the detected regions are determined; The detection region and the adjacent detection region are merged to obtain the adjacent detection region pair.

4. The optical character recognition method according to claim 3, characterized in that, The categories of the detected regions in the split identification results and the unsplit identification results include a first detection region, a second detection region, and a third detection region; The step of determining the adjacent detection regions of the detection region based on the category of the detection region in the split identification result and the unsplit identification result includes: When the category of the detection area is the first detection area, the adjacent detection areas of the first detection area are determined to be the detection area below and the detection area to the right of the first detection area. When the category of the detection area is the second detection area, the adjacent detection area of ​​the second detection area is determined as the right detection area of ​​the second detection area; If the category of the detection area is the third detection area, the adjacent detection area of ​​the third detection area is determined as the detection area below the third detection area.

5. An optical character recognition device, characterized in that, include: The recognition unit is used to acquire the image to be recognized and to recognize the image to obtain the initial recognition result of the image to be recognized; An execution unit is used to execute a loop process until a preset condition is met. The cyclic process includes: If the text within the text detection area in the initial recognition result is not the same phrase or the same short sentence, the text is split to obtain a split recognition result; Based on the initial identification result and the split identification result, an unsplit identification result is determined, and adjacent detection region pairs in the split identification result and the unsplit identification result are determined; In the presence of a preset phrase list, the preset phrase list is matched with the text of the adjacent detection region pair to obtain the semantic score of the adjacent detection region pair. In the absence of the preset phrase table, or in the case where the semantic score of the adjacent detection region pair is 0, it is determined whether the text of the adjacent detection region pair is the same phrase or the same short sentence, and the confidence score of the text of the adjacent detection region pair being the same phrase or the same short sentence is obtained. The confidence score is used as the semantic score of the adjacent detection region pair. Determine the region distance between the center detection region of the adjacent detection region pair and the adjacent detection regions of the detection region, and determine the distance score of the adjacent detection region pair based on the region distance; Determine the string length of each detection region in the adjacent detection region pair, and determine the string merging score of the adjacent detection region pair based on the string length; Based on the semantic score, the distance score, and the string merging score, a merging index for the adjacent detection region pairs is determined. The adjacent detection region pairs are then merged based on the merging index to obtain a target adjacent detection region. The preset condition is that the obtained target adjacent detection region remains unchanged. The formula for the combined index is as follows: CB = N score / (1+L) score *alpha^S score ; Where CB represents the merging index of adjacent detection region pairs, and N score L represents the semantic score. score S represents the distance score. score This represents the score for string merging, where alpha represents the preset coefficient. The optical character recognition result determination unit is used to determine the optical character recognition result of the image to be recognized based on the target adjacent detection area; The step of determining the string length of each detection region in the adjacent detection region pair, and determining the string merging score of the adjacent detection region pair based on the string length, includes: Determine the length of the first string in the middle detection area of ​​the adjacent detection area, and the length of the second string in the middle detection area of ​​the other detection area of ​​the adjacent detection area; Determine the minimum and maximum string lengths among the first string length and the second string length; Based on the minimum string length and the maximum string length, the string merging score of the adjacent detection region pair is determined; The formula for the string merging score is as follows: S score =[min(length(S j ),length(S j+1 ))] / [max(length(S j ),length(S j+1 ))]; Among them, S score This represents the score for string merging, min(length(S)). j ),length(S j+1 )) represents the minimum string length between the length of the first string and the length of the second string, max(length(S) j ),length(S j+1 )) represents the maximum string length between the length of the first string and the length of the second string; The step of determining the distance score of the adjacent detection region pair based on the region distance includes: If the distance between the regions is greater than a first preset threshold, the distance score of the adjacent detection region pair is determined to be a second preset value; If the distance between the regions is less than or equal to the first preset threshold, the total length of the adjacent detection region pair is determined, and the distance score of the adjacent detection region pair is determined based on the total length and the distance between the regions. The formula for the distance score is as follows: L score =d j / Length j ; Among them, L score d represents the distance score between adjacent detection region pairs. j Indicates the distance between regions, Length j Indicates the total length; The step of matching the preset phrase list with the text of the adjacent detection region pair to obtain the semantic score of the adjacent detection region pair includes: The text of the adjacent detection regions is merged to obtain the merged text and the length of the merged text; The preset phrase list is matched with the merged text, and if the length of the phrase in the preset phrase list is greater than or equal to the length of the merged text, and the preset phrase list contains the merged text, the semantic score of the adjacent detection region pair is determined to be a third preset value. If the preset phrase table does not contain the merged text, the semantic score of the adjacent detection region pair is determined to be the fourth preset value.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the optical character recognition method as described in any one of claims 1 to 4.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the optical character recognition method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Character recognition method and device based on artificial intelligence, and electronic equipment

    CN113705559A

  • Relay protection information standardization processing method based on knowledge graph

    CN113934865A