Method, device and equipment for determining font type in text image

By using character template image matching and skeleton line overlap technology, the problem of font type recognition under poor image quality is solved, and high-accuracy font recognition is achieved in a variety of scenarios.

CN121963224APending Publication Date: 2026-05-01NANJING UNIV OF INFORMATION SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANJING UNIV OF INFORMATION SCI & TECH
Filing Date
2026-01-23
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing font type recognition methods cannot accurately identify the font of text images when the image quality is poor, especially in scenarios such as screen photography, mobile phone photography, screen screenshots, and displaying fonts at reduced sizes, where the stroke features of characters are missing, resulting in a significant reduction in recognition accuracy.

Method used

By acquiring the text image to be detected, segmenting it into character images, and performing matching operations with character template images, the font type of the character image to be detected is determined by using the overlap and similarity calculation of character stroke skeleton lines, combined with coarse-grained image template matching and fine-grained character structure feature matching.

Benefits of technology

Even with poor image quality, it can accurately identify the font type of text images, improving the accuracy and applicability of recognition, and is suitable for various scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121963224A_ABST
    Figure CN121963224A_ABST
Patent Text Reader

Abstract

The invention provides a method, device and equipment for determining font types in a text image, and the method comprises the steps: segmenting a to-be-detected text image, and obtaining a to-be-detected character image; performing image matching operation on the to-be-detected character image and a corresponding character template image in the class representative font of each large class in the character template to obtain a plurality of matching similarity values; determining a target font category to which the to-be-detected character image belongs according to the maximum matching similarity value in the matching similarity values; performing image stroke alignment on the to-be-detected character image and a character template image corresponding to each sub-class font in the target font large class to obtain a target skeleton line overlapping image; determining the similarity between a to-be-detected character image skeleton line of the to-be-detected character image and a character template image skeleton line corresponding to the subclass fonts; and determining a target subclass font of the to-be-detected character image according to the similarity. According to the scheme, the fonts of the text image can be accurately recognized under the condition that the image quality is poor.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer information processing technology, and in particular to a method, apparatus, and device for determining the font type in a text image. Background Technology

[0002] The core significance of font type recognition lies in achieving efficient and accurate text information processing by analyzing the stroke characteristics, structural rules, and visual morphology of Chinese characters. Technically, it improves the efficiency of document digitization (e.g., print font recognition accuracy exceeds 99%), assists in forensic identification (identifying document authenticity through font features), and promotes cultural heritage protection (e.g., ancient book font classification). In terms of social applications, this technology not only ensures commercial copyright compliance (detecting unauthorized font use) but also supports scenarios such as intelligent transportation (license plate recognition) and education (calligraphy teaching), becoming an important bridge connecting traditional written culture with modern digital society.

[0003] Current font type identification methods are mainly divided into two types: functional identification technology and stroke feature analysis technology. Functional identification technology primarily uses deep learning-based algorithms (such as CNN and RNN) to automatically identify various fonts (such as Song, Kai, and Hei) and text styles (size, color, slant, etc.), suitable for fields such as design and printing. This type of technology requires significant computing resources and a large amount of labeled training data, making it unsuitable for widespread use in multiple scenarios. The latter mainly uses traditional methods to analyze the basic stroke forms of Chinese characters (eight types: dot, horizontal, vertical, left-falling stroke, right-falling stroke, rising stroke, turning stroke, and hook), stroke combination methods (three combination methods: separated, connected, and intersecting), structural features (single-component characters and compound characters), and writing norms (emphasizing stroke alignment, such as aligning the left-falling and right-falling strokes with the center line) to determine font type. However, for many similar fonts, the above features are basically consistent, making it impossible to accurately distinguish between them at a fine-grained level. In addition, existing methods all have a common problem: they can only support scenarios with relatively high printing or scanning quality. However, in scenarios such as screen photography, mobile phone photography, screen capture, and displaying with reduced font size, when the image quality is poor, the stroke features of the characters are lacking, and the accuracy of font type identification is greatly reduced. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a method, apparatus and device for determining the font type in a text image, which can accurately identify the font in a text image even when the image quality is poor.

[0005] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows:

[0006] A method for determining the font type in a text image includes:

[0007] Obtain the image of the text to be detected;

[0008] The text image to be detected is segmented to obtain the character image to be detected;

[0009] The image of the character to be detected is matched with the corresponding character template image in the class representative font of each major category in the character template to obtain multiple matching similarity values;

[0010] The target font category to which the character image to be detected belongs is determined based on the maximum matching similarity value among multiple matching similarity values;

[0011] The character image to be detected is aligned with the character template image corresponding to each subclass of the target font category by means of the image strokes, so that the corresponding character stroke skeleton lines in the two images coincide, and the target skeleton line coincidence image is obtained.

[0012] In the target skeleton line overlapping image, determine the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the subclass font;

[0013] Based on the similarity of the skeleton lines, the target subclass font within the target font category to which the character image to be detected belongs is determined.

[0014] Optionally, the image of the character to be detected is matched with the corresponding character template image in the class representative font of each major category in the character template to obtain multiple matching similarity values, including:

[0015] The character image to be detected is aligned with the corresponding character template image in the class representative font of each major category in the character template to obtain a first character image to be detected and multiple first character template images of the same size;

[0016] The first character image to be detected is enlarged or reduced multiple times according to a preset ratio to obtain multiple enlarged or reduced intermediate character images to be detected.

[0017] The similarity between the plurality of intermediate character images to be detected and the first character image to be detected is calculated with the first character template image to obtain a plurality of intermediate similarities;

[0018] Based on the maximum value among the multiple intermediate similarities, the matching similarity value between the character image to be detected and the character template image in each class representative font is determined.

[0019] Optionally, the similarity between the plurality of intermediate character images to be detected and the first character image to be detected is calculated with the first character template image to obtain a plurality of intermediate similarities, including:

[0020] Each of the intermediate character images to be detected and the first character image to be detected are slid on the first character template image according to a preset sliding step size to obtain multiple pause points;

[0021] Multiple intermediate similarities are obtained based on the normalized correlation coefficients between the intermediate character images to be detected at multiple pause points or between the first character image to be detected and the first character template image.

[0022] Optionally, the character image to be detected is aligned with the character template image corresponding to each subclass of the target font category by image strokes, so that the corresponding character stroke skeleton lines in the two images coincide, to obtain a target skeleton line coincidence image, including:

[0023] Align the center of the character image to be detected with the center of the character template image corresponding to each subclass of the target font category to obtain a center-aligned image;

[0024] In the center-aligned image, determine the vertical offset distance required to make the character image to be detected coincide with the target horizontal stroke in the character template image;

[0025] In the center-aligned image, determine the lateral offset distance required to make the character image to be detected coincide with the target vertical stroke in the character template image;

[0026] Using the character template image as a reference, the character image to be detected is offset by a horizontal offset distance in the horizontal direction and a vertical offset distance in the vertical direction to obtain the target character overlapping image;

[0027] Based on the target character overlap image, a target skeleton line overlap image with overlapping character stroke skeleton lines is obtained.

[0028] Optionally, in the center-aligned image, the required vertical offset distance for the target horizontal stroke in the character image to be detected to coincide with the target horizontal stroke in the character template image is determined, including:

[0029] The first horizontal stroke is searched in the character template image in order from top to bottom and from left to right; the horizontal stroke is represented by a point set P containing multiple points.

[0030] Search for horizontal strokes within the target range of the character image to be detected to obtain a point set Q; the target range is determined based on the coordinate values ​​of the point set P.

[0031] When each pair of points in point set P and point set Q satisfies the first preset condition, the longitudinal offset distance is obtained.

[0032] Optionally, in the target skeleton line overlapping image, determining the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the subclass font includes:

[0033] Obtain all stroke paths in the skeleton line of the character image to be detected;

[0034] Determine the distance between each path point in the stroke path and the corresponding point in the skeleton line of the character template image;

[0035] Based on the dot distance, the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the subclass font is obtained.

[0036] Optionally, determining the point distance between each path point in the stroke path and the corresponding point in the character template image skeleton line includes:

[0037] Obtain a sub-path near the target path point in the stroke path;

[0038] Based on the sub-path, determine the normal function that is perpendicular to the line connecting the first and last ends of the sub-path;

[0039] According to the normal function, within a preset range, when the normal function intersects with the skeleton line of the character template image, the intersection point is determined as the corresponding point of the target path point in the skeleton line of the character template image, and the distance between the intersection point and the target path point is determined as the point distance.

[0040] Within a preset range, when the normal function and the character template image skeleton line do not intersect, the preset value is determined as the dot distance.

[0041] The present invention also provides a device for determining the font type in a text image, comprising:

[0042] The acquisition module is used to acquire the text image to be detected;

[0043] The processing module is used to segment the text image to be detected to obtain character images to be detected; perform image matching operations on the character images to be detected with the corresponding character template images of the class representative fonts of each major category in the character templates to obtain multiple matching similarity values; determine the target font major category to which the character image to be detected belongs based on the maximum matching similarity value among the multiple matching similarity values; perform image stroke alignment between the character image to be detected and the character template images corresponding to each sub-category font in the target font major category, so that the corresponding character stroke skeleton lines in the two images coincide, to obtain a target skeleton line overlapping image; determine the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the sub-category font in the target font major category to which the character image to be detected belongs based on the skeleton line similarity; and determine the target sub-category font in the target font major category to which the character image to be detected belongs based on the skeleton line similarity.

[0044] The present invention also provides a computing device, comprising: a processor and a memory storing a computer program, wherein the computer program, when executed by the processor, performs the method described above.

[0045] The present invention also provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the method described above.

[0046] The above-described solution of the present invention has at least the following beneficial effects:

[0047] The above-described solution of the present invention involves: acquiring a text image to be detected; segmenting the text image to be detected to obtain character images to be detected; performing image matching operations on the character images to be detected with the corresponding character template images of the class representative fonts in each major category of the character templates to obtain multiple matching similarity values; determining the target font major category to which the character image to be detected belongs based on the maximum matching similarity value among the multiple matching similarity values; aligning the character images to be detected with the character template images corresponding to each sub-category font in the target font major category by image strokes, so that the corresponding character stroke skeleton lines in the two images coincide, obtaining a target skeleton line coincident image; determining the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the sub-category font in the target font major category based on the skeleton line similarity; and determining the target sub-category font in the target font major category to which the character image to be detected belongs based on the skeleton line similarity. This method can accurately identify the font of a text image even when the image quality is poor. Attached Figure Description

[0048] Figure 1 This is a flowchart illustrating the method for determining the font type in a text image according to an embodiment of the present invention;

[0049] Figure 2 is the text image to be detected in the embodiment of the present invention;

[0050] Figure 3 is a schematic diagram of the matching between the character image to be detected and the character template image in the embodiment of the present invention;

[0051] Figure 4 is a schematic diagram of character images of four fonts in the Song typeface category in the embodiment of the present invention;

[0052] Figure 5 is a schematic diagram of the matching of the skeleton line structure of the character image in the embodiment of the present invention;

[0053] Figure 6 is a diagram of the skeleton line structure corresponding to the image of the character "世" in the embodiment of the present invention;

[0054] Figure 7 is a schematic diagram of the matching of the character template image in the embodiment of the present invention;

[0055] Figure 8 is a schematic diagram of the matching of the skeleton line structure in the embodiment of the present invention;

[0056] Figure 9 is a schematic diagram of the vertex types of the skeleton lines of the character image in the embodiment of the present invention;

[0057] Figure 10 is a schematic diagram of the intersection types of the skeleton lines of the character image in the embodiment of the present invention;

[0058] <000013\alpha>is a schematic diagram of the structure of the device for determining the font type in the text image in the embodiment of the present invention. Detailed implementation manners

[0059] Hereinafter, the exemplary embodiments of the present invention will be described in more detail with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present invention can be more thoroughly understood and the scope of the present invention can be completely conveyed to those skilled in the art.

[0060] As Figure 1 shown, an embodiment of the present invention provides a method for determining the font type in a text image, including: <00001\beta>

[0061] Step 11, obtaining the text image to be detected;

[0062] Here, the text image to be detected, as Figure 2 shown, includes a passage of text. <00001\alpha>Step 12, segmenting the text image to be detected to obtain the character image to be detected;

[0064] Here, perform optical character image recognition on the text image to be detected, and segment out all Chinese character image regions , where is the circumscribed rectangle of the th Chinese character image region, are respectively the left, right, upper, and lower four boundaries of the circumscribed rectangle, is the number of all Chinese characters. Among all Chinese character images, Chinese character image regions are selected by sampling. Preferably, . The Chinese character image regions are determined as detectable character images.

[0065] Step 13: Perform image matching operations on the detectable character images respectively with the corresponding character template images in the class representative fonts of each major category in the character template, and obtain multiple matching similarity values;

[0066] Here, the character template includes Chinese characters in various fonts. According to the stroke characteristics of character images, common Chinese character characters are classified, and a typical font is selected as the class representative. The stroke styles of Chinese characters between different major font categories in the character template have significant differences, while the topological structures of the character vector contours of different subcategories within the same major category have certain similarities. In this embodiment, the characters in the character template are divided into the following four major categories:

[0067] Fangsong category:

[0068] The Fangsong category includes subcategory fonts such as Fangsong, Founder Fangsong, Founder Official Fangsong, and Fangsong GB2312. Most of these subcategory fonts are evolved based on the Fangsong font structure. The main feature is that the horizontal direction forms a certain angle with the horizontal direction, and the boundaries of the strokes show regular acute or obtuse angles at the starting and ending ends. The class representative is the Fangsong font.

[0069] Kaiti category:

[0070] The Kaiti category includes subcategory fonts such as Kaiti, Founder Kaiti, Founder Official Kaiti, and Kaiti GB2312. Most of these subcategory fonts are evolved based on the Kaiti font. The horizontal and vertical directions form a certain angle with the horizontal and vertical directions, and the boundaries at the starting and ending points of the strokes show a circular arc shape. Moreover, the stroke widths at different positions of the same stroke show certain regular changes. The class representative is the Kaiti font.

[0071] Songti category:

[0072] The Song typeface class includes sub - typefaces such as Song typeface, Founder Book Song, Founder Small - Title Song, and Founder Official Small - Title Song. The characteristics of these sub - typefaces are that the horizontal strokes are straight and the vertical strokes are much wider than the horizontal strokes, and there is a pointed structure at the end of the horizontal strokes. The representative of the class is the Song typeface.

[0073] Black - typeface class:

[0074] The black - typeface class includes sub - typefaces such as black typeface, Microsoft YaHei, PingFang font, Founder Black, and Founder Official Black. Similar to the typefaces in the Song typeface class, the typefaces in the black - typeface class are also horizontal and vertical, but the difference is that the horizontal and vertical widths of the black - typeface class are the same, and the included angle of the stroke boundary is a right angle at both the starting and ending points of the strokes. The representative of the class is the black typeface.

[0075] As Figure 3 shown, taking the character "世" in the character image to be detected as an example, the character image to be detected of the character "世" is respectively image - matched with the character template images of the character "世" of the representative typeface of Fangsong, the representative typeface of regular script, the representative typeface of Song, and the representative typeface of black, to obtain the matching similarity values between the character image to be detected and the Fangsong "世", the regular - script "世", the Song "世", and the black "世".

[0076] Step 14: Determine the target font class to which the character image to be detected belongs according to the maximum matching similarity value among multiple matching similarity values;

[0077] Here, taking Figure 3 (a)-(d) as an example, the matching similarity values between the character image to be detected "世" and the "世" of Fangsong, regular script, Song, and black are 0.715, 0.552, 0.5832, and 0.679 respectively. Then the target font class to which the character image to be detected belongs is the Fangsong class.

[0078] Step 15: Align the strokes of the character image to be detected with the character template images corresponding to each sub - typeface in the target font class, so that the corresponding character stroke skeleton lines in the two images coincide, to obtain the target skeleton - line - coincidence image;

[0079] Here, taking the target font class to which the character image to be detected belongs as the Fangsong class as an example, the Fangsong class includes four sub - typefaces: Fangsong, Founder Fangsong, Fangsong GB2312, and Founder Official Fangsong. The character template images of the character "世" corresponding to Fangsong, Founder Fangsong, Fangsong GB2312, and Founder Official Fangsong are as Figure 4As shown. The character image to be detected is aligned with four character template images respectively. The skeleton lines of the character image to be detected and the skeleton lines of the character template images are extracted from the aligned and overlapping character images to obtain a target skeleton line overlapping image. The target skeleton line overlapping image is shown below. Figure 5 As shown.

[0080] Step 16: In the target skeleton line overlapping image, determine the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the subclass font.

[0081] Step 17: Based on the similarity of the skeleton lines, determine the target subclass font within the target font category to which the character image to be detected belongs.

[0082] In this embodiment, firstly, based on the basic stroke shapes and brushstroke style characteristics of Chinese characters, common Chinese character types are divided into different major categories, and typical fonts are selected as class representatives in each category. Secondly, using a character template image matching method, the similarity between the image of the character to be detected and the corresponding character template image in each class representative is calculated, and the font with the highest similarity value is selected as the major category to which the font type belongs. Then, all font type images in the major category are read, and the skeleton line of each character image and the skeleton line of the image of the character to be detected are calculated. Finally, by sequentially calculating the similarity between the skeleton line of the image of the character to be detected and the skeleton line of each character image, the final font type is determined.

[0083] In an optional embodiment of the present invention, step 13 may include:

[0084] Step 131: Align the character image to be detected with the corresponding character template image in the class representative font of each major category in the character template to obtain a first character image to be detected and multiple first character template images of the same size;

[0085] Here, the skeleton lines of the character image to be detected and the skeleton lines of each character template image are first generated, as shown below. Figure 6 As shown, (a) is from Figure 2 The selected Fangzheng Fangsong fonts are shown in (b) as the character skeleton lines of Fangsong, (c) as the character skeleton lines of Kaiti, (d) as the character skeleton lines of Songti, and (e) as the character skeleton lines of Heiti. Then, following the principle of high consistency, the following are respectively... Figure 6 The skeleton lines in (a) are scaled to match... Figure 6(b)-(e) Scales with equal height. Under the condition of consistent height, the scaled character image corresponding to the skeleton line of the scaled character image to be detected is adjusted to the same size as the character template image. The adjustment method is as follows: align the centers of the two images, then add corresponding white pixels above and below the image with smaller height, and add white pixels to the left and right sides of the image with smaller width. This results in a first character image to be detected and multiple first character template images of the same size.

[0086] Step 132: The first character image to be detected is enlarged or reduced multiple times according to a preset ratio to obtain multiple enlarged or reduced intermediate character images to be detected;

[0087] Here, based on the image scaling of the first character image to be detected with the same image size in step 131, the scaling is performed according to a step size of... Each pixel is used to enlarge or shrink the image of the first character image to be detected. The image scale is enumerated once to obtain 2S images of intermediate characters to be detected, where S is an integer.

[0088] Step 133: Calculate the similarity between the plurality of intermediate character images to be detected and the first character image to be detected and the first character template image respectively to obtain a plurality of intermediate similarities;

[0089] Here, the intermediate similarity between the first character image to be detected and the first character template image of the font representing a certain font category is denoted as . Let the intermediate similarity between the intermediate character image to be detected and the first character template image of the font representing a certain font category be denoted as . .according to and Get the set .

[0090] Step 134: Determine the matching similarity value between the character image to be detected and the character template image in each class representative font based on the maximum value among the multiple intermediate similarities.

[0091] Here, in Select the largest intermediate similarity value and record the scaling scale of the intermediate character image to be detected or the first character image to be detected under that intermediate similarity value.

[0092] In an optional embodiment of the present invention, step 133 may include:

[0093] Step 1331: Slide each of the intermediate character images to be detected and the first character image to be detected on the first character template image according to a preset sliding step size to obtain multiple pause points;

[0094] Step 1332: Based on the normalized correlation coefficients of the intermediate character images to be detected at multiple pause points or the first character image to be detected and the first character template image, multiple intermediate similarities are obtained.

[0095] In this embodiment, as Figure 7 As shown, the image of the intermediate character to be detected and the first image of the character to be detected are denoted as image B, and the first character template image is denoted as image A. When image A slides on image B at a preset step size, the entire range that A can scan is as follows: Figure 7 As shown in the dashed box, the size of its sliding window is the same as the image size M of A. A *N A Let the top-left corner of image B be the origin (0,0). When image A slides to the point where its top-left corner stops at coordinates (u,v), its normalized correlation coefficient is calculated as follows:

[0096] (1)

[0097] Calculate the normalized correlation coefficient between image A and image B when image A slides to its top-left corner at coordinates (u,v). Then, the normalized correlation coefficients between image A and image B are calculated when image A slides to each stopping point; where, Image A slides to coordinates The normalized correlation coefficient between image A and image B at time point B. Image B is located at coordinates The grayscale value of a dot. Image A is located at the coordinates of its upper left corner at the pause point. grayscale value at time Image A is located at the coordinates of its upper left corner at the pause point. grayscale value at time and Image B and image A are respectively placed within the sliding window (i.e. Figure 7 The average gray level of the gray area, i.e. It is the average gray level of image B in the region where it overlaps with image A. It is the average gray level of image A in the region where it overlaps with image B. These are coordinate values.

[0098] When image A slides to each point in image B, a normalized correlation coefficient can be calculated. The maximum value of the normalized correlation coefficient among all points from image A to image B is the intermediate similarity between image A and image B.

[0099] In an optional embodiment of the present invention, step 15 may include:

[0100] Step 151: Align the center of the character image to be detected with the center of the character template image corresponding to each subclass of the target font category to obtain a center-aligned image;

[0101] Step 152: In the center-aligned image, determine the vertical offset distance required to make the character image to be detected coincide with the target horizontal stroke in the character template image.

[0102] Step 153: In the center-aligned image, determine the horizontal offset distance required to make the character image to be detected coincide with the target vertical stroke in the character template image.

[0103] Step 154: Using the character template image as a reference, the character image to be detected is offset by a horizontal offset distance in the horizontal direction and a vertical offset distance in the vertical direction to obtain the target character overlapping image;

[0104] Step 155: Based on the target character overlap image, obtain the target skeleton line overlap image where the character stroke skeleton lines overlap.

[0105] In this embodiment, the center points of the two images are first aligned. Then, corresponding horizontal strokes are searched on both images. Using the position of one horizontal stroke as a reference, the distance between the other horizontal stroke and that horizontal stroke is calculated to determine the vertical offset distance between the images. The unit is pixels. Then, the corresponding vertical strokes are searched on both images respectively. Taking the position of one vertical stroke as a reference, the distance between the other vertical stroke and the first vertical stroke is calculated to determine the horizontal offset distance between the images. The unit is pixels. Finally, using the character template image as a reference, the image of the character to be detected is offset ( , Finally, the two images are aligned to obtain the target character overlapping image. Based on the target character overlapping image, skeleton lines are generated for the character image to be detected and the character template image in the target character overlapping image. The overlap relationship of their skeleton lines is as follows: Figure 8 The image shows the target skeleton lines coinciding.

[0106] In an optional embodiment of the present invention, step 152 may include:

[0107] Step 1521: Search for the first horizontal stroke in the character template image in order from top to bottom and from left to right; the horizontal stroke is represented by a point set P containing multiple points;

[0108] Here, the character template image is scanned from top to bottom and from left to right until a black dot is found. Simultaneously set two variables, both with an initial value of 0. ;

[0109] by Starting from the left and right points, search in both directions to obtain a set of points connected end to end.

[0110] Taking a search to the left as an example, let the currently found point be... It is necessary to Search for the next point on the left: Determine the coordinates. Is it a black dot? If so, then set it as a black dot. Starting from the current point, continue searching for the next point to the left, and record the result. = If not, then in the following point set:

[0111] (2)

[0112] Search for black spots; if one of their coordinates is... If the point is black, then that coordinate point is taken as the current point. Continue searching to the left, while recording... = If there are no black points in the point set, then... Continue searching to the right from the starting point. This represents the vertical fluctuation range of a pixel, in this embodiment... .

[0113] Determine if the set of searched points forms a horizontal stroke:

[0114] Set of points The set of all points found is the point set. All points in the array are arranged in ascending order of their x-coordinates, forming a... ,in For point set The number of points contained. If the following equation (3) holds, the point set can be determined. The stroke that forms it is a horizontal line:

[0115] (3)

[0116] Where L is a threshold, in this embodiment, L is 1 / 4 of the image width. The first condition in (3) ensures that the stroke has a certain length, and the second condition distinguishes horizontal strokes from strokes such as dots and left-falling strokes.

[0117] Step 1522: Search for horizontal strokes within the target range of the character image to be detected to obtain a point set Q; the target range is determined based on the coordinate values ​​of the point set P.

[0118] Here, the corresponding horizontal stroke is searched in the image of the character to be detected. Let... , , , Let x, y, y, and y be the maximum x-coordinate, minimum x-coordinate, maximum y-coordinate, and minimum y-coordinate of all points in the point set P collected from the character template image, respectively. Then, the target range in the character image to be detected is: [ , ], that is, the upper boundary of the horizontal stroke search in the character image to be detected is The lower boundary is The left boundary is The right boundary is . This is a constant, and in this embodiment, it is taken as 1 / 20 of the height of the character template image. Following the method for searching for horizontal strokes in the character template image in step 1521 above, within a specified range in the character image to be detected... , Search for a set of points, let the set of points be... , where t is a point set The number of points contained.

[0119] Step 1523: When each pair of points in the point set P and the point set Q satisfies the first preset condition, the longitudinal offset distance is obtained.

[0120] Here, the first preset condition is: the longitudinal offset distance minimizes the value of the following formula (4):

[0121] , (4)

[0122] in Let be the ordinate of the i-th point in set P. Let be the y-coordinate of the t-th point in set Q. Let x be the x-coordinate of the i-th point in set P. Let x be the x-coordinate of the t-th point in set Q. This represents the longitudinal offset distance.

[0123] To make the horizontal strokes in two images coincide, find all points with the same horizontal coordinate in the point sets of the two horizontal strokes to form a series of point pairs, and offset them vertically by a certain distance. Minimize the absolute value of the sum of the differences in the ordinates of corresponding points in a pair of points.

[0124] Using a similar method, search for vertical strokes in the character image to be detected and the character template image, and calculate the lateral offset distance for alignment between the character image to be detected and the character template image. Finally, the image of the character to be detected is offset ( ).

[0125] In an optional embodiment of the present invention, step 16 may include:

[0126] Step 161: Obtain all stroke paths in the skeleton line of the character image to be detected;

[0127] Here, the connection points between strokes in the character image skeleton line are of the following three types:

[0128] A vertex is the starting or ending point of a branch of a connected skeleton line, and there is only one branch point in its eight neighborhoods centered at that point.

[0129] Intersection point: The point where two non-parallel skeleton line stroke paths intersect. There are at least three branch points in the eight neighborhoods of the skeleton line centered on that point, corresponding to paths in different directions.

[0130] Ordinary point: The remaining pixels on the skeleton line excluding vertices and intersections. Each ordinary point has exactly two branch points in its eight neighborhoods.

[0131] like Figure 9 and Figure 10 The image shown is a magnified schematic diagram of a portion of the skeleton line structure. Figure 9 In the diagram, starting from the gray point, there is only one upward branch; this point is a vertex. Figure 10 In the diagram, starting from the gray point, three branch points can be found. Each branch point can be the starting point of a line segment in a specific direction. Therefore, the point marked in gray is called an intersection point.

[0132] The method for searching all stroke paths in the skeleton line of the character image to be detected is as follows:

[0133] Scan the entire skeleton image until a vertex is found, then use that vertex as the starting point for path searching. During the search, different processing methods are applied depending on the type of vertex found:

[0134] If the currently searched point D is a vertex, it means that the search for the currently connected strokes has been completed. Exit and then proceed to the search for the next connected stroke.

[0135] If the currently searched point D is an intersection point, it means that multiple paths intersect at this point. Select the points adjacent to point D that have not been searched as new starting points and recursively call the search function.

[0136] If the currently searched point D is a normal point, then continue searching for the next point connected to D that has not yet been searched.

[0137] Repeat the above process until all points on the path have been found.

[0138] Step 162: Determine the distance between each path point in the stroke path and the corresponding point in the skeleton line of the character template image;

[0139] Here, a path point in the stroke path is denoted as... The corresponding point in the skeleton line of the character template image is The and The distance between the dots is .but The calculation method is as follows: for any point on the stroke path of the skeleton line of the character image to be detected... Draw a normal line passing through that point and perpendicular to the stroke. If the normal line intersects with a stroke of the character template image skeleton line... Then the distance of the corresponding point is... Right now and The straight-line distance between them.

[0140] Step 163: Based on the dot distance, obtain the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the subclass font.

[0141] Here, the similarity is denoted as Then, based on the distance of the dots Calculate similarity The method is as follows:

[0142] (5)

[0143] in, The number of path points in the skeleton line of the character image to be detected, The allowable error range for skeleton line stroke search, in pixels, is preferred. .

[0144] In an optional embodiment of the present invention, step 162 may include:

[0145] Step 1621: Obtain a sub-path near the target path point in the stroke path;

[0146] Here, all points are traversed along the stroke path in the skeleton line of the character image to be detected. Let the current point be... On the same path, take the AND from both the beginning and the end. The nearest 2 hours' worth of points form the sub-path .like If the path is close to the endpoint of the stroke, then construct a sub-path by taking 2h+1 points starting from the endpoint of the stroke; otherwise, take... h points before and after, plus points This forms a sub-path, with h=5 being the preferred value.

[0147] Step 1622: Based on the sub-path, determine the normal function that is perpendicular to the line connecting the beginning and end of the sub-path;

[0148] Here, the two endpoints of the sub-path are connected by a connecting line. The coordinates of the two endpoints are respectively The slope is ,Right now:

[0149] (6)

[0150] Then point The slope of the normal direction at that point is When the line connecting the first and last ends of a sub-path is a horizontal or vertical line, the point... The corresponding normal at that point is either a vertical line or a horizontal line.

[0151] According to the slope Then the normal function is , Let x be the x-coordinate of any point on the normal. for The corresponding ordinate. Wherein,

[0152]

[0153] Step 1623: According to the normal function, within a preset range, when the normal function intersects with the skeleton line of the character template image, the intersection point is determined as the corresponding point of the target path point in the skeleton line of the character template image, and the distance between the intersection point and the target path point is determined as the point distance.

[0154] Here, based on the stated normal function, with point... Centered on point, along the normal direction at point Calculate at both ends of the path of the normal. The coordinates of the positions of connected discrete pixels, i.e., points Discrete points on the r connected normals in the vicinity.

[0155] Let the set of r discrete points on the normal be denoted as . Then the point set The calculation methods are divided into the following three types:

[0156] like If the x-coordinate is greater than 0, then the corresponding y-coordinate is calculated by incrementing the x-coordinate: the range of the x-coordinate on the normal segment is... For any x-coordinate , corresponding to the vertical axis The calculation method is as follows:

[0157] (7)

[0158] in,

[0159] (8)

[0160] Calculate the coordinates of each pixel Get the strokes A normal segment.

[0161] like > If the value is 0, then the corresponding x-coordinate is calculated by incrementing the y-coordinate: the range of the y-coordinates on the normal segment is... For any ordinate , corresponding to the x-axis The calculation method is as follows:

[0162] (9)

[0163] like The set of points on the normal segment is:

[0164] (10)

[0165] Similarly, when When, the set of points on the normal segment is:

[0166] (11)

[0167] Based on the set of discrete points on the normal line If set There exists a certain point in it. If a point falls exactly on the skeleton line stroke structure of the character template image, then that point is considered to be... This is the intersection point of the normal and the skeleton line of the character template image. and The straight-line distance between the two lines is the distance between the corresponding points of the two skeleton line strokes.

[0168] Step 1624: Within a preset range, when the normal function and the character template image skeleton line do not intersect, the preset value is determined as the dot distance.

[0169] Here, if none of the discrete points on the r connected normals fall on the character template image skeleton line, then the normals have no intersection points with the character template image skeleton line within a preset range. The maximum value r of the preset range is then denoted as point r. The distance between the dots and the corresponding points on the skeleton line of the character template image.

[0170] For all points on the stroke path of the skeleton line in the character image to be detected, the distance to the corresponding point in the skeleton line of the character template image can be obtained using the above method. Finally, the similarity is calculated. The similarity measure between two skeleton line structures is obtained.

[0171] In the above embodiments of the present invention, common Chinese characters are classified according to the stroke features of character images, and typical fonts are selected as class representatives; the font type category of the character image to be detected is determined by the character template image matching method; within the font type category, the similarity between the skeleton line of the character image to be detected and the skeleton line structure of the corresponding character template image of each sub-class font is calculated in turn, and the font with the highest similarity is selected as the final font of the character image to be detected.

[0172] The above embodiments of the present invention employ a method combining coarse-grained image template matching and fine-grained character structure feature matching, resulting in high font type recognition accuracy. By calculating the similarity between character structures based on the distance offset between corresponding pixels along the character image skeleton lines, the calculation speed is fast, the applicability is wider, and high recognition accuracy can be maintained even with poor image quality.

[0173] The method of the present invention will be specifically described below with reference to a specific embodiment.

[0174] Example 1,

[0175] From all Chinese character image regions Selected from In this embodiment, a representative character image is provided. The five character images to be detected are matched with the corresponding character template images in each class representative, and the font type category of the character image to be detected is determined based on the maximum matching similarity value.

[0176] For ease of description, one of the selected Chinese character images to be detected will be denoted as... The corresponding character template images of the representative fonts in the four major categories of Fangsong, Kaiti, Songti, and Heiti are denoted as follows: Generate the selected Chinese characters to be detected. Image regions and corresponding Chinese characters The skeleton line structure of the image region. The skeleton line structure diagram is as follows Figure 6 As shown in (a), The corresponding skeleton line structure diagrams are as follows: Figure 6 (b) Figure 6 (c) Figure 6 as shown in (d) and Figure 6 (e).

[0177] Then, respectively, scale the skeleton line size in (a) to the same height as the skeleton line sizes in Figure 6 (b), Figure 6 (c), Figure 6 (d) and Figure 6 (e) according to the principle of consistent height; and adjust the two images to the same height and width according to the maximum of the height and width of the Chinese character character image to be detected and the character template image corresponding to the skeleton line of the same height. Then, use the template image matching method to calculate the image matching value Figure 6 between the two images of the same size. .

[0178] At the above image scaling scale, respectively, with a step size of pixels, scale the image size corresponding to the skeleton line in Figure 6 (a) larger and smaller for times of image scale enumeration, and calculate the image matching value respectively according to the same method, and obtain .

[0179] Finally, select the largest image matching value in and record the image scaling scale under this image matching value.

[0180] According to the same method as above, calculate the maximum matching similarity values between the character image to be detected and the character template images corresponding to FangSong, KaiTi, SongTi and HeiTi respectively, and select the standard font corresponding to the largest image matching value as the font type category.

[0181] In this embodiment, as Figure 3 shown, the matching effects between the character image to be detected and the character template images corresponding to FangSong, KaiTi, SongTi and HeiTi are respectively as Figure 3 (a)- Figure 3 (d) shown, and their respective image matching values are 0.715, 0.552, 0.5832, 0.679. Therefore, the font type category to which the character image to be detected belongs is the FangSong category.

[0182] ]>Within the font type category, calculate the similarity between the skeleton line of each character image to be detected and the skeleton line of the character template image corresponding to each font in the secondary subtype respectively, and select the font with the largest similarity measure from the calculation results of all font types in the secondary subtype as the finally detected font type.

[0183] For example, for the character "世" in the character image to be detected, the text images of each subtype font in the FangSong category are as​ Figure 4 As shown, among various font structures of the Song typeface, except for the slight difference in stroke width, it is very difficult to visually distinguish specific font categories. According to the method described in this embodiment, after aligning the character image skeleton lines to calculate the similarity, the obtained results are as Figure 5 shown, where the similarities obtained by comparing the font to be detected with four Song typefaces are 0.932, 0.982, 0.853, and 0.954 respectively. From this, it can be determined that the font of the character "世" in the character image to be detected is Founder Song. After performing similarity calculations on each representative character image with all character images of the Song typeface fonts, the average similarity with the character images of Founder Song is the highest. Therefore, as Figure 2 shown, the font type of the text image is determined to be Founder Song.

[0184] As Figure 11 shown, an embodiment of the present invention further provides a device 110 for determining the font type in a text image, including:

[0185] An acquisition module 111, configured to acquire a text image to be detected;

[0186] A processing module 112, configured to segment the text image to be detected to obtain a character image to be detected; perform image matching operations on the character image to be detected with the corresponding character template images in each class representative font in the character template to obtain multiple matching similarity values; determine the target font class to which the character image to be detected belongs according to the maximum matching similarity value among the multiple matching similarity values; align the strokes of the character image to be detected with the character template images corresponding to each subclass font in the target font class, so that the corresponding character stroke skeleton lines in the two images coincide, to obtain a target skeleton line coincidence image; in the target skeleton line coincidence image, determine the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the subclass font; and determine the target subclass font in the target font class to which the character image to be detected belongs according to the similarity of the skeleton lines.

[0187] Optionally, performing image matching operations on the character image to be detected with the corresponding character template images in each class representative font in the character template to obtain multiple matching similarity values includes:

[0188] Aligning the character image to be detected with the corresponding character template images in each class representative font in the character template to obtain a first character image to be detected of the same size and multiple first character template images;

[0189] Performing multiple operations of magnifying or reducing the first character image to be detected according to a preset ratio to obtain multiple intermediate character images to be detected after magnification or reduction;

[0190] The similarity between the plurality of intermediate character images to be detected and the first character image to be detected is calculated with the first character template image to obtain a plurality of intermediate similarities;

[0191] Based on the maximum value among the multiple intermediate similarities, the matching similarity value between the character image to be detected and the character template image in each class representative font is determined.

[0192] Optionally, the similarity between the plurality of intermediate character images to be detected and the first character image to be detected is calculated with the first character template image to obtain a plurality of intermediate similarities, including:

[0193] Each of the intermediate character images to be detected and the first character image to be detected are slid on the first character template image according to a preset sliding step size to obtain multiple pause points;

[0194] Multiple intermediate similarities are obtained based on the normalized correlation coefficients between the intermediate character images to be detected at multiple pause points or between the first character image to be detected and the first character template image.

[0195] Optionally, the character image to be detected is aligned with the character template image corresponding to each subclass of the target font category by image strokes, so that the corresponding character stroke skeleton lines in the two images coincide, to obtain a target skeleton line coincidence image, including:

[0196] Align the center of the character image to be detected with the center of the character template image corresponding to each subclass of the target font category to obtain a center-aligned image;

[0197] In the center-aligned image, determine the vertical offset distance required to make the character image to be detected coincide with the target horizontal stroke in the character template image;

[0198] In the center-aligned image, determine the lateral offset distance required to make the character image to be detected coincide with the target vertical stroke in the character template image;

[0199] Using the character template image as a reference, the character image to be detected is offset by a horizontal offset distance in the horizontal direction and a vertical offset distance in the vertical direction to obtain the target character overlapping image;

[0200] Based on the target character overlap image, a target skeleton line overlap image with overlapping character stroke skeleton lines is obtained.

[0201] Optionally, in the center-aligned image, the required vertical offset distance for the target horizontal stroke in the character image to be detected to coincide with the target horizontal stroke in the character template image is determined, including:

[0202] The first horizontal stroke is searched in the character template image in order from top to bottom and from left to right; the horizontal stroke is represented by a point set P containing multiple points.

[0203] Search for horizontal strokes within the target range of the character image to be detected to obtain a point set Q; the target range is determined based on the coordinate values ​​of the point set P.

[0204] When each pair of points in point set P and point set Q satisfies the first preset condition, the longitudinal offset distance is obtained.

[0205] Optionally, in the target skeleton line overlapping image, determining the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the subclass font includes:

[0206] Obtain all stroke paths in the skeleton line of the character image to be detected;

[0207] Determine the distance between each path point in the stroke path and the corresponding point in the skeleton line of the character template image;

[0208] Based on the dot distance, the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the subclass font is obtained.

[0209] Optionally, determining the point distance between each path point in the stroke path and the corresponding point in the character template image skeleton line includes:

[0210] Obtain a sub-path near the target path point in the stroke path;

[0211] Based on the sub-path, determine the normal function that is perpendicular to the line connecting the first and last ends of the sub-path;

[0212] According to the normal function, within a preset range, when the normal function intersects with the skeleton line of the character template image, the intersection point is determined as the corresponding point of the target path point in the skeleton line of the character template image, and the distance between the intersection point and the target path point is determined as the point distance.

[0213] Within a preset range, when the normal function and the character template image skeleton line do not intersect, the preset value is determined as the dot distance.

[0214] It should be noted that this device is the same as the method described above. All implementations in the above method embodiments are applicable to the embodiments of this device and can achieve the same technical effect.

[0215] Embodiments of the present invention also provide a computing device, including: a processor and a memory storing a computer program, wherein the computer program, when executed by the processor, performs the method as described above. All implementations in the above method embodiments are applicable to this embodiment and can achieve the same technical effects.

[0216] Embodiments of the present invention also provide a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the method as described above. All implementations in the above method embodiments are applicable to this embodiment and can achieve the same technical effects.

[0217] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0218] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0219] In the embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0220] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0221] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0222] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0223] Furthermore, it should be noted that in the apparatus and method of the present invention, it is obvious that the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered equivalent solutions of the present invention. Moreover, the steps performing the above series of processes can naturally be executed in the order described, but are not necessarily required to be executed in chronological order; some steps can be executed in parallel or independently of each other. Those skilled in the art will understand that all or any step or component of the method and apparatus of the present invention can be implemented in any computing device (including processors, storage media, etc.) or network of computing devices, in hardware, firmware, software, or a combination thereof. This is something that those skilled in the art can achieve by using their basic programming skills after reading the description of the present invention.

[0224] Therefore, the object of the present invention can also be achieved by running a program or a set of programs on any computing device. The computing device can be a known general-purpose device. Therefore, the object of the present invention can also be achieved simply by providing a program product containing program code implementing the method or apparatus. That is, such a program product also constitutes the present invention, and the storage medium storing such a program product also constitutes the present invention. Obviously, the storage medium can be any known storage medium or any storage medium developed in the future. It should also be noted that in the apparatus and method of the present invention, it is obvious that the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered equivalent to the present invention. Furthermore, the steps performing the above series of processes can naturally be performed in the order described, but are not necessarily required to be performed in chronological order. Some steps can be performed in parallel or independently of each other.

[0225] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for determining the font type in a text image, characterized in that, include: Obtain the image of the text to be detected; The text image to be detected is segmented to obtain the character image to be detected; The image of the character to be detected is matched with the corresponding character template image in the class representative font of each major category in the character template to obtain multiple matching similarity values; The target font category to which the character image to be detected belongs is determined based on the maximum matching similarity value among multiple matching similarity values; The character image to be detected is aligned with the character template image corresponding to each subclass of the target font category by means of the image strokes, so that the corresponding character stroke skeleton lines in the two images coincide, and the target skeleton line coincidence image is obtained. In the target skeleton line overlapping image, determine the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the subclass font; Based on the similarity of the skeleton lines, the target subclass font within the target font category to which the character image to be detected belongs is determined.

2. The method for determining the font type in a text image according to claim 1, characterized in that, The image of the character to be detected is matched with the corresponding character template image in the class representative font of each major category in the character template to obtain multiple matching similarity values, including: The character image to be detected is aligned with the corresponding character template image in the class representative font of each major category in the character template to obtain a first character image to be detected and multiple first character template images of the same size; The first character image to be detected is enlarged or reduced multiple times according to a preset ratio to obtain multiple enlarged or reduced intermediate character images to be detected. The similarity between the plurality of intermediate character images to be detected and the first character image to be detected is calculated with the first character template image to obtain a plurality of intermediate similarities; Based on the maximum value among the multiple intermediate similarities, the matching similarity value between the character image to be detected and the character template image in each class representative font is determined.

3. The method for determining the font type in a text image according to claim 2, characterized in that, The similarity scores of the plurality of intermediate character images to be detected and the first character image to be detected are calculated with the first character template image to obtain a plurality of intermediate similarities, including: For each intermediate character image to be detected and the first character image to be detected, slide the intermediate character image to be detected or the first character image to be detected on the first character template image according to a preset sliding step size to obtain multiple pause points; Based on the normalized correlation coefficients between the intermediate character image to be detected or the first character image to be detected and the first character template image at multiple pause points, the intermediate similarity between the intermediate character image or the first character image to be detected and the first character template image is determined; then the intermediate similarity between each intermediate character image to be detected and the first character image to be detected and the first character template image is obtained.

4. The method for determining the font type in a text image according to claim 1, characterized in that, The character image to be detected is aligned with the character template image corresponding to each subclass of the target font category by stroke alignment, so that the corresponding character stroke skeleton lines in the two images coincide, resulting in a target skeleton line aligned image, including: Align the center of the character image to be detected with the center of the character template image corresponding to each subclass of the target font category to obtain a center-aligned image; In the center-aligned image, determine the vertical offset distance required to make the character image to be detected coincide with the target horizontal stroke in the character template image; In the center-aligned image, determine the lateral offset distance required to make the character image to be detected coincide with the target vertical stroke in the character template image; Using the character template image as a reference, the character image to be detected is offset by a horizontal offset distance in the horizontal direction and a vertical offset distance in the vertical direction to obtain the target character overlapping image; Based on the target character overlap image, a target skeleton line overlap image with overlapping character stroke skeleton lines is obtained.

5. The method for determining the font type in a text image according to claim 4, characterized in that, In the center-aligned image, the required vertical offset distance to make the target horizontal stroke in the character image to be detected coincide with the target horizontal stroke in the character template image is determined, including: The first horizontal stroke is searched in the character template image in order from top to bottom and from left to right; the horizontal stroke is represented by a point set P containing multiple points. Search for horizontal strokes within the target range of the character image to be detected to obtain a point set Q; the target range is determined based on the coordinate values ​​of the point set P. When each pair of points in point set P and point set Q satisfies the first preset condition, the longitudinal offset distance is obtained.

6. The method for determining the font type in a text image according to claim 1, characterized in that, In the target skeleton line overlapping image, determining the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the subclass font includes: Obtain all stroke paths in the skeleton line of the character image to be detected; Determine the distance between each path point in the stroke path and the corresponding point in the skeleton line of the character template image; Based on the dot distance, the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the subclass font is obtained.

7. The method for determining the font type in a text image according to claim 6, characterized in that, Determining the distance between each path point in the stroke path and the corresponding point in the character template image skeleton line includes: Obtain a sub-path near the target path point in the stroke path; Based on the sub-path, determine the normal function that is perpendicular to the line connecting the first and last ends of the sub-path; According to the normal function, within a preset range, when the normal function intersects with the skeleton line of the character template image, the intersection point is determined as the corresponding point of the target path point in the skeleton line of the character template image, and the distance between the intersection point and the target path point is determined as the point distance. Within a preset range, when the normal function and the character template image skeleton line do not intersect, the preset value is determined as the dot distance.

8. A device for determining the font type in a text image, characterized in that, include: The acquisition module is used to acquire the text image to be detected; The processing module is used to segment the text image to be detected to obtain the character image to be detected; The image of the character to be detected is matched with the corresponding character template image in the class representative font of each major category in the character template to obtain multiple matching similarity values; The target font category to which the character image to be detected belongs is determined based on the maximum matching similarity value among multiple matching similarity values; The character image to be detected is aligned with the character template image corresponding to each sub-class font in the target font category by stroke alignment, so that the corresponding character stroke skeleton lines in the two images coincide, resulting in a target skeleton line coincidence image; in the target skeleton line coincidence image, the similarity between the skeleton line of the character image to be detected and the skeleton line of the character template image corresponding to the sub-class font is determined; based on the similarity of the skeleton lines, the target sub-class font in the target font category to which the character image to be detected belongs is determined.

9. A computing device, characterized in that, include: A processor, a memory storing a computer program, wherein the computer program, when executed by the processor, performs the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, A storage instruction that, when executed on a computer, causes the computer to perform the method as described in any one of claims 1 to 7.