A text recognition method and device, electronic equipment and storage medium

By constructing a character set using a confidence range in scan-based text recognition products, the problem of high error rates in the beginning and end regions was solved, achieving accurate text recognition results.

CN115346216BActive Publication Date: 2026-04-10BEIJING UNISOUND INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING UNISOUND INFORMATION TECH CO LTD
Filing Date
2022-06-17
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

When using scanning text recognition products, the error rate is high in the beginning and end areas due to incomplete images or the presence of non-character patterns.

Method used

By acquiring the target image, detecting characters and generating character sequences and confidence sequences, and constructing a character set using the confidence range of the first and last characters, non-character pattern interference is eliminated to ensure recognition accuracy.

Benefits of technology

It reduces the error rate of the beginning and end of the text recognition results, ensuring accurate text recognition even when the image is incomplete.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115346216B_ABST
    Figure CN115346216B_ABST
Patent Text Reader

Abstract

The application discloses a text recognition method and device, electronic equipment and storage medium. The method comprises the following steps: acquiring a target image, the target image containing target text to be detected; detecting characters contained in the target text, obtaining a character sequence corresponding to the target text and a confidence sequence, wherein the confidence sequence comprises a confidence corresponding to each character in the character sequence; obtaining at least two first indexes from the head and tail of the character sequence by using the head and tail characters in the character sequence respectively, constructing a first character set based on the first indexes, and the target index position is the position of the character whose confidence falls within the confidence range; and determining the first character set as a text recognition result. According to the application, the character index position is determined from the head character and the tail character according to the confidence, which can eliminate the interference of the pattern on the character recognition accuracy. Even if the image is not displayed completely, the head and tail recognition accuracy can still be ensured, and the error rate of the head and tail part in the text recognition result is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of text recognition, and in particular to a text recognition method and device, an electronic device, and a storage medium. BACKGROUND

[0002] When a user uses a scanning type text recognition product (such as a pen), characters exist at the start and end positions of scanning, and the two areas are not complete due to incomplete shooting of the scanning area, resulting in a high error rate in the head and tail areas. In addition, if non-character patterns exist in the head and tail areas, the error rate in the head and tail areas is also high. SUMMARY

[0003] To solve the above technical problems or at least partially solve the above technical problems, the present application provides a text recognition method and device, an electronic device, and a storage medium.

[0004] According to an aspect of an embodiment of the present application, a text recognition method is provided, including:

[0005] obtaining a target image, wherein the target image contains target text to be detected;

[0006] detecting characters contained in the target text to obtain a character sequence corresponding to the target text and a confidence sequence, wherein the confidence sequence includes a confidence corresponding to each character in the character sequence;

[0007] obtaining at least two first indexes from the head and tail of the character sequence using the head and tail characters in the character sequence respectively, and constructing a first character set based on the first indexes, wherein the target index position is a position corresponding to a character whose confidence falls within a confidence range;

[0008] determining the first character set as the text recognition result.

[0009] Further, the obtaining at least two first indexes from the head and tail of the character sequence using the head and tail characters in the character sequence respectively, and constructing a first character set based on the first indexes includes:

[0010] taking the head character of the character sequence as a starting point, sequentially traversing the characters at the head of the character sequence, determining a first target character as a character whose first confidence falls within the confidence range, and determining a first starting index as a position corresponding to the first target character;

[0011] taking the tail character of the character sequence as a starting point, sequentially traversing the characters at the tail of the character sequence, determining a second target character as a character whose first confidence falls within the confidence range, and determining a first termination index as a position corresponding to the second target character;

[0012] generate the first character set based on characters between the first start index and the first end index.

[0013] Further, the method further comprises:

[0014] detecting a character feature of the character in the target text;

[0015] determining a target language corresponding to the character feature based on a correspondence relationship between preset character features and language types.

[0016] Further, the method further comprises:

[0017] in a case where the target language is an English language, obtaining an English word sequence based on the first character set;

[0018] in a case where the first target character belongs to a first character of a first English word in the English word sequence and the second target character belongs to a last character of a last English word in the English word sequence, determining that the first English word and the last English word are complete;

[0019] determining the first character set as the text recognition result.

[0020] Further, the method further comprises:

[0021] in a case where the first target character does not belong to a first character of a first English word in the English word sequence and / or the second target character belongs to a last character of a last English word in the English word sequence, determining that the first English word and / or the last English word are incomplete;

[0022] removing the first English word and / or the last English word to obtain an updated first character set.

[0023] Further, the method further comprises:

[0024] in a case where the target language is a Chinese language, detecting characters included in the first character set to obtain a Chinese character sequence corresponding to the first character set and a character width sequence, wherein the character width sequence includes a character width corresponding to each character in the Chinese character sequence;

[0025] obtaining at least two second indexes from a head and a tail of the Chinese character sequence by using head and tail characters in the Chinese character sequence respectively, and constructing a second character set based on the second indexes, wherein the index position is a position corresponding to a character whose character width falls within a preset width range;

[0026] determine the second character set as the text recognition result.

[0027] Further, the first and last characters in the Chinese character sequence are used to obtain at least two second indexes from the head and tail of the Chinese character sequence respectively, and a second character set is constructed based on the second indexes, including:

[0028] The first character of the Chinese character sequence is used as a starting point, and the characters in the head of the Chinese character sequence are sequentially traversed, a first target character is determined as a character whose width falls within the preset width range, and a second starting index corresponding to the first target character is determined.

[0029] The last character of the Chinese character sequence is used as a starting point, and the characters in the tail of the Chinese character sequence are sequentially traversed, a fourth target character is determined as a character whose width falls within the preset width range, and a second ending index corresponding to the fourth target character is determined.

[0030] The second character set is generated based on the characters between the second starting index and the second ending index.

[0031] According to another aspect of the embodiments of the present application, a text recognition device is also provided, including:

[0032] An acquisition module is configured to acquire a target image, wherein the target image contains a target text to be detected.

[0033] A detection module is configured to detect characters contained in the target text to obtain a character sequence corresponding to the target text and a confidence sequence, wherein the confidence sequence includes a first confidence corresponding to each character in the character sequence.

[0034] A query module is configured to obtain at least two target index positions from the head and tail of the character sequence respectively using the first and last characters in the character sequence, and construct a first character set based on the target index positions, wherein the target index positions are positions corresponding to characters whose first confidence falls within a first confidence range.

[0035] A determination module is configured to determine the first character set as the text recognition result.

[0036] According to another aspect of the embodiments of the present application, a storage medium is also provided, which includes a stored program, and the program performs the above steps when running.

[0037] According to a further aspect of the embodiments of the present application, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; the memory is configured to store a computer program; and the processor is configured to execute the steps of the above method by running the computer program stored in the memory.

[0038] The embodiments of the present application further provide a computer program product containing instructions which, when executed on a computer, cause the computer to perform the steps of the above method.

[0039] The above technical solution provided by the embodiments of the present application has the following advantages compared with the prior art: the method provided by the embodiments of the present application determines the character index positions from the first character and the last character respectively according to the confidence, which can eliminate the interference of non-character patterns on the character recognition accuracy. Meanwhile, even in the case of incomplete image display, the first and last recognition accuracy can still be ensured, and the error rate of the first and last parts in the text recognition result is reduced. BRIEF DESCRIPTION OF DRAWINGS

[0040] The accompanying drawings, which are incorporated herein and constitute part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or the prior art description will be briefly introduced here. Obviously, for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.

[0042] Figure 1 A flow chart of a text recognition method provided by the embodiments of the present application;

[0043] Figure 2 A schematic diagram of a text recognition method provided by the embodiments of the present application;

[0044] Figure 3 A block diagram of a text recognition device provided by the embodiments of the present application;

[0045] Figure 4 A structural schematic diagram of an electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION

[0046] In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application but not all the embodiments of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and should not be construed as an improper limitation on the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative effort belong to the scope of protection of the present application.

[0047] It should be noted that, in this document, relational terms such as "first" and "second", and the like, are used solely to distinguish one entity or action from another entity or action, without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element preceded by "comprises... " does not exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the stated elements.

[0048] The embodiments of the present application provide a text recognition method, device, electronic device and storage medium. The method provided by the embodiments of the present application can be applied to any required electronic device, for example, a server, a terminal or the like, which is not limited here. For the convenience of description, hereinafter, it is simply referred to as an electronic device.

[0049] According to an aspect of the embodiments of the present application, a method embodiment of a text recognition method is provided, Figure 1 A flowchart of the text recognition method provided by the embodiments of the present application is shown in Figure 1 The method comprises the following steps:

[0050] In step S11, a target image is acquired, wherein the target image contains a target text to be detected.

[0051] The method provided by the embodiments of the present application is applied to a smart terminal, which can be a smart phone, a notebook computer, a tablet computer or the like. The step of acquiring the target text to be recognized by the smart terminal can be: receiving an image processing request sent by a requesting terminal, and acquiring the target image from the image processing request. Alternatively, the smart terminal can call a camera device to take a picture, and the picture taken is used as the target image, which contains the target text to be detected. The target text can be a script, a textbook, news or the like.

[0052] Step S12, detecting the characters contained in the target text to obtain a character sequence corresponding to the target text and a confidence sequence, wherein the confidence sequence includes a confidence corresponding to each character in the character sequence.

[0053] In the embodiments of the present application, in order to accurately detect the characters contained in the target text, first, the target text needs to be preprocessed, for example: performing grayscale processing on the target image, performing binarization processing on the target image after grayscale processing, and performing light superposition processing on the target image to obtain a high-contrast image. The binarization processing can be Gaussian blur processing, inverse color processing, opacity processing, etc. Secondly, a plurality of pixel matrices corresponding to the high-contrast image are generated (for example: performing layout analysis on the preprocessed original image to obtain a plurality of pixel matrices), performing layout analysis on the preprocessed original image to obtain a plurality of pixel matrices, performing feature extraction on the plurality of pixel matrices to obtain a plurality of feature maps. Thirdly, performing character recognition on the plurality of feature maps to obtain a character sequence.

[0054] In the embodiments of the present application, the pre-trained recognition model is used to perform feature extraction on the plurality of pixel matrices to obtain a plurality of feature maps. The plurality of feature maps are respectively subjected to character recognition to obtain a character sequence. The pre-trained recognition model can be a long short-term memory network (LSTM) model or the like. The plurality of feature maps are respectively subjected to character recognition, and a character sequence is generated based on the character corresponding to the current feature of the feature map. Then, character recognition is performed on each feature map to determine the character corresponding to the current feature of the feature map, and the confidence corresponding to the character is determined. The confidence sequence is generated based on the confidence corresponding to each character.

[0055] For example: the number of characters contained in the target text in the target image is N, and the obtained character sequence is O_1,…,O_N. The confidence sequence is s_1,…,s_N.

[0056] Step S13, obtaining at least two first indexes from the head and tail of the character sequence based on the first index, and constructing a first character set based on the first index, wherein the index position is the position of the character corresponding to the confidence falling within the confidence range.

[0057] In the embodiments of the present application, before obtaining the index position, the confidence threshold needs to be calculated. The calculation formula of the confidence threshold is as follows: T1=alpha×sum(s_2,s_(N-1)) / (N-2), wherein alpha is an adjustment coefficient, T1 is the confidence threshold, and the confidence range is [T1, 1].

[0058] In the embodiment of the present application, in step S13, at least two first indexes are obtained from the head and tail of the character sequence respectively by using the head and tail characters in the character sequence, and a first character set is constructed based on the first indexes, including the following steps A1-A3:

[0059] In step A1, the head character of the character sequence is taken as a starting point, and the characters in the head of the character sequence are sequentially traversed, the first character whose confidence falls within the confidence range is determined as a first target character, and the position corresponding to the first target character is determined as a first starting index.

[0060] In the embodiment of the present application, the head character of the character sequence is taken as a starting point, and the i-th character is searched from the head character O_1 of the character sequence, if the i-th character satisfies s_i>T1, the i-th character is determined as a first target character, and the position corresponding to the first target character is determined as a first starting index.

[0061] In step A2, the tail character of the character sequence is taken as a starting point, and the characters in the tail of the character sequence are sequentially traversed, the first character whose confidence falls within the confidence range is determined as a second target character, and the position corresponding to the second target character is determined as a first ending index.

[0062] In the embodiment of the present application, the head and tail characters of the character sequence are taken as starting points, and the j-th character is searched from the head character O_N of the character sequence, if the j-th character satisfies s_j>T1, the j-th character is determined as a second target character, and the position corresponding to the first target character is determined as a first ending index.

[0063] In step A3, the first character set is generated based on the characters between the first starting index and the first ending index.

[0064] In the embodiment of the present application, the i-th character and the j-th character are retained, and the first character set is generated based on the characters between the i-th character and the j-th character, that is, the first character set is a trusted recognition result.

[0065] In step S14, the first character set is determined as a text recognition result.

[0066] In the embodiment of the present application, in order to ensure that the text recognition result is more accurate, it is also necessary to detect the language type of the target text. Therefore, the method further includes the following steps: detecting the character features of the characters in the target text. Based on the correspondence between the preset character features and the language type, the target language corresponding to the character features is determined.

[0067] In the embodiment of the present application, in step S14, the first character set is determined as a text recognition result, including the following steps B1-B3:

[0068] Step B1, in the case that the target language is English, obtaining an English word sequence based on the first character set.

[0069] Step B2, in the case that the first target character belongs to the first character of the first English word in the English word sequence and the second target character belongs to the last character of the last English word in the English word sequence, determining that the first English word and the last English word are complete.

[0070] Step B3, determining the first character set as the text recognition result.

[0071] In the embodiments of the present application, in the case that the target language is English, to solve the situation that the character is complete but the word is not complete, a word sequence W_k,..., W_t corresponding to the first character set (O_i,..., O_j) is obtained. If the character i belongs to the first character of the English word W_k, it is determined that the first English word is complete, and W_k is retained at this time. Similarly, if the character j belongs to the last character of the English word W_t, it is determined that the last English word is complete, and W_t is retained at this time.

[0072] In the embodiments of the present application, the method further includes the following steps C1-C2:

[0073] Step C1, in the case that the first target character does not belong to the first character of the first English word in the English word sequence and / or the second target character belongs to the last character of the last English word in the English word sequence, determining that the first English word and / or the last English word is not complete.

[0074] Step C2, removing the first English word and / or the last English word to obtain an updated first character set.

[0075] In the embodiments of the present application, if the character i does not belong to the first character of the English word W_k, it is determined that the first English word is not complete, and the first word is taken as W_k+1 at this time. If the character j does not belong to the last character of the English word W_t, it is determined that the last English word is not complete, and the last word is retained as W_t-1 at this time.

[0076] The method provided in the embodiments of the present application can determine the character index positions from the first character and the last character according to the confidence, which can exclude the interference of non-character patterns on the character recognition accuracy. At the same time, even in the case that the image is not complete, the first and last recognition accuracy can be ensured, and the error rate of the first and last parts in the text recognition result is reduced.

[0077] In the embodiments of the present application, step S14 of determining the first character set as the text recognition result includes the following steps D1-D3:

[0078] Step D1, in the case that the target language is Chinese, detecting the characters contained in the first character set to obtain a Chinese character sequence corresponding to the first character set and a character width sequence, wherein the character width sequence includes a character width corresponding to each character in the Chinese character sequence.

[0079] In the embodiment of the present application, the number of characters in the Chinese character sequence corresponding to the first character set is M, and the character sequence is represented as O_1,…,O_M. The character width sequence is represented as c_1,…c_M, and the adaptive width threshold T2 is calculated as beta×sum(c_2,c_(M-1)) / (M-2). Wherein beta is an adjustment coefficient, and T2 is a width threshold.

[0080] Step D2, at least two second indexes are obtained from the head and tail of the Chinese character sequence using the head and tail characters in the Chinese character sequence respectively, and a second character set is constructed based on the second indexes, wherein the index position is the position of the character whose character width falls within the preset width range.

[0081] Step D3, the second character set is determined as the text recognition result.

[0082] In the embodiment of the present application, in the case that the target language is Chinese, in view of the problem of incomplete Chinese characters, a width threshold is set using the character width consistency information of Chinese characters, and a preset width range [T2, x] is determined based on the width threshold. Finally, the head and tail characters are filtered using the preset width range, thereby solving the problem of incomplete Chinese characters, for example, as shown in “Guanzi” and “Over Qin” in “Over Qin” are not displayed completely, and are removed in the detection process using the detection method of the present application. Figure 2

[0083] In the embodiment of the present application, at least two second indexes are obtained from the head and tail of the Chinese character sequence using the head and tail characters in the Chinese character sequence respectively, and a second character set is constructed based on the second indexes, including:

[0084] Step E1, taking the head character of the Chinese character sequence as a starting point, sequentially traversing the characters in the head of the Chinese character sequence, determining the character whose first character width falls within the preset width range as a third target character, and determining the position corresponding to the third target character as a second starting index.

[0085] In the embodiment of the present application, taking the head character of the Chinese character sequence as a starting point, starting from the head character O_1 of the Chinese character sequence, finding the pth character, if the pth character satisfies c_p≥T2, it indicates that the head character is complete, the pth character is determined as the third target character, and the position corresponding to the third target character is determined as the second starting index.

[0086] ​Step E2: Starting from the last character of the Chinese character sequence, traverse the last characters of the Chinese character sequence in turn, determine the first character whose width falls within the preset width range as the fourth target character, and determine the position corresponding to the third target character as the second termination index.

[0087] In this embodiment, the last character of the Chinese character sequence is taken as the starting point. Starting from the last character O_M of the Chinese character sequence, the q-th character is searched. If the q-th character satisfies c_q≥T2, it means that the last character is complete. The q-th character is determined as the fourth target character, and the position corresponding to the fourth target character is determined as the second termination index.

[0088] Step E3: Generate a second character set based on the characters between the second starting index and the second ending index.

[0089] In this embodiment of the application, the p-th character and the q-th character are retained, and a second character set is generated based on the characters between the p-th character and the q-th character.

[0090] Additionally, if c_p < T2, it is determined that the first character is incomplete, and the first character is taken as O_2. Similarly, the last character is determined as O_M. If c_M < T2, the last character is incomplete, and the last character is taken as O_M-1 (j = M-1).

[0091] Figure 3 This is a block diagram of a text recognition device provided in an embodiment of this application. This device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 3 As shown, the device includes:

[0092] The acquisition module 31 is used to acquire the target text to be identified, wherein the target text contains characters corresponding to at least one language;

[0093] The detection module 32 is used to detect the characters contained in the target text and obtain the character sequence and confidence sequence corresponding to the target text. The confidence sequence includes the first confidence level corresponding to each character in the character sequence.

[0094] The query module 33 is used to obtain at least two target index positions from the beginning and end of the character sequence using the first and last characters in the character sequence, respectively, and to construct a first character set based on the target index positions, wherein the target index position is the position corresponding to the character whose first confidence level falls within the first confidence level range;

[0095] The determination module 34 is used to determine the first character set as the text recognition result.

[0096] In the embodiment of the present application, the query module 33 is configured to take the first character of the character sequence as a starting point, sequentially traverse the characters at the head of the character sequence, determine the first character whose confidence falls within the confidence range as a first target character, and determine the position corresponding to the first target character as a first starting index; take the last character of the character sequence as a starting point, sequentially traverse the characters at the tail of the character sequence, determine the first character whose confidence falls within the confidence range as a second target character, and determine the position corresponding to the second target character as a first ending index; and generate a first character set based on the characters between the first starting index and the first ending index.

[0097] In the embodiment of the present application, the device further includes an identification module configured to detect a character feature of the character in the target text; and determine a target language corresponding to the character feature based on a corresponding relationship between the preset character feature and the language type.

[0098] In the embodiment of the present application, the determination module 34 is configured to, in a case where the target language is an English language, acquire an English word sequence based on the first character set; in a case where the first target character belongs to the first character of the first English word in the English word sequence and the second target character belongs to the last character of the last English word in the English word sequence, determine that the first English word and the last English word are complete; and determine the first character set as the text recognition result.

[0099] In the embodiment of the present application, the determination module 34 is configured to, in a case where the first target character does not belong to the first character of the first English word in the English word sequence and / or the second target character belongs to the last character of the last English word in the English word sequence, determine that the first English word and / or the last English word is / are incomplete; and remove the first English word and / or the last English word to obtain an updated first character set.

[0100] In the embodiment of the present application, the determination module 34 is configured to, in a case where the target language is a Chinese language, detect the characters included in the first character set to obtain a Chinese character sequence corresponding to the first character set and a character width sequence, wherein the character width sequence includes the character width corresponding to each character in the Chinese character sequence; acquire at least two second indexes from the head and tail of the Chinese character sequence by using the first and last characters in the Chinese character sequence respectively, and construct a second character set based on the second indexes, wherein the index position is the position corresponding to the character whose character width falls within a preset width range; and determine the second character set as the text recognition result.

[0101] In the embodiments of the present application, the determining module 34 is configured to take the first character of the Chinese character sequence as a starting point, sequentially traverse the characters in the head part of the Chinese character sequence, determine the character whose width falls into the preset width range as the third target character, and determine the position corresponding to the third target character as the second starting index; take the last character of the Chinese character sequence as a starting point, sequentially traverse the characters in the tail part of the Chinese character sequence, determine the character whose width falls into the preset width range as the fourth target character, and determine the position corresponding to the third target character as the second ending index.

[0102] The second character set is generated based on the characters between the second starting index and the second ending index.

[0103] The embodiments of the present application also provide an electronic device, as shown in the accompanying drawings. Figure 4 The electronic device can include a processor 1501, a communication interface 1502, a memory 1503 and a communication bus 1504, wherein the processor 1501, the communication interface 1502 and the memory 1503 can communicate with each other through the communication bus 1504.

[0104] The memory 1503 is configured to store a computer program.

[0105] The processor 1501 is configured to execute the computer program stored in the memory 1503, so as to realize the steps of the above embodiments.

[0106] The communication bus mentioned in the above terminal can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one thick line is shown in the figure, but it does not mean that there is only one bus or only one type of bus.

[0107] The communication interface is configured to realize the communication between the terminal and other devices.

[0108] The memory can include a random access memory (RAM) and can also include a non-volatile memory, for example, at least one disk memory. Optionally, the memory can also be at least one storage device located away from the aforementioned processor.

[0109] The processor described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.

[0110] In another embodiment provided in the present application, a computer readable storage medium is provided, and the computer readable storage medium stores instructions, which, when executed on a computer, cause the computer to perform the text recognition method in any of the above embodiments.

[0111] In another embodiment provided in the present application, a computer program product is provided, and the computer program product includes instructions, which, when executed on a computer, cause the computer to perform the text recognition method in any of the above embodiments.

[0112] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable apparatus. The computer instructions can be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available medium can be a magnetic medium (for example, floppy disk, hard disk, magnetic tape), an optical medium (for example, DVD), or a semiconductor medium (for example, solid state disk) and the like.

[0113] The above descriptions are only the preferred embodiment of the present application, not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

[0114] The above descriptions are only the specific embodiments of the present application, which enable those skilled in the art to understand or implement the present application. Various modifications to these embodiments will be obvious to those skilled in the art, and the generic principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Accordingly, the present application will not be limited to these embodiments shown herein but will be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A text recognition method, characterized by, The method comprises: obtaining a target image, wherein the target image contains target text to be detected; detecting characters contained in the target text to obtain a character sequence corresponding to the target text and a confidence sequence, wherein the confidence sequence comprises a confidence corresponding to each character in the character sequence; obtaining at least two first indexes from the beginning and end of the character sequence by using the first and last characters in the character sequence respectively, and constructing a first character set based on the first indexes, comprising: taking the first character of the character sequence as a starting point, sequentially traversing the characters at the beginning of the character sequence, determining a first target character whose confidence falls within the confidence range as the first character, and determining a first starting index corresponding to the first target character; taking the last character of the character sequence as a starting point, sequentially traversing the characters at the end of the character sequence, determining a second target character whose confidence falls within the confidence range as the last character, and determining a first termination index corresponding to the second target character; generating the first character set based on the characters between the first starting index and the first termination index; wherein the target index position is the position of the character whose confidence falls within the confidence range; determining the first character set as the text recognition result; The method further comprises: detecting a character feature of the character in the target text; determining a target language corresponding to the character feature based on a corresponding relationship between a preset character feature and a language type; The determination of the first character set as the text recognition result comprises: in the case that the target language is an English language, obtaining an English word sequence based on the first character set; in the case that the first target character belongs to the first character of the first English word in the English word sequence, and the second target character belongs to the last character of the last English word in the English word sequence, determining that the first English word and the last English word are complete; determining the first character set as the text recognition result; The determination of the first character set as the text recognition result comprises: in the case that the target language is a Chinese language, detecting characters contained in the first character set to obtain a Chinese character sequence corresponding to the first character set and a character width sequence, wherein the character width sequence comprises a character width corresponding to each character in the Chinese character sequence; obtaining at least two second indexes from the beginning and end of the Chinese character sequence by using the first and last characters in the Chinese character sequence respectively, and constructing a second character set based on the second indexes, wherein the index position is the position of the character whose character width falls within a preset width range; determining the second character set as the text recognition result.

2. The method of claim 1, wherein, The method further comprises: in the case that the first target character does not belong to the first character of the first English word in the English word sequence, and / or the second target character belongs to the last character of the last English word in the English word sequence, determining that the first English word and / or the last English word are incomplete; The first English word and / or the last English word are removed to obtain an updated first character set.

3. The method of claim 1, wherein, The first and last characters in the Chinese character sequence are used to obtain at least two second indexes from the beginning and end of the Chinese character sequence, respectively, and a second character set is constructed based on the second indexes, including: The first character of the Chinese character sequence is used as a starting point, and the characters at the beginning of the Chinese character sequence are traversed in sequence, and the first character whose width falls within the preset width range is determined as a third target character, and the position corresponding to the third target character is determined as a second starting index; The last character of the Chinese character sequence is used as a starting point, and the characters at the end of the Chinese character sequence are traversed in sequence, and the first character whose width falls within the preset width range is determined as a fourth target character, and the position corresponding to the third target character is determined as a second ending index; The second character set is generated based on the characters between the second starting index and the second ending index.

4. A text recognition apparatus employing the method according to any one of claims 1 to 3, characterized by Comprising: An acquisition module is configured to acquire a target image, wherein the target image contains a target text to be detected; A detection module is configured to detect characters contained in the target text to obtain a character sequence corresponding to the target text and a confidence sequence, wherein the confidence sequence includes a first confidence corresponding to each character in the character sequence; A query module is configured to obtain at least two target index positions from the beginning and end of the character sequence using the first and last characters in the character sequence, respectively, and construct a first character set based on the target index positions, wherein the target index positions are positions corresponding to characters whose first confidence falls within a first confidence range; A determination module is configured to determine the first character set as the text recognition result.

5. A storage medium, characterized by The storage medium includes a stored program, wherein the program executes the method steps of any one of claims 1-3 when running.

6. An electronic device, comprising: A processor, a communication interface, a memory and a communication bus are included, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus; wherein: The memory is used to store a computer program; The processor is used to execute the method steps of any one of claims 1-3 by running the program stored in the memory.

Citation Information

Patent Citations

  • Text recognition method and device and storage medium

    CN111401099A

  • Information processing method and apparatus, electronic device, and storage medium

    WO2022111347A1