Optical character recognition method, device and electronic device
By classifying and converting character images in optical character recognition technology, the semantic correctness of the recognition results is ensured, the problem in the existing technology that the recognition results do not conform to the semantics is solved, and the recognition accuracy is improved.
Patent Information
- Application Number
- CN202011513721.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-18
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2040-12-18
AI Technical Summary
When existing optical character recognition technology recognizes text information in images, it is difficult to accurately capture the semantic relationship of character elements, resulting in recognition results that do not conform to the semantic meaning and affect the accuracy rate.
In the optical character recognition method, the first character image is classified, the arrangement direction and semantic relationship of the character elements are generated, the second character image is generated, and optical character recognition is performed to ensure the semantic correctness of the recognition result.
It improves the accuracy of optical character recognition, avoids the situation where the recognition results do not conform to the semantic meaning, and enhances the reliability of the recognition results.
Smart Images

Figure CN112488094B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of Internet technology, and in particular to an optical character recognition method, device and electronic device. Background Art
[0002] With the development of the Internet, users are increasingly using terminal devices to achieve various functions. For example, with the popularity of smart devices, people can easily obtain images. Text, as high-level semantic information in images, can help people better understand images. Converting text information in images into computer-readable and editable characters is of great significance for improving multimedia retrieval capabilities, industrial automation levels, scene understanding capabilities, etc. Summary of the invention
[0003] This disclosure section is provided to introduce concepts in a brief form, which will be described in detail in the detailed description section below. This disclosure section is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0004] In a first aspect, an embodiment of the present disclosure provides an optical character recognition method, the method comprising: acquiring a first character image, wherein the first character image comprises at least two character elements; classifying the first character image to generate a classification result, wherein the classification result comprises an arrangement direction of the character elements in the direction of the character image, the character image direction is used to indicate a positional relationship between adjacent characters having semantic connections, and the arrangement direction is used to indicate a direction of the character elements according to the semantics; generating a second character image based on the classification result and the first character image; performing optical character recognition on the second character image to obtain a recognition result.
[0005] In a second aspect, an embodiment of the present disclosure provides an optical character recognition device, comprising: an acquisition unit, for acquiring a first character image, wherein the first character image comprises at least two character elements; a classification unit, for classifying the first character image and generating a classification result, wherein the classification result comprises an arrangement direction of the character elements in the direction of the character image, wherein the character image direction is used to indicate a positional relationship between adjacent characters having semantic connections, and wherein the arrangement direction is used to indicate a direction of the character elements according to semantics; a generation unit, for generating a second character image based on the classification result and the first character image; and a recognition unit, for performing optical character recognition on the second character image and obtaining a recognition result.
[0006] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the optical character recognition method as described in the first aspect.
[0007] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the optical character recognition method as described in the first aspect.
[0008] The optical character recognition method, device and electronic device provided by the embodiments of the present disclosure classify the first character image before performing optical character recognition to generate a classification result, and the classification result may include the arrangement direction of the character elements in the character image direction. Thus, the correct direction of the character elements with semantic connection can be obtained, and the situation where the recognition result does not conform to the semantics can be avoided as much as possible, thereby improving the accuracy of the recognition result. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0010] Figure 1 is a flow chart of an embodiment of an optical character recognition method according to the present disclosure;
[0011] Figure 2A and Figure 2B is a schematic diagram of an application scenario of the optical character recognition method according to the present disclosure
[0012] Figure 3A and Figure 3B is a schematic diagram of an application scenario of the optical character recognition method according to the present disclosure;
[0013] Figure 4 is a schematic diagram of another embodiment of an optical character recognition method according to the present disclosure;
[0014] Figure 5 is a schematic diagram of another embodiment of an optical character recognition method according to the present disclosure;
[0015] Figure 6 is a schematic structural diagram of an embodiment of an optical character recognition device according to the present disclosure;
[0016] Figure 7is an exemplary system architecture in which the optical character recognition method of one embodiment of the present disclosure may be applied;
[0017] Figure 8 It is a schematic diagram of the basic structure of an electronic device provided according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0018] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0019] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0020] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0021] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0022] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0023] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0024] Please refer to Figure 1 , which shows the process of an embodiment of the optical character recognition method according to the present disclosure. Figure 1 The optical character recognition method shown comprises the following steps:
[0025] Step 101, obtain a first character image.
[0026] In this embodiment, an execution subject (such as a terminal device or a server) of the optical character recognition method may obtain a first character image.
[0027] In this embodiment, the first character image may be an image including characters. The form and source of the first character image may be set according to the actual application scenario and are not limited herein. The language to which the characters belong may also be any one or more and is not limited herein.
[0028] As an example, the first character image may include one or at least two character lines, or may also include one or at least two character columns.
[0029] As an example, the first character image may be intercepted from a video frame.
[0030] In this embodiment, the above-mentioned first character image may include at least two character elements.
[0031] Here, the above-mentioned character elements may indicate characters. Please refer to Figure 3A , Figure 3A Each character in "All under heaven are beautiful" in Figure 3A may be understood as a character element.
[0032] Step 102, classify the first character image to generate a classification result.
[0033] In this embodiment, the above-mentioned execution subject may classify the first character image to generate a classification result.
[0034] Here, the classification result may include the arrangement direction of the character elements in the direction of the character image.
[0035] In this embodiment, the character image direction may indicate the positional relationship between adjacent characters with semantic connections. The character image direction may be a scalar.
[0036] As an example, the character image direction of the character elements in the first character image may include a row direction or a column direction. The row direction may indicate that adjacent character elements with semantic connections are adjacent left and right, that is, the adjacent character elements on the left and right form a semantic group. The column direction may indicate that adjacent character elements with semantic connections are adjacent up and down, that is, the adjacent character elements above and below form a semantic group.
[0037] Please refer to Figure 3A , Figure 3A The positional relationship between the characters in "All under heaven are beautiful" in
[0038] As an example, the character image direction of the character element in the first character image is oblique. The oblique direction may indicate that the central connection line between the adjacent character elements having semantic connection is inclined.
[0039] Here, the arrangement direction can indicate the direction of the character elements according to the semantics. The arrangement direction can be indicated by two vector directions parallel to the character image direction, and the two vector directions can be defined as the positive or negative direction along the distribution direction. In other words, the arrangement direction can be positive or negative. As an example, please refer to Figure 3A , Figure 3A According to the meaning of "the world is beautiful", the arrangement direction can be from top to bottom. If from top to bottom is set as the positive direction in advance, then Figure 3A The arrangement direction of the character elements shown in the figure is the positive direction in the direction of the character image.
[0040] In some embodiments, the classification result may include an arrangement direction.
[0041] In some embodiments, the classification result may include character image direction and arrangement direction.
[0042] Step 103: Generate a second character image based on the classification result and the first character image.
[0043] In this embodiment, the execution entity may generate a second character image based on the classification result and the first character image.
[0044] As an example, if the above classification result indicates that the arrangement direction of the character elements in the first character image is positive, the first character image may not be rotated.
[0045] As an example, if the above classification result indicates that the arrangement direction of the character elements in the first character image is not positive, the first character image may be rotated to obtain the second character image.
[0046] Step 104: perform optical character recognition on the second character image to obtain a recognition result.
[0047] In this embodiment, the execution entity may perform optical character recognition on the second character image to obtain a recognition result.
[0048] In this embodiment, the recognition process can adopt various methods, such as Euclidean space comparison method, relaxation comparison method (Relaxation), dynamic programming comparison method (Dynamic Programming, DP), database establishment and comparison, hidden Markov model (Hidden Markov Model HMM), etc., which will not be repeated here.
[0049] It should be noted that the optical character recognition method provided in this embodiment, before performing optical character recognition, classifies the first character image to generate a classification result, and the classification result may include the arrangement direction of the character elements in the character image direction. In this way, the correct direction of the character elements with semantic connection can be obtained, and the situation that the recognition result does not conform to the semantics can be avoided as much as possible, thereby improving the accuracy of the recognition result.
[0050] In some embodiments, the character image direction of the character element in the first character image may include a row direction or a column direction.
[0051] Please refer to Figure 2A and Figure 2B . Figure 2A A first character image is shown whose character image direction is the row direction, and the arrangement direction of the character elements in the first character image in the row direction is the positive direction. Figure 2B The first character image is shown in which the character image direction is the row direction, and the arrangement direction of the character elements in the first character image in the row direction is the reverse direction, which is 180 degrees from the forward direction.
[0052] Please refer to Figure 3A and Figure 3B . Figure 3A A first character image is shown whose character image direction is the column direction, and the arrangement direction of the character elements in the first character image in the column direction is the positive direction. Figure 3B The first character image is shown in which the character image direction is the column direction, and the arrangement direction of the character elements in the first character image in the row direction is the reverse direction, which is 180 degrees from the forward direction.
[0053] It should be noted that the row direction and column direction are the character image directions that appear most frequently in actual application scenarios. By setting the classification of the row direction and column direction, the recognition speed and efficiency of the character image can be improved in actual application scenarios.
[0054] Please refer to Figure 4 , which shows a flow chart of another embodiment of an optical character recognition method according to the present disclosure.
[0055] Step 401, obtaining a first character image.
[0056] In this embodiment, the first character image includes at least two character elements.
[0057] The relevant description of step 401 can refer to step 101 and will not be repeated here.
[0058] Step 402: import the first character image into a pre-established first classification model to obtain a first arrangement direction.
[0059] Here, the first arrangement direction can be understood as a classification result.
[0060] In this embodiment, the first classification model can be used to characterize the correspondence between the first character image and the first arrangement direction. In other words, the input of the first classification model can be the first character image, and the output can be the first arrangement direction. The output of the first classification model may not include the character image direction.
[0061] Here, the first classification model can be obtained by training the first initial classification network. The training samples of the first initial classification network can be pre-labeled with arrangement direction labels, and the arrangement direction labels can indicate the arrangement direction of the training samples. The specific structure of the first initial classification network can be set according to the actual application scenario and is not limited here.
[0062] As an example, the training process may include: obtaining training samples from a training sample set including row direction samples and / or column direction samples; importing the obtained training samples into a first initial classification network that has not been trained or has not yet been trained; the first initial classification network may output a classification result for the training sample (including whether the arrangement direction is forward or reverse); performing loss calculation on the arrangement direction output by the first initial classification network and the arrangement direction in the label, and adjusting the weights in the first initial network based on the calculated loss value.
[0063] It can be understood that the stopping condition of training can be set according to the actual application scenario and is not limited here; for example, the number of network updates is greater than the preset update number threshold or the weight update amplitude is less than the preset amplitude threshold, etc.
[0064] Step 403 , in response to the first arrangement direction indicating a preset reverse direction, the first character image is rotated to the preset positive direction to obtain the second character image.
[0065] Here, you can refer to Figure 2B , Figure 2B The figure shows a schematic diagram of the reverse direction when the character image is in the row direction; in this case, the first character image can be rotated to the positive direction, please refer to Figure 2A A schematic diagram showing the positive direction.
[0066] You can refer to Figure 3B , Figure 3B The figure shows a schematic diagram of the reverse direction when the character image is in the column direction; in this case, the first character image can be rotated to the positive direction, please refer to Figure 3A A schematic diagram showing the positive direction.
[0067] Step 404: import the second character image into the pre-established first character recognition model to obtain the recognition result.
[0068] Here, the training sample set of the first character recognition model includes row direction samples and column direction samples. The training samples may be pre-labeled with labels indicating character recognition results.
[0069] Here, the row direction sample may be a character image whose character image direction is the row direction. In other words, the character elements with semantic connection in the row direction sample are in a left-right position relationship.
[0070] Here, the column direction sample may be a character image whose character image direction is the column direction. In other words, the character elements with semantic connection in the column direction sample are in an up-down position relationship.
[0071] Here, the first character recognition model can be obtained by training the first initial recognition network. The specific structure of the first initial recognition network can be set according to the actual application scenario and is not limited here.
[0072] As an example, the training process of the first initial recognition network may include: obtaining training samples from a training sample set including row direction samples and column direction samples; importing the obtained training samples into an untrained or untrained first initial recognition network; the first initial recognition network may output a character recognition result for the training sample; performing loss calculation on the character recognition result output by the first initial recognition network and the character recognition result in the label, and adjusting the weights in the first initial recognition network based on the calculated loss value.
[0073] It should be noted that the first character recognition model is trained using row direction samples and column direction samples, so that the first character recognition model has good recognition capabilities for both character images in the row direction and character images in the column direction. In this case, the output of the first classification model includes the first arrangement direction, so that the output of the first classification model does not need to include the character image direction, thereby reducing the complexity of the first classification model and the steps of selecting the character recognition model, thereby improving the classification speed and recognition speed.
[0074] Please refer to Figure 5 , which shows the process of another embodiment of the optical character recognition method according to the present disclosure.
[0075] Step 501, obtaining a first character image.
[0076] In this embodiment, the first character image includes at least two character elements.
[0077] The relevant description of step 501 can refer to step 101 and will not be repeated here.
[0078] Step 502: Import the first character image into a pre-established second classification model to obtain character image direction information and a second arrangement direction.
[0079] Here, the second arrangement direction and the character image direction information can be understood as the classification result.
[0080] In this embodiment, the second classification model can be used to characterize the correspondence between the first character image and the character image direction information and the second arrangement direction. In other words, the input of the second classification model can be the first character image, and the output can be the character image direction information and the second arrangement direction.
[0081] Here, the second classification model can be obtained by training the second initial classification network. The training samples of the second initial classification network can be pre-labeled with character image direction information and arrangement direction, and the label of the arrangement direction can indicate the character image direction information and arrangement direction of the training sample. The specific structure of the second initial classification network can be set according to the actual application scenario and is not limited here.
[0082] As an example, the training process may include: obtaining training samples from a training sample set including row direction samples and column direction samples; importing the obtained training samples into a second initial classification network that has not been trained or has not yet been trained; the second initial classification network can output the classification results for the training samples (including whether the arrangement direction is forward or reverse, and whether the character image direction information is row direction or column direction); performing loss calculation on the arrangement direction and character image direction information output by the second initial classification network and the arrangement direction and character image direction information in the label; and adjusting the weights in the first initial network based on the calculated loss value.
[0083] Step 503 , in response to the second arrangement direction indicating a preset reverse direction, the first character image is rotated to the preset positive direction to obtain the second character image.
[0084] Here, you can refer to Figure 2B , Figure 2B The figure shows a schematic diagram of the reverse direction when the character image is in the row direction; in this case, the first character image can be rotated to the positive direction, please refer to Figure 2A A schematic diagram showing the positive direction.
[0085] You can refer to Figure 3B , Figure 3B The figure shows a schematic diagram of the reverse direction when the character image is in the column direction; in this case, the first character image can be rotated to the positive direction, please refer to Figure 3A A schematic diagram showing the positive direction.
[0086] Step 504 , in response to the character image direction information indicating the row direction, the second character image is imported into a pre-established second character recognition model to obtain the recognition result.
[0087] Here, the training sample set of the second character recognition model includes row direction samples. The training samples may be pre-labeled with labels indicating character recognition results.
[0088] Here, the second character recognition model can be obtained by training the second initial recognition network. The specific structure of the second initial recognition network can be set according to the actual application scenario and is not limited here.
[0089] As an example, the training process of the second initial recognition network may include: obtaining training samples from a training sample set including row direction samples; importing the obtained training samples into an untrained or untrained second initial recognition network; the second initial recognition network may output character recognition results for the training samples; performing loss calculation on the character recognition results output by the second initial recognition network and the character recognition results in the label, and adjusting the weights in the second initial recognition network based on the calculated loss values.
[0090] Step 505 , in response to the character image direction information indicating a column direction, importing the second character image into a pre-established third character recognition model to obtain the recognition result.
[0091] Here, the training sample set of the third character recognition model includes column direction samples. The training samples may be pre-labeled with labels indicating character recognition results.
[0092] Here, the third character recognition model can be obtained by training the third initial recognition network. The specific structure of the third initial recognition network can be set according to the actual application scenario and is not limited here.
[0093] As an example, the training process of the third initial recognition network may include: obtaining training samples from a training sample set including column-direction samples; importing the obtained training samples into an untrained or untrained third initial recognition network; the third initial recognition network may output a character recognition result for the training sample; performing loss calculation on the character recognition result output by the third initial recognition network and the character recognition result in the label, and adjusting the weights in the third initial recognition network based on the calculated loss value.
[0094] It should be noted that the second classification model can determine the direction of the character image while determining the arrangement direction. After obtaining the second character image according to the arrangement direction, the second character image can be imported into the character recognition model corresponding to the direction of the character image; here, the character recognition models for recognizing row direction character images and recognizing column direction character images are set as two separate models, which can specifically improve the recognition ability of a single model for the character image corresponding to the model, thereby improving the recognition accuracy of row direction character images, and also improving the recognition accuracy of column direction character images.
[0095] Further references Figure 6 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an optical character recognition device. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0096] like Figure 6 As shown, the optical character recognition device of this embodiment includes: an acquisition unit 601, a classification unit 602, a generation unit 603 and a recognition unit 604. The acquisition unit is used to acquire a first character image, wherein the first character image includes at least two character elements; the classification unit is used to classify the first character image and generate a classification result, wherein the classification result includes the arrangement direction of the character elements in the character image direction, the character image direction is used to indicate the positional relationship between adjacent characters with semantic connection, and the arrangement direction is used to indicate the direction of the character elements according to the semantics; the generation unit is used to generate a second character image based on the classification result and the first character image; the recognition unit is used to perform optical character recognition on the second character image to obtain a recognition result.
[0097] In this embodiment, the specific processing of the acquisition unit 601, the classification unit 602, the generation unit 603 and the recognition unit 604 of the optical character recognition device and the technical effects thereof can be referred to respectively. Figure 1 The relevant descriptions of step 101, step 102, step 103 and step 104 in the corresponding embodiment are not repeated here.
[0098] In some embodiments, the character image direction in the first character image includes a row direction or a column direction.
[0099] In some embodiments, classifying the first character image to generate a classification result includes: importing the first character image into a pre-established first classification model to obtain a first arrangement direction.
[0100] In some embodiments, generating the second character image based on the classification result and the first character image includes: in response to the first arrangement direction indicating a preset reverse direction, rotating the first character image to the preset positive direction to obtain the second character image.
[0101] In some embodiments, performing optical character recognition on the second character image to obtain a recognition result includes: importing the second character image into a pre-established first character recognition model to obtain the recognition result, wherein the training sample set of the first character recognition model includes row direction samples and column direction samples.
[0102] In some embodiments, classifying the first character image to generate a classification result includes: importing the first character image into a pre-established second classification model to obtain character image direction information and a second arrangement direction.
[0103] In some embodiments, generating the second character image based on the classification result and the first character image includes: in response to the second arrangement direction indicating a preset reverse direction, rotating the first character image to the preset positive direction to obtain the second character image.
[0104] In some embodiments, performing optical character recognition on the second character image to obtain a recognition result includes: in response to the character image directional information indicating a row direction, importing the second character image into a pre-established second character recognition model to obtain the recognition result, wherein the training sample set of the second character recognition model includes row direction samples; in response to the character image directional information indicating a column direction, importing the second character image into a pre-established third character recognition model to obtain the recognition result, wherein the training sample set of the third character recognition model includes column direction samples.
[0105] Please refer to Figure 7 , Figure 7 An exemplary system architecture is shown in which the optical character recognition method according to one embodiment of the present disclosure can be applied.
[0106] like Figure 7 As shown, the system architecture may include terminal devices 701, 702, 703, a network 704, and a server 705. The network 704 is used to provide a medium for communication links between the terminal devices 701, 702, 703 and the server 705. The network 704 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0107] The terminal devices 701, 702, and 703 can interact with the server 705 through the network 704 to receive or send messages, etc. Various client applications, such as web browser applications, search applications, and news information applications, can be installed on the terminal devices 701, 702, and 703. The client applications in the terminal devices 701, 702, and 703 can receive user instructions and perform corresponding functions according to the user instructions, such as adding corresponding information to the information according to the user instructions.
[0108] Terminal devices 701, 702, and 703 can be hardware or software. When terminal devices 701, 702, and 703 are hardware, they can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) players, laptop computers, and desktop computers, etc. When terminal devices 701, 702, and 703 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0109] The server 705 may be a server that provides various services, such as receiving information acquisition requests sent by the terminal devices 701, 702, and 703, acquiring display information corresponding to the information acquisition requests in various ways according to the information acquisition requests, and sending relevant data of the display information to the terminal devices 701, 702, and 703.
[0110] It should be noted that the optical character recognition method provided in the embodiment of the present disclosure can be executed by a terminal device, and accordingly, the optical character recognition device can be set in the terminal devices 701, 702, and 703. In addition, the optical character recognition method provided in the embodiment of the present disclosure can also be executed by a server 705, and accordingly, the optical character recognition device can be set in the server 705.
[0111] It should be understood that Figure 7 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0112] Reference below Figure 8 , which shows an electronic device (eg, Figure 7 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0113] like Figure 8 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0114] Typically, the following devices may be connected to the I / O interface 805: input devices 806 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 808 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 809. The communication device 809 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 8 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0115] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0116] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0117] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText TransferProtocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0118] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0119] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains a first character image, wherein the first character image includes at least two character elements; classifies the first character image to generate a classification result, wherein the classification result includes an arrangement direction of the character elements in the direction of the character image, wherein the character image direction is used to indicate the positional relationship between adjacent characters with semantic connection, and wherein the arrangement direction is used to indicate the direction of the character elements according to the semantics; generates a second character image based on the classification result and the first character image; performs optical character recognition on the second character image to obtain a recognition result
[0120] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0121] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0122] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the acquisition unit may also be described as a "unit for acquiring a first character image".
[0123] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0124] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0125] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0126] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0127] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. An optical character recognition method, characterized in that: include: Acquire a first character image, wherein the first character image includes at least two character elements; Classifying the first character image to generate a classification result, wherein the classification result includes an arrangement direction of character elements in a character image direction, the character image direction is used to indicate a positional relationship between adjacent characters with semantic connections, and the arrangement direction is used to indicate a direction of the character elements according to the semantics; generating a second character image based on the classification result and the first character image; Performing optical character recognition on the second character image to obtain a recognition result; The generating of the second character image based on the classification result and the first character image includes: if the classification result indicates that the arrangement direction of the character elements in the first character image is positive, then the first character image is not rotated; if the classification result indicates that the arrangement direction of the character elements in the first character image is not positive, then the first character image can be rotated to obtain the second character image.
2. The method according to claim 1, characterized in that The character image direction in the first character image includes a row direction or a column direction.
3. The method according to claim 2, characterized in that The classifying the first character image to generate a classification result includes: The first character image is imported into a pre-established first classification model to obtain a first arrangement direction.
4. The method according to claim 3, characterized in that The step of generating a second character image based on the classification result and the first character image comprises: In response to the first arrangement direction indicating a preset reverse direction, the first character image is rotated to a preset positive direction to obtain the second character image.
5. The method according to claim 4, characterized in that The performing optical character recognition on the second character image to obtain a recognition result includes: The second character image is imported into a pre-established first character recognition model to obtain the recognition result, wherein the training sample set of the first character recognition model includes row direction samples and column direction samples.
6. The method according to claim 2, characterized in that The classifying the first character image to generate a classification result includes: The first character image is introduced into a pre-established second classification model to obtain character image direction information and a second arrangement direction.
7. The method according to claim 6, characterized in that The step of generating a second character image based on the classification result and the first character image comprises: In response to the second arrangement direction indicating a preset reverse direction, the first character image is rotated to a preset positive direction to obtain the second character image.
8. The method according to claim 7, characterized in that The performing optical character recognition on the second character image to obtain a recognition result includes: In response to the character image direction information indicating a row direction, the second character image is imported into a pre-established second character recognition model to obtain the recognition result, wherein the training sample set of the second character recognition model includes row direction samples; In response to the character image direction information indicating a column direction, the second character image is imported into a pre-established third character recognition model to obtain the recognition result, wherein the training sample set of the third character recognition model includes column direction samples.
9. An optical character recognition device, characterized in that: include: An acquiring unit, configured to acquire a first character image, wherein the first character image includes at least two character elements; a classification unit, configured to classify the first character image and generate a classification result, wherein the classification result includes an arrangement direction of character elements in a character image direction, the character image direction is used to indicate a positional relationship between adjacent characters having a semantic connection, and the arrangement direction is used to indicate a direction of the character elements according to the semantics; A generating unit, configured to generate a second character image based on the classification result and the first character image; A recognition unit, used for performing optical character recognition on the second character image to obtain a recognition result; The generation unit is also used for: if the classification result indicates that the arrangement direction of the character elements in the first character image is positive, then the first character image is not rotated; if the classification result indicates that the arrangement direction of the character elements in the first character image is not positive, then the first character image can be rotated to obtain a second character image.
10. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.
11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
