A geometric feature calculation method and recognition method and device for text primitives

The geometric characteristics are determined by generating the convex polygon of the text map, and the problem of limited text structure and applicability of traditional methods relying on text structure and limited applicability.

CN112507938BActive Publication Date: 2025-01-24GLODON CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011492328.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-16
Publication Date
2025-01-24
Estimated Expiration
2040-12-16

AI Technical Summary

Technical Problem

The traditional geometric feature calculation method of text primitives relies on language and text structure and is only suitable for simple text primitives. The calculation accuracy is not high, resulting in the accuracy of the recognition of drawings that cannot be guaranteed.

Method used

By obtaining the text line collection of the target text graphic, it traverses and stores the starting point and end point of the text line to form a two -dimensional point set. Based on the two -dimensional point collection to generate the convex polygon corresponding to the target text graph, then its geometric characteristics are determined.

Benefits of technology

This method does not depend on the structure of the text. It is suitable for a variety of scenarios and complex text graphics, which improves the accuracy of the geometric characteristics of the text graphic, and then improves the accuracy of drawing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112507938B_ABST
    Figure CN112507938B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for calculating geometric features of text primitives and a method and device for recognizing them, wherein the method for calculating geometric features of text primitives includes: obtaining a text line set of a target text primitive; traversing all text lines in the text line set, storing the starting points and end points of all text lines, and forming a two-dimensional point set; generating a convex polygon corresponding to the target text primitive based on the two-dimensional point set; and determining the geometric features of the target text primitive according to the convex polygon corresponding to the target text primitive. The present invention determines the two-dimensional point set by the endpoint coordinates of all text lines in the text line set, and then determines the bounding box of the target text primitive, and then determines the geometric features of the target text primitive using the bounding box and the endpoint coordinates of the text line; the calculation method does not depend on the structure of the text, and can be applied to a variety of scenarios and complex text primitives, thereby ensuring the accuracy of calculating the geometric features of the text primitives, and further improving the recognition accuracy of the drawings.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of text data processing, and in particular to a geometric feature calculation method and recognition method and device for text primitives. Background Art

[0002] With the development of information technology, the demand for computer-aided image recognition is increasing. In the process of drawing, a certain geometric position relationship will be set between line primitives and text primitives. In the process of drawing recognition, the geometric position relationship between line primitives and text primitives will be used, or based on the direction of text primitives, the recognition accuracy will be improved. However, in the process of importing drawings, text primitives will be broken up into text lines and text information cannot be directly obtained. In order to facilitate recognition, text lines need to be restored to text primitives. However, the restoration of text primitives depends on their geometric features, such as the bounding box, insertion point, direction and size of text primitives. The traditional method of calculating the geometric features of text primitives not only depends on the language structure, but is also only applicable to simple text primitives. It can only roughly calculate geometric features with low accuracy, which leads to the inability to guarantee the recognition accuracy of drawings. Summary of the invention

[0003] In view of this, an embodiment of the present invention provides a text primitive geometric feature calculation method and recognition method and device, which solves the problem that the traditional text primitive geometric feature calculation method depends on the language and text structure and is only applicable to simple text primitives.

[0004] According to a first aspect, an embodiment of the present invention provides a method for calculating geometric features of a text primitive, comprising:

[0005] Get the text line set of the target text primitive;

[0006] Traversing all the text lines in the text line set, storing the starting points and end points of all the text lines, and forming a two-dimensional point set;

[0007] Generate a convex polygon corresponding to the target text primitive based on the two-dimensional point set;

[0008] The geometric features of the target text primitive are determined according to the convex polygon corresponding to the target text primitive.

[0009] The method for calculating the geometric features of text primitives provided in an embodiment of the present invention determines a two-dimensional point set through the endpoint coordinates of all text lines in a text line set, and then determines the bounding box of a target text primitive, and then uses the bounding box and the endpoint coordinates of the text lines to determine the geometric features of the target text primitive; the calculation method is independent of the structure of the text, and can be applied to a variety of scenarios and complex text primitives, thereby ensuring the accuracy of calculating the geometric features of text primitives and further improving the recognition accuracy of drawings.

[0010] In combination with the first aspect, in a first implementation of the first aspect, determining the geometric features of the target text primitive according to the convex polygon corresponding to the target text primitive includes:

[0011] Determine the bounding box of the target text primitive based on each vertex of the convex polygon and the direction of the edge corresponding to each vertex;

[0012] The direction, insertion point and size of the target text primitive are determined according to the bounding box of the target text primitive.

[0013] The method for calculating the geometric features of text primitives provided in an embodiment of the present invention determines the bounding box of the target text primitive through the vertices of the convex polygon and the directions of the edges corresponding to the vertices, and then determines the direction, insertion point and size of the target text primitive, thereby ensuring the calculation accuracy of the geometric features of the text primitives and improving the calculation efficiency.

[0014] In combination with the first implementation of the first aspect, in the second implementation of the first aspect, determining the bounding box of the target text primitive based on each vertex of the convex polygon and the direction of the edge corresponding to each vertex includes:

[0015] Based on each vertex of the convex polygon and the direction of the side corresponding to each vertex, construct a circumscribed rectangular outline of the convex polygon;

[0016] The areas of the circumscribed rectangular contours of the convex polygon are compared to determine the bounding box of the target text primitive.

[0017] The method for calculating the geometric features of text primitives provided in an embodiment of the present invention utilizes the coordinates of each point in a two-dimensional point set to generate a convex polygon corresponding to a target text primitive, and then constructs a circumscribed rectangular outline of the convex polygon, and determines the bounding box of the target text primitive by comparing the areas of the circumscribed rectangular outlines; and then uses the bounding box to assist in identifying the geometric features of the target text primitive.

[0018] In combination with the second implementation of the first aspect, in the third implementation of the first aspect, constructing the circumscribed rectangular outline of the convex polygon based on each vertex of the convex polygon and the direction of the side corresponding to each vertex includes:

[0019] Each vertex is taken as a starting point, and the direction of the edge corresponding to the starting point is taken as a starting direction;

[0020] Based on each vertex of the convex polygon, the starting point and the starting direction, a circumscribed rectangular outline corresponding to the convex polygon is constructed respectively, and a mapping relationship between the starting point and the starting direction and the circumscribed rectangular outline is recorded.

[0021] The method for calculating the geometric features of text primitives provided in an embodiment of the present invention determines multiple circumscribed rectangular contours using different starting directions, and saves the mapping relationship between the starting point and the starting direction and the circumscribed rectangular contour, so as to facilitate the determination of the direction through the circumscribed rectangular contour, thereby ensuring the simplicity of calculating the area and geometric features of the target text primitive.

[0022] In combination with the third implementation manner of the first aspect, in the fourth implementation manner of the first aspect, comparing the areas of the circumscribed rectangular outlines of the convex polygon to determine the bounding box of the target text primitive includes:

[0023] Comparing the areas of the circumscribed rectangular contours of the convex polygon, determining the circumscribed rectangular contour with the smallest area, so as to obtain a target circumscribed rectangular contour;

[0024] Determine a corresponding mapping relationship according to the target circumscribed rectangular outline;

[0025] The bounding box of the target text primitive is determined by using the mapping relationship and the coordinates of each point in the two-dimensional point set.

[0026] The method for calculating the geometric features of a text primitive provided in an embodiment of the present invention determines the circumscribed rectangular contour with the smallest area among multiple circumscribed rectangular contours as the target circumscribed rectangular contour, and obtains a corresponding mapping relationship, which is convenient for determining the direction through the circumscribed rectangular contour, thereby ensuring the simplicity of calculating the area and geometric features of the target text primitive.

[0027] In combination with the fourth implementation of the first aspect, in the fifth implementation of the first aspect, determining the bounding box of the target text primitive by using the mapping relationship and the coordinates of each point in the two-dimensional point set includes:

[0028] Establishing a local coordinate system with the starting point in the mapping relationship as the origin and the starting direction as the axis;

[0029] Based on the coordinates of each point in the two-dimensional point set, each vertex of the corresponding circumscribed rectangular outline is converted to a local coordinate system to determine the local coordinates of each vertex of the circumscribed rectangular outline;

[0030] The bounding box of the target text primitive is determined according to each local coordinate.

[0031] The method for calculating the geometric features of text primitives provided in an embodiment of the present invention determines the bounding box in the local coordinate system, thereby ensuring the convenience of calculating the area of ​​the circumscribed rectangular outline, and converts each local coordinate into the world coordinate system to determine the bounding box of the target text primitive, which helps to calculate the geometric features of the text primitives.

[0032] In combination with the first implementation of the first aspect, in a sixth implementation of the first aspect, the text line set further includes an index of each of the text lines, the index is used to indicate a writing order of each of the text lines, and determining the direction, insertion point, and size of the target text primitive according to the bounding box of the target text primitive includes:

[0033] Determine the start and end points of the target text primitive using the endpoint coordinates of all text lines in the text set and the index of the text line;

[0034] Determine the initial text direction using the starting point and the end point of the target text primitive;

[0035] Based on the initial text direction and the bounding box of the target text primitive, the direction, insertion point and size of the target text primitive are determined.

[0036] The method for calculating the geometric features of text primitives provided in an embodiment of the present invention uses the endpoint coordinates of a text line and the index of the text line to determine the starting point and end point of a target text primitive, and further determines the initial text direction, so as to calculate the geometric features of the target text primitive.

[0037] In combination with the sixth implementation of the first aspect, in the seventh implementation of the first aspect, determining the direction, insertion point, and size of the target text primitive based on the initial text direction and the bounding box of the target text primitive includes:

[0038] Convert each vertex of the bounding box of the target text primitive to the world coordinate system to determine the side length and center point of the target circumscribed rectangular outline;

[0039] Based on the respective sides of the target circumscribed rectangular outline, four auxiliary directions corresponding to the respective sides are determined;

[0040] Determine the angles between each auxiliary direction and the initial text direction, and determine the auxiliary direction with the smallest angle as the direction of the target text primitive;

[0041] Determine the insertion point of the target text primitive based on the center point of the target circumscribed rectangular outline;

[0042] The size of the target text primitive is determined according to the direction of the target text primitive and the side length of the target circumscribed rectangular outline.

[0043] The method for calculating the geometric features of a text primitive provided by an embodiment of the present invention determines the geometric features of the text primitive, the direction, insertion point and size of the target text primitive by determining a bounding box and utilizing the features of the bounding box and a two-dimensional point set.

[0044] In combination with the first aspect, in an eighth implementation of the first aspect, traversing all the text lines in the text line set, storing the start points and end points of all the text lines, and forming a two-dimensional point set, includes:

[0045] All the text lines in the text line set are traversed to determine the endpoint coordinates of the start points and end points of all the text lines, and duplicate endpoints are screened to determine the two-dimensional point set of the target text primitive.

[0046] The geometric feature calculation method of the text primitive provided by the embodiment of the present invention ensures the accuracy and uniqueness of the two-dimensional point set by screening repeated endpoints, thereby ensuring the calculation efficiency and accuracy of the geometric features.

[0047] According to a second aspect, an embodiment of the present invention provides a method for recognizing text primitives, the method comprising:

[0048] Determine the geometric features of the text primitive based on the method for calculating the geometric features of the text primitive described in the first aspect or any one of the embodiments of the first aspect;

[0049] The text primitives are subjected to text recognition using the geometric features of the text primitives to determine a recognition result.

[0050] The text primitive recognition method provided by the embodiment of the present invention utilizes the geometric features of the text primitives to perform text recognition on the text primitives, thereby ensuring the accuracy of the final recognition result.

[0051] According to a third aspect, an embodiment of the present invention provides a device for calculating geometric features of a text primitive, comprising:

[0052] A first processing module is used to obtain a text line set of a target text primitive;

[0053] A second processing module is used to traverse all the text lines in the text line set, store the starting points and end points of all the text lines, and form a two-dimensional point set;

[0054] A third processing module, used for generating a convex polygon corresponding to the target text primitive based on the two-dimensional point set;

[0055] The fourth processing module is used to determine the geometric features of the target text primitive according to the convex polygon corresponding to the target text primitive.

[0056] According to a fourth aspect, an embodiment of the present invention provides a text primitive recognition device, comprising:

[0057] A geometric feature determination module, used to determine the geometric features of the text primitives based on the geometric feature calculation device of the text primitives described in the third aspect;

[0058] The recognition module is used to perform text recognition on the text primitives by using the geometric features of the text primitives and determine the recognition results.

[0059] According to the fifth aspect, an embodiment of the present invention provides an electronic device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to execute the method for calculating geometric features of text primitives described in the first aspect or any one of the embodiments of the first aspect, or executing the method for recognizing text primitives described in the second aspect.

[0060] According to the sixth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute the method for calculating geometric features of text primitives described in the first aspect or any one of the embodiments of the first aspect, or execute the method for recognizing text primitives described in the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0062] Figure 1 is a flow chart of a method for calculating geometric features of text primitives according to an embodiment of the present invention;

[0063] Figure 2 is a schematic diagram of a text line set of a text primitive according to an embodiment of the present invention;

[0064] Figure 3 is a schematic diagram of specific text line set numbering of a text primitive according to an embodiment of the present invention;

[0065] Figure 4 is a schematic diagram of a two-dimensional point set according to an embodiment of the present invention;

[0066] Figure 5 is a flow chart of determining a bounding box of a target text primitive according to a preferred embodiment of the present invention;

[0067] Figure 6 is a schematic diagram of the Jarvis stepping method according to an embodiment of the present invention;

[0068] Figure 7 is a schematic diagram of a convex polygon of a two-dimensional point set according to an embodiment of the present invention;

[0069] Figure 8 is a schematic diagram of a circumscribed rectangular outline of a convex polygon according to an embodiment of the present invention;

[0070] Fig. 9 is a schematic diagram of determining an index order of text primitives according to an embodiment of the present invention;

[0071] Fig.10 is a schematic diagram of determining geometric features of a specific text primitive according to an embodiment of the present invention;

[0072] Fig.11 is a schematic diagram of a bounding box of a text primitive according to an embodiment of the present invention;

[0073] Fig.12 is a flow chart of forming a two-dimensional point set according to a preferred embodiment of the present invention;

[0074] Fig.13 is a flow chart of a text primitive recognition method according to an embodiment of the present invention;

[0075] Fig.14 is a schematic diagram of a geometric feature calculation device for a text primitive according to an embodiment of the present invention;

[0076] Fig.15 is a schematic diagram of a text primitive recognition device according to an embodiment of the present invention;

[0077] Fig.16 It is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0078] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0079] The geometric feature calculation method for text primitives provided by the embodiments of the present invention can be applied to the geometric feature calculation and recognition of municipal quantity calculation drawings such as PDF drawings, and can also be applied to the recognition of other types of drawings, such as DWG or other CAD drawings. In the present invention, no restrictions are imposed on the specific application scenarios of the geometric feature calculation method for text primitives. In the following description, the geometric features of PDF drawings are taken as an example for detailed description.

[0080] Architectural engineering drawings mainly consist of two-dimensional vector PDF drawings. Due to the limitations of line descriptions, each drawing also contains annotations and related text descriptions. Among them, the lines mainly describe the geometric shapes of objects, and the text is used to describe the geometric parameters and related attributes of objects, enabling a comprehensive expression of the objects. Two-dimensional vector PDF drawings have the characteristics of simple drawing and convenient printing and dissemination, and are widely used in the engineering field. When users draw drawings, they will set certain geometric positional relationships between line primitives and text primitives, such as parallel, perpendicular, overlapping, distance, etc. When the program recognizes, it will use the geometric positional relationships between line primitives and text primitives to improve the recognition accuracy.

[0081] Currently, in order to prevent the original drawings from being tampered with, CAD software (AutoCAD software) is usually used to convert the original drawings into PDF drawings, and then the business data of the converted drawings is recognized. During the conversion process, the text in the original drawings will be scattered and converted into geometric graphics to form a set of two-dimensional line segments (a set of text lines). Since the text in the drawings is scattered, the text information cannot be directly obtained. For the recognition of text, the geometric features of the text help to assist the recognition algorithm to improve the accuracy of text recognition. Traditionally, for the calculation of the geometric features of vector map PDF text lines, the following several methods are commonly used:

[0082] Text direction: Depending on the language text structure (such as the upper-lower structure "学" and left-right structure "旧" in Chinese characters), multiple directions are calculated based on multiple sets of text lines, and then the average value is taken.

[0083] Text size / text insertion point: The bounding boxes of each text line in the world coordinates are merged to obtain the bounding box of the overall text line. min(length of the bounding box, width of the bounding box) is regarded as the text size, and the center point of the bounding box is regarded as the insertion point of the text.

[0084] Among them, the traditional methods can only roughly calculate the geometric features of text lines, and the accuracy is not high: compared with the text lines in the original drawings, there are deviations in the text direction, size, and insertion point, and the calculation of the geometric features of texts in different countries needs to be implemented separately. Therefore, the text lines cannot be accurately converted into CAD text primitives.

[0085] According to an embodiment of the present invention, an embodiment of a method for calculating the geometric features of text primitives is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0086] In this embodiment, a method for calculating geometric features of text primitives is provided, which can be used in electronic devices such as computers, mobile phones, tablet computers, etc. Figure 1 is a flow chart of a method for calculating geometric features of text primitives according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:

[0087] S11, obtaining a text line set of a target text primitive.

[0088] The text line set includes all text lines of the target text primitive. When the drawing is input into the existing CAD software, the target text primitive in the drawing is broken up into an ordered text line set. For example, the annotation information (text primitive) of a primitive in the drawing is "CH.0+850". Figure 2 As shown in FIG. 1 , the text primitive “CH.0+850” is broken up into text lines, and all the text lines are grouped into a text line set. The text lines formed by “C” in the text are as follows: Figure 3 As shown, "C" forms 17 line segments, each with a corresponding number, some of which are omitted in the figure. The text line set of the text primitive can be obtained according to the writing direction.

[0089] The text line set of the target text primitive can be directly acquired by the electronic device from the outside world, or it can be acquired by using a text line acquisition device in the electronic device. There is no restriction on the way in which the electronic device acquires the text line set of the target text primitive. It is only necessary to ensure that the electronic device can acquire the text line set of the target text primitive.

[0090] S12, traversing all the text lines in the text line set, storing the starting points and end points of all the text lines, and forming a two-dimensional point set.

[0091] After the electronic device obtains the text line set in the above S11, it traverses the text line set and uses the endpoint coordinates of all the text lines in the text line set to store the endpoints of each text line in a two-dimensional point set. For example, "CH" in the text primitive is Figure 4 In this embodiment, only "CH" is used as an example to illustrate the formation process of the two-dimensional point set. In actual applications, it is only necessary to store the endpoint coordinates of all text lines, and this embodiment is not limited to this.

[0092] S13, generating a convex polygon corresponding to the target text primitive based on the two-dimensional point set.

[0093] Based on the coordinates of each point in the formed two-dimensional point set, the smallest convex polygon corresponding to the target text primitive that can just surround the two-dimensional point set is determined, that is, all the outermost points in the two-dimensional point set are connected into lines to form a convex polygon.

[0094] S14, determining the geometric features of the target text primitive according to the convex polygon corresponding to the target text primitive.

[0095] The geometric features of the target text primitive are determined by combining the convex polygon corresponding to the target text primitive and the endpoint coordinates of all text lines in the text line set. Therefore, the above geometric features can be used to improve the accuracy of text recognition, support multi-language, and efficiently calculate the geometric features of text lines, solving the problem of low accuracy of geometric features of text lines in two-dimensional vector PDF drawings.

[0096] The method for calculating the geometric features of text primitives provided in this embodiment determines a two-dimensional point set through the endpoint coordinates of all text lines in a text line set, and then determines the bounding box of the target text primitive, and then uses the bounding box and the endpoint coordinates of the text lines to determine the geometric features of the target text primitive; the calculation method does not depend on the structure of the text, and can be applied to a variety of scenarios and complex text primitives, thereby ensuring the accuracy of calculating the geometric features of text primitives and further improving the recognition accuracy of drawings.

[0097] In this embodiment, a method for calculating geometric features of text primitives is provided. Figure 5 is a flow chart of a method for calculating geometric features of text primitives according to an embodiment of the present invention. Figure 5 As shown, the process includes the following steps:

[0098] S21, obtaining a text line set of a target text primitive.

[0099] For details, please see Figure 1 S11 of the illustrated embodiment will not be described in detail here.

[0100] S22, traverse all the text lines in the text line set, store the starting points and end points of all the text lines, and form a two-dimensional point set.

[0101] For details, please see Figure 1 S12 of the illustrated embodiment will not be described in detail here.

[0102] S23, generating a convex polygon corresponding to the target text primitive based on the two-dimensional point set.

[0103] Using the coordinates of each point in the two-dimensional point set, the Jarvis stepping method can be used to calculate the convex polygon of the two-dimensional point set, and then generate the convex polygon corresponding to the target text primitive. This embodiment only illustrates the use of the Jarvis stepping method to calculate the convex polygon. In practical applications, other methods can be selected according to actual needs, such as the Graham scanning method. This embodiment is not limited to this.

[0104] Since the Jarvis stepping method has low complexity, complexity O(nH), H is the number of points; and is simple to implement, the present embodiment selects the Jarvis stepping method to calculate the convex polygon, where Figure 6 As shown, the Jarvis stepping method algorithm is as follows:

[0105] a. First find the point with the smallest ordinate p0 (if there are multiple points with the smallest ordinate, then find the point with the smallest abscissa among these points, that is, the point in the lower left corner of the point set) and put it into the stack, then traverse the remaining points and find the point p1 with the smallest angle with the horizontal direction and put it into the stack;

[0106] b. Traverse all points and find the point pn with the smallest angle with the line connecting the two top points of the stack (if the angles of the two points are equal, choose the farthest point) and put it into the stack. Repeat this process until the next pn cannot be found;

[0107] c. All the points in the stack are points on the convex polygon, thus a convex polygon can be formed.

[0108] The meaning of a convex polygon is that it needs to completely contain all the points on the left and right of the two-dimensional point set. Therefore, in practical applications, any achievable algorithm can be selected as long as it can form a convex polygon. Taking the above text primitives as a column, the convex polygon formed is as follows Figure 7 shown.

[0109] S24, determining the geometric features of the target text primitive according to the bounding box of the target text primitive and the endpoint coordinates of all text lines in the text line set.

[0110] Specifically, as an optional implementation of this embodiment, the above S24 may include the following steps:

[0111] S241, determining a bounding box of a target text primitive based on each vertex of the convex polygon and the direction of the edge corresponding to each vertex.

[0112] The bounding box of the target text primitive is determined by the vertices of the convex polygon and the directions of the edges corresponding to each vertex. The bounding box is the optimal enclosing space for solving a discrete point set. The basic idea is to use a geometric body (called a bounding box) with a slightly larger volume and simpler characteristics to approximate complex geometric objects.

[0113] S242, determining the direction, insertion point and size of the target text primitive according to the bounding box of the target text primitive.

[0114] Specifically, the above S241 also includes:

[0115] S2411, constructing a circumscribed rectangular outline of the convex polygon based on each vertex of the convex polygon and the direction of the side corresponding to each vertex.

[0116] After the convex polygon is determined, the circumscribed rectangular outline of the corresponding convex polygon can be constructed based on the vertices of the convex polygon and the directions of the sides corresponding to the vertices. The implementation steps of constructing the circumscribed rectangular outline will be specifically described below.

[0117] S2412, comparing the areas of the circumscribed rectangular contours of the convex polygon to determine the bounding box of the target text primitive.

[0118] After constructing the circumscribed rectangular contours of the convex polygon, the area of ​​each circumscribed rectangular contour can be determined, wherein the area of ​​the circumscribed rectangular contour is calculated using existing technology. As long as the area of ​​the circumscribed rectangular contour can be solved, this embodiment is not limited to this.

[0119] As an optional implementation of this embodiment, the above S2411 may include the following steps:

[0120] (1) Take each vertex as the starting point and the direction of the edge corresponding to the starting point as the starting direction.

[0121] For ease of understanding, this embodiment illustrates the process of forming the circumscribed rectangular outline of a convex polygon. Figure 8 As shown, first determine the starting point and starting direction of the convex polygon. Each side of the convex polygon can be used as the starting direction, and the point where the line segment of the starting direction starts can be used as the starting point.

[0122] It should be noted that this embodiment only takes the formation of one circumscribed rectangular outline as an example for description, and other circumscribed rectangular outlines are all formed according to this method, and the present invention is not limited thereto.

[0123] (2) Based on the vertices, starting point and starting direction of the convex polygon, the circumscribed rectangular contour corresponding to the convex polygon is constructed respectively, and the mapping relationship between the starting point and the starting direction and the circumscribed rectangular contour is recorded.

[0124] Based on the vertices, starting point and starting direction of the convex polygon, the circumscribed rectangular contour corresponding to the convex polygon is constructed respectively, and the mapping relationship between the starting point and starting direction and the circumscribed rectangular contour is recorded, wherein the mapping relationship is to associate the starting point and starting direction of the current circumscribed rectangular contour with the circumscribed rectangular contour. Figure 8As shown, taking a starting point and a starting direction as an example, for a side a of a convex polygon, its starting point and starting direction are shown in the figure, then at least three points need to be determined to obtain the corresponding circumscribed rectangular outline. Determine the rightmost point, leftmost point, and farthest point of side a relative to the starting point, and then use the starting direction as a reference to determine the circumscribed rectangular outline.

[0125] It should be noted that this embodiment only takes side a as an example. The method for determining the circumscribed rectangular outline using other sides of the convex polygon is the same as described above and will not be repeated here. Therefore, the circumscribed rectangular outline corresponding to each side of the convex polygon can be determined.

[0126] Specifically, the above S242 includes the following steps:

[0127] S2421, using the endpoint coordinates of all text lines in the text set and the indexes of the text lines, determine the start point and end point of the target text primitive.

[0128] The determined text line set also includes the index of each text line, and the index is used to indicate the writing order of each text line. In the process of converting the original drawing into a PDF drawing using CAD software, for example Fig. 9 As shown, taking the above "CH" as an example, the text in the original drawing is broken up into a set of two-dimensional line segments according to the writing order, and the index is determined for each text line according to the writing order, so each text line in the text line set is ordered and has a unique index. The endpoint coordinates of all text lines in the text set and the index of the text line determine the start and end points of the target text primitive.

[0129] S2422, using the starting point and the end point of the target text primitive, determine the initial text direction.

[0130] Use the starting and ending points of the target text primitive to determine the initial text direction, such as Fig.10 As shown, taking the above “CH.0+850” as an example, the initial text direction, that is, the direction of the arrow in the bounding box in the figure, can be determined according to the starting point and end point of the target text primitive.

[0131] S2423, based on the initial text direction and the bounding box of the target text primitive, determine the direction, insertion point and size of the target text primitive.

[0132] As an optional implementation of this embodiment, the above S2423 may include the following steps:

[0133] (1) The vertices of the bounding box of the target text primitive are converted to the world coordinate system to determine the side length and center point of the target circumscribed rectangular outline.

[0134] First, each vertex of the bounding box of the target text primitive is converted to the world coordinate system, and then the side length and center point of the target circumscribed rectangular outline in the world coordinate system are obtained.

[0135] (2) Based on the edges of the target circumscribed rectangular contour, four auxiliary directions corresponding to the edges are determined.

[0136] Based on the edges of the target circumscribed rectangular contour, four auxiliary directions corresponding to the edges are determined, parallel to the edges and according to the forming direction, four auxiliary directions corresponding to the edges are determined, such as Fig.10 The four directed line segments shown parallel to the four sides are four auxiliary directions.

[0137] (3) Determine the angles between each auxiliary direction and the initial text direction, and determine the auxiliary direction with the smallest angle as the direction of the target text primitive.

[0138] Determine the angles between each auxiliary direction and the initial text direction, calculate the angles between each auxiliary direction and the initial text direction, and determine the auxiliary direction with the smallest angle as the direction of the target text primitive.

[0139] (4) Determine the insertion point of the target text primitive based on the center point of the target circumscribed rectangular outline.

[0140] The center point of the bounding box of the target text primitive is obtained, and the center point is used to determine the insertion point of the target text primitive.

[0141] (5) Determine the size of the target text primitive according to the direction of the target text primitive and the side length of the target circumscribed rectangular outline.

[0142] After determining the direction of the target text primitive, the size of the target text primitive can be determined based on the length of each side of the bounding box of the target text primitive. Fig.10 , the direction of the target text primitive is parallel to side b, then the length of side a is the size of the target text primitive.

[0143] As an optional implementation of this embodiment, the above S2412 may include the following steps:

[0144] S01, comparing the areas of the circumscribed rectangular contours of the convex polygon, and determining the circumscribed rectangular contour with the smallest area, so as to obtain a target circumscribed rectangular contour.

[0145] After each circumscribed rectangular contour is determined, its area can be calculated, and then the areas of each circumscribed rectangular contour of the convex polygon are compared to determine the circumscribed rectangular contour with the smallest area to obtain the target circumscribed rectangular contour.

[0146] S02, determining a corresponding mapping relationship according to the target circumscribed rectangular outline.

[0147] After the target circumscribed rectangular outline is determined in the above step S01, the corresponding mapping relationship can be obtained, wherein the mapping relationship can be determined as in the steps of the above embodiment, which will not be described in detail here.

[0148] S03, determining the bounding box of the target text primitive using the mapping relationship and the coordinates of each point in the two-dimensional point set.

[0149] As an optional implementation of this embodiment, the above S03 may include the following steps:

[0150] (1) Establish a local coordinate system with the starting point in the mapping relationship as the origin and the starting direction as the axis.

[0151] In order to facilitate understanding and more accurately calculate the geometric features of the target text primitive, the bounding box in the local coordinates can be converted to the world coordinates for calculation. First, the local coordinate system is established with the starting point in the mapping relationship as the origin and the starting direction as the axis.

[0152] (2) Based on the coordinates of each point in the two-dimensional point set, each vertex of the corresponding circumscribed rectangular contour is converted into a local coordinate system to determine the local coordinates of each vertex of the circumscribed rectangular contour.

[0153] The vertices of the circumscribed rectangular outline in the coordinates of each point in the known two-dimensional point set are converted to the local coordinate system to determine the local coordinates of each vertex of the circumscribed rectangular outline, which is convenient for determining the bounding box in the local coordinate system and for calculating the area of ​​the circumscribed rectangular outline.

[0154] (3) Determine the bounding box of the target text primitive based on the local coordinates.

[0155] Finally, each local coordinate is converted to the world coordinate system to determine the bounding box of the target text primitive, such as Fig.11 As shown, this is the bounding box finally determined in the above example, which lays the foundation for the subsequent calculation of the geometric features of the text primitive.

[0156] In this embodiment, a method for calculating geometric features of text primitives is provided. Fig.12 is a flow chart of a method for calculating geometric features of text primitives according to an embodiment of the present invention. Fig.12 As shown, the process includes the following steps:

[0157] S31, obtaining a text line set of a target text primitive.

[0158] For details, please see Figure 1 S11 of the illustrated embodiment will not be described in detail here.

[0159] S32, traverse all the text lines in the text line set, store the starting points and end points of all the text lines, and form a two-dimensional point set.

[0160] Specifically, the above S32 may include the following steps:

[0161] S321, traverse all the text lines in the text line set, determine the endpoint coordinates of the start and end points of all the text lines, and filter out duplicate endpoints to determine the two-dimensional point set of the target text primitive.

[0162] Among them, when the endpoint coordinates of all text lines in the text line set are pushed into a stack, it can be first determined whether the endpoint coordinates to be pushed into the stack already exist, and the duplicate endpoints can be filtered; in addition, all traversed endpoints can be pushed into the stack first, and then the duplicate endpoints can be filtered according to the endpoint coordinates, and finally the two-dimensional point set of the target text primitive is determined. It should be noted that this embodiment only illustrates the process of removing duplicate points, as long as the filtering of duplicate points can be achieved, this embodiment is not limited to this.

[0163] S33, generating a convex polygon corresponding to the target text primitive based on the two-dimensional point set.

[0164] For details, please see Figure 1 S13 of the illustrated embodiment will not be described in detail here.

[0165] S34, determining the geometric features of the target text primitive according to the convex polygon corresponding to the target text primitive.

[0166] For details, please see Figure 1 S14 of the illustrated embodiment will not be described in detail here.

[0167] The method for calculating the geometric features of text primitives provided in this embodiment determines a two-dimensional point set through the endpoint coordinates of all text lines in a text line set, and then determines the bounding box of the target text primitive, and then uses the bounding box and the endpoint coordinates of the text lines to determine the geometric features of the target text primitive; the calculation method does not depend on the structure of the text, and can be applied to a variety of scenarios and complex text primitives, thereby ensuring the accuracy of calculating the geometric features of text primitives and further improving the recognition accuracy of drawings.

[0168] In this embodiment, a text primitive recognition method is provided. Fig.13 is a flowchart of a method for recognizing text primitives according to an embodiment of the present invention. Fig.13 As shown, the process includes the following steps:

[0169] S41, determining the geometric features of the text primitives based on the geometric feature calculation method of the text primitives.

[0170] The geometric features of the text primitives are determined using the geometric feature calculation method of any one of the above embodiments.

[0171] S42, performing text recognition on the text primitives using the geometric features of the text primitives to determine a recognition result.

[0172] Then, the geometric features of the text primitives are used to perform text recognition on the text primitives to determine the recognition results. In the field of CAD recognition, many recognition algorithms rely on the geometric features of CAD text primitives to improve the recognition rate (such as using the distance / direction range constraints between CAD text primitives and other CAD line primitives, feature search, etc.); in the field of vector PDF text recognition (recognizing text content), according to the geometric features of PDF text lines, text lines of any angle can be rotated to the horizontal direction (using the calculated "text direction"), and normalized (scaling the PDF text lines to a fixed height, using the calculated "text height"), and finally outputting the PDF text lines to the image for recognition (traditional image recognition technology cannot effectively calculate geometric features: rotating the horizontal text by 90°, 180°, and 270° respectively, and the "Hough transform detection line" in opencv cannot accurately calculate the direction). Therefore, the geometric features of text primitives can be used to perform text recognition on text primitives to determine the recognition results. It should be noted that this embodiment only illustrates the role of using the geometric features of text primitives to assist in text recognition. The geometric features of text primitives can also be used in the text recognition process in other forms as long as the recognition accuracy can be improved. This embodiment is not limited to this.

[0173] The text primitive recognition method provided in this embodiment utilizes the geometric features of the text primitives to perform text recognition on the text primitives, thereby ensuring the accuracy of the final recognition result.

[0174] In the present embodiment, a geometric feature calculation device for text primitives is also provided, and the device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0175] This embodiment provides a device for calculating geometric features of text primitives, such as Fig.14As shown, it includes: a first processing module 1, used to obtain a text line set of a target text primitive; a second processing module 2, used to traverse all text lines in the text line set, store the starting points and end points of all text lines, and form a two-dimensional point set; a third processing module 3, used to generate a convex polygon corresponding to the target text primitive based on the two-dimensional point set; and a fourth processing module 4, used to determine the geometric features of the target text primitive according to the convex polygon corresponding to the target text primitive.

[0176] This embodiment provides a text primitive recognition device, such as Fig.15 As shown, it includes: a geometric feature determination module 01, which is used for the geometric feature calculation device of the text primitive in the above embodiment to determine the geometric features of the text primitive; a recognition module 02, which is used to perform text recognition on the text primitive using the geometric features of the text primitive and determine the recognition result.

[0177] The geometric feature calculation device of the text primitive, or the recognition device of the text primitive in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0178] The further functional description of each of the above modules is the same as that of the above corresponding embodiments and will not be repeated here.

[0179] The embodiment of the present invention also provides an electronic device having the above Fig.14 or Fig.15 The device for calculating geometric features of text primitives or the device for recognizing text primitives is shown.

[0180] See also Fig.16 , Fig.16 is a schematic diagram of the structure of an electronic device provided by an optional embodiment of the present invention, such as Fig.16As shown, the electronic device may include: at least one processor 601, such as a CPU (Central Processing Unit), at least one communication interface 603, a memory 604, and at least one communication bus 602. The communication bus 602 is used to realize the connection and communication between these components. The communication interface 603 may include a display screen (Display), a keyboard (Keyboard), and the optional communication interface 603 may also include a standard wired interface and a wireless interface. The memory 604 may be a high-speed RAM memory (Random Access Memory) or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 604 may optionally be at least one storage device located away from the aforementioned processor 601. The processor 601 may be combined with Fig.14 or Fig.15 In the described device, the memory 604 stores an application program, and the processor 601 calls the program code stored in the memory 604 to execute any of the above method steps.

[0181] The communication bus 602 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The communication bus 602 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.16 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0182] Among them, the memory 604 may include a volatile memory (English: volatile memory), such as a random access memory (English: random-access memory, abbreviated: RAM); the memory may also include a non-volatile memory (English: non-volatile memory), such as a flash memory (English: flash memory), a hard disk drive (English: hard disk drive, abbreviated: HDD) or a solid-state drive (English: solid-state drive, abbreviated: SSD); the memory 604 may also include a combination of the above types of memory.

[0183] The processor 601 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and a NP.

[0184] The processor 601 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0185] Optionally, the memory 604 is also used to store program instructions. The processor 601 can call the program instructions to implement the present application Figure 1 , 5 and the geometric feature calculation method of the text primitive shown in the embodiment 12, or the implementation of the present application Fig.13 The text primitive recognition method shown in the embodiment.

[0186] The embodiment of the present invention also provides a non-transitory computer storage medium, which stores computer executable instructions, and the computer executable instructions can execute the geometric feature calculation method of the text primitive in any of the above method embodiments, or execute the text primitive recognition method in any of the above method embodiments. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above types of memory.

[0187] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A method for calculating geometric features of text primitives, characterized in that: The method comprises: Get the text line set of the target text primitive; Traversing all the text lines in the text line set, storing the starting points and end points of all the text lines, and forming a two-dimensional point set; Generate a convex polygon corresponding to the target text primitive based on the two-dimensional point set; Determine the geometric features of the target text primitive according to the convex polygon corresponding to the target text primitive; Wherein, determining the geometric features of the target text primitive according to the convex polygon corresponding to the target text primitive includes: Determine the bounding box of the target text primitive based on each vertex of the convex polygon and the direction of the edge corresponding to each vertex; The direction, insertion point and size of the target text primitive are determined according to the bounding box of the target text primitive.

2. The method according to claim 1, characterized in that The step of determining the bounding box of the target text primitive based on the vertices of the convex polygon and the directions of the edges corresponding to the vertices includes: Based on each vertex of the convex polygon and the direction of the side corresponding to each vertex, construct a circumscribed rectangular outline of the convex polygon; The areas of the circumscribed rectangular contours of the convex polygon are compared to determine the bounding box of the target text primitive.

3. The method according to claim 2, characterized in that The step of constructing a circumscribed rectangular outline of the convex polygon based on each vertex of the convex polygon and the direction of the side corresponding to each vertex includes: Each vertex is taken as a starting point, and the direction of the edge corresponding to the starting point is taken as a starting direction; Based on each vertex of the convex polygon, the starting point and the starting direction, a circumscribed rectangular outline corresponding to the convex polygon is constructed respectively, and a mapping relationship between the starting point and the starting direction and the circumscribed rectangular outline is recorded.

4. The method according to claim 3, characterized in that: The step of comparing the areas of the circumscribed rectangular contours of the convex polygons to determine the bounding box of the target text primitive includes: Comparing the areas of the circumscribed rectangular contours of the convex polygon, determining the circumscribed rectangular contour with the smallest area, so as to obtain a target circumscribed rectangular contour; Determine a corresponding mapping relationship according to the target circumscribed rectangular outline; The bounding box of the target text primitive is determined by using the mapping relationship and the coordinates of each point in the two-dimensional point set.

5. The method according to claim 4, characterized in that The method of determining the bounding box of the target text primitive by using the mapping relationship and the coordinates of each point in the two-dimensional point set includes: Establishing a local coordinate system with the starting point in the mapping relationship as the origin and the starting direction as the axis; Based on the coordinates of each point in the two-dimensional point set, each vertex of the corresponding circumscribed rectangular outline is converted to a local coordinate system to determine the local coordinates of each vertex of the circumscribed rectangular outline; The bounding box of the target text primitive is determined according to each local coordinate.

6. The method according to claim 1, characterized in that The text line set also includes an index of each of the text lines, where the index is used to indicate the writing order of each of the text lines. The determining the direction, insertion point and size of the target text primitive according to the bounding box of the target text primitive includes: Determine the start point and end point of the target text primitive by using the endpoint coordinates of all text lines in the text set and the index of the text line; Determine the initial text direction using the starting point and the end point of the target text primitive; Based on the initial text direction and the bounding box of the target text primitive, the direction, insertion point and size of the target text primitive are determined.

7. The method according to claim 6, characterized in that The determining the direction, insertion point and size of the target text primitive based on the initial text direction and the bounding box of the target text primitive comprises: Convert each vertex of the bounding box of the target text primitive to the world coordinate system to determine the side length and center point of the target circumscribed rectangular outline; Based on the respective sides of the target circumscribed rectangular outline, four auxiliary directions corresponding to the respective sides are determined; Determine the angles between each auxiliary direction and the initial text direction, and determine the auxiliary direction with the smallest angle as the direction of the target text primitive; Determine the insertion point of the target text primitive based on the center point of the target circumscribed rectangular outline; The size of the target text primitive is determined according to the direction of the target text primitive and the side length of the target circumscribed rectangular outline.

8. The method according to claim 1, characterized in that The traversal of all the text lines in the text line set, storing the starting points and end points of all the text lines, and forming a two-dimensional point set includes: All the text lines in the text line set are traversed to determine the endpoint coordinates of the start points and end points of all the text lines, and duplicate endpoints are screened to determine the two-dimensional point set of the target text primitive.

9. A method for recognizing text primitives, characterized in that: The method comprises: Determine the geometric features of the text primitive based on the geometric feature calculation method of the text primitive described in any one of claims 1 to 8; The text primitives are subjected to text recognition using the geometric features of the text primitives to determine a recognition result.

10. A device for calculating geometric features of text primitives, characterized in that: include: A first processing module is used to obtain a text line set of a target text primitive; A second processing module is used to traverse all the text lines in the text line set, store the starting points and end points of all the text lines, and form a two-dimensional point set; A third processing module, used for generating a convex polygon corresponding to the target text primitive based on the two-dimensional point set; A fourth processing module, used for determining the geometric features of the target text primitive according to the convex polygon corresponding to the target text primitive; Wherein, the fourth processing module is specifically used for: Determine the bounding box of the target text primitive based on each vertex of the convex polygon and the direction of the edge corresponding to each vertex; The direction, insertion point and size of the target text primitive are determined according to the bounding box of the target text primitive.

11. A text primitive recognition device, characterized in that: include: A geometric feature determination module, used to determine the geometric features of the text primitive based on the geometric feature calculation device of the text primitive according to claim 10; The recognition module is used to perform text recognition on the text primitives by using the geometric features of the text primitives and determine the recognition results.

12. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for calculating geometric features of text primitives as described in any one of claims 1 to 8, or executes the method for recognizing text primitives as described in claim 9, by executing the computer instructions.

13. A computer storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method for calculating geometric features of text primitives as described in any one of claims 1 to 8, or to execute the method for recognizing text primitives as described in claim 9.

Citation Information

Patent Citations

  • A character detection method in binary engineering drawings

    CN102289662A

  • Three-dimensional reconstruction and visualization method for engineering drawings

    CN102855668A