Character division method and device, computer equipment and storage medium
Through the character classification model and attraction fusion technology based on neural network, the problem of inaccurate recognition of two-dimensional structure mathematical formulas in the existing technology is solved, and higher recognition accuracy is achieved.
Patent Information
- Application Number
- CN202411714490.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-11-27
AI Technical Summary
Existing mathematical formula recognition technology is difficult to accurately identify composite characters such as matrices or determinants with two-dimensional structures.
A character classification model based on neural network is used to determine the character type of the character to be recognized, and the attraction degree is determined based on the range coordinates of different characters within the composite character range, and character fusion is performed to ensure the integrity and accuracy of character elements.
The accuracy of recognition of mathematical formulas with two-dimensional structures is improved, and the special nature of composite characters is fully considered for division processing.
Smart Images

Figure CN119649385A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of character recognition, and in particular relates to a character segmentation method, device, computer equipment and storage medium. Background Art
[0002] Mathematical formula recognition technology is mainly divided into two types: one type is based on syntax drive, which includes three steps, namely character segmentation, recognition and spatial relationship structure analysis. For example, SVM, K-means, graph structure, syntax tree, etc. are used for recognition. The other type is based on the theory and method of deep learning, such as realizing end-to-end recognition of mathematical formulas by improving the network structure; adopting the framework of encoding and decoding, and introducing the attention mechanism at the same time. For example, an end-to-end model architecture is adopted, and the attention mechanism is introduced at the same time; a dense convolutional network is used as an encoder, a gated recurrent unit is used as a decoder, and an attention mechanism is introduced to recognize mathematical formulas; a paired adversarial learning algorithm is used to recognize printed mathematical formulas; the formula is decoded into a tree structure through a sequence relationship decoder for online handwritten mathematical expression recognition. This type of recognition algorithm is the main research field of mathematical formula recognition.
[0003] However, so far, the recognition objects have all been general mathematical formulas, ignoring the particularities of multi-layer two-dimensional structures such as matrices and determinants, resulting in inaccurate recognition of mathematical formulas with the above-mentioned two-dimensional structures such as matrices or determinants. Summary of the invention
[0004] In order to solve the problem of inaccurate recognition of mathematical formulas with two-dimensional structures, the present invention provides a character segmentation method, device, computer equipment and storage medium.
[0005] In order to achieve the above object, the present invention provides the following technical solutions:
[0006] First, a character segmentation method is provided, the method comprising:
[0007] Constructing a neural network-based character classification model, and determining the character type of the character to be recognized according to the character classification model; the character types include compound characters, variable characters, binary characters and general characters; the compound characters are two-dimensional structured characters with boundary characters as the outer periphery, the variable characters are characters containing only macro operators, the binary characters are characters containing only binary operators, and the general characters are characters other than compound characters, variable characters and binary characters;
[0008] Determine the range coordinates of the area where the composite characters, variable characters, binary characters and general characters are located;
[0009] Within the range coordinates of the same composite character, the attraction between the regions where different characters are located is determined according to the range coordinates of the variable characters, the binary characters and the general characters;
[0010] The variable characters, binary characters and general characters are merged according to the attractiveness to determine a target character.
[0011] Optionally, the constructing of a character classification model and determining the character type of the character to be recognized according to the character classification model comprises:
[0012] Build a YOLOv8 model, train the YOLOv8 model using the pre-acquired training samples, and obtain a character classification model;
[0013] The character to be recognized is input into the character classification model to determine the character type of the character to be recognized.
[0014] Optionally, determining the range coordinates of the area where the composite characters, variable characters, binary characters and general characters are located includes:
[0015] Determine the range coordinates of the area where the composite character is located according to the coordinates of the upper left corner point and the lower right corner point of the composite character;
[0016] The range coordinates of the area where the variable characters are located are determined as follows:
[0017]
[0018] The range coordinates of the area where the binary character is located are determined as:
[0019]
[0020] Determine the range coordinates of the area where the general character is located according to the coordinates of the upper left corner point and the lower right corner point of the general character;
[0021] Among them, maxx is the maximum horizontal coordinate of the range coordinates, minx is the minimum horizontal coordinate of the range coordinates, maxy is the maximum vertical coordinate of the range coordinates, miny is the minimum vertical coordinate of the range coordinates, charmax is the maximum value of the area, charmin is the minimum value of the area, h is the border height of the character area, and w is the border width of the character area.
[0022] Optionally, the formula for determining the attractiveness is:
[0023]
[0024] Among them, d(E, F) is the attraction of the areas where the two different characters E and F are located, and dx and dy are the horizontal distance and vertical distance of the overlapping parts of the coordinates of different character ranges, respectively.
[0025] Optionally, the variable characters, the binary characters and the general characters are merged according to the attractiveness to determine the target characters, including:
[0026] When the attractiveness of the regions where two adjacent different characters are located is less than or equal to the preset attractiveness, the two adjacent different characters are fused according to a preset fusion formula to determine the target character.
[0027] Optionally, the preset fusion formula is:
[0028]
[0029] Among them, L x1 , L y1 , L x2 and L y2 are the horizontal and vertical coordinates of the upper left point of the range coordinates of the two different characters merged, R x1 , R y1 , R x2 and R y2 are the horizontal and vertical coordinates of the lower right point of the range coordinates of the two different characters merged, NL x NL y NR x and NR y They are respectively the horizontal and vertical coordinates of the upper left point and the horizontal and vertical coordinates of the lower right point of the fused character range coordinates.
[0030] Optionally, when the attractiveness of the regions where two adjacent different characters are located is less than or equal to a preset attractiveness, the two adjacent different characters are merged according to a preset fusion formula, and determining the target character includes:
[0031] When the first attraction between the area where the first character is located and the area where the second character is located, and the second attraction between the area where the first character is located and the area where the third character is located are both less than or equal to the preset attraction, determining the magnitude of the first attraction and the second attraction;
[0032] Determine and merge two regions corresponding to the smaller attraction between the first attraction and the second attraction;
[0033] When the first attraction degree and the second attraction degree are the same, the regions where the first character, the second character and the third character are located are kept unchanged.
[0034] Secondly, a character segmentation device is provided, the device comprising:
[0035] A construction module is used to construct a character classification model based on a neural network, and determine the character type of the character to be recognized according to the character classification model; the character types include compound characters, variable characters, binary characters and general characters; the compound characters are two-dimensional structured characters with boundary characters as the outer periphery, the variable characters are characters containing only macro operators, the binary characters are characters containing only binary operators, and the general characters are characters other than compound characters, variable characters and binary characters;
[0036] A coordinate determination module, used to determine the range coordinates of the area where the composite characters, variable characters, binary characters and general characters are located;
[0037] An attraction determination module is used to determine the attraction between regions where different characters are located according to the range coordinates of variable characters, binary characters and general characters within the range coordinates of the same composite character;
[0038] A fusion module is used to fuse the variable characters, binary characters and general characters according to the attractiveness to determine a target character.
[0039] In addition, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned character segmentation method is implemented.
[0040] Finally, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned character segmentation method when executing the program.
[0041] The character segmentation method provided by the present invention has the following beneficial effects:
[0042] First, the characters are classified to determine the character types of the characters to be recognized. This allows them to be processed separately according to the particularities of different types of characters to be recognized, which is beneficial to improving the accuracy of character processing. Then, range division is performed according to the composite characters, that is, the range coordinates of the areas where different characters are located are determined within the composite characters, and the degree of fusion is determined based on the range coordinates of the areas where different characters are located. Further fusion division is performed based on the degree of fusion, thereby ensuring the integrity and accuracy of the character elements. In this way, full consideration is given to the composite characters with two-dimensional structures, and further character division is performed within the composite characters, which is beneficial to improving the recognition accuracy of mathematical formulas with two-dimensional structures. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiment of the present invention and its design scheme, the following briefly introduces the drawings required for this embodiment. The drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0044] Figure 1 A schematic diagram of handwritten characters provided according to an exemplary embodiment of the present invention.
[0045] Figure 2 The figure is a flow chart of a character segmentation method provided according to an exemplary embodiment of the present invention.
[0046] Figure 3 Another schematic diagram of coarse grouping of handwritten characters provided according to an exemplary embodiment of the present invention.
[0047] Figure 4 The present invention is a block diagram of a character segmentation device provided according to an exemplary embodiment. DETAILED DESCRIPTION
[0048] In order to enable those skilled in the art to better understand the technical solution of the present invention and implement it, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the scope of protection of the present invention.
[0049] There is a difference in the neatness of the arrangement of handwritten compound formulas and printed compound formulas. The rows and columns of printed compound formulas are usually arranged more neatly. Handwritten compound formulas often have staggered columns or tilted rows, such as Figure 1 Therefore, the vertical projection and horizontal projection methods are not suitable for its segmentation, so effectively segmenting handwritten composite shapes is a difficult problem in mathematical formula recognition.
[0050] The technical solutions provided by various embodiments of the present invention are described in detail below in conjunction with the accompanying drawings.
[0051] First, the present invention provides a character segmentation method, specifically as follows Figure 2 As shown, the following steps are included:
[0052] S201, constructing a character classification model based on a neural network, and determining the character type of a character to be recognized according to the character classification model.
[0053] Specifically, first, a YOLOv8 model can be constructed, and the YOLOv8 model can be trained by using pre-acquired training samples to obtain a character classification model. Secondly, the character to be recognized is input into the character classification model to determine the character type of the character to be recognized.
[0054] The character types include compound characters, variable characters, binary characters and general characters; the compound characters are two-dimensional structured characters with boundary characters on the outside, the variable characters are characters that only contain macro operators, the binary characters are characters that only contain binary operators, and the general characters are characters other than compound characters, variable characters and binary characters.
[0055] Based on the high accuracy and fast processing capability of YOLOv8 in object classification, real-time effects can be achieved on general edge devices. For these characters, because there are fewer categories, the smallest version of YOLOv8, YOLOv8n, is used to classify these composite characters, variable characters, binary characters, and general characters, and obtain the regions of these characters. During training, its public pre-trained weights are used, and the weights for classifying such characters are obtained after sample training.
[0056] By way of example, multiple sample formulas containing the above-mentioned compound characters, variable characters, binary characters and general characters and their corresponding classification results can be obtained in advance, and the multiple sample formulas can be respectively input into YOLOv8 to obtain recognition results. YOLOv8 is trained for the purpose of minimizing the difference between the recognition results and the classification results to obtain a character classification model.
[0057] The outermost characters of the composite shape are relatively simple, including (,), [, ], |, {,} and ‖, that is, for the two-dimensional structure characters with boundary characters on the outer periphery, the present invention collectively refers to these as composite characters. The invention is to segment composite characters, and the circumscribed rectangular boundary box of the characters is needed, that is, the range coordinates of the composite characters are needed. At the same time, such as fraction lines, The characters of giant operators such as "+", "-", "≥", etc., vary greatly in size when written, so the present invention refers to the characters containing only giant operators as variable characters. Formula symbols of binary operators such as , which are generally used for horizontal connection and require a wide area. This article calls the above characters that only contain binary operators as binary characters. All characters other than the above three types of characters, namely, composite characters, variable characters, and binary characters, are called general characters.
[0058] S202: Determine the range coordinates of the area where the composite character, variable character, binary character and general character are located.
[0059] Because mathematical formulas express their mathematical meaning based on spatial relationship structures, and some unique writing methods have been formed in the long-term use process, if the circumscribed rectangular bounding box of each character is directly used as its area, the final accuracy will be reduced. This rule also applies to variable characters and binary characters.
[0060] Let the maximum and minimum horizontal and vertical coordinates of the area where the character is located be charmaxx, charminx, charmaxy and charminy respectively, and the maximum and minimum horizontal and vertical coordinates of the area be maxx, maxy, minx and miny respectively.
[0061] Specifically, for a compound character, the range coordinates of the area where the compound character is located are determined according to the coordinates of the upper left corner point and the lower right corner point of the compound character.
[0062] For variable characters, these characters usually have upper and lower adjacent characters, which are usually in the same unit as the variable characters in the formula. In order to effectively adsorb these characters to one area, their area is increased by a value in the upper and lower directions of their original area. Based on experimental statistics of different values, this value is determined to be h / 6, where h is the height of the bounding box of these characters.
[0063] Determine the range coordinates of the area where the variable character is located:
[0064]
[0065] The area where the variable characters are located is expanded in the vertical direction to enhance the attraction between adjacent characters.
[0066] For binary characters, the writing format of these characters in the formula is larger than that of general characters, so their area is also increased by w / 4 on the left and right sides on the basis of their original area, where w represents the width of the bounding box of these characters. Expand in the horizontal direction to accurately reflect its role in the formula, and determine the range coordinates of the area where the binary character is located as follows:
[0067]
[0068] The area containing the binary characters is expanded horizontally to enhance the attraction between adjacent characters.
[0069] The range coordinates of the area where the general character is located are determined according to the coordinates of the upper left corner point and the lower right corner point of the general character.
[0070] Wherein, maxx is the maximum horizontal coordinate of the range coordinates, minx is the minimum horizontal coordinate of the range coordinates, maxy is the maximum vertical coordinate of the range coordinates, miny is the minimum vertical coordinate of the range coordinates, charmax is the maximum value of the area, charmin is the minimum value of the area, h is the border height of the character area, w is the border width of the character area, and int(·) is the rounding function.
[0071] S203. Determine the attractiveness between regions where different characters are located according to the range coordinates of variable characters, binary characters and general characters within the range coordinates of the same composite character.
[0072] Among them, for compound characters, after the compound characters are obtained through the character classification model, the area where the compound characters are located and the characters within the range of the compound characters can be located through the symmetry relationship of the compound characters.
[0073] For example, let the horizontal and vertical coordinates of the upper left corner of the left character area be (Lx, Ly), the horizontal and vertical coordinates of the lower right corner of the right character area be (Rx, Ry), and the coordinates of the center point of the bounding box of all characters except the composite character be (C ix ,C iy ), then the characters inside this composite shape are determined by the following algorithm 1.
[0074] Algorithm 1: / / According to the composite character coordinates in the matrix and determinant, find all the characters in this area and put them in L.
[0075] s 1: Start with nothing in it.
[0076] s2: Traverse all variable characters, binary characters and general characters C in mathematical formulas i :
[0077] If Rx>C ix >Lx and Ry>C iy >Ly, then L←C i .
[0078] s3: Return L.
[0079] The center point coordinates of variable characters, binary characters, and general characters are applied because of the irregularity of handwritten formulas. They often exceed the boundaries of compound characters, that is, the upper boundary of the first row of characters or the lower boundary of the last row of characters will exceed the upper and lower boundaries of the compound characters. Therefore, the center point coordinates of the boundary boxes of all characters except the compound characters are used for calculation here.
[0080] In the same composite character, the attraction between the regions where different characters are located is determined according to the range coordinates of the variable character, the binary character and the general character; the variable character, the binary character and the general character are merged according to the attraction to determine the target character.
[0081] Attraction refers to the degree to which two character regions attract each other. In handwritten math formulas, the farther apart the two regions are, the weaker the attraction. If the two regions do not intersect, the farther apart they are in the horizontal and vertical directions, the easier it is to explain the degree of separation between the two. If the two regions intersect, the more overlapped they are, the stronger the attraction.
[0082] For example, here E and F represent two areas (E is on the left and F is on the right), and the formula for determining the attraction d(E, F) of the two areas is:
[0083]
[0084] Among them, d(E, F) is the attraction of the areas where two different characters E and F are located, and dx and dy are the horizontal distance and vertical distance of the overlapping parts of the coordinates of different character ranges, respectively.
[0085] When E and F intersect, dx and dy are the horizontal distance and vertical distance of the overlapping parts respectively. If dx or dy is 0, it is judged as non-intersecting.
[0086] When E and F do not intersect, dx represents the shortest horizontal distance between the vertical edge lines of the two regions, and dy represents the shortest vertical distance between the horizontal edge lines. α is used as a coefficient. Experiments have found that characters in different regions with up-and-down relationships are easily attracted to one region based on distance alone. Therefore, different αs are used for experiments, and the optimal result is α = 1.5. The final addition of 1 is for the continuity of the distance formula.
[0087] max(·) means taking the maximum value of all parameters. If d(E,F) is smaller, it means the attraction between the two rectangles is stronger, otherwise it is weaker, and the two regions with strong attraction should be merged.
[0088] S204: The variable character, the binary character and the general character are merged according to the attractiveness to determine the target character.
[0089] When the attractiveness of the regions where two adjacent different characters are located is less than or equal to the preset attractiveness, the two adjacent different characters are fused according to a preset fusion formula to determine the target character.
[0090] Specifically, if the distance between two regions is less than a threshold δ (different values are taken according to different situations in the experiment), the two regions are said to be attracted, otherwise the two regions are said to be not attracted. As shown in the following formula. When d(E, F) is less than δ, result is 1, indicating that the two regions are attracted, otherwise it is 0.
[0091] result=d(E,F)<δ.
[0092] If two regions attract each other, merge them to form a new region. Let the horizontal and vertical coordinates of the upper left corner and lower right corner of the two regions be: (L x1 ,L y1 )、(R x1 ,R y1 )、(L x2 ,L y2 )、(R x2 ,R y2 ), the coordinates of the upper left corner and lower right corner of the new area (NL x ,NL y ), (NR x ,NR y ), then the preset fusion formula is:
[0093]
[0094] Among them, L x1 , L y1 , L x2 and L y2 are the horizontal and vertical coordinates of the upper left point of the range coordinates of the two different characters merged, R x1 , R y1 , R x2 and R y2 are the horizontal and vertical coordinates of the lower right point of the range coordinates of the two different characters merged, NL x NL y NR x and NR y They are respectively the horizontal and vertical coordinates of the upper left point and the horizontal and vertical coordinates of the lower right point of the fused character range coordinates.
[0095] After obtaining the type of the character, the range coordinates of the regions where the characters of different types are located are determined, and after determining the attraction based on the range coordinates of the regions where the characters of different types are located, it is further determined whether the regions where two adjacent characters of different types are located are attracted to each other. Specifically, the present invention calls this algorithm the adsorption method. It is divided into the following two parts:
[0096] (1) Non-compound characters are divided into formula elements, that is, characters belonging to the same row i and column j are determined.
[0097] (2) Determine the row and column numbering of the formula elements and determine the structure of the composite character.
[0098] In a composite character, there is a certain distance between rows and columns. In most cases, the attraction of character areas in the same unit is smaller than that of character areas in different units, and the attraction of composite characters in the same unit is smaller than that of composite characters in different units. Based on this rule, the area formed by the attractive characters is first determined.
[0099] For example, let L = (C1, C2,..., C n ), C i (i = 1, 2,... n) represents the area where the composite character is located. First, take C1 as the area A1 where the first target character is located, and calculate d(A1, C t ), (t = 2,... n). Assume that the first area that attracts A1 is C t , that is, d(A1, C t ) < δ, then merge A1 and C t into a new composite character area, still named A1. Through experimental comparison and analysis, the threshold δ finally takes the value of 5 here.
[0100] Then calculate d(A1, C p1 ), where t < p1 ≤ n. Similarly, if there is C p1 that attracts A1, then continue to merge C p1 and A1 into a new composite character area, still named A1, and continue to judge whether the subsequent character areas of C p1 attract A1 until C n . Finally, a composite character area A1 is obtained, and this area is called the first area. Let L1 represent the set formed by the character areas within the first area.
[0101] For the first unmerged character area C 21 , C 21 in L, take it as the area A2 where the second target character is located. Sequentially find the first character area C 21 in L that is different from C 21 but attracts C p2 (1 ≤ p2 ≤ n), merge these two areas, still named A2, and continue to use A2 to judge the attraction with the subsequent character areas of C p2 in L until C n . In this way, the division of the character areas in L is obtained, and this area is called A2.
[0102] Repeat the above steps so that all the character areas in L are attracted to different areas, and in this way, the area set A = (A1, A2,..., A m ) of the target characters is obtained.
[0103] Due to the threshold for judging whether two areas attract each other and the different sorting of the character areas in L, two problems may need to be solved in this process.
[0104] The first problem is that due to being written too close, a character area may be attracted to different areas. For example Figure 3As shown, the character "3" in the first column of the second row is attracted to two different regions (indicated by the dashed boxes), so it is necessary to determine which region the "3" will ultimately be divided into.
[0105] The second problem is that a character region that should have been divided into one region is divided into different regions. For example, Figure 2 in the case of the second column of the second row in 22 "P 22 " and "3" are divided into different regions. The reason for this situation is that due to the different order of character extraction, when "3" is ranked in front of P in L, since "3" is not attracted to all character regions, it forms an independent region by itself. In the subsequent discrimination of the character regions in P and L, since "3" is extracted and discriminated first, and then attracted to the region of "2" on the left, although a new region is formed and attracted to "3" at this time, "3" has already been discriminated, so "3" will not be discriminated to be attracted to the region where 22 "P
[0106] First, deal with the first problem. When the first attraction degree between the region where the first character is located and the region where the second character is located, and the second attraction degree between the region where the first character is located and the region where the third character is located are both less than or equal to the preset attraction degree, determine the magnitudes of the first attraction degree and the second attraction degree; determine the two regions corresponding to the smaller attraction degree among the first attraction degree and the second attraction degree for fusion; when the first attraction degree and the second attraction degree are the same, keep the regions where the first character, the second character, and the third character are located unchanged.
[0107] That is, a character region belongs to two different regions. Let the character region of the first region be, and the character region of the second region be Let the composite region formed by the former be M, and the region formed by the latter be N. If d(M, P) < d(N, P), then p belongs to the first region; otherwise, it belongs to the second region.
[0108] On the basis of solving the first problem, for the second problem, group all the independent regions A i using the character region division algorithm for adsorption grouping. Since this is a discrimination based on the adsorption of the composite region and a single character, if the threshold δ is too large, two similar regions will be attracted into a large composite region. Therefore, the adsorption threshold should be relatively reduced at this time. Through experimental analysis, take this threshold as 3 of δ.
[0109] Finally, obtain a set of regions A′ = (A1, A2, …, A r )), and a character region only belongs to one region. It can be considered that these regions are the formula elements in the composite character.
[0110] Using the above method, firstly, the characters are classified to determine the character types of the characters to be recognized, so that they can be processed separately according to the particularities of different types of characters to be recognized, which is beneficial to improving the accuracy of character processing; then, the range is divided according to the composite characters, that is, the range coordinates of the areas where different characters are located are determined within the composite characters, and the degree of fusion is determined according to the range coordinates of the areas where different characters are located, and further fusion division is performed according to the degree of fusion, thereby ensuring the integrity and accuracy of the character elements. In this way, the composite characters with two-dimensional structures are fully considered, and further character division is performed within the composite characters, which is beneficial to improving the recognition accuracy of mathematical formulas with two-dimensional structures.
[0111] Secondly, the present invention also provides a character segmentation device, such as Figure 4 As shown, including:
[0112] Construction module 401 is used to construct a character classification model based on a neural network, and determine the character type of the character to be recognized according to the character classification model; the character types include compound characters, variable characters, binary characters and general characters; the compound characters are two-dimensional structured characters with boundary characters on the outside, the variable characters are characters that only contain macro operators, the binary characters are characters that only contain binary operators, and the general characters are characters other than compound characters, variable characters and binary characters.
[0113] The coordinate determination module 402 is used to determine the range coordinates of the area where the composite characters, variable characters, binary characters and general characters are located.
[0114] The attraction determination module 403 is used to determine the attraction between the regions where different characters are located according to the range coordinates of the variable characters, the binary characters and the general characters within the range coordinates of the same composite character.
[0115] The fusion module 404 is used to fuse the variable characters, binary characters and general characters according to the attractiveness to determine the target characters.
[0116] When using the above-mentioned device, the characters are first classified to determine the character types of the characters to be recognized. In this way, the characters to be recognized of different types can be processed separately according to their particularities, which is beneficial to improving the accuracy of character processing; then, the range is divided according to the composite characters, that is, the range coordinates of the areas where different characters are located are determined within the composite characters, and further fusion and division are performed based on the range coordinates of the areas where different characters are located, thereby ensuring the integrity and accuracy of the character elements. In this way, the composite characters with two-dimensional structures are fully considered, and character division is further performed within the composite characters, which is beneficial to improving the recognition accuracy of mathematical formulas with two-dimensional structures.
[0117] The present invention also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 Provide the steps of the character segmentation method.
[0118] The present invention also provides a computer device. At the hardware level, the computer device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Provide the steps of the character segmentation method.
[0119] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0120] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as a combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0121] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0122] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0123] It should be noted that the above specific implementation method can enable those skilled in the art to understand the invention more comprehensively, but does not limit the invention in any way. Therefore, although the present invention has been described in detail in this specification, those skilled in the art should understand that the invention can still be modified or replaced by equivalents; and all technical solutions and improvements that do not deviate from the spirit and scope of the invention are included in the protection scope of the patent for the invention. Any figure mark in the claims should not be regarded as limiting the claims involved.
Claims
1. A character segmentation method, characterized in that: The method comprises: Constructing a neural network-based character classification model, and determining the character type of the character to be recognized according to the character classification model; the character types include compound characters, variable characters, binary characters and general characters; the compound characters are two-dimensional structured characters with boundary characters as the outer periphery, the variable characters are characters containing only macro operators, the binary characters are characters containing only binary operators, and the general characters are characters other than compound characters, variable characters and binary characters; Determine the range coordinates of the area where the composite characters, variable characters, binary characters and general characters are located; Within the range coordinates of the same composite character, the attraction between the regions where different characters are located is determined according to the range coordinates of the variable characters, the binary characters and the general characters; The variable characters, binary characters and general characters are merged according to the attractiveness to determine a target character.
2. The character segmentation method according to claim 1, characterized in that: The step of constructing a character classification model and determining the character type of a character to be recognized according to the character classification model comprises: Build a YOLOv8 model, train the YOLOv8 model using the pre-acquired training samples, and obtain a character classification model; The character to be recognized is input into the character classification model to determine the character type of the character to be recognized.
3. The character segmentation method according to claim 1, characterized in that: Determining the range coordinates of the area where the composite characters, variable characters, binary characters and general characters are located includes: Determine the range coordinates of the area where the composite character is located according to the coordinates of the upper left corner point and the lower right corner point of the composite character; The range coordinates of the area where the variable characters are located are determined as follows: The range coordinates of the area where the binary character is located are determined as: Determine the range coordinates of the area where the general character is located according to the coordinates of the upper left corner point and the lower right corner point of the general character; Among them, maxx is the maximum horizontal coordinate of the range coordinates, minx is the minimum horizontal coordinate of the range coordinates, maxy is the maximum vertical coordinate of the range coordinates, miny is the minimum vertical coordinate of the range coordinates, charmax is the maximum value of the area, charmin is the minimum value of the area, h is the border height of the character area, and w is the border width of the character area.
4. The character segmentation method according to claim 1, characterized in that: The formula for determining the attractiveness is: Among them, d(E, F) is the attraction of the areas where the two different characters E and F are located, and dx and dy are the horizontal distance and vertical distance of the overlapping parts of the coordinates of different character ranges, respectively.
5. The character segmentation method according to claim 1, characterized in that: The variable characters, binary characters and general characters are merged according to the attractiveness to determine the target characters, including: When the attractiveness of the regions where two adjacent different characters are located is less than or equal to the preset attractiveness, the two adjacent different characters are fused according to a preset fusion formula to determine the target character.
6. The character segmentation method according to claim 5, characterized in that: The preset fusion formula is: Among them, L x1 , L y1 , L x2 and L y2 are the horizontal and vertical coordinates of the upper left point of the range coordinates of the two different characters merged, R x1 , R y1 , R x2 and R y2 are the horizontal and vertical coordinates of the lower right point of the range coordinates of the two different characters merged, NL x NL y NR x and NR y They are respectively the horizontal and vertical coordinates of the upper left point and the horizontal and vertical coordinates of the lower right point of the fused character range coordinates.
7. The character segmentation method according to claim 5, characterized in that: When the attractiveness of the regions where two adjacent different characters are located is less than or equal to the preset attractiveness, the two adjacent different characters are merged according to a preset fusion formula, and the target character is determined, including: When the first attraction between the area where the first character is located and the area where the second character is located, and the second attraction between the area where the first character is located and the area where the third character is located are both less than or equal to the preset attraction, determining the magnitude of the first attraction and the second attraction; Determine and merge two regions corresponding to the smaller attraction between the first attraction and the second attraction; When the first attraction degree and the second attraction degree are the same, the regions where the first character, the second character and the third character are located are kept unchanged.
8. A character segmentation device, characterized in that: The device comprises: A construction module is used to construct a character classification model based on a neural network, and determine the character type of the character to be recognized according to the character classification model; the character types include compound characters, variable characters, binary characters and general characters; the compound characters are two-dimensional structured characters with boundary characters as the outer periphery, the variable characters are characters containing only macro operators, the binary characters are characters containing only binary operators, and the general characters are characters other than compound characters, variable characters and binary characters; A coordinate determination module, used to determine the range coordinates of the area where the composite characters, variable characters, binary characters and general characters are located; An attraction determination module is used to determine the attraction between regions where different characters are located according to the range coordinates of variable characters, binary characters and general characters within the range coordinates of the same composite character; A fusion module is used to fuse the variable characters, binary characters and general characters according to the attractiveness to determine a target character.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the program.
Citation Information
Patent Citations
Character recognition processing method and device
CN109558876A
Character recognition method, device and equipment and computer readable storage medium
CN118799884A
Balance exercise equipment
KR1020230116403A