CN111626283B - Character extraction method and device and electronic equipment - Google Patents

Character extraction method and device and electronic equipment Download PDF

Info

Publication number
CN111626283B
CN111626283B CN202010428850.7A CN202010428850A CN111626283B CN 111626283 B CN111626283 B CN 111626283B CN 202010428850 A CN202010428850 A CN 202010428850A CN 111626283 B CN111626283 B CN 111626283B
Authority
CN
China
Prior art keywords
image
character
edge information
text
extraction model
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.)
Active
Application number
CN202010428850.7A
Other languages
Chinese (zh)
Other versions
CN111626283A (en
Inventor
周恺卉
王长虎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010428850.7A priority Critical patent/CN111626283B/en
Publication of CN111626283A publication Critical patent/CN111626283A/en
Application granted granted Critical
Publication of CN111626283B publication Critical patent/CN111626283B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/22Image preprocessing by selection of a specific region containing or referencing a pattern; Locating or processing of specific regions to guide the detection or recognition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/60Type of objects
    • G06V20/62Text, e.g. of license plates, overlay texts or captions on TV images

Abstract

The embodiment of the disclosure discloses a character extraction method and device, electronic equipment and a computer-readable storage medium. The character extraction method comprises the following steps: acquiring an image to be extracted; acquiring a first characteristic image of the image to be extracted; and obtaining a character image in the image to be extracted according to the first characteristic image. The method solves the technical problem of inaccurate character extraction in the prior art by acquiring the first characteristic image of the image to be extracted.

Description

Character extraction method and device and electronic equipment
Technical Field
The present disclosure relates to the field of image generation, and in particular, to a method and an apparatus for extracting text, an electronic device, and a computer-readable storage medium.
Background
Characters are used as abstract communication symbols of human inventions, have rich expressiveness, and appear in large quantities as information expressions in natural scenes. Because the characters contain rich semantic information, identifying the characters in natural scenes becomes the basis of a large number of visual applications, such as target positioning, human-computer interaction, image search, machine navigation, industrial automation and the like. Therefore, recognition and understanding of characters in natural scenes is one of the hot spots of recent research and application.
The character detection technology in the prior art is generally like the traditional OCR and target detection algorithm, when extracting characters, only a certain range of characters can be circled, for example, characters are circled by a circular frame or a rectangular frame, but the method is very inaccurate, and when the characters in an image need to be extracted, pixels of non-character parts in the image may exist in the extracted area, which brings inconvenience to subsequent application.
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 order to solve the technical problem that the extraction of characters in the prior art is not accurate enough, the embodiment of the present disclosure provides the following technical solutions.
In a first aspect, an embodiment of the present disclosure provides a text extraction method, including:
acquiring an image to be extracted;
acquiring a first characteristic image of the image to be extracted;
and obtaining a character image in the image to be extracted according to the first characteristic image.
In a second aspect, an embodiment of the present disclosure provides a text extraction apparatus, including:
the image to be extracted acquisition module is used for acquiring an image to be extracted;
the characteristic image acquisition module is used for acquiring a first characteristic image of the image to be extracted;
and the character extraction module is used for obtaining a character image in the image to be extracted according to the first characteristic image.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including: at least one processor; and (c) a second step of,
a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of the preceding first aspects.
In a fourth aspect, the present disclosure provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions for causing a computer to perform the method of any one of the foregoing first aspects.
The embodiment of the disclosure discloses a character extraction method and device, electronic equipment and a computer-readable storage medium. The character extraction method comprises the following steps: acquiring an image to be extracted; acquiring a first characteristic image of the image to be extracted; and obtaining a character image in the image to be extracted according to the first characteristic image. The method solves the technical problem of inaccurate character extraction in the prior art by acquiring the first characteristic image of the image to be extracted.
The foregoing is a summary of the present disclosure, and for the purposes of promoting a clear understanding of the technical means of the present disclosure, the present disclosure may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
Drawings
The above and other features, advantages, and aspects of 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.
Fig. 1 is a schematic flow chart of a text extraction method provided in the embodiment of the present disclosure;
FIG. 2 is a schematic flow chart illustrating the training steps of the text extraction model provided in the embodiment of the present disclosure;
fig. 3 is a diagram illustrating a specific implementation of the training step S204 of the text extraction model provided in the embodiment of the present disclosure;
fig. 4 is a diagram illustrating a specific implementation of the training step S302 of the text extraction model provided in the embodiment of the present disclosure;
fig. 5 is a diagram illustrating a specific implementation of the training step S205 of the text extraction model according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of an embodiment of a text extraction device according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of an electronic device provided according to an embodiment of the present disclosure.
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 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 flowchart of an embodiment of a text extraction method provided in this disclosure, where the text extraction method provided in this embodiment may be executed by a text extraction device, and the text extraction device may be implemented as software or as a combination of software and hardware, and the text extraction device may be integrated in a certain device in a text extraction system, such as a text extraction server or a text extraction terminal device. As shown in fig. 1, the method comprises the steps of:
step S101, acquiring an image to be extracted;
step S102, acquiring a first characteristic image of the image to be extracted;
and step S103, obtaining a character image in the image to be extracted according to the first characteristic image.
The image to be extracted is an image including text, such as an image frame including subtitles in a video image frame.
Optionally, the step S102 includes:
and inputting the image to be extracted into a plurality of convolution layers of a character extraction model to obtain the first characteristic image.
In this step, the plurality of convolutional layers down-sample the image to be extracted to obtain a first feature image of a predetermined size.
Optionally, the step S103 includes:
and inputting the first characteristic image into a plurality of deconvolution layers of the character extraction model to obtain the character image.
In this step, the plurality of deconvolution layers up-sample the first feature image to obtain a text image with the same size as the image to be extracted, where the text image only includes the text in the image to be extracted and the position of the text.
Optionally, the text extraction model is obtained through the following training steps:
step S201, acquiring a training set, wherein the training set comprises a plurality of image pairs, and the image pairs comprise a first image and a character image corresponding to the first image;
optionally, in this embodiment of the present disclosure, the pixel points of the text image correspond to the pixel points of the first image, that is, the resolution of the text image is the same as that of the first image, the pixel points may be in one-to-one correspondence, and the text image only includes the text included in the first image and does not include other images. Illustratively, the text image is a binary image with a black background and white text, and pixel-level labeling can be conveniently performed on the text image by using the image, namely, white pixel points are text pixel points, and black pixel points are non-text pixel points, so that the purpose of performing pixel-level labeling on the first image can be achieved.
Optionally, the first image is an image synthesized by an image not including text and the text image, that is, some images not including text and text images are obtained in advance and synthesized in a pixel superposition manner, so as to be described in the above example, since the background color is black, the pixel value of the background color is (0, 0) in the RGB space, and the pixel value of the text portion is (255 ), the background color is added to the pixel value of the pixel of the image not including text, the image portion not including text coinciding with the black portion retains the original pixel value, and the pixel value of the image portion coinciding with the text portion is set to (255 ), thereby obtaining the first image including text, and generating the text image of the first image as the labeling information at the pixel level of the first image.
Step S202, acquiring first edge information, wherein the first edge information is edge information of characters in the character image;
in order to determine the boundaries of the text more accurately, rather than merely framing the position of the text as in the prior art, the edge information of the text is added as another set of label information in the embodiment of the present disclosure. In the present disclosure, the first edge information may be obtained by an edge detection algorithm, and typically, a Canny edge detection algorithm may be used to detect pixel points on text edges in a text image. For the text image with black background and white font in the example in the embodiment of the present disclosure, the detection of the edge pixel point is easier, and only the white pixel point with the black adjacent pixel point needs to be detected. The detected edge pixel of the character is the first edge information, namely the category of the pixel is the edge pixel. And finally, classifying each pixel point by the character extraction model into a non-character pixel point, an edge pixel point and a character pixel point, wherein the edge pixel point is a special character pixel point.
Optionally, the step S202 includes: and acquiring the positions of pixel points at the edge of the characters in the character image. The positions of the edge pixels can be represented by the pixel coordinates of the edge pixels, and are not described in detail herein.
Step S203, initializing parameters of a character extraction model;
illustratively, in an embodiment of the present disclosure, the text extraction model includes a plurality of convolutional layers, a plurality of anti-convolutional layers, a fully-connected layer, a classification layer, and an output layer. Each layer includes a plurality of parameters such as convolution kernels for convolutional and deconvolution layers, bias terms, weight coefficients for fully-connected layers, and so on. The initialization may be initialized to a preset value or a random value, which is not described herein again.
Step S204, inputting the first image in the training set into a character extraction model to obtain a two-dimensional image and second edge information, wherein the second edge information is the edge information of characters in the two-dimensional image;
in this step, the first image is input into a text extraction model, the text extraction model finally outputs a two-dimensional image, the two-dimensional image is generated according to the classification result of each pixel point, illustratively, the pixel points classified as non-text types are output as black, the pixel points classified as text types are output as white, and the positions of edge pixel points are output, and the positions of the pixel points can be represented by the pixel coordinates of the edge pixel points in the two-dimensional image.
As shown in fig. 3, optionally, the step S204 includes:
step S301, a first image is down-sampled in a plurality of convolution layers of the first image input character extraction model to obtain a first feature map with a preset scale size;
step S302, inputting the first feature map into a plurality of deconvolution layers of the character extraction model, and performing upsampling on the first feature map to obtain a two-dimensional image with the same size as the character image and second edge information.
In step S301, a first feature map smaller than the first image size is obtained by downsampling the first image through a plurality of convolutional layers of the text extraction model, where the first feature map has a preset scale size, and the preset scale size can be set by designing the number of layers of the plurality of convolutional layers and the size of a convolutional kernel of each convolutional layer. In step S302, the first feature map is upsampled by multiple deconvolution layers of the text extraction model to restore the first feature map to a two-dimensional image with the same size as the first image, and which pixel points in the two-dimensional image are predicted to be edge pixel points of a text. Wherein the two-dimensional image is an image including only text, as the text image, and the text in the two-dimensional image may not be accurate until the text extraction model is not trained.
As shown in fig. 4, optionally, the step S302 further includes:
step S401, inputting the first feature map into a plurality of deconvolution layers of the character extraction model, and performing up-sampling on the first feature map to obtain a second feature map;
step S402, inputting the second feature map into a classification layer to obtain a classification result of each pixel point on the second feature map;
step S403, generating a two-dimensional image and second edge information according to the classification result.
In the step S401, the first feature map is up-sampled by the deconvolution layer to form a second feature map, where the second feature map may include three channels, and a pixel value of each pixel point in each channel respectively represents a probability that the pixel point is in the three categories, and when the probability is greater than a threshold, the pixel point may be considered as the category; it can be understood that two channels may also be used, wherein one channel may represent the probability that a pixel is a text pixel, and if the threshold is not reached, the channel is a non-text pixel, and the other channel is used to represent the probability that a pixel is a text edge pixel. In step S402, the classification layer obtains a classification result of each pixel point according to the pixel value of the pixel point, and then in step S403, the two-dimensional image and the second edge information may be generated according to the classification result.
Step S205, calculating an error according to the two-dimensional image, the character image, the first edge information and the second edge information;
the two-dimensional image and the second edge information obtained in step S204 are predicted values of the character extraction model in the training phase, and after the predicted values are obtained, an error is calculated with corresponding labeled values to determine whether parameters of the character extraction model are appropriate.
As shown in fig. 5, optionally, the step S205 includes:
step S501, calculating a first classification error according to the two-dimensional image and the character image;
step S502, calculating a second classification error according to the second edge information and the first edge information;
step S503, calculating a total error according to the first classification error and the second classification error.
For example, in step S501, a first classification error between the predicted value of the pixel point of the two-dimensional image and the pixel value of the pixel point in the text image is calculated, and when the first classification error is calculated, the classification probability value of each pixel point obtained in step S204 is used for calculation. Therefore, the probability that each pixel point is a character pixel point and the character image can be directly used for calculating the first classification error, in the character image, the probability of the character pixel point is 1, and the probability of the non-character pixel point is 0. Optionally, the first classification error is calculated by the following formula:
Figure BDA0002499758990000091
wherein L is mask Representing the first classification error, wherein N is the number of first images in a training set or the number of first images used in each training batch; x is the number of i X is used for representing character type predicted value obtained by inputting the ith first image into the character extraction model and can be understood i Which may be a matrix, representing the prediction probability values for each pixel in the first image,
Figure BDA0002499758990000092
is equal to the x i The labeling probability value of the corresponding character image can directly calculate a first error of a first image through the calculation of a matrix, and then calculate an average first error value of N first images as the first type error.
For example, in step S502, a second classification error between the second edge information and the first edge information is calculated, and when the second classification error is calculated, the edge classification probability value of each pixel obtained in step S104 is used for calculation. Therefore, the probability that each pixel point is a character edge pixel point and the character edge pixel point probability of the pixel point of the character image can be directly used for calculating a second classification error, wherein in the character image, the probability of the pixel point of the character edge is 1, and the probability of the pixel point of the non-character edge is 0. Optionally, the second classification error is calculated by the following formula:
Figure BDA0002499758990000093
wherein L is edge Representing the second classification error, wherein N is the number of the first images in the training set or the number of the first images used in each training batch; y is j The type prediction value of the edge pixel point obtained by inputting the jth first image into the character extraction model is expressed, and y can be understood j Which may be a matrix, representing the prediction probability values for each pixel in the first image,
Figure BDA0002499758990000094
is a reaction with the above-mentioned y j And labeling probability values of corresponding edges, so that a second error of the first image can be directly calculated through calculation of a matrix, and then an average second error value of the N first images is calculated to serve as the second type of error.
In step S503, a weighted average of the first type error value and the second type error value is calculated as a total error value. Illustratively, the total error value is calculated using the following formula:
L=δL mask +(1-δ)L edge (3)
where δ is a weighting factor and 0< δ <1, the weight of the two-part error in the total error can be adjusted. The parameters of the character extraction model can be verified through the loss function shown in the formula (3), and whether the parameters can accurately judge the characters and the edges of the characters can be verified.
Step S206, updating parameters of the character extraction model based on the error;
in this step, parameters of the text extraction model may be updated by back-propagation based on the error. For example, the text extraction model can be regarded as a function with parameters as variablesf (θ), where θ represents a set of parameters of the text extraction model, then:
Figure BDA0002499758990000102
to update the parameters, wherein
Figure BDA0002499758990000101
The convergence rate is determined as a learning rate.
Step S207, iterating the parameter updating process based on the updated parameters and the training set until a convergence condition is reached;
and step S208, taking the parameters obtained when the convergence condition is reached as the parameters of the trained character extraction model.
In the step S206, the iterative execution of the steps S204-S206 is continued based on the updated parameters of the character extraction model until a convergence condition is reached, where the convergence condition may be that the iteration number exceeds a preset number or that the error is smaller than a preset error value. It can be understood that the number of times of iteration is preset, for example, 100 times, the above iteration process is stopped when the parameter is updated for 100 times, and in step S107, the parameter obtained after 100 times of iteration is used as the parameter of the trained character extraction model; or an error value may be preset, for example, 0.001, and when the value of the above formula (2) is less than or equal to 0.001, the update of the parameter is stopped, and the finally obtained parameter is used as the parameter of the trained character extraction model. Therefore, the training of the character extraction model is finished, and the trained character extraction model is obtained.
It can be understood that after the training process is finished, another data set may be used to verify or test the training of the text extraction model, so as to prevent the text extraction model from being over-fitted, which is not described herein again.
In an embodiment, the text extraction method is a process of extracting a text prediction text image by using the text extraction model, and obtains a mask image (text mask) including only texts in the image to be extracted, where the texts in the text mask and the texts in the image to be extracted have pixel-level correspondence, rather than only identifying text frames with texts as in the prior art, and the extracted text region does not include other pixels in the image to be extracted, so that the extraction accuracy is improved.
The above embodiment discloses a method for extracting a character, wherein the method for extracting a character includes: acquiring an image to be extracted; acquiring a first characteristic image of the image to be extracted; and obtaining a character image in the image to be extracted according to the first characteristic image. The method solves the technical problem of inaccurate character extraction in the prior art by acquiring the first characteristic image of the image to be extracted.
In the above, although the steps in the above method embodiments are described in the above sequence, it should be clear to those skilled in the art that the steps in the embodiments of the present disclosure are not necessarily performed in the above sequence, and they may also be performed in other sequences such as reverse, parallel, and cross, and other sequences may also be added on the basis of the above steps, and these obvious modifications or equivalents should also be included in the protection scope of the present disclosure, and are not described herein again.
Fig. 6 is a schematic structural diagram of an embodiment of a text extraction device provided in the embodiment of the present disclosure, and as shown in fig. 6, the device 600 includes: an image to be extracted acquisition module 601, a characteristic image acquisition module 602 and a character extraction module 603. Wherein the content of the first and second substances,
an image to be extracted acquisition module 601, configured to acquire an image to be extracted;
a feature image obtaining module 602, configured to obtain a first feature image of the image to be extracted;
and the text extraction module 603 is configured to obtain a text image in the image to be extracted according to the first feature image.
Further, the feature image obtaining module 602 is further configured to:
and inputting the image to be extracted into a plurality of convolution layers of a character extraction model to obtain the first characteristic image.
Further, the text extraction module 603 is further configured to:
and inputting the first characteristic image into a plurality of deconvolution layers of the character extraction model to obtain the character image.
Further, the character extraction model is obtained through the following training steps:
acquiring a training set, wherein the training set comprises a plurality of image pairs, and the image pairs comprise a first image and a text image corresponding to the first image;
acquiring first edge information, wherein the first edge information is edge information of characters in the character image;
initializing parameters of a character extraction model;
inputting a first image in the training set into a character extraction model to obtain a two-dimensional image and second edge information, wherein the second edge information is the edge information of characters in the two-dimensional image;
calculating an error according to the two-dimensional image, the text image, the first edge information and the second edge information;
updating parameters of the text extraction model based on the error;
the updated parameters and the training set continue the parameter updating process until a convergence condition is reached;
and taking the parameters obtained when the convergence condition is reached as the parameters of the trained character extraction model.
Further, the pixel points of the text image correspond to the pixel points of the first image, and the text image only includes the text included in the first image.
Further, the first image is an image synthesized by an image not containing text and the text image.
Further, the character image is a binary image with black background and white characters.
Further, the acquiring the first edge information includes: and acquiring the positions of pixel points at the edge of the characters in the character image.
Further, the inputting the first image in the training set into the text extraction model to obtain a two-dimensional image and second edge information includes:
inputting the first image into a plurality of convolution layers of a character extraction model, and downsampling the first image to obtain a first feature map with a preset scale size;
inputting the first feature map into a plurality of deconvolution layers of the character extraction model to perform upsampling on the first feature map to obtain a two-dimensional image with the same size as the character image and second edge information.
Further, the inputting the feature map into the plurality of deconvolution layers of the text extraction model to perform upsampling on the feature map to obtain a two-dimensional image and second edge information, where the two-dimensional image and the second edge information are the same as the text image in size, includes:
inputting the first feature map into a plurality of deconvolution layers of the character extraction model to perform upsampling on the first feature map to obtain a second feature map;
inputting the second feature map into a classification layer to obtain a classification result of each pixel point on the second feature map;
and generating a two-dimensional image and second edge information according to the classification result.
Further, the calculating an error according to the two-dimensional image, the text image, the first edge information, and the second edge information includes:
calculating a first classification error according to the two-dimensional image and the character image;
calculating a second classification error according to the second edge information and the first edge information;
and calculating a total error according to the first classification error and the second classification error.
Further, the convergence condition includes: the iteration times exceed a preset time value or the error is smaller than a preset error value.
The apparatus shown in fig. 6 can perform the method of the embodiment shown in fig. 1-5, and the detailed description of the embodiment not described in detail can refer to the related description of the embodiment shown in fig. 1-5. The implementation process and technical effect of the technical solution refer to the descriptions in the embodiments shown in fig. 1 to fig. 5, which are not described herein again.
Referring now to FIG. 7, shown is a block diagram of an electronic device 700 suitable for use in implementing embodiments of the present disclosure. 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. 7 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. 7, electronic device 700 may include a processing means (e.g., central processing unit, graphics processor, etc.) 701 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM) 702 or a program loaded from storage 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the electronic apparatus 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other by a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Generally, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 707 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 708 including, for example, magnetic tape, hard disk, etc.; and a communication device 709. The communication means 709 may allow the electronic device 700 to communicate wirelessly or by wire with other devices to exchange data. While fig. 7 illustrates an electronic device 700 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 embodiments, the computer program may be downloaded and installed from a network via the communication means 709, or may be installed from the storage means 708, or may be installed from the ROM 702. The computer program, when executed by the processing device 701, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium of the present disclosure may 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 be separate and not incorporated 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: acquiring an image to be extracted; acquiring a first characteristic image of the image to be extracted; and obtaining a character image in the image to be extracted according to the first characteristic image.
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 latter scenario, 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 units described in the embodiments of the present disclosure may be implemented by software or hardware. Wherein the name of an element does not in some cases constitute a limitation on the element itself.
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 compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, there is provided a text extraction method including:
acquiring an image to be extracted;
acquiring a first characteristic image of the image to be extracted;
and obtaining a character image in the image to be extracted according to the first characteristic image.
Further, the acquiring the first feature image of the image to be extracted includes:
and inputting the image to be extracted into a plurality of convolution layers of a character extraction model to obtain the first characteristic image.
Further, the obtaining of the text image in the image to be extracted according to the first feature image includes:
and inputting the first characteristic image into a plurality of deconvolution layers of the character extraction model to obtain the character image.
Further, the character extraction model is obtained through the following training steps:
acquiring a training set, wherein the training set comprises a plurality of image pairs, and the image pairs comprise a first image and a text image corresponding to the first image;
acquiring first edge information, wherein the first edge information is edge information of characters in the character image;
initializing parameters of a character extraction model;
inputting a first image in the training set into a character extraction model to obtain a two-dimensional image and second edge information, wherein the second edge information is the edge information of characters in the two-dimensional image;
calculating an error according to the two-dimensional image, the text image, the first edge information and the second edge information;
updating parameters of the text extraction model based on the error;
iterating the parameter updating process based on the updated parameters and the training set until a convergence condition is reached;
and taking the parameters obtained when the convergence condition is reached as the parameters of the trained character extraction model.
Furthermore, the pixel points of the text image correspond to the pixel points of the first image, and the text image only contains the text contained in the first image.
Further, the first image is an image synthesized by an image not including a character and the character image.
Further, the character image is a binary image with black background and white characters.
Further, the acquiring the first edge information includes:
and acquiring the positions of pixel points at the edge of the characters in the character image.
Further, the inputting the first image in the training set into the text extraction model to obtain a two-dimensional image and second edge information includes:
inputting the first image into a plurality of convolution layers of a character extraction model, and downsampling the first image to obtain a first feature map with a preset scale size;
and inputting the first feature map into a plurality of deconvolution layers of the character extraction model to perform upsampling on the first feature map to obtain a two-dimensional image with the same size as the character image and second edge information.
Further, the inputting the feature map into the plurality of deconvolution layers of the text extraction model to perform upsampling on the feature map to obtain a two-dimensional image and second edge information, where the two-dimensional image and the second edge information are the same as the text image in size, includes:
inputting the first feature map into a plurality of deconvolution layers of the character extraction model to perform upsampling on the first feature map to obtain a second feature map;
inputting the second feature map into a classification layer to obtain a classification result of each pixel point on the second feature map;
and generating a two-dimensional image and second edge information according to the classification result.
Further, the calculating an error according to the two-dimensional image, the text image, the first edge information, and the second edge information includes:
calculating a first classification error according to the two-dimensional image and the character image;
calculating a second classification error according to the second edge information and the first edge information;
and calculating a total error according to the first classification error and the second classification error.
Further, the convergence condition includes:
the iteration times exceed a preset time value or the error is smaller than a preset error value.
According to one or more embodiments of the present disclosure, there is provided a character extraction device including:
the image to be extracted acquisition module is used for acquiring an image to be extracted;
the characteristic image acquisition module is used for acquiring a first characteristic image of the image to be extracted;
and the character extraction module is used for obtaining a character image in the image to be extracted according to the first characteristic image.
Further, the feature image obtaining module is further configured to:
and inputting the image to be extracted into a plurality of convolution layers of a character extraction model to obtain the first characteristic image.
Further, the text extraction module is further configured to:
and inputting the first characteristic image into a plurality of deconvolution layers of the character extraction model to obtain the character image.
Further, the character extraction model is obtained through the following training steps:
acquiring a training set, wherein the training set comprises a plurality of image pairs, and the image pairs comprise a first image and a text image corresponding to the first image;
acquiring first edge information, wherein the first edge information is edge information of characters in the character image;
initializing parameters of a character extraction model;
inputting a first image in the training set into a character extraction model to obtain a two-dimensional image and second edge information, wherein the second edge information is the edge information of characters in the two-dimensional image;
calculating an error according to the two-dimensional image, the text image, the first edge information and the second edge information;
updating parameters of the text extraction model based on the error;
the updated parameters and the training set continue the parameter updating process until a convergence condition is reached;
and taking the parameters obtained when the convergence condition is reached as the parameters of the trained character extraction model.
Further, the pixel points of the text image correspond to the pixel points of the first image, and the text image only includes the text included in the first image.
Further, the first image is an image synthesized by an image not including a character and the character image.
Further, the character image is a binary image with black background and white characters.
Further, the acquiring the first edge information includes: and acquiring the positions of pixel points at the edge of the characters in the character image.
Further, the inputting the first image in the training set into the text extraction model to obtain a two-dimensional image and second edge information includes:
inputting the first image into a plurality of convolution layers of a character extraction model, and downsampling the first image to obtain a first feature map with a preset scale size;
and inputting the first feature map into a plurality of deconvolution layers of the character extraction model to perform upsampling on the first feature map to obtain a two-dimensional image with the same size as the character image and second edge information.
Further, the inputting the feature map into the plurality of deconvolution layers of the text extraction model to perform upsampling on the feature map to obtain a two-dimensional image and second edge information, where the two-dimensional image and the second edge information are the same as the text image in size, includes:
inputting the first feature map into a plurality of deconvolution layers of the character extraction model to perform upsampling on the first feature map to obtain a second feature map;
inputting the second feature map into a classification layer to obtain a classification result of each pixel point on the second feature map;
and generating a two-dimensional image and second edge information according to the classification result.
Further, the calculating an error according to the two-dimensional image, the text image, the first edge information, and the second edge information includes:
calculating a first classification error according to the two-dimensional image and the character image;
calculating a second classification error according to the second edge information and the first edge information;
and calculating a total error according to the first classification error and the second classification error.
Further, the convergence condition includes: the iteration times exceed a preset time value or the error is smaller than a preset error value.
According to one or more embodiments of the present disclosure, there is provided an electronic device including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of the preceding first aspects.
According to one or more embodiments of the present disclosure, there is provided a non-transitory computer-readable storage medium characterized by storing computer instructions for causing a computer to perform the method of any of the preceding first aspects.
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 the technical features disclosed in the present disclosure (but not limited to) having similar functions are replaced with each other to form the technical solution.

Claims (10)

1. A character extraction method is characterized by comprising the following steps:
acquiring an image to be extracted;
acquiring a first characteristic image of the image to be extracted, wherein the method comprises the following steps: inputting the image to be extracted into a plurality of convolution layers of a character extraction model to obtain the first characteristic image;
obtaining a character image in the image to be extracted according to the first characteristic image, wherein the character image comprises: inputting the first characteristic image into a plurality of deconvolution layers of the character extraction model to obtain the character image;
the character extraction model is obtained through the following training steps:
acquiring a training set, wherein the training set comprises a plurality of image pairs, and the image pairs comprise a first image and a text image corresponding to the first image; the pixel points of the character image correspond to the pixel points of the first image, and the character image only comprises characters contained in the first image; the character image is a binary image with black background and white characters;
detecting white pixel points with black adjacent pixel points in the character image to obtain first edge information, wherein the first edge information is edge information of characters in the character image;
initializing parameters of a character extraction model;
inputting a first image in the training set into a character extraction model to obtain a two-dimensional image and second edge information, wherein the second edge information is the edge information of characters in the two-dimensional image;
calculating an error according to the two-dimensional image, the text image, the first edge information and the second edge information;
updating parameters of the text extraction model based on the error;
iterating the parameter updating process based on the updated parameters and the training set until a convergence condition is reached;
and taking the parameters obtained when the convergence condition is reached as the parameters of the trained character extraction model.
2. The character extraction method of claim 1, wherein the first image is an image synthesized by an image containing no character and the character image.
3. The text extraction method of claim 1, wherein the obtaining the first edge information comprises:
and acquiring the positions of pixel points at the edges of the characters in the character image.
4. The method of extracting words according to claim 1, wherein said inputting a first image in said training set into a word extraction model to obtain a two-dimensional image and a second edge information comprises:
inputting the first image into a plurality of convolution layers of a character extraction model, and down-sampling the first image to obtain a first feature map with a preset scale size;
and inputting the first feature map into a plurality of deconvolution layers of the character extraction model to perform upsampling on the first feature map to obtain a two-dimensional image with the same size as the character image and second edge information.
5. The method of extracting text as claimed in claim 4, wherein said inputting said feature map into said plurality of deconvolution layers of said text extraction model upsamples said feature map to obtain a two-dimensional image of the same size as said text image and second edge information, comprising:
inputting the first feature map into a plurality of deconvolution layers of the character extraction model to perform upsampling on the first feature map to obtain a second feature map;
inputting the second feature map into a classification layer to obtain a classification result of each pixel point on the second feature map;
and generating a two-dimensional image and second edge information according to the classification result.
6. The text extraction method of claim 1, wherein said calculating an error based on the two-dimensional image, the text image, the first edge information, and the second edge information comprises:
calculating a first classification error according to the two-dimensional image and the character image;
calculating a second classification error according to the second edge information and the first edge information;
and calculating a total error according to the first classification error and the second classification error.
7. The text extraction method of claim 1, wherein the convergence condition comprises:
the iteration times exceed a preset time value or the error is smaller than a preset error value.
8. A character extraction device, comprising:
the image to be extracted acquisition module is used for acquiring an image to be extracted;
the characteristic image acquisition module is used for acquiring a first characteristic image of the image to be extracted, and comprises: inputting the image to be extracted into a plurality of convolution layers of a character extraction model to obtain the first characteristic image;
the character extraction module is used for obtaining the character image in the image to be extracted according to the first characteristic image, and comprises: inputting the first characteristic image into a plurality of deconvolution layers of the character extraction model to obtain the character image;
the character extraction model is obtained through the following training steps:
acquiring a training set, wherein the training set comprises a plurality of image pairs, and the image pairs comprise a first image and a text image corresponding to the first image; the pixel points of the character image correspond to the pixel points of the first image, and the character image only contains characters contained in the first image; the character image is a binary image with black background and white characters;
detecting white pixel points with black adjacent pixel points in the character image to obtain first edge information, wherein the first edge information is edge information of characters in the character image;
initializing parameters of a character extraction model;
inputting a first image in the training set into a character extraction model to obtain a two-dimensional image and second edge information, wherein the second edge information is the edge information of characters in the two-dimensional image;
calculating an error according to the two-dimensional image, the text image, the first edge information and the second edge information;
updating parameters of the text extraction model based on the error;
iterating the parameter updating process based on the updated parameters and the training set until a convergence condition is reached;
and taking the parameters obtained when the convergence condition is reached as the parameters of the trained character extraction model.
9. An electronic device, comprising:
a memory for storing computer readable instructions; and
a processor for executing the computer readable instructions such that the processor when executed implements the method of any of claims 1-7.
10. A non-transitory computer-readable storage medium storing computer-readable instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1-7.
CN202010428850.7A 2020-05-20 2020-05-20 Character extraction method and device and electronic equipment Active CN111626283B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010428850.7A CN111626283B (en) 2020-05-20 2020-05-20 Character extraction method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010428850.7A CN111626283B (en) 2020-05-20 2020-05-20 Character extraction method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN111626283A CN111626283A (en) 2020-09-04
CN111626283B true CN111626283B (en) 2022-12-13

Family

ID=72260029

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010428850.7A Active CN111626283B (en) 2020-05-20 2020-05-20 Character extraction method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN111626283B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105574513A (en) * 2015-12-22 2016-05-11 北京旷视科技有限公司 Character detection method and device
CN108805131A (en) * 2018-05-22 2018-11-13 北京旷视科技有限公司 Text line detection method, apparatus and system
CN109784304A (en) * 2019-01-29 2019-05-21 北京字节跳动网络技术有限公司 Method and apparatus for marking dental imaging
CN109961068A (en) * 2017-12-26 2019-07-02 阿里巴巴集团控股有限公司 Image recognition, training, searching method and device and equipment, medium
CN110263610A (en) * 2019-02-28 2019-09-20 重庆大学 A kind of degeneration file and picture binary coding method and system based on deep learning
CN110443252A (en) * 2019-08-16 2019-11-12 广东工业大学 A kind of character detecting method, device and equipment
CN110472632A (en) * 2019-07-31 2019-11-19 上海海事大学 Character segmentation method, device and computer storage medium based on character feature
CN110738207A (en) * 2019-09-10 2020-01-31 西南交通大学 character detection method for fusing character area edge information in character image
CN110991439A (en) * 2019-12-09 2020-04-10 南京红松信息技术有限公司 Method for extracting handwritten characters based on pixel-level multi-feature joint classification

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105574513A (en) * 2015-12-22 2016-05-11 北京旷视科技有限公司 Character detection method and device
CN109961068A (en) * 2017-12-26 2019-07-02 阿里巴巴集团控股有限公司 Image recognition, training, searching method and device and equipment, medium
CN108805131A (en) * 2018-05-22 2018-11-13 北京旷视科技有限公司 Text line detection method, apparatus and system
CN109784304A (en) * 2019-01-29 2019-05-21 北京字节跳动网络技术有限公司 Method and apparatus for marking dental imaging
CN110263610A (en) * 2019-02-28 2019-09-20 重庆大学 A kind of degeneration file and picture binary coding method and system based on deep learning
CN110472632A (en) * 2019-07-31 2019-11-19 上海海事大学 Character segmentation method, device and computer storage medium based on character feature
CN110443252A (en) * 2019-08-16 2019-11-12 广东工业大学 A kind of character detecting method, device and equipment
CN110738207A (en) * 2019-09-10 2020-01-31 西南交通大学 character detection method for fusing character area edge information in character image
CN110991439A (en) * 2019-12-09 2020-04-10 南京红松信息技术有限公司 Method for extracting handwritten characters based on pixel-level multi-feature joint classification

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Fully Convolutional Networks for Semantic Segmentation;Jonathan Long等;《IEEE》;20151231;参见第3431-3440页 *

Also Published As

Publication number Publication date
CN111626283A (en) 2020-09-04

Similar Documents

Publication Publication Date Title
CN110084172B (en) Character recognition method and device and electronic equipment
CN111381909A (en) Page display method and device, terminal equipment and storage medium
CN112668588B (en) Parking space information generation method, device, equipment and computer readable medium
CN112883968B (en) Image character recognition method, device, medium and electronic equipment
CN113313064A (en) Character recognition method and device, readable medium and electronic equipment
CN112883967B (en) Image character recognition method, device, medium and electronic equipment
CN110826567A (en) Optical character recognition method, device, equipment and storage medium
CN112712036A (en) Traffic sign recognition method and device, electronic equipment and computer storage medium
CN111209856B (en) Invoice information identification method and device, electronic equipment and storage medium
CN113239925A (en) Text detection model training method, text detection method, device and equipment
CN113468330B (en) Information acquisition method, device, equipment and medium
CN113420757B (en) Text auditing method and device, electronic equipment and computer readable medium
CN111612714B (en) Image restoration method and device and electronic equipment
CN110442719B (en) Text processing method, device, equipment and storage medium
CN111626283B (en) Character extraction method and device and electronic equipment
CN111612715B (en) Image restoration method and device and electronic equipment
CN113255812B (en) Video frame detection method and device and electronic equipment
CN114429628A (en) Image processing method and device, readable storage medium and electronic equipment
CN113033552B (en) Text recognition method and device and electronic equipment
CN115375657A (en) Method for training polyp detection model, detection method, device, medium, and apparatus
CN114495080A (en) Font identification method and device, readable medium and electronic equipment
CN115375656A (en) Training method, segmentation method, device, medium, and apparatus for polyp segmentation model
CN115019321A (en) Text recognition method, text model training method, text recognition device, text model training equipment and storage medium
CN113205092A (en) Text detection method, device, equipment and storage medium
CN114898190A (en) Image processing method and device

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
GR01 Patent grant
GR01 Patent grant