CN107220640B - Character recognition method, character recognition device, computer equipment and computer-readable storage medium - Google Patents

Character recognition method, character recognition device, computer equipment and computer-readable storage medium Download PDF

Info

Publication number
CN107220640B
CN107220640B CN201710369090.5A CN201710369090A CN107220640B CN 107220640 B CN107220640 B CN 107220640B CN 201710369090 A CN201710369090 A CN 201710369090A CN 107220640 B CN107220640 B CN 107220640B
Authority
CN
China
Prior art keywords
character
image
character recognition
recognition result
preprocessed
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
CN201710369090.5A
Other languages
Chinese (zh)
Other versions
CN107220640A (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.)
Guangzhou Epbox Information Technology Co ltd
Original Assignee
Guangzhou Epbox Information 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 Guangzhou Epbox Information Technology Co ltd filed Critical Guangzhou Epbox Information Technology Co ltd
Priority to CN201710369090.5A priority Critical patent/CN107220640B/en
Publication of CN107220640A publication Critical patent/CN107220640A/en
Application granted granted Critical
Publication of CN107220640B publication Critical patent/CN107220640B/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
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/14Image acquisition
    • G06V30/146Aligning or centring of the image pick-up or image-field
    • G06V30/1475Inclination or skew detection or correction of characters or of image to be recognised
    • G06V30/1478Inclination or skew detection or correction of characters or of image to be recognised of characters or characters lines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition

Abstract

The invention relates to a character recognition method, a character recognition device, computer equipment and a computer readable storage medium. The method comprises the following steps: acquiring a character image to be recognized, and carrying out gray processing on the character image to be recognized to obtain a preprocessed character image; inputting the preprocessed character image as a whole into a preset character recognition model, and calculating a first character recognition result of the preprocessed character image by using the character recognition model; rotating the preprocessed character image for a plurality of times, inputting the preprocessed character image after each rotation as a whole into the character recognition model, and calculating a second character recognition result of the preprocessed character image after each rotation by the character recognition model; and obtaining characters in the character image to be recognized according to the first character recognition result and the second character recognition result, wherein the method improves the accuracy of character recognition.

Description

Character recognition method, character recognition device, computer equipment and computer-readable storage medium
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to a character recognition method, a character recognition apparatus, a computer device, and a computer-readable storage medium.
Background
With the development of science and technology, the use of character recognition technology is more common, and the complicated character input can be reduced or replaced. For example, for an image containing characters, a user may recognize the characters in the image by a character Recognition technology, such as OCR (optical character Recognition), and then perform operations such as searching or translating according to the recognized characters. However, when character recognition is performed by using the character recognition technology in the conventional technology, characters in an image generally need to be segmented, and when the characters are segmented, erroneous recognition of the characters is easily caused due to character adhesion, so that the character recognition accuracy is not high.
Disclosure of Invention
Accordingly, it is necessary to provide a character recognition method, a device, a computer device, and a computer-readable storage medium, which can perform overall recognition on a character image and improve the accuracy of character recognition, for the problem of low accuracy of character recognition in the conventional technology.
A character recognition method comprising the steps of:
acquiring a character image to be recognized, and carrying out gray processing on the character image to be recognized to obtain a preprocessed character image;
inputting the preprocessed character image as a whole into a preset character recognition model, and calculating a first character recognition result of the preprocessed character image by using the character recognition model, wherein the character recognition model is generated by training a set neural network model by using a training sample set of the character image;
rotating the preprocessed character image for a plurality of times, inputting the preprocessed character image after each rotation as a whole into the character recognition model, and calculating a second character recognition result of the preprocessed character image after each rotation by the character recognition model;
and obtaining characters in the character image to be recognized according to the first character recognition result and the second character recognition result.
According to the character recognition method, the character recognition model is preset, then the character image to be recognized is processed and then is integrally input into the character recognition model, the character image is integrally recognized through the character recognition model, character segmentation is not needed any more, therefore, false recognition caused by character adhesion during character segmentation is avoided, the character recognition accuracy is improved, the method is effective and robust, and the method has a great application value.
In one embodiment, deriving the character in the character image to be recognized according to the first character recognition result and the second character recognition result includes: if the first character recognition result is the same as each second character recognition result, calculating the length-width ratio of the preprocessed character image before rotation and the length-width ratio of the preprocessed character image after each rotation; calculating the total character length of the first character recognition result or the second character recognition result; and if all the length-width ratios are larger than the product of the total length of the characters and a first ratio and smaller than the product of the total length of the characters and a second ratio, taking the first character recognition result or the second character recognition result as the character recognition result of the character image to be recognized. Considering that when the pixel points of the character image are symmetrical, the identification results are easy to be consistent, if the wrong identification occurs, the wrong result is taken as the final output, and the problem can be effectively avoided by comparing the length-width ratio with the total length of the character, so that the correct identification result is further screened out.
In one embodiment, after the graying processing is performed on the character image to be recognized and before the preprocessed character image is obtained, the method further includes the steps of: carrying out image binarization on the grayed character image to be recognized to obtain a binary image; and carrying out image normalization on the binary image.
In one embodiment, image normalizing the binary image comprises: and adjusting the binary image into a pattern of black bottom white characters.
In one embodiment, adjusting the binary image to a pattern of black bottom white characters comprises: acquiring a first contour of a white part in the binary image; performing black-white overturning processing on the binary image to obtain a second outline of a white part in the overturned binary image; calculating the maximum width of the first contour and the maximum width of the second contour respectively; if the maximum width of the first contour is smaller than the maximum width of the second contour, the binary image before black-white inversion is reserved, otherwise, the binary image after black-white inversion is reserved.
In one embodiment, image normalizing the binary image further comprises: and removing the boundary of the binary image, and scaling the binary image with the boundary removed to a preset size.
In one embodiment, removing the boundary of the binary image comprises: respectively carrying out horizontal integral projection and vertical integral projection on the binary image; traversing the row pixels of the binary image after horizontal integral projection, and acquiring the starting row number and the ending row number in the row pixels; traversing the column pixels of the binary image after vertical integral projection, and acquiring the initial column number and the ending column number in the column pixels; and setting an interested region in the binary image according to the starting line number, the ending line number, the starting column number and the ending column number, and removing the boundary except the interested region in the binary image.
A character recognition apparatus comprising:
the character image preprocessing module is used for acquiring a character image to be recognized, and carrying out graying processing on the character image to be recognized to obtain a preprocessed character image;
the first character recognition module is used for inputting the preprocessed character images into a preset character recognition model as a whole, and calculating a first character recognition result of the preprocessed character images by the character recognition model, wherein the character recognition model is generated by training a set neural network model by a training sample set of the character images;
the second character recognition module is used for rotating the preprocessed character image for a plurality of times, inputting the preprocessed character image after each rotation as a whole into the character recognition model, and calculating a second character recognition result of the preprocessed character image after each rotation by the character recognition model;
and the character recognition result determining module is used for obtaining characters in the character image to be recognized according to the first character recognition result and the second character recognition result.
The character recognition device is provided with the character recognition model in advance, then the character recognition model is input integrally after the character image to be recognized is processed, the character image is recognized integrally through the character recognition model, character segmentation is not needed any more, and therefore mistaken recognition caused by character adhesion during character segmentation is avoided, accuracy of character recognition is improved, the character recognition device is effective in robustness, and the character recognition device has great application value.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of any of the methods described above when executing the program.
The computer equipment is characterized in that a character recognition model is preset, then the character recognition model is input integrally after the character image to be recognized is processed, the character image is recognized integrally through the character recognition model, character segmentation is not needed any more, and therefore misrecognition caused by character adhesion during character segmentation is avoided, accuracy of character recognition is improved, and the computer equipment is effective in robustness and has great application value.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of any of the above.
The computer readable storage medium is provided with the character recognition model in advance, then the character image to be recognized is input into the character recognition model in an integral mode after being processed, the character image is recognized in an integral mode through the character recognition model, character segmentation is not needed any more, therefore, false recognition caused by character adhesion during character segmentation is avoided, character recognition accuracy is improved, and the computer readable storage medium is effective in robustness and has a high application value.
Drawings
FIG. 1 is a flow chart illustrating a character recognition method according to an embodiment;
FIG. 2 is a flow diagram illustrating recognition of characters by a character recognition model during a testing phase according to an embodiment;
FIG. 3 is a flowchart illustrating an embodiment of adjusting a binary image into a black-and-white pattern;
FIG. 4 is a schematic flowchart of removing a boundary from a binary image according to an embodiment;
FIG. 5 is a flowchart illustrating a character recognition method according to another embodiment;
FIG. 6 is a flow chart illustrating a character recognition method according to an embodiment;
FIG. 7 is a block diagram of a character recognition apparatus according to an embodiment;
FIG. 8 is a schematic structural diagram of a computer device according to an embodiment.
Detailed Description
In order to further explain the technical means and effects of the present invention, the following description of the present invention with reference to the accompanying drawings and preferred embodiments will be made for clarity and completeness.
As shown in fig. 1, in one embodiment, there is provided a character recognition method including the steps of:
s110, acquiring a character image to be recognized, and carrying out gray processing on the character image to be recognized to obtain a preprocessed character image;
the character image to be recognized is the image needing character recognition. The graying processing of the image to be recognized can be realized according to the existing mode in the prior art, and the preprocessed character image of the character image to be recognized is obtained after the graying processing of the image.
S120, inputting the preprocessed character image as a whole into a preset character recognition model, and calculating a first character recognition result of the preprocessed character image by using the character recognition model, wherein the character recognition model is generated by training a set neural network model by using a training sample set of the character image;
the preset character recognition model is a model generated by training a set neural network model by a training sample set, and the character recognition model is used for performing character recognition on a character image to be recognized. There are various types of neural network models, and optionally, the neural network model is set as a Back Propagation (BP) neural network model. The training sample set comprises a plurality of character image training samples, and optionally, after an original character image is obtained, a series of processing such as graying, binarization, normalization and the like is performed on the original character image to obtain the character image training samples. The character image is input as a whole, namely the character segmentation is not needed to be carried out on the preprocessed character image, and the character image is directly used as a whole for character recognition. And after the preprocessed character image is taken as a whole to be input into the character recognition model, the character recognition result A is obtained by the character recognition model.
S130, rotating the preprocessed character image for a plurality of times, inputting the preprocessed character image after each rotation into the character recognition model as a whole, and calculating a second character recognition result of the preprocessed character image after each rotation by the character recognition model;
the number of times of rotating the preprocessed character image can be determined according to actual needs, the preprocessed character image after each rotation is input into the character recognition model, and a character recognition result of the preprocessed character image after each rotation is obtained. For example, since the pre-processed character image may be placed in the front or in the back, and therefore the direction of the character cannot be determined, in one embodiment, as shown in fig. 2, the pre-processed character image may be rotated three times: and rotating the preprocessed character image A clockwise by 90 degrees to obtain a preprocessed character image B, rotating the preprocessed character image A clockwise by 180 degrees to obtain a preprocessed character image C, and rotating the preprocessed character image C clockwise by 90 degrees to obtain a preprocessed character image D, wherein the preprocessed character image A is the preprocessed character image in S120. And respectively inputting the preprocessed character images after the three rotations into the character recognition model to obtain a character recognition result B, a character recognition result C and a character recognition result D.
S140, obtaining characters in the character image to be recognized according to the first character recognition result and the second character recognition result.
The character recognition method provided by the embodiment can be implemented by a corresponding program, and the program runs in a terminal, such as a mobile phone, a tablet computer or a computer. The method carries out integral identification on the character image area, omits the step of character segmentation, avoids false identification caused by character adhesion during character segmentation, is effective and robust, and has great application value. In addition, the method effectively avoids the error of character recognition caused by different terminal placement modes by comparing the recognition results of all characters after the image is rotated, and improves the accurate probability of actual recognition.
In order to further improve the accuracy of character recognition, in an embodiment, after performing graying processing on the character image to be recognized and before obtaining a preprocessed character image, the method further includes the steps of: carrying out image binarization on the grayed character image to be recognized to obtain a binary image; and carrying out image normalization on the binary image. It should be noted that the present invention is not limited to this, and may perform only the operation of image binarization, perform only the operation of image normalization, or perform other image processing besides the image binarization and the image normalization.
The image binarization is to set the gray value of a pixel point on an image to be 0 or 255, that is, the whole image presents an obvious black and white effect. The binarization of the image is beneficial to further processing of the image, so that the image is simple, the data volume is reduced, and the outline of an interested target can be highlighted. The image binarization has various implementation modes, and optionally, the image binarization is implemented by adopting an Otsu algorithm.
The image normalization is to convert the original image to be processed into a corresponding unique standard form (the standard form has invariant characteristics to affine transformations such as translation, rotation, scaling and the like) through a series of transformations (namely, a set of parameters is found by using invariant moment of the image so that the influence of other transformation functions on image transformation can be eliminated). Image normalization makes the image resistant to attacks by geometric transformations. There are various implementations of image normalization, for example, in one embodiment, image normalization of the binary image includes S1101: and adjusting the binary image into a pattern of black bottom white characters.
As shown in fig. 3, in one embodiment, adjusting the binary image into a pattern of black bottom white characters comprises:
s1101a, acquiring a first outline A of a white part in the binary image;
there are various implementations for extracting the contour of the white portion of the binary image, for example, the contour a is extracted using the function cvFindContours.
S1101B, performing black and white inversion processing on the binary image to obtain a second outline B of a white part in the inverted binary image;
the black-white turning processing is carried out on the binary image, namely, white pixel points in the binary image are changed into black pixel points, and meanwhile, the black pixel points are changed into white pixel points. After the black-and-white flip, the contour B can be extracted by the function cvFindContours.
S1101c, respectively calculating the maximum width maxw _ a of the outline A and the maximum width maxw _ B of the outline B;
calculating the maximum width of the contour can be done according to methods known in the art.
And S1101d, if the maximum width maxw _ a of the outline A is smaller than the maximum width maxw _ B of the outline B, retaining the binary image before black-white inversion, otherwise, retaining the binary image after black-white inversion.
The binary image before the inversion is the binary image in S1101 a. Because the maximum width of the outline of the white part when the picture is in the black background and white characters is smaller than the maximum width of the outline of the white part when the picture is in the white background and black characters, whether the original picture is in the pattern of the black background and white characters can be judged according to the rule, and adjustment is made.
In another embodiment, image normalizing the binary image comprises S1102: the image normalization of the binary image further comprises: and removing the boundary of the binary image, and scaling the binary image with the boundary removed to a preset size. Step S1102 and step S1101 may be executed simultaneously or alternatively. The preset size may be determined according to actual needs, for example, scaling the binary image to a height of 50 pixels.
As shown in fig. 4, in one embodiment, removing the boundary of the binary image includes:
s1102a, respectively carrying out horizontal integral projection and vertical integral projection on the binary image;
s1102b, traversing the line pixels of the binary image after horizontal integral projection, and acquiring the starting line number and the ending line number in the line pixels;
s1102c, traversing the column pixels of the binary image after vertical integral projection, and acquiring the initial column number and the ending column number in the column pixels;
s1102d, setting a region of interest (ROI) in the binary image according to the starting row number, the ending row number, the starting column number, and the ending column number, and removing a boundary except the region of interest in the binary image. The area enclosed by the starting row number, the ending row number, the starting column number and the ending column number is the region of interest.
It should be noted that the above process of processing the character image to be recognized is also applicable to obtaining a training sample set in the character recognition model, that is, after obtaining a plurality of original character images, the above method may be adopted to perform graying processing, image binarization and image normalization on the plurality of original character images, then train the set neural network model through the character images of the plurality of image normalization, and retain the network model parameters to obtain the character recognition model.
As shown in fig. 5, in one embodiment, deriving the character in the character image to be recognized according to the first character recognition result and the second character recognition result includes:
s1401, if the first character recognition result is the same as each second character recognition result, calculating the aspect ratio of the preprocessed character image before rotation and the aspect ratio of the preprocessed character image after each rotation; calculating the total character length of the first character recognition result or the second character recognition result;
since the requirement for the accuracy of character recognition is relatively strict in practical commercial applications, it is necessary to confirm that the character recognition results in step S120 and step S130 are consistent, so as to increase the probability of the accuracy of actual recognition. Therefore, in this step, the obtained character recognition results need to be compared, if the character recognition results are consistent, the character recognition result is retained, and if the character recognition results are inconsistent, the character recognition result is discarded. For example, four character recognition results are obtained by the recognition method shown in fig. 2: the character recognition method comprises the steps of obtaining a character recognition result A, a character recognition result B, a character recognition result C and a character recognition result D, reserving the character recognition result A, the character recognition result B, the character recognition result C and the character recognition result D if the character recognition result A is equal to the character recognition result B, the character recognition result C is equal to the character recognition result D, and discarding the character recognition result if the four character recognition results are inconsistent.
The pre-processed character image before rotation is the pre-processed character image in step S120. For example, as shown in fig. 2, this step calculates four aspect Ratio ratios of the pre-processed character image a, the pre-processed character image B, the pre-processed character image C, and the pre-processed character image D, respectively.
Since the respective character recognition results are the same, the total character length Str L en only needs to be calculated from the character recognition results of any one of them.
S1402, if all the length-width ratios are larger than the product of the total length of the characters and the first ratio and smaller than the product of the total length of the characters and the second ratio, taking the first character recognition result or the second character recognition result as the character recognition result of the character image to be recognized.
For example, a is set to 1/2, B is set to 3/2, whether Ratio ∈ ((1/2) × Str L en, (3/2) × Str L en) is established or not is respectively judged, if each Ratio value belongs to the range, the character recognition result is determined as the final recognition result, and if part of the Ratio values does not belong to the range, the character recognition result is discarded.
When the pixel points or contents of the character images are symmetrical, the character recognition results are easy to be consistent, if the character images are recognized by mistake, the wrong character recognition results are taken as final output, and the problem can be effectively solved through the embodiment shown in fig. 5, so that the correct character recognition results can be further screened out.
For a better understanding of the present invention, reference is made to the following detailed description taken in conjunction with a specific embodiment.
As shown in fig. 6, a character recognition method includes a training phase and a testing phase:
s1, training:
s11, acquiring a training sample set containing a plurality of character images, and graying the training sample set;
s12, carrying out image binarization on the grayed training sample set by utilizing an Otsu algorithm to obtain a binary image;
s13, carrying out image normalization on the binary image, wherein the image normalization comprises the following steps: adjusting the binary image into a pattern of black bottom white characters; removing the boundary of the binary image, and unifying the size; wherein adjusting the pattern and removing the border may be performed according to the above-described manner;
and S14, training a BP neural network model by taking the normalized binary image, and storing parameters of the neural network model to obtain a trained character recognition model.
S2, testing:
s21, acquiring a character image to be recognized, and graying the character image to be recognized;
s22, carrying out image binarization on the grayed character image to be recognized by utilizing an Otsu algorithm to obtain a binary image;
s23, carrying out image normalization on the binary image, wherein the image normalization comprises the following steps: adjusting the binary image into a pattern of black bottom white characters; removing the boundary of the binary image, and unifying the size; wherein adjusting the pattern and removing the border may be performed according to the above-described manner;
s24, taking the normalized binary image, recognizing the normalized binary image by using a trained BP neural network model (character recognition model) to obtain a recognition result A, then clockwise rotating the normalized binary image by 90 degrees, recognizing the normalized binary image by using the trained BP neural network model to obtain a recognition result B, clockwise rotating the normalized binary image by 180 degrees, recognizing the normalized binary image by using the trained BP neural network model to obtain a recognition result C, clockwise rotating the normalized binary image by 90 degrees, recognizing the normalized binary image by using the trained BP neural network model to obtain a recognition result D, and ensuring that the character images in four directions are respectively recognized once to obtain four recognition results to be determined next step;
s25, determining whether the recognition result a, B, C, D is true, if the four recognition results are the same, retaining the recognition result, proceeding to the next step, and if the four recognition results are not the same, discarding the result;
s26, calculating the aspect Ratio of the four character images to be recognized and the total character length Str L en. of the obtained recognition result, respectively, determines whether Ratio ∈ ((1/2) × Str L en, (3/2) × Str L en) is true, if all Ratio values are within the range, the result is determined as the final recognition result, and if the condition is not true, the result is discarded.
Based on the same inventive concept, the invention also provides a character recognition device, and the following detailed description is provided for the specific implementation mode of the character recognition device in combination with the accompanying drawings.
As shown in fig. 7, a character recognition apparatus includes:
the character image preprocessing module 110 is configured to obtain a character image to be recognized, perform graying processing on the character image to be recognized, and obtain a preprocessed character image;
a first character recognition module 120, configured to input the preprocessed character images as a whole into a preset character recognition model, and calculate a first character recognition result of the preprocessed character images from the character recognition model, where the character recognition model is generated by training a set neural network model by using a training sample set of the character images;
a second character recognition module 130, configured to rotate the preprocessed character image for multiple times, input the preprocessed character image after each rotation as a whole into the character recognition model, and calculate, by the character recognition model, a second character recognition result of the preprocessed character image after each rotation;
and a character recognition result determining module 140, configured to obtain characters in the character image to be recognized according to the first character recognition result and the second character recognition result.
The character recognition device (character classifier) provided by the embodiment can be operated in a terminal, such as a mobile phone, a tablet computer or a computer. The device carries out integral identification on the character image area, omits the step of character segmentation, avoids false identification caused by character adhesion during character segmentation, is effective and robust, and has great application value. In addition, the device effectively avoids the error of character recognition caused by different terminal placing modes through the comparison of the recognition results of all characters after the image is rotated, and improves the accurate probability of actual recognition.
In one embodiment, the character recognition result determining module 140 calculates an aspect ratio of the pre-processed character image before rotation and an aspect ratio of the pre-processed character image after each rotation when the first character recognition result and each second character recognition result are the same; calculating the total character length of the first character recognition result or the second character recognition result; and if all the length-width ratios are larger than the product of the total length of the characters and a first ratio and smaller than the product of the total length of the characters and a second ratio, taking the first character recognition result or the second character recognition result as the character recognition result of the character image to be recognized. When the pixel points or the contents of the character images are symmetrical, the character recognition results are easy to be consistent, if the wrong recognition occurs, the wrong result is taken as the final output, and the embodiment can effectively solve the problem and further screen out the correct character recognition result.
In order to further improve the accuracy of character recognition, in an embodiment, the character image preprocessing module 110 is further configured to perform image binarization on the grayed character image to be recognized to obtain a binary image, and perform image normalization on the binary image, after performing graying processing on the character image to be recognized and before obtaining the preprocessed character image.
In one embodiment, the character image pre-processing module 110 image normalizes the binary image by adjusting the binary image to a pattern of black bottom white characters. Optionally, the character image preprocessing module 110 obtains a first contour of a white portion in the binary image; performing black-white overturning processing on the binary image to obtain a second outline of a white part in the overturned binary image; calculating the maximum width of the first contour and the maximum width of the second contour respectively; if the maximum width of the first contour is smaller than the maximum width of the second contour, the binary image before black-white inversion is reserved, otherwise, the binary image after black-white inversion is reserved.
In one embodiment, the character image preprocessing module 110 further performs image normalization on the binary image by removing a boundary of the binary image and scaling the boundary-removed binary image to a preset size. Optionally, the character image preprocessing module 110 performs horizontal integral projection and vertical integral projection on the binary image respectively; traversing the row pixels of the binary image after horizontal integral projection, and acquiring the starting row number and the ending row number in the row pixels; traversing the column pixels of the binary image after vertical integral projection, and acquiring the initial column number and the ending column number in the column pixels; and setting an interested region in the binary image according to the starting line number, the ending line number, the starting column number and the ending column number, and removing the boundary except the interested region in the binary image.
Other technical features of the character recognition apparatus are the same as those of the character recognition method, and are not described herein again.
As shown in fig. 8, in one embodiment, there is provided a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the program:
acquiring a character image to be recognized, and carrying out gray processing on the character image to be recognized to obtain a preprocessed character image;
inputting the preprocessed character image as a whole into a preset character recognition model, and calculating a first character recognition result of the preprocessed character image by using the character recognition model, wherein the character recognition model is generated by training a set neural network model by using a training sample set of the character image;
rotating the preprocessed character image for a plurality of times, inputting the preprocessed character image after each rotation as a whole into the character recognition model, and calculating a second character recognition result of the preprocessed character image after each rotation by the character recognition model;
and obtaining characters in the character image to be recognized according to the first character recognition result and the second character recognition result.
In another embodiment, the processor, when executing the program, further performs the steps of: obtaining characters in the character image to be recognized according to the first character recognition result and the second character recognition result comprises: if the first character recognition result is the same as each second character recognition result, calculating the length-width ratio of the preprocessed character image before rotation and the length-width ratio of the preprocessed character image after each rotation; calculating the total character length of the first character recognition result or the second character recognition result; and if all the length-width ratios are larger than the product of the total length of the characters and a first ratio and smaller than the product of the total length of the characters and a second ratio, taking the first character recognition result or the second character recognition result as the character recognition result of the character image to be recognized.
In another embodiment, the processor, when executing the program, further performs the steps of: after the graying processing is carried out on the character image to be recognized and before the preprocessed character image is obtained, the method further comprises the following steps: carrying out image binarization on the grayed character image to be recognized to obtain a binary image; and carrying out image normalization on the binary image.
In another embodiment, the processor, when executing the program, further performs the steps of: the image normalization of the binary image comprises: and adjusting the binary image into a pattern of black bottom white characters.
In another embodiment, the processor, when executing the program, further performs the steps of: adjusting the binary image into a pattern of black bottom white characters comprises: acquiring a first contour of a white part in the binary image; performing black-white overturning processing on the binary image to obtain a second outline of a white part in the overturned binary image; calculating the maximum width of the first contour and the maximum width of the second contour respectively; if the maximum width of the first contour is smaller than the maximum width of the second contour, the binary image before black-white inversion is reserved, otherwise, the binary image after black-white inversion is reserved.
In another embodiment, the processor, when executing the program, further performs the steps of: the image normalization of the binary image further comprises: and removing the boundary of the binary image, and scaling the binary image with the boundary removed to a preset size.
In another embodiment, the processor, when executing the program, further performs the steps of: removing the boundary of the binary image comprises: respectively carrying out horizontal integral projection and vertical integral projection on the binary image; traversing the row pixels of the binary image after horizontal integral projection, and acquiring the starting row number and the ending row number in the row pixels; traversing the column pixels of the binary image after vertical integral projection, and acquiring the initial column number and the ending column number in the column pixels; and setting an interested region in the binary image according to the starting line number, the ending line number, the starting column number and the ending column number, and removing the boundary except the interested region in the binary image.
Other technical features of the computer device are the same as those of the character recognition method, and are not described herein again.
In one embodiment, a computer-readable storage medium is provided, having stored thereon a computer program which, when executed by a processor, performs the steps of:
acquiring a character image to be recognized, and carrying out gray processing on the character image to be recognized to obtain a preprocessed character image;
inputting the preprocessed character image as a whole into a preset character recognition model, and calculating a first character recognition result of the preprocessed character image by using the character recognition model, wherein the character recognition model is generated by training a set neural network model by using a training sample set of the character image;
rotating the preprocessed character image for a plurality of times, inputting the preprocessed character image after each rotation as a whole into the character recognition model, and calculating a second character recognition result of the preprocessed character image after each rotation by the character recognition model;
and obtaining characters in the character image to be recognized according to the first character recognition result and the second character recognition result.
In another embodiment, the computer program when executed by the processor further performs the following steps of deriving a character in the character image to be recognized from the first character recognition result and the second character recognition result includes: if the first character recognition result is the same as each second character recognition result, calculating the length-width ratio of the preprocessed character image before rotation and the length-width ratio of the preprocessed character image after each rotation; calculating the total character length of the first character recognition result or the second character recognition result; and if all the length-width ratios are larger than the product of the total length of the characters and a first ratio and smaller than the product of the total length of the characters and a second ratio, taking the first character recognition result or the second character recognition result as the character recognition result of the character image to be recognized.
In another embodiment, the computer program when executed by the processor further performs the steps of: after the graying processing is carried out on the character image to be recognized and before the preprocessed character image is obtained, the method further comprises the following steps: carrying out image binarization on the grayed character image to be recognized to obtain a binary image; and carrying out image normalization on the binary image.
In another embodiment, the computer program when executed by the processor further performs the steps of: the image normalization of the binary image comprises: and adjusting the binary image into a pattern of black bottom white characters.
In another embodiment, the computer program when executed by the processor further performs the steps of: adjusting the binary image into a pattern of black bottom white characters comprises: acquiring a first contour of a white part in the binary image; performing black-white overturning processing on the binary image to obtain a second outline of a white part in the overturned binary image; calculating the maximum width of the first contour and the maximum width of the second contour respectively; if the maximum width of the first contour is smaller than the maximum width of the second contour, the binary image before black-white inversion is reserved, otherwise, the binary image after black-white inversion is reserved.
In another embodiment, the computer program when executed by the processor further performs the steps of: the image normalization of the binary image further comprises: and removing the boundary of the binary image, and scaling the binary image with the boundary removed to a preset size.
In another embodiment, the computer program when executed by the processor further performs the steps of: removing the boundary of the binary image comprises: respectively carrying out horizontal integral projection and vertical integral projection on the binary image; traversing the row pixels of the binary image after horizontal integral projection, and acquiring the starting row number and the ending row number in the row pixels; traversing the column pixels of the binary image after vertical integral projection, and acquiring the initial column number and the ending column number in the column pixels; and setting an interested region in the binary image according to the starting line number, the ending line number, the starting column number and the ending column number, and removing the boundary except the interested region in the binary image.
Other technical features of the computer-readable storage medium are the same as those of the character recognition method, and are not described herein again.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (9)

1. A character recognition method, comprising the steps of:
acquiring a character image to be recognized, and carrying out gray processing on the character image to be recognized to obtain a preprocessed character image;
inputting the preprocessed character image as a whole into a preset character recognition model, and calculating a first character recognition result of the preprocessed character image by using the character recognition model, wherein the character recognition model is generated by training a set neural network model by using a training sample set of the character image, and the training sample set comprises a plurality of character image training samples; inputting the preprocessed character image of the character recognition model without character segmentation;
rotating the preprocessed character image for a plurality of times, inputting the preprocessed character image after each rotation as a whole into the character recognition model, and calculating a second character recognition result of the preprocessed character image after each rotation by the character recognition model;
obtaining characters in the character image to be recognized according to the first character recognition result and the second character recognition result;
obtaining characters in the character image to be recognized according to the first character recognition result and the second character recognition result comprises the following steps:
if the first character recognition result is the same as each second character recognition result, calculating the length-width ratio of the preprocessed character image before rotation and the length-width ratio of the preprocessed character image after each rotation; calculating the total character length of the first character recognition result or the second character recognition result;
and if all the length-width ratios are larger than the product of the total length of the characters and a first ratio and smaller than the product of the total length of the characters and a second ratio, taking the first character recognition result or the second character recognition result as the character recognition result of the character image to be recognized.
2. The character recognition method of claim 1, wherein after graying the character image to be recognized and before obtaining the pre-processed character image, further comprising the steps of:
carrying out image binarization on the grayed character image to be recognized to obtain a binary image;
and carrying out image normalization on the binary image.
3. The character recognition method according to claim 2, wherein image-normalizing the binary image comprises: and adjusting the binary image into a pattern of black bottom white characters.
4. The character recognition method of claim 3, wherein adjusting the binary image to a pattern of black bottom white characters comprises:
acquiring a first contour of a white part in the binary image;
performing black-white overturning processing on the binary image to obtain a second outline of a white part in the overturned binary image;
calculating the maximum width of the first contour and the maximum width of the second contour respectively;
if the maximum width of the first contour is smaller than the maximum width of the second contour, the binary image before black-white inversion is reserved, otherwise, the binary image after black-white inversion is reserved.
5. The character recognition method of claim 3, wherein image normalizing the binary image further comprises: and removing the boundary of the binary image, and scaling the binary image with the boundary removed to a preset size.
6. The character recognition method according to claim 5, wherein removing the boundary of the binary image comprises:
respectively carrying out horizontal integral projection and vertical integral projection on the binary image;
traversing the row pixels of the binary image after horizontal integral projection, and acquiring the starting row number and the ending row number in the row pixels;
traversing the column pixels of the binary image after vertical integral projection, and acquiring the initial column number and the ending column number in the column pixels;
and setting an interested region in the binary image according to the starting line number, the ending line number, the starting column number and the ending column number, and removing the boundary except the interested region in the binary image.
7. A character recognition apparatus, comprising:
the character image preprocessing module is used for acquiring a character image to be recognized, and carrying out graying processing on the character image to be recognized to obtain a preprocessed character image;
the first character recognition module is used for inputting the preprocessed character images into a preset character recognition model as a whole, and calculating a first character recognition result of the preprocessed character images by the character recognition model, wherein the character recognition model is generated by training a set neural network model by a training sample set of the character images, and the training sample set comprises a plurality of character image training samples; inputting the preprocessed character image of the character recognition model without character segmentation;
the second character recognition module is used for rotating the preprocessed character image for a plurality of times, inputting the preprocessed character image after each rotation as a whole into the character recognition model, and calculating a second character recognition result of the preprocessed character image after each rotation by the character recognition model;
a character recognition result determining module, configured to obtain characters in the character image to be recognized according to the first character recognition result and the second character recognition result, and if the first character recognition result is the same as each second character recognition result, calculate an aspect ratio of the pre-processed character image before rotation and an aspect ratio of the pre-processed character image after each rotation; calculating the total character length of the first character recognition result or the second character recognition result;
and if all the length-width ratios are larger than the product of the total length of the characters and a first ratio and smaller than the product of the total length of the characters and a second ratio, taking the first character recognition result or the second character recognition result as the character recognition result of the character image to be recognized.
8. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1-6 are implemented when the program is executed by the processor.
9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 6.
CN201710369090.5A 2017-05-23 2017-05-23 Character recognition method, character recognition device, computer equipment and computer-readable storage medium Active CN107220640B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710369090.5A CN107220640B (en) 2017-05-23 2017-05-23 Character recognition method, character recognition device, computer equipment and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710369090.5A CN107220640B (en) 2017-05-23 2017-05-23 Character recognition method, character recognition device, computer equipment and computer-readable storage medium

Publications (2)

Publication Number Publication Date
CN107220640A CN107220640A (en) 2017-09-29
CN107220640B true CN107220640B (en) 2020-07-17

Family

ID=59945268

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710369090.5A Active CN107220640B (en) 2017-05-23 2017-05-23 Character recognition method, character recognition device, computer equipment and computer-readable storage medium

Country Status (1)

Country Link
CN (1) CN107220640B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108345853B (en) * 2018-02-08 2020-10-23 吉首大学 Character recognition method and device based on isomorphic theory and terminal equipment
CN108681738A (en) * 2018-03-21 2018-10-19 江苏善壶网络科技有限公司 A kind of seal recognition methods and system
CN109271998A (en) * 2018-08-31 2019-01-25 摩佰尔(天津)大数据科技有限公司 Character identifying method, device, equipment and storage medium
CN109271993A (en) * 2018-09-28 2019-01-25 徐常柏 A kind of document scanning system, computer equipment and readable storage medium storing program for executing
CN109344836B (en) * 2018-09-30 2021-05-14 金蝶软件(中国)有限公司 Character recognition method and equipment
CN109447081B (en) * 2018-11-14 2021-07-23 广东小天才科技有限公司 Method and system for acquiring optical character recognition data set
AU2020222971A1 (en) 2019-02-12 2021-09-23 Ecoatm, Llc Connector carrier for electronic device kiosk
EP3928254A1 (en) 2019-02-18 2021-12-29 ecoATM, LLC Neural network based physical condition evaluation of electronic devices, and associated systems and methods
USD1010271S1 (en) 2020-02-12 2024-01-02 Ecoatm, Llc Kiosk for processing electronic devices
CN111401366B (en) * 2020-03-20 2022-08-19 江苏苏宁物流有限公司 Character recognition method, character recognition device, computer equipment and storage medium
US11922467B2 (en) 2020-08-17 2024-03-05 ecoATM, Inc. Evaluating an electronic device using optical character recognition
CN114666312B (en) * 2022-03-29 2024-03-01 西安热工研究院有限公司 Universal data acquisition method, system and equipment for weighing instrument and readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102890784A (en) * 2011-07-20 2013-01-23 富士通株式会社 Method and device for identifying directions of characters in image blocks
CN103870799A (en) * 2012-12-17 2014-06-18 北京千橡网景科技发展有限公司 Character direction judging method and device
CN105139042A (en) * 2015-09-08 2015-12-09 携程计算机技术(上海)有限公司 Image identification method and system
CN106408038A (en) * 2016-09-09 2017-02-15 华南理工大学 Rotary Chinese character identifying method based on convolution neural network model
CN107220611A (en) * 2017-05-23 2017-09-29 上海交通大学 A kind of space-time feature extracting method based on deep neural network

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106407976B (en) * 2016-08-30 2019-11-05 百度在线网络技术(北京)有限公司 The generation of image character identification model and perpendicular column character picture recognition methods and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102890784A (en) * 2011-07-20 2013-01-23 富士通株式会社 Method and device for identifying directions of characters in image blocks
CN103870799A (en) * 2012-12-17 2014-06-18 北京千橡网景科技发展有限公司 Character direction judging method and device
CN105139042A (en) * 2015-09-08 2015-12-09 携程计算机技术(上海)有限公司 Image identification method and system
CN106408038A (en) * 2016-09-09 2017-02-15 华南理工大学 Rotary Chinese character identifying method based on convolution neural network model
CN107220611A (en) * 2017-05-23 2017-09-29 上海交通大学 A kind of space-time feature extracting method based on deep neural network

Also Published As

Publication number Publication date
CN107220640A (en) 2017-09-29

Similar Documents

Publication Publication Date Title
CN107220640B (en) Character recognition method, character recognition device, computer equipment and computer-readable storage medium
CN110046529B (en) Two-dimensional code identification method, device and equipment
CN110232369B (en) Face recognition method and electronic equipment
CN108388879B (en) Target detection method, device and storage medium
CN110232713B (en) Image target positioning correction method and related equipment
WO2020010547A1 (en) Character identification method and apparatus, and storage medium and electronic device
US20170124386A1 (en) Method, device and computer-readable medium for region recognition
US20110211233A1 (en) Image processing device, image processing method and computer program
CN107977658B (en) Image character area identification method, television and readable storage medium
CN108108731B (en) Text detection method and device based on synthetic data
US11367310B2 (en) Method and apparatus for identity verification, electronic device, computer program, and storage medium
TWI525555B (en) Image processing apparatus and processing method thereof
CN113139445A (en) Table recognition method, apparatus and computer-readable storage medium
CN114155546B (en) Image correction method and device, electronic equipment and storage medium
CN111985465A (en) Text recognition method, device, equipment and storage medium
US11341739B2 (en) Image processing device, image processing method, and program recording medium
CN111368758A (en) Face ambiguity detection method and device, computer equipment and storage medium
CN111461100A (en) Bill identification method and device, electronic equipment and storage medium
CN112396050B (en) Image processing method, device and storage medium
CN111340023A (en) Text recognition method and device, electronic equipment and storage medium
CN112597918A (en) Text detection method and device, electronic equipment and storage medium
CN111737478A (en) Text detection method, electronic device and computer readable medium
CN107506767B (en) Method and device for recognizing digital adhesion in picture
CN112949649B (en) Text image identification method and device and computing equipment
CN111435407A (en) Method, device and equipment for correcting wrongly written characters and storage medium

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
PE01 Entry into force of the registration of the contract for pledge of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: Character recognition method, device, computer equipment and computer-readable storage medium

Effective date of registration: 20210923

Granted publication date: 20200717

Pledgee: Bank of China Limited by Share Ltd. Guangzhou Panyu branch

Pledgor: GUANGZHOU EPBOX INFORMATION TECHNOLOGY Co.,Ltd.

Registration number: Y2021440000297

PC01 Cancellation of the registration of the contract for pledge of patent right
PC01 Cancellation of the registration of the contract for pledge of patent right

Date of cancellation: 20231012

Granted publication date: 20200717

Pledgee: Bank of China Limited by Share Ltd. Guangzhou Panyu branch

Pledgor: GUANGZHOU EPBOX INFORMATION TECHNOLOGY Co.,Ltd.

Registration number: Y2021440000297