A character recognition method based on text skeleton and key points
By extracting the text skeleton and key points, and combining hidden Markov models and neural networks, the problem of existing OCR technology in recognizing the radicals and structural components of Chinese characters has been solved, achieving accurate recognition of Chinese characters under various interferences.
Patent Information
- Application Number
- CN202410653436.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2044-05-24
AI Technical Summary
Existing text skeleton-based OCR technology struggles to correctly identify the radicals of Chinese characters, distinguish between characters with different structural elements, and handle images with significant noise, such as handwritten, distorted, or tilted images.
By extracting the text skeleton and key points, combining hidden Markov models and neural networks, the occupancy parameters and structural composition of each radical are calculated. The second-order Viterbi algorithm is then used to optimize the recognition process, reduce noise, and improve recognition efficiency.
Without significantly increasing the time required, it can accurately identify Chinese characters, reduce the false recognition rate, improve recognition efficiency, and adapt to various interferences, especially handwritten and distorted or tilted Chinese character images.
Smart Images

Figure CN118609142B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of optical character recognition, and more particularly relates to a character recognition method based on text skeleton and key points. BACKGROUND
[0002] Optical Character Recognition (OCR) technology is a technology that can recognize printed or handwritten characters on paper as computer text documents, and is widely used in artificial intelligence, machine vision, automation and planning management fields. In recent years, OCR technology has developed rapidly, and the comprehensive performance of the system has been continuously improved, and the stability and user-friendliness of the software have made great progress.
[0003] However, the mainstream OCR system has good effect when processing English, but has great shortcomings when processing Chinese characters, especially handwritten Chinese characters, with high rejection rate and misrecognition rate. This is because the mainstream OCR system mostly directly inputs the to-be-recognized image into a convolutional neural network for character division, which is difficult to distinguish between radicals and entire Chinese characters, resulting in errors such as misrecognition of Chinese character radicals as Chinese characters and multiple Chinese characters as one Chinese character.
[0004] The OCR technology based on text skeleton can construct each radical of Chinese characters according to the continuity of strokes, and can accurately distinguish various radicals of Chinese characters and Chinese punctuation marks, providing a new way for Chinese character OCR. For example, 1. Patent No. CN115588211A, entitled "Text image generation method, device, electronic equipment and storage medium", provides a text image generation method with higher flexibility and can generate target text images including text meeting certain rules; 2. Patent No. CN114241481A, an invention patent, provides a text detection method based on text skeleton, which improves the accuracy of text detection.
[0005] However, the OCR technology based on text skeleton still has the following technical difficulties: 1. It is difficult to solve the problem of dividing radicals into single Chinese characters, and it is difficult to correctly recognize mixed English and Chinese text segments. 2. It is difficult to distinguish Chinese characters with different frame structures, and it is difficult to combine radicals into complete Chinese characters. 3. It is difficult to handle handwritten, distorted, and inclined pictures with high picture noise.
[0006] The main reasons for the above problems of the OCR technology based on text skeleton are as follows: 1. It cannot use the continuity within Chinese characters to assist in recognizing text, i.e. it cannot correctly determine the character attributes. 2. It cannot use the continuity between Chinese characters to assist in recognizing text, i.e. it cannot correctly determine the core position and space occupation of the character. 3. It cannot use the continuity of text to assist in recognizing text, i.e. it cannot correctly determine the upper and lower boundaries of each line of text. Summary of the Invention
[0007] To address the shortcomings and improvement needs of existing technologies, this invention provides a character recognition method based on text skeleton and key points. Its purpose is to accurately recognize Chinese characters under various interferences without significantly increasing the time consumption.
[0008] To achieve the above objectives, according to one aspect of the present invention, a character recognition method based on text skeleton and key points is provided, comprising:
[0009] Extract all text skeletons and text key points from a grayscale image containing the text to be identified;
[0010] Based on all text skeletons, a neural network is used to classify and identify each radical and symbol in the text to be identified; by combining all text skeletons and text key points, the upper and lower bounds of the position of each line of text are obtained; and based on the spatial arrangement of text key points, the core position of each radical in the text to be identified is determined.
[0011] Hidden Markov Model (HMM) is used, with the matrix consisting of the core positions of each radical in each line of text serving as the result chain Y and the two-dimensional balance parameter. The resulting matrix is P(Y|X). The probability chain X is calculated, and each element corresponds to a placeholder parameter L for each radical. o,i ,;
[0012] Based on the text skeleton, upper bound, and lower bound of each line of text, a neural network is used to obtain the probability P of each radical in that line of text appearing as a single Chinese character. q,i The probability P of appearing as a left radical l,i And the probability P of appearing as a right radical r,i ; Calculate P I,i =P q,i +P l,i +P r,i Using HMM, the P radicals of each part of the text in that line are... q,i The resulting matrix serves as the result chain Y and the non-partitioned probability. The resulting matrix is P(Y|X). The probability chain X is calculated, and each element corresponds to the probability P of extracting each radical. f,i Using Hidden Markov Models (HMMs), the left-attachment probability C of each radical in the text line is determined. l,i =P r,i *P l,i+1 The resulting matrix serves as the result chain Y and the delimited probability. The resulting matrix is P(Y|X). The probability chain X is calculated, and each element corresponds to the left-side radicalization probability P of each radical. l,i ; where the probability of rightward attachment is C r,i =Pl,i *P r,i+1 , right bias side radical probability P r,i = 1-P f,i -P l,i ;
[0013] find the maximum value of the probability sequence , and according to the left attachment probability, the right attachment probability and the extraction probability of each bias side corresponding to the maximum value, judge the interval structure of the corresponding bias side;
[0014] determine the number of spaces between each adjacent bias side according to the core position of each bias side and L o,i , extract each Chinese character according to the interval structure of each bias side, and insert each symbol between each Chinese character to complete character recognition.
[0015] Further, the extraction method of the text skeleton is:
[0016] find a continuous line of the highest gray value in each stroke area with high gray value in the gray image as the ridge line of the stroke area, and the linear regression line segment of each point on each ridge line as a text skeleton;
[0017] The extraction method of the text key point is:
[0018] Using the gray peak value method, find the point with the highest gray value at both ends of each ridge line and at each intersection position with other ridge lines on the ridge line with a certain search radius, as the key point of the text to be identified; wherein the search radius is determined by experiment optimization.
[0019] Further, the determination method of the upper bound and the lower bound of each line of text position is:
[0020] Based on the text skeleton, calibrate the upper and lower boundary position data of each bias side in the line of text, to respectively perform interpolation fitting of the upper boundary and the lower boundary, to obtain the first upper bound and the first lower bound of the line of text;
[0021] merge each key point connected by the same bias side into a point group, fit the point with the largest longitudinal coordinate of all the point groups in the line of text, and the fitting result is taken as the second upper bound of the line of text; fit the point with the smallest longitudinal coordinate of all the point groups in the line of text, and the fitting result is taken as the second lower bound of the line of text;
[0022] weight the first upper bound and the second upper bound, and the weighted result is taken as the upper bound of the line of text position; weight the first lower bound and the second lower bound, and the weighted result is taken as the lower bound of the line of text position.
[0023] Further, the calculation method of the core position of each bias side is:
[0024] averaging the coordinates of all the key points in each point group the core position of the component corresponding to the point group, wherein the key points connected by the same component are merged into one point group.
[0025] Further, according to the spatial arrangement of the text key points, the word density in the text to be recognized is determined;
[0026] The word density is calculated in the following manner:
[0027]
[0028] In the formula, p represents the word density, S0 represents the area of the figure surrounded by all the key points located at the outermost periphery of the gray-scale image, and N0 represents the total number of point groups of the key points in the text to be recognized, wherein the key points connected by the same component are merged into one point group.
[0029] When the hidden Markov model HMM is used to calculate the occupancy parameter L of each component in each line of text, on the sub-density is used as a verification parameter.
[0030] Further, the number of spaces between adjacent components is determined in the following manner:
[0031] The core position and the occupancy parameter of each component are used to determine whether there is a space or a gap between each adjacent component, and the determination manner is as follows: the value of If Δ>0, it is considered that there is a space before the character, and the value of Δ rounded up is the number of spaces before the character.
[0032] Further, the maximum value of the probability sequence is obtained by using the second-order Viterbi algorithm.
[0033] The neural network used to obtain P q,i , P l,i and P r,i is also used to identify each component as a single structure from each component of the text to be recognized, and reset the left attachment probability and the right attachment probability of each component as a single structure to the minimum probability that can be calculated by the neural network.
[0034] Further, before extracting the text skeleton and the text key points, the method further comprises: pooling the gray-scale image containing the text to be recognized by using the average pooling manner to obtain a new gray-scale image.
[0035] The text skeleton and the text key points are extracted from the new gray-scale image.
[0036] The present invention also provides a computer-readable storage medium comprising a stored computer program, wherein the computer program, when executed by a processor, controls the device containing the storage medium to perform a character recognition method based on key points and text skeleton as described above.
[0037] In summary, the above-described technical solutions conceived in this invention can achieve the following beneficial effects:
[0038] (1) This invention proposes to extract the text skeleton and text key points from the text image to be identified, and to combine the text skeleton and text key points to determine the upper and lower bounds of the position of each line of text. At the same time, based on the text skeleton, each radical and each symbol in the text to be identified is identified, and based on the text key points, the core position of each radical is determined. Subsequently, a Hidden Markov Model (HMM) is used to calculate the occupancy parameters of each radical based on the core position, and a neural network is used to combine the text skeleton, upper bound, and lower bound to determine the probability P of each radical appearing as a single Chinese character. q,i The probability P of appearing as a left radical l,i And the probability P of appearing as a right radical r,i To re-introduce the Hidden Markov Model (HMM), two consecutive HMM operations are performed to obtain the extraction probability P of each radical. f,i The left-leaning and right-leaning probabilities are used to determine the structural framework of each radical. Finally, based on the core position, space-occupying parameters, and structural framework, each Chinese character is identified. This invention solves the problems of existing text skeleton-based OCR technology, which struggles to divide characters into individual characters based on radicals, distinguish characters with different structural frameworks, handle large noise in images such as handwritten, distorted, or tilted images (i.e., cannot correctly determine character attributes), correctly determine the core position and space-occupying of characters, and correctly determine the upper and lower boundaries of each line of text. This invention can accurately identify Chinese characters under various interferences without significantly increasing the processing time.
[0039] (2) Before performing OCR, a pooling operation is introduced at the input, which has a significant noise reduction effect and reduces the number of parameters, thus greatly accelerating the operation and significantly compensating for the slowdown in operation caused by the high time complexity of the neural network.
[0040] (3) This invention expands the scope of single-component structure classification and innovatively adds prior analysis to the OCR process. It uses commonly used single-component characters to break the Viterbi chain to accelerate program operation, greatly improving recognition efficiency while reducing the false recognition rate. Attached Figure Description
[0041] Figure 1 This invention provides a character recognition method based on text skeleton and key points. Detailed Implementation
[0042] In order to make the objects, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application. In addition, the technical features involved in the various embodiments of the present application described below can be combined with each other as long as they do not conflict with each other.
[0043] Embodiment one
[0044] A character recognition method based on text skeleton and key point, as shown in Figure 1 , comprising:
[0045] extracting all text skeletons and text key points in a gray image containing text to be recognized;
[0046] based on all text skeletons, using neural network classification to recognize each component and each symbol in the text to be recognized; combining all text skeletons and text key points to obtain the upper and lower boundaries of each line of text position; determining the core position of each component in the text to be recognized according to the spatial arrangement of the text key points;
[0047] using hidden Markov model HMM, taking the matrix composed of the core positions of each component in each line of text as the result chain Y, the two-dimensional balance parameter composed of the matrix as P(y|x), calculating the probability chain X, each element of which corresponds to the placeholder parameter L o,i of each component;
[0048] based on the text skeleton, upper boundary and lower boundary of each line of text, using neural network to obtain the probability P q,i of each component of this line of text as a single Chinese character, the probability P l,i of left component and the probability P r,i of right component; calculating P I,i =P q,i +P l,i +P r,i ; using HMM, taking the matrix composed of P q,i of each component of this line of text as the result chain Y, the non-component probability composed of the matrix as P(Y|X), calculating the probability chain X, each element of which corresponds to the extraction probability P f,i of each component, the extraction probability P f of certain component is approximately equal to the probability of the component appearing as a single character; using HMM, taking the matrix composed of the left attachment probability C l,i =P r,i *P l,i+1 of each component in this line of text as the result chain Y, the component probability The matrix is configured as P(Y|X), and a probability chain X is calculated, each element of which corresponds to a left radicalization probability P l,i ; wherein the right attachment probability C r,i =P l,i *P r,i+1 , the right radicalization probability P r,i =1-P f,i -P l,i ;
[0049] The maximum value of the probability sequence is found, and according to the left attachment probability, the right attachment probability and the extraction probability of each radical corresponding to the maximum value, the interval structure of the corresponding radical is judged;
[0050] The number of spaces between each adjacent radical is determined according to the core position of each radical and L o,i , and each Chinese character is extracted according to the interval structure of each radical, and finally an image matrix composed of a series of equal-interval, correct-radical-position, to-be-recognized Chinese character images is obtained, each symbol is inserted into each Chinese character image, a sentence framework is obtained, and character recognition is completed.
[0051] It should be noted that the result chain Y is composed of Y1, Y2,..., Y n , and n represents the total number of radicals in each line of text.
[0052] The principle of Hidden Markov Model (HMM) is that a probability chain X1, X2,..., X n with all unknown variables is input, and an observed result chain Y1, Y2,..., Y n is observed. If the probability chain X1, X2,..., X n has the following properties:
[0053] P(X n+1 =x|X1=x1,X2=x2...,X n =x n )=P(X n+1 =x|X n =x n )
[0054] and
[0055] P(X1=x1,X2=x2...,X n =x n )>0
[0056] Then the result chain Y1, Y2,..., Y n has the following properties:
[0057] P(Y)=∑ X P(Y|X)P(X)
[0058] Using this formula, it is possible to obtain the known Y n Chain, calculate X n Chain. Through Y n Chain Construction X n The chain process is called HMM.
[0059] When using a Hidden Markov Model (HMM) to determine the placeholder parameters, the placeholder parameter for each radical is obtained based on its core position. Specifically, the matrix composed of the core positions of each radical in each line of text is used as the result chain Y1, Y2, ..., Y in the HMM. n Based on the result chain property formula in HMM, the two-dimensional equilibrium parameters of each radical are... The resulting matrix serves as P(Y|X) in the formula for this property, and the probability chain X1,X2,...,X is calculated. n And use it as the placeholder parameter L for each radical in the text of that line. n,i As a further preferred option, the left boundary position Y of the i-th radical can be set... i -(Y i -Y i-1 )L o,i and the right boundary position Y i +(Y i+1 -Y i )L o,i The space occupied by the i-th radical can be reused in the neural network to achieve self-learning of the neural network.
[0060] Using a neural network to obtain P q,i P l,i and P r,i In this process, the neural network used plays the role of learning P. I P l P r Parameters such as the upper and lower bounds of each line of text obtained in the previous step will significantly affect the C output of the HMM corresponding to this neural network. l,i and C r,i Specifically, if the upper or lower bound has an upward tangent at a point, then the neural network should provide the calculated C. l,i A positive value is compensated, and C is given. r,iA negative value correction, the specific function relationship is determined by the sample learned by the neural network. The text skeleton, upper bound and lower bound of each line of text are input into the neural network containing HMM to determine the component continuity between the components, and the interval structure of each component is obtained, which has three types of left component, independent structure or upper and lower structure, and right component. That is, the embodiment finds the relationship between the tangent of the upper and lower bounds and the connection of the characters, uses the neural network to fit it, and corrects the result to make it tend to be correct, avoiding the inaccurate recognition result caused by paper folding, wrinkling, etc., and successfully using the continuity of the text to enhance the accuracy of OCR.
[0061] It should be noted that the upper and lower structure, semi-enclosed structure, etc. are neither left-right structure nor independent structure, but the commonly used characters of such structures are much less than the left-right structure and independent structure, and the neural network almost does not misclassify the components of such structures as single characters, which proves that the neural network has enough computing power to include them in the independent structure category, so the upper and lower structure, semi-enclosed structure, etc. are all included in the independent structure category.
[0062] In addition, the embodiment uses the HMM model to determine the character attribute (i.e. the interval structure), and uses a series of parameters such as the extraction probability, the component probability, the left (right) component probability, and the left (right) attachment probability, which are used to determine the character attribute by using the continuity of the characters themselves and the continuity between the characters, greatly improving the accuracy of the OCR system recognition.
[0063] As a preferred embodiment, the second-order Viterbi algorithm is used to find the maximum value of the probability sequence . Since there are many commonly used characters (such as “I”, “also”, “not”, etc.) in the independent structure, and the independent structure will break the probability chain in the Viterbi algorithm used in the embodiment, a large number of models of such characters can be stored in the neural network containing HMM in advance, and such characters are preferentially recognized. If these characters are recognized, the sentence is truncated, and probability operations are performed before and after, which can almost completely compensate for the high time complexity of the Viterbi algorithm, and also avoid overfitting, with excellent results. After application, the recognition efficiency is increased by 160%, and the misrecognition rate is also reduced to 65% of the original, based on which, the neural network for obtaining P q,i , P l,i and P r,i can be used as a preferred embodiment.
[0064] As an example, the neural network used to identify each component and each symbol in the text to be identified can be a convolutional neural network, and the network structure can be Faster R-CNN; the neural network used to obtain P q,i , P l,i , and P r,i may be HCNN.
[0065] As a preferred embodiment, the text skeleton extraction method is as follows:
[0066] In each stroke area with a high gray value in the gray image, a continuous line with the highest gray value is found as the ridge line of the stroke area, and the linear regression line segment of each point on each ridge line is taken as a text skeleton;
[0067] The text key point extraction method is as follows:
[0068] The gray peak value method is used to find the point with the highest gray value at each end of each ridge line and each intersection position of the ridge line with other ridge lines with a certain search radius, as the key point of the text to be identified; wherein the search radius is determined by experiment optimization, for example, the search radius is 2 / 13 of the corresponding ridge line length.
[0069] As a preferred embodiment, the determination method of the upper and lower boundaries of each line of text is as follows:
[0070] (1) Based on the text skeleton, the upper and lower boundary position data of each component in the line of text are calibrated to perform interpolation fitting of the upper boundary and the lower boundary respectively to obtain the first upper boundary and the first lower boundary of the line of text.
[0071] Wherein, the calibration of the upper and lower boundary position data of each component in the text to be identified can be specifically: the midpoint of the upper and lower boundary of each component is calibrated as the upper and lower boundary position data of the component. When performing interpolation fitting, the interpolation ratio can be 3, and after interpolation is completed, linear, quadratic, and triangular fitting can be performed respectively, and the R 2 value of the maximum one is taken as the final fitting result of the corresponding boundary.
[0072] (2) Each key point connected by the same component is merged into a point group, the point with the maximum vertical coordinate of all the point groups in the line of text is fitted, and the fitting result is taken as the second upper boundary of the line of text; the point with the minimum vertical coordinate of all the point groups in the line of text is fitted, and the fitting result is taken as the second lower boundary of the line of text.
[0073] The operation is also to calculate the second upper bound and the second lower bound of each line of text according to the spatial arrangement of the text key points in the gray image. For example, the calculation method of the second upper bound and the second lower bound of each line of text is as follows: linear, quadratic, and triangular fitting is respectively performed on the maximum point and the minimum point of the longitudinal coordinates of all point groups, and the R 2 value of the maximum one is taken as the second upper bound and the second lower bound.
[0074] (3) The first upper bound and the second upper bound are weighted and combined, and the weighted result is taken as the upper bound of the position of the line of text; the first lower bound and the second lower bound are weighted and combined, and the weighted result is taken as the lower bound of the position of the line of text. The weighting coefficient can be determined by experiment optimization.
[0075] As a preferred embodiment, the calculation method of the core position of each component is as follows:
[0076] The coordinates of all key points in each point group are averaged to obtain the core position of the component corresponding to the point group, wherein the key points connected by the same component are combined into one point group.
[0077] As a preferred embodiment, according to the spatial arrangement of the text key points, the character density in the text to be recognized is also determined, and the calculation method is as follows:
[0078]
[0079] In the formula, ρ represents the character density, S0 represents the area of the figure surrounded by all key points located at the outermost periphery of the gray image; N0 represents the total number of point groups of key points in the text to be recognized, and the key points connected by the same component are combined into one point group;
[0080] When the hidden Markov model HMM is used to calculate the occupancy parameter L oi of each component in each line of text, the character density is taken as a verification parameter.
[0081] As a preferred embodiment, the determination method of the number of spaces between adjacent components is as follows:
[0082] The core position and the occupancy parameter of each component are used to determine whether there is a space or a gap between each adjacent component, and the determination method is as follows: the difference between the core position of the component and the occupancy parameter of the component is calculated If Δ>0, it is considered that there is a space before the character, and the value of Δ is rounded up to obtain the number of spaces before the character. After the calculation, the corresponding number of space marks are left before the character and output.
[0083] As a preferred embodiment, before extracting the text skeleton and the text key point, the method further comprises: pooling the gray image containing the text to be recognized by using the average pooling method to obtain a new gray image. Then the text skeleton and the text key point are extracted from the new gray image. The pooling operation can be specifically as follows: the gray image is divided into n*n blocks, the average value of the gray scale of each pixel in each block is taken to form a new pixel as the pixel of the block, so that the length and width of the original image are shortened to 1 / n of the original length and width, and a new image is obtained, so as to eliminate noise and reduce the data amount, facilitating calculation and skeleton construction.
[0084] In order to realize the above method, the present application gives a specific example:
[0085] The PDA with the Microsoft Windows 10 operating system is used as the terminal, Pycharm and Visual Studio are used as the development platform, python and C++ languages are used for programming, the pytorch image processing neural network library is loaded, computer fonts and handwritten texts are used as the training set, and handwritten texts are used as the test set. After the above steps, 1000 handwritten characters are successfully distinguished, and the accuracy rate reaches 100%.
[0086] It should be noted that the above device is not the optimal model adapted to the present application, and the device matched with the present application is not limited to the above model. The present application can use computer programming languages including but not limited to C++, Java, Python, etc., can be mounted on a PDA, a multifunction platform, etc. host system using windows, Linux, etc. system, and can be matched with various word processing systems.
[0087] Due to its extremely low rejection rate and misrecognition rate, it is extremely suitable for scanning, desensitization and transfer of important paper documents and confidential paper documents.
[0088] In general, the embodiment contains artificial intelligence and deep learning modules and algorithms such as Hidden Markov Model (HMM), Artificial Neural Networks (ANN), Convolutional Neural Networks (CNN), etc. can simulate the human reading comprehension process of Chinese characters, learn the continuity of text and characters in depth, solve the problem of dividing radicals into single Chinese characters, correctly recognize the structure between Chinese characters, and adapt to the case of large picture noise such as handwriting, distortion and inclination.
[0089] Embodiment two
[0090] A computer readable storage medium, comprising a stored computer program, wherein the computer program, when executed by a processor, controls a device in which the storage medium is located to perform a character recognition method based on key points and text skeletons as described in Embodiment One.
[0091] The related technical solutions are the same as those in Embodiment One, and will not be described herein.
[0092] Those skilled in the art will easily understand that the above description is only the preferred embodiments of the present application, and is not intended to limit the present application. Any modification, equivalent replacement and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A character recognition method based on text skeleton and key points, characterized in that, The method comprises the following steps: extracting all text skeletons and text key points in a gray-scale image containing to-be-recognized text; based on all the text skeletons, using a neural network to classify and recognize each component and each symbol in the to-be-recognized text; combining all the text skeletons and text key points to obtain the upper bound and lower bound of the position of each line of text; and determining the core position of each component in the to-be-recognized text according to the spatial arrangement of the text key points; Using a Hidden Markov Model (HMM), a matrix composed of the core positions of each component in each line of text is used as the result chain Y, a two-dimensional balance parameter is used as P(Y|x), and a probability chain X is calculated, the elements of which correspond to the position parameters L of each component o,i ; Based on the text skeleton, upper bound, and lower bound of each line of text, a neural network is used to obtain the probability P of each radical in that line of text appearing as a single Chinese character. q,i The probability P of appearing as a left radical l,i And the probability P of appearing as a right radical r,i ; Calculate P I,i =P q,i +P l,i +P r,i Using HMM, the P radicals of each part of the text in that line are... q,i The resulting matrix serves as the result chain Y and the non-partitioned probability. The resulting matrix is P(Y|X). The probability chain X is calculated, and each element corresponds to the probability P of extracting each radical. f,i Using Hidden Markov Models (HMMs), the left-attachment probability C of each radical in the text line is determined. l,i =P r,i *P l,i+1 The resulting matrix serves as the result chain Y and the delimited probability. The resulting matrix is P(Y|X). The probability chain X is calculated, and each element corresponds to the left-side radicalization probability P of each radical. l,i ; wherein the right-attached probability C r,i = P l,i * P r,i+1 , the right-attached probability P r,i = 1 - P f,i - P l,i ; Probability sequence of maximum value, n represents total number of radicals, according to C l,i , C r,i and P f,i of each radical corresponding to maximum value, determine frame structure of corresponding radical; According to the core position of each component and L o,i The number of spaces between each adjacent component is determined, each Chinese character is extracted according to the interval structure of each component, each symbol is inserted into each Chinese character, and character recognition is completed.
2. The character recognition method of claim 1, wherein, the extraction method of the text skeleton is as follows: finding a continuous line of the highest gray-scale points in each stroke region with a high gray scale in the gray-scale image as the ridge line of the stroke region, and taking the linear regression line segment of each point on each ridge line as a text skeleton; the extraction method of the text key point is as follows: using the gray-scale peak value method to find the highest gray-scale points at both ends of each ridge line and at each intersection position of the ridge line with other ridge lines with a certain search radius, and taking the highest gray-scale points as the key points of the to-be-recognized text; wherein the search radius is determined by experiment optimization.
3. The character recognition method of claim 1, wherein, the determination method of the upper bound and lower bound of the position of each line of text is as follows: based on the text skeleton, calibrating the upper and lower boundary position data of each component in the line of text to respectively perform interpolation fitting of the upper boundary and the lower boundary, and obtaining the first upper bound and the first lower bound of the line of text; merging each key point connected by the same component into a point group, fitting the point with the largest vertical coordinate of all the point groups in the line of text, and taking the fitting result as the second upper bound of the line of text; fitting the point with the smallest vertical coordinate of all the point groups in the line of text, and taking the fitting result as the second lower bound of the line of text; weighting and merging the first upper bound and the second upper bound, and taking the weighted result as the upper bound of the position of the line of text; weighting and merging the first lower bound and the second lower bound, and taking the weighted result as the lower bound of the position of the line of text.
4. The character recognition method of claim 1, wherein, the calculation method of the core position of each component is as follows: averaging the coordinates of all the key points in each point group the core position of the radical to which the point group corresponds, wherein the key points connected via the same radical are merged into one point group.
5. The character recognition method of claim 1, wherein, according to the spatial arrangement of the text key points, the word density in the to-be-recognized text is further determined; the calculation method of the word density is as follows: wherein, ρ represents the word density, S0 represents the area of a figure surrounded by all key points located at the outermost periphery of the gray-scale image; N0 represents the total number of point groups of key points in the to-be-recognized text, and each key point connected by the same component is merged into a point group; If the word density is used as a verification parameter when calculating the position parameter L of each component in each line of text by using a hidden Markov model HMM oi 6. The character recognition method of claim 1, wherein, the determination method of the number of spaces between adjacent components is as follows: Using the core position and the occupation parameter of each radical, it is determined whether there is a space or a blank between each adjacent radical. The determination method is as follows: calculating If Δ>0, it is considered that there is a space before the character, and the value of Δ rounded up is the number of spaces before the character.
7. The character recognition method of claim 1, wherein, A second order Viterbi algorithm is used to find the maximum of the probability sequence . then the neural network for obtaining P q,i , P l,i , and P r,i is also used to identify each radical as an independent structure from each radical of the text to be recognized, and reset the left-attached probability and the right-attached probability of each radical as an independent structure to the minimum probability that the neural network can calculate.
8. The character recognition method according to any one of claims 1 to 7, characterized by, before extracting the text skeleton and the text key point, the method further comprises the following step: pooling the gray-scale image containing the to-be-recognized text by using the average value pooling method to obtain a new gray-scale image; 9. A computer-readable storage medium, characterized in that, then the text skeleton and the text key point are extracted from the new gray-scale image. The computer readable storage medium comprises a stored computer program, wherein when the computer program is run by a processor, the computer program controls the device where the storage medium is located to execute the character recognition method based on text skeletons and key points according to any one of claims 1 to 8.
Citation Information
Patent Citations
Text detection method and device based on text skeleton and computer equipment
CN114241481A
Text image generation method and device, electronic equipment and storage medium
CN115588211A
Radical set determination for hmm based east asian character recognition
CN101971192A
Complex image and text sequence identification method based on CNN-RNN
CN105678293A