CN114429628A - Image processing method and device, readable storage medium and electronic equipment - Google Patents
Image processing method and device, readable storage medium and electronic equipment Download PDFInfo
- Publication number
- CN114429628A CN114429628A CN202210072765.0A CN202210072765A CN114429628A CN 114429628 A CN114429628 A CN 114429628A CN 202210072765 A CN202210072765 A CN 202210072765A CN 114429628 A CN114429628 A CN 114429628A
- Authority
- CN
- China
- Prior art keywords
- character
- sequence
- line region
- text
- module
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
Landscapes
- Engineering & Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Bioinformatics & Computational Biology (AREA)
- Artificial Intelligence (AREA)
- Evolutionary Biology (AREA)
- Evolutionary Computation (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Character Input (AREA)
- Character Discrimination (AREA)
Abstract
The disclosure relates to an image processing method, an image processing device, a readable storage medium and an electronic device. The method comprises the following steps: extracting a text line area from a target image; for each character line region, segmenting the character line region to obtain at least one single character image corresponding to the character line region; and inputting at least one single character image corresponding to the character line region into a pre-trained character recognition model to obtain a recognition text corresponding to the character line region. Because the text recognition is carried out according to the single character images corresponding to the character line area, the influence of the character gaps in the character line area on the text recognition result can be avoided, and the accuracy of the text recognition can be improved. In addition, text recognition is carried out according to the single-character images corresponding to the text line region, instead of respectively recognizing each single-character image, so that the association characteristics between adjacent characters in the text line region can be captured, and the accuracy of text recognition is further improved.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an image processing method and apparatus, a readable storage medium, and an electronic device.
Background
With the continuous development of science and technology, text Recognition technology is widely applied, especially Optical Character Recognition (OCR) and the like. OCR obtains an image by scanning, photographing or sensing characters written on a print by a user through an electronic device, and obtains text contents in the image by detecting shapes of the characters on the image. But the text recognition result is not accurate enough due to the influence of character gaps in the image and the like. Therefore, how to improve the accuracy of text recognition is a problem to be solved in the related art.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
In a first aspect, the present disclosure provides an image processing method, including:
extracting a text line area from a target image;
for each character line region, segmenting the character line region to obtain at least one single character image corresponding to the character line region; and inputting the at least one single character image corresponding to the character line region into a pre-trained character recognition model to obtain a recognition text corresponding to the character line region.
In a second aspect, the present disclosure provides an image processing apparatus comprising:
the extraction module is used for extracting a text line region from the target image;
the segmentation module is used for segmenting each character line region extracted by the extraction module to obtain at least one single character image corresponding to the character line region; and the recognition module is used for inputting the at least one single character image corresponding to the character line region obtained by segmenting through the segmentation module into a pre-trained character recognition model to obtain a recognition text corresponding to the character line region.
In a third aspect, the present disclosure provides a computer readable medium having stored thereon a computer program which, when executed by a processing apparatus, performs the steps of the method provided by the first aspect of the present disclosure.
In a fourth aspect, the present disclosure provides an electronic device comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to implement the steps of the method provided by the first aspect of the present disclosure.
In the technical scheme, firstly, a text line area is extracted from a target image; then, aiming at each character row area, segmenting the character row area to obtain at least one single character image corresponding to the character row area; and inputting at least one single character image corresponding to the character line region into a pre-trained character recognition model to obtain a recognition text corresponding to the character line region. Because the text recognition is carried out according to the single character images corresponding to the character line area, the influence of the character gaps in the character line area on the text recognition result can be avoided, and the accuracy of the text recognition can be improved. In addition, text recognition is carried out according to the single-character images corresponding to the text line region, instead of respectively recognizing each single-character image, so that the association characteristics between adjacent characters in the text line region can be captured, and the accuracy of text recognition is further improved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale. In the drawings:
FIG. 1 is a flow diagram illustrating an image processing method according to an exemplary embodiment.
FIG. 2 is a schematic diagram illustrating a structure of a feature extraction model according to an exemplary embodiment.
FIG. 3 is a flow diagram illustrating a method of feature extraction model training in accordance with an exemplary embodiment.
FIG. 4 is a block diagram illustrating a character recognition model according to an exemplary embodiment.
Fig. 5 is a block diagram illustrating an image processing apparatus according to an exemplary embodiment.
FIG. 6 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and the embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "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". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
FIG. 1 is a flow diagram illustrating an image processing method according to an exemplary embodiment. As shown in fig. 1, the method includes S101 to S103.
In S101, a text line region is extracted from the target image.
In the present disclosure, the target image includes text information, wherein the text information may be chinese, english, or numeric, and the language of the text information included in the target image is not specifically limited in the present disclosure. And, the text information can be located at any one or more positions in the target image.
In addition, a text line detection algorithm may be used to perform text line detection on the target image to obtain at least one text line region corresponding to the target image. The character line detection algorithm detects characters in the target image by taking a line as a unit, can detect the boundary of each character line in the target image, can mark the boundary by using a rectangular frame, and the area defined by the rectangular frame is the detected character line area. The above-mentioned text line detection algorithm may adopt a currently general text line detection algorithm, for example, an edge-based detection algorithm, a connected domain-based detection algorithm, a texture-based detection algorithm, a deep learning-based detection algorithm, and the like.
In S102, for each text line region, the text line region is segmented to obtain at least one single character image corresponding to the text line region.
In the present disclosure, a single character image is an image containing a single character.
For example, the text line region a includes 8 characters, and by segmenting the text line region a, 8 single-character images corresponding to the text line region a can be obtained.
In S103, at least one single-character image corresponding to the text line region is input into a pre-trained character recognition model, and a recognition text corresponding to the text line region is obtained.
In the technical scheme, firstly, a text line area is extracted from a target image; then, aiming at each character row area, segmenting the character row area to obtain at least one single character image corresponding to the character row area; and inputting at least one single character image corresponding to the character line region into a pre-trained character recognition model to obtain a recognition text corresponding to the character line region. Because the text recognition is carried out according to the single character images corresponding to the character line area, the influence of the character gaps in the character line area on the text recognition result can be avoided, and the accuracy of the text recognition can be improved. In addition, text recognition is carried out according to the single-character images corresponding to the text line region, instead of respectively recognizing each single-character image, so that the association characteristics between adjacent characters in the text line region can be captured, and the accuracy of text recognition is further improved.
A detailed description will be given below of a specific embodiment of obtaining at least one single-character image corresponding to the text line region by segmenting the text line region in S102. Specifically, the method can be realized by the following steps (1) and (2):
(1) and inputting the character row area into a pre-trained feature extraction model to obtain a target sequence for representing whether each pixel column in the character row area contains characters.
In the present disclosure, the length of the target sequence is equal to the number of pixel columns included in the text row region, i.e., the width of the text row region.
Illustratively, the size of the text row area is 32 × 48, where the width is 32 pixels and the height is 48 pixels, and then the width of the text row area is 32 pixels, that is, the text row area includes 32 pixel columns, where each pixel column includes 48 pixels, and the length of the target sequence is 32.
(2) And segmenting the character line region according to the target sequence to obtain at least one single character image corresponding to the character line region.
As shown in fig. 2, the feature extraction model may include a feature extraction module, a first coding module, a first full connection layer, and a post-processing module, which are connected in sequence. The character line region is used for carrying out character extraction on the character line region to obtain a first characteristic sequence corresponding to the character line region; the first coding module is used for coding the first characteristic sequence to obtain a first coding sequence; the first full-connection layer is used for generating a second characteristic sequence for representing the position information of each character in the character line region according to the first coding sequence; and the post-processing module is used for normalizing the second characteristic sequence and adjusting the length of the second characteristic sequence obtained after normalization into a target length to obtain a target sequence for representing whether each pixel column in the text row area contains characters or not, wherein the target length is equal to the number of the pixel columns contained in the text row area.
In the present disclosure, the feature extraction module may be composed of a plurality of CNNs (Convolutional Neural Networks).
The first coding module may be composed of one coding network or may be composed of a plurality of coding networks connected in sequence. Preferably, the first coding module is composed of a plurality of coding networks connected in sequence, so that the richness and accuracy of feature extraction can be improved, and the accuracy of text recognition is further improved.
In one embodiment, the length of the second feature sequence is a preset fixed value M, and the second feature sequence may include a probability that each of the M positions contains a character. At this time, the post-processing module may normalize the second feature sequence by: firstly, normalizing each numerical value in the second characteristic sequence into a numerical value within the range of 0-1; then, normalizing the value of the second feature sequence obtained after normalization to be greater than or equal to a preset threshold (for example, 0.5) to be 1, and normalizing the value of the second feature sequence obtained after normalization to be less than the preset threshold to be 0, thereby obtaining a 0-1 sequence, i.e., a target sequence, wherein 1 in the target sequence indicates that the pixel column corresponding to the target sequence in the text row region contains characters, and 0 indicates that the pixel column corresponding to the target sequence in the text row region does not contain non-characters.
In another embodiment, the length of the second feature sequence is a preset fixed value M, and the second feature sequence may include a probability that each of the M positions does not contain a character (e.g., contains a character space). At this time, the post-processing module may normalize the second feature sequence by: firstly, normalizing each numerical value in the second characteristic sequence into a numerical value within the range of 0-1; then, normalizing the value of the second feature sequence obtained after normalization to be greater than or equal to a preset threshold (for example, 0.5) to be 1, and normalizing the value of the second feature sequence obtained after normalization to be less than the preset threshold to be 0, thereby obtaining a 0-1 sequence, i.e., a target sequence, wherein 0 in the target sequence indicates that the pixel column corresponding to the target sequence in the text row region contains characters, and 1 indicates that the pixel column corresponding to the target sequence in the text row region does not contain characters.
The length of the second signature sequence may be a predetermined fixed value, and may be greater than the number of pixel columns included in the text row region, may be smaller than the number of pixel columns included in the text row region, or may be equal to the number of pixel columns included in the text row region.
When the length of the second feature sequence is greater than the number of pixel columns included in the text row region, that is, the length of the second feature sequence is greater than the target length, at this time, sampling processing may be performed on the second feature sequence obtained after normalization to obtain a sequence of the target length, that is, a target sequence.
When the length of the second feature sequence is smaller than the number of pixel columns included in the text line region, that is, the length of the second feature sequence is smaller than the target length, in this case, interpolation processing may be performed on the normalized second feature sequence to adjust the length of the normalized second feature sequence to the target length, so as to obtain the target sequence.
When the length of the second feature sequence is equal to the number of pixel columns included in the text row region, that is, the length of the second feature sequence is equal to the target length, the length of the second feature sequence obtained after normalization may not be adjusted, and the second feature sequence obtained after normalization may be directly determined as the target sequence.
The following describes the training method of the feature extraction model in detail. Specifically, the above-described feature extraction model can be trained through S301 to S304 shown in fig. 3.
In S301, a sample text line region and a labeling sequence for characterizing whether each pixel column in the sample text line region contains a character are obtained.
In S302, the sample text line region is input into the feature extraction model, and a training sequence for characterizing whether each pixel column in the sample text line region includes a character is obtained.
In S303, a target loss is determined according to the training sequence and the tagging sequence.
In one embodiment, the target loss may be determined based on a mean square error loss function based on the training sequence and the annotation sequence.
In another embodiment, the target loss may be determined based on a CTC loss function according to a training sequence and an annotation sequence, where CTC is Connectionist Temporal Classification, i.e., a neural network-based Temporal class Classification.
When determining the loss of the feature extraction model, the CTC loss function may be used in a training process of unaligned serialized data, and may automatically align unaligned data, so that when determining the loss of the feature extraction model, the CTC loss function is used for calculation, which may effectively ensure the accuracy of the determined target loss, thereby ensuring the accuracy of subsequent parameter updating of the feature extraction model.
In S304, the parameter of the feature extraction model is updated according to the target loss, and the training is terminated when the target loss is less than or equal to the preset threshold, so as to obtain the feature extraction model.
In the present disclosure, the preset threshold may be set according to an actual usage scenario, and the higher the accuracy of the feature extraction model is required to be, the smaller the value of the preset threshold is.
In this step, when it is determined that the target loss of the feature extraction model is greater than the preset threshold, the step of obtaining the sample text line region and the labeling sequence used for representing whether each pixel column in the sample text line region contains a character or not may be executed again to the step of updating the parameters of the feature extraction model according to the target loss. In the process of re-executing the steps, different training samples can be selected for training, so that the comprehensiveness and the universality of learnable features in the feature extraction model can be improved, and the learning efficiency of the feature extraction model is improved. And when the target loss is less than or equal to the preset threshold value, finishing the training, which shows that the feature extraction accuracy of the feature extraction model is higher at the moment, so that the use requirements of users are met, and the trained feature extraction model is obtained at the moment.
A detailed description will be given below of a specific embodiment in which the text line region is segmented according to the target sequence in step (2) to obtain at least one single-character image corresponding to the text line region.
Specifically, when the target sequence is a 0-1 sequence, and 1 indicates that the pixel column corresponding to the target sequence in the text row region contains a character, and 0 indicates that the pixel column corresponding to the target sequence in the text row region does not contain a character, at least one single-character image corresponding to the text row region can be obtained by segmentation in the following manner: firstly, determining pixel columns corresponding to continuous 1 in a target sequence in the character line region as a single character region; then, each single character area is divided from the character line area to obtain at least one single character image corresponding to the character line area.
Exemplarily, the target sequence is 000111001111011000011110001011000, where 1 indicates that the pixel column corresponding to the text row region contains a character, and 0 indicates that the pixel column corresponding to the text row region does not contain a character, the pixel column corresponding to the consecutive 1 from the fourth bit to the sixth bit in the target sequence in the text row region may be determined as a single character region a, that is, the fourth pixel column, the fifth pixel column, and the sixth pixel column (viewed from left to right) in the text row region may be determined as the single character region a; determining pixel columns corresponding to 1 continuous from the ninth bit to the twelfth bit in the target sequence in the character row area as a single character area B, namely determining a ninth pixel column, a tenth pixel column, an eleventh pixel column and a twelfth pixel column in the character row area as the single character area B; determining a pixel column corresponding to 1 consecutive to the fourteenth bit and the fifteenth bit in the target sequence in the text row area as a single character area C, namely determining the fourteenth pixel column and the fifteenth pixel column in the text row area as the single character area C; determining pixel columns in the character row area, which correspond to consecutive 1's from the twentieth bit to the twenty-third bit in the target sequence, as a single character area D, namely determining the twentieth pixel column, the twenty-first pixel column, the twenty-second pixel column and the twenty-third pixel column in the character row area as the single character area D; determining pixel columns in the text line region corresponding to continuous 1 from twenty ninth to thirty fifth bits in the target sequence as a single character region E, namely determining twenty ninth pixel column and thirty third pixel column in the text line region as the single character region E; then, the single character region a, the single character region B, the single character region C, the single character region D, and the single character region E are respectively segmented from the character line region to obtain 5 single character images corresponding to the character line region. Since the twenty-seventh bit in the target sequence is 1, and both the front and rear bits are 0, and the sequence is not a continuous 1, it can be considered that the pixel column corresponding to the twenty-seventh bit in the target sequence in the text row region does not include a character.
When the target sequence is a sequence of 0 to 1, and 0 indicates that the pixel column corresponding to the target sequence in the text row region contains characters, and 1 indicates that the pixel column corresponding to the target sequence in the text row region does not contain characters, at least one single-character image corresponding to the text row region can be obtained by segmenting in the following way: firstly, determining pixel columns in the character line region corresponding to continuous 0 s in the target sequence as a single character region; then, each single character area is divided from the character line area to obtain at least one single character image corresponding to the character line area.
As shown in fig. 4, the character recognition model includes a preprocessing module, a second encoding module, a decoding module, and a second full-link layer, which are connected in sequence. The preprocessing module is used for normalizing the single-character images into images with preset sizes (for example, 32 × 32) aiming at each single-character image in at least one single-character image corresponding to the text row area, straightening the single-character images obtained after normalization into one-dimensional row vectors with preset lengths (for example, 1024), and then forming the one-dimensional vectors corresponding to each single-character image corresponding to the text row area into a multi-dimensional matrix; the second coding module is used for coding the multidimensional matrix to obtain a second coding sequence; the decoding module is used for capturing the association characteristics between adjacent characters in the character line area according to the second coding sequence so as to generate a characteristic vector corresponding to each single-character image; and the second full connection layer is used for generating the identification text corresponding to the character line region according to each feature vector.
The second coding module may be composed of one coding network or a plurality of coding networks connected in sequence. Preferably, the second coding module is composed of a plurality of coding networks connected in sequence, so that the richness and accuracy of feature extraction can be improved, and the accuracy of text recognition is further improved.
The decoding module can be composed of one decoding network or a plurality of decoding networks which are connected in sequence. Preferably, the decoding module is composed of a plurality of decoding networks connected in sequence, so that the richness and accuracy of feature extraction can be improved, and the accuracy of text recognition can be improved.
Fig. 5 is a block diagram illustrating an image processing apparatus according to another exemplary embodiment. As shown in fig. 5, the apparatus 500 includes:
an extracting module 501, configured to extract a text line region from a target image;
a segmentation module 502, configured to segment, for each text line region extracted by the extraction module 501, the text line region to obtain at least one single-character image corresponding to the text line region; the recognition module 503 is configured to input the at least one single-character image corresponding to the text line region obtained by segmentation by the segmentation module 502 into a pre-trained character recognition model, so as to obtain a recognition text corresponding to the text line region.
In the technical scheme, firstly, a text line area is extracted from a target image; then, aiming at each character row area, segmenting the character row area to obtain at least one single character image corresponding to the character row area; and inputting at least one single character image corresponding to the character line region into a pre-trained character recognition model to obtain a recognition text corresponding to the character line region. Because the text recognition is carried out according to the single character images corresponding to the character line area, the influence of the character gaps in the character line area on the text recognition result can be avoided, and the accuracy of the text recognition can be improved. In addition, text recognition is carried out according to the single-character images corresponding to the text line region, instead of respectively recognizing each single-character image, so that the association characteristics between adjacent characters in the text line region can be captured, and the accuracy of text recognition is further improved.
Optionally, the slicing module 502 includes:
the input submodule is used for inputting the character line area into a pre-trained feature extraction model to obtain a target sequence for representing whether each pixel column in the character line area contains characters or not, wherein the length of the target sequence is equal to the number of the pixel columns contained in the character line area;
and the first cutting module is used for cutting the character line region according to the target sequence to obtain at least one single character image corresponding to the character line region.
Optionally, the feature extraction model includes a feature extraction module, a first coding module, a first full connection layer, and a post-processing module, which are connected in sequence;
the character line region is used for carrying out character extraction on the character line region to obtain a first characteristic sequence corresponding to the character line region;
the first coding module is used for coding the first characteristic sequence to obtain a first coding sequence;
the first full-connection layer is used for generating a second characteristic sequence for representing the position information of each character in the character line region according to the first coding sequence;
and the post-processing module is used for normalizing the second feature sequence and adjusting the length of the second feature sequence obtained after normalization into a target length to obtain a target sequence for representing whether each pixel column in the text row area contains characters or not, wherein the target length is equal to the number of the pixel columns contained in the text row area.
Optionally, the feature extraction model is obtained by training through a training device, where the training device includes:
the system comprises an acquisition module, a display module and a display module, wherein the acquisition module is used for acquiring a sample text line region and a marking sequence used for representing whether each pixel column in the sample text line region contains characters;
the input module is used for inputting the sample text line area into the feature extraction model to obtain a training sequence for representing whether each pixel column in the sample text line area contains characters;
the determining module is used for determining target loss according to the training sequence and the labeling sequence;
and the updating module is used for updating parameters of the feature extraction model according to the target loss and finishing training when the target loss is less than or equal to a preset threshold value so as to obtain the feature extraction model.
Optionally, the determining module is configured to determine a target loss based on a CTC loss function according to the training sequence and the annotation sequence.
Optionally, the target sequence is a 0-1 sequence, where 1 indicates that the pixel column corresponding to the text row region contains a character, and 0 indicates that the pixel column corresponding to the text row region does not contain a character;
the first molecular module comprises:
the determining submodule is used for determining pixel columns corresponding to continuous 1 in the target sequence in the character line region as a single character region;
and the second segmentation submodule is used for segmenting each single-character region from the character line region to obtain at least one single-character image corresponding to the character line region.
Optionally, the character recognition model includes a preprocessing module, a second encoding module, a decoding module, and a second full connection layer, which are connected in sequence;
the preprocessing module is used for normalizing the single character image into an image with a preset size aiming at each single character image in the at least one single character image corresponding to the text line region, straightening the single character image obtained after normalization into a one-dimensional line vector with a preset length, and then forming a multi-dimensional matrix by the one-dimensional vector corresponding to each single character image;
the second coding module is used for coding the multidimensional matrix to obtain a second coding sequence;
the decoding module is used for generating a feature vector corresponding to each single character image according to the second coding sequence;
and the second full connection layer is used for generating the identification text corresponding to the character line region according to each feature vector.
The training device may be independent of the image processing device 500, or may be integrated into the image processing device 500, and the disclosure is not particularly limited thereto.
The present disclosure also provides a computer readable medium having stored thereon a computer program which, when executed by a processing apparatus, implements the steps of the above-mentioned image processing method provided by the present disclosure.
Referring now to fig. 6, a schematic diagram of an electronic device (terminal device or server) 600 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 6, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: extracting a text line area from a target image; for each character line region, segmenting the character line region to obtain at least one single character image corresponding to the character line region; and inputting the at least one single character image corresponding to the character line region into a pre-trained character recognition model to obtain a recognition text corresponding to the character line region.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of 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 the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented by software or hardware. The name of the module does not in some cases constitute a limitation to the module itself, and for example, the extraction module may also be described as a "module that extracts a text line region from a target image".
The functions described herein above 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 a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The 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, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
Example 1 provides an image processing method according to one or more embodiments of the present disclosure, including: extracting a text line area from a target image; for each character line region, segmenting the character line region to obtain at least one single character image corresponding to the character line region; and inputting the at least one single character image corresponding to the character line region into a pre-trained character recognition model to obtain a recognition text corresponding to the character line region.
Example 2 provides the method of example 1, where the segmenting the text line region to obtain at least one single-character image corresponding to the text line region includes: inputting the character row area into a pre-trained feature extraction model to obtain a target sequence for representing whether each pixel column in the character row area contains characters, wherein the length of the target sequence is equal to the number of the pixel columns contained in the character row area; and segmenting the character line region according to the target sequence to obtain at least one single character image corresponding to the character line region.
Example 3 provides the method of example 2, the feature extraction model including a feature extraction module, a first coding module, a first fully-connected layer, and a post-processing module connected in sequence, in accordance with one or more embodiments of the present disclosure; the character line region is used for carrying out character extraction on the character line region to obtain a first characteristic sequence corresponding to the character line region; the first coding module is used for coding the first characteristic sequence to obtain a first coding sequence; the first full-connection layer is used for generating a second characteristic sequence for representing the position information of each character in the character line region according to the first coding sequence; and the post-processing module is used for normalizing the second feature sequence and adjusting the length of the second feature sequence obtained after normalization into a target length to obtain a target sequence for representing whether each pixel column in the text row area contains characters, wherein the target length is equal to the number of the pixel columns contained in the text row area.
Example 4 provides the method of example 2, the feature extraction model being trained in the following manner, in accordance with one or more embodiments of the present disclosure: acquiring a sample text line region and a labeling sequence for representing whether each pixel column in the sample text line region contains characters; inputting the sample text line area into the feature extraction model to obtain a training sequence for representing whether each pixel column in the sample text line area contains characters; determining target loss according to the training sequence and the labeling sequence; and updating parameters of the feature extraction model according to the target loss, and finishing training when the target loss is less than or equal to a preset threshold value to obtain the feature extraction model.
Example 5 provides the method of example 4, wherein determining a target loss from the training sequence and the tagging sequence comprises: and determining target loss based on a CTC loss function according to the training sequence and the labeling sequence.
Example 6 provides the method of example 2, wherein the target sequence is a 0-1 sequence, wherein 1 indicates that the pixel column corresponding to the text row region contains a character, and 0 indicates that the pixel column corresponding to the text row region does not contain a character; the segmenting the character line region according to the target sequence to obtain at least one single character image corresponding to the character line region comprises the following steps: determining pixel columns in the character line region corresponding to continuous 1 s in the target sequence as a single character region; and cutting each single character area from the character line area to obtain at least one single character image corresponding to the character line area.
Example 7 provides the method of any one of examples 1-6, the character recognition model comprising a pre-processing module, a second encoding module, a decoding module, and a second fully-connected layer connected in sequence; the preprocessing module is used for normalizing the single character image into an image with a preset size aiming at each single character image in the at least one single character image corresponding to the text line region, straightening the single character image obtained after normalization into a one-dimensional line vector with a preset length, and then forming a multi-dimensional matrix by the one-dimensional vector corresponding to each single character image; the second coding module is used for coding the multidimensional matrix to obtain a second coding sequence; the decoding module is used for generating a feature vector corresponding to each single character image according to the second coding sequence; and the second full connection layer is used for generating the identification text corresponding to the character line region according to each feature vector.
Example 8 provides an image processing apparatus according to one or more embodiments of the present disclosure, including: the extraction module is used for extracting a text line region from the target image; the segmentation module is used for segmenting each character line region extracted by the extraction module to obtain at least one single character image corresponding to the character line region; and the recognition module is used for inputting the at least one single character image corresponding to the character line region obtained by segmenting through the segmentation module into a pre-trained character recognition model to obtain a recognition text corresponding to the character line region.
Example 9 provides a computer readable medium having stored thereon a computer program that, when executed by a processing apparatus, performs the steps of the method of any of examples 1-7, in accordance with one or more embodiments of the present disclosure.
Example 10 provides, in accordance with one or more embodiments of the present disclosure, an electronic device comprising: a storage device having a computer program stored thereon; processing means for executing the computer program in the storage means to carry out the steps of the method of any of examples 1-7.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Claims (10)
1. An image processing method, comprising:
extracting a text line area from a target image;
for each character line region, segmenting the character line region to obtain at least one single character image corresponding to the character line region; and inputting the at least one single character image corresponding to the character line region into a pre-trained character recognition model to obtain a recognition text corresponding to the character line region.
2. The method of claim 1, wherein the segmenting the text line region to obtain at least one single character image corresponding to the text line region comprises:
inputting the character row area into a pre-trained feature extraction model to obtain a target sequence for representing whether each pixel column in the character row area contains characters, wherein the length of the target sequence is equal to the number of the pixel columns contained in the character row area;
and segmenting the character line region according to the target sequence to obtain at least one single character image corresponding to the character line region.
3. The method according to claim 2, wherein the feature extraction model comprises a feature extraction module, a first coding module, a first full connection layer and a post-processing module which are connected in sequence;
the character line region is used for carrying out character extraction on the character line region to obtain a first characteristic sequence corresponding to the character line region;
the first coding module is used for coding the first characteristic sequence to obtain a first coding sequence;
the first full-connection layer is used for generating a second characteristic sequence for representing the position information of each character in the character line region according to the first coding sequence;
and the post-processing module is used for normalizing the second feature sequence and adjusting the length of the second feature sequence obtained after normalization into a target length to obtain a target sequence for representing whether each pixel column in the text row area contains characters or not, wherein the target length is equal to the number of the pixel columns contained in the text row area.
4. The method of claim 2, wherein the feature extraction model is trained by:
acquiring a sample text line area and a labeling sequence for representing whether each pixel column in the sample text line area contains characters or not;
inputting the sample text line area into the feature extraction model to obtain a training sequence for representing whether each pixel column in the sample text line area contains characters;
determining target loss according to the training sequence and the labeling sequence;
and updating parameters of the feature extraction model according to the target loss, and finishing training when the target loss is less than or equal to a preset threshold value to obtain the feature extraction model.
5. The method of claim 4, wherein determining a target loss based on the training sequence and the annotation sequence comprises:
and determining target loss based on a CTC loss function according to the training sequence and the labeling sequence.
6. The method of claim 2, wherein the target sequence is a sequence of 0-1, wherein 1 indicates that the corresponding pixel column in the text row area contains a character, and 0 indicates that the corresponding pixel column in the text row area does not contain a character;
the segmenting the character line region according to the target sequence to obtain at least one single character image corresponding to the character line region comprises the following steps:
determining pixel columns in the character line region corresponding to continuous 1 s in the target sequence as a single character region;
and cutting each single character area from the character line area to obtain at least one single character image corresponding to the character line area.
7. The method according to any one of claims 1-6, wherein the character recognition model comprises a preprocessing module, a second encoding module, a decoding module, and a second fully-connected layer connected in sequence;
the preprocessing module is used for normalizing the single character image into an image with a preset size aiming at each single character image in the at least one single character image corresponding to the character line region, straightening the single character image obtained after normalization into a one-dimensional line vector with a preset length, and then forming a multi-dimensional matrix by the one-dimensional vector corresponding to each single character image;
the second coding module is used for coding the multidimensional matrix to obtain a second coding sequence;
the decoding module is used for generating a feature vector corresponding to each single character image according to the second coding sequence;
and the second full connection layer is used for generating an identification text corresponding to the text line region according to each feature vector.
8. An image processing apparatus characterized by comprising:
the extraction module is used for extracting a text line region from the target image;
the segmentation module is used for segmenting each character line region extracted by the extraction module to obtain at least one single character image corresponding to the character line region; and the recognition module is used for inputting the at least one single character image corresponding to the character line region obtained by segmenting through the segmentation module into a pre-trained character recognition model to obtain a recognition text corresponding to the character line region.
9. A computer-readable medium, on which a computer program is stored, characterized in that the program, when being executed by processing means, carries out the steps of the method of any one of claims 1 to 7.
10. An electronic device, comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to carry out the steps of the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210072765.0A CN114429628A (en) | 2022-01-21 | 2022-01-21 | Image processing method and device, readable storage medium and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210072765.0A CN114429628A (en) | 2022-01-21 | 2022-01-21 | Image processing method and device, readable storage medium and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114429628A true CN114429628A (en) | 2022-05-03 |
Family
ID=81313692
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210072765.0A Pending CN114429628A (en) | 2022-01-21 | 2022-01-21 | Image processing method and device, readable storage medium and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114429628A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2023236614A1 (en) * | 2022-06-07 | 2023-12-14 | 华为云计算技术有限公司 | Cloud computing technology-based image recognition method, apparatus, and related device |
-
2022
- 2022-01-21 CN CN202210072765.0A patent/CN114429628A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2023236614A1 (en) * | 2022-06-07 | 2023-12-14 | 华为云计算技术有限公司 | Cloud computing technology-based image recognition method, apparatus, and related device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113313064B (en) | Character recognition method and device, readable medium and electronic equipment | |
EP3893125A1 (en) | Method and apparatus for searching video segment, device, medium and computer program product | |
CN111369427B (en) | Image processing method, image processing device, readable medium and electronic equipment | |
CN111950555B (en) | Text recognition method and device, readable medium and electronic equipment | |
CN110942061A (en) | Character recognition method, device, equipment and computer readable medium | |
CN110826567B (en) | Optical character recognition method, device, equipment and storage medium | |
CN112883968B (en) | Image character recognition method, device, medium and electronic equipment | |
CN112041851A (en) | Text recognition method and terminal equipment | |
CN110659639B (en) | Chinese character recognition method and device, computer readable medium and electronic equipment | |
CN113140012B (en) | Image processing method, device, medium and electronic equipment | |
CN114463768A (en) | Form recognition method and device, readable medium and electronic equipment | |
CN112488095B (en) | Seal image recognition method and device and electronic equipment | |
CN110674813B (en) | Chinese character recognition method and device, computer readable medium and electronic equipment | |
CN111209856B (en) | Invoice information identification method and device, electronic equipment and storage medium | |
CN110442719B (en) | Text processing method, device, equipment and storage medium | |
CN113033552B (en) | Text recognition method and device and electronic equipment | |
CN112800961B (en) | Stroke writing sequence detection method, device, medium and electronic equipment | |
CN114429628A (en) | Image processing method and device, readable storage medium and electronic equipment | |
CN112651399A (en) | Method for detecting same-line characters in oblique image and related equipment thereof | |
CN113780294B (en) | Text character segmentation method and device | |
CN116311290A (en) | Handwriting and printing text detection method and device based on deep learning | |
CN115937888A (en) | Document comparison method, device, equipment and medium | |
CN114495080A (en) | Font identification method and device, readable medium and electronic equipment | |
CN114612909A (en) | Character recognition method and device, readable medium and electronic equipment | |
CN111291758B (en) | Method and device for recognizing seal characters |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |