Method, device, equipment and storage medium for converting text into three-dimensional mesh surface
By grouping and completing triangular facets, the problem of low accuracy of three-dimensional mesh facets caused by text complexity is solved, and higher accuracy and effect are achieved.
Patent Information
- Application Number
- CN202210648006.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-08
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2042-06-08
AI Technical Summary
The existing methods of converting text into three-dimensional grid patches have low accuracy and poor results due to the high complexity of text, making it difficult to effectively deal with the complex outer and inner contours of Chinese fonts.
By obtaining the text outline vector path, grouping it into outer contour group and inner contour group, generating a triangle grid, and identifying the missing triangle faces, completing it, eliminating the triangle faces outside the outline, correcting the vertex order, and finally generating the target three-dimensional Mesh patch.
It improves the accuracy and effect of converting text into three-dimensional grid patches, and enhances the perfection and visualization of three-dimensional grid patches.
Smart Images

Figure CN114972685B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of graphics rendering and drawing technology, and in particular to a method, device, equipment and storage medium for converting text into three-dimensional mesh facets. Background Art
[0002] In some special effects requirements, it is necessary to convert text into a three-dimensional mesh and add special effects to the text of the three-dimensional mesh. Due to the complexity of Chinese fonts, a character may have multiple outer contour paths, and one outer contour has multiple inner contours. In theory, there should be multiple independent outer contours. Due to the adhesion of the strokes of the font, they are merged into one outer contour; and the contour is also convex, and there may be large concave corners in the contour. Therefore, the complexity of Chinese characters is indeed much higher than that of other characters. These factors make it difficult to convert text into three-dimensional mesh patches.
[0003] The existing solution for converting text into 3D meshes is mainly to generate all the triangular meshes by sequentially searching points and edge lines to see if they can combine the most suitable triangular faces. However, due to the high complexity of text, this method results in low accuracy and poor effect in converting text into 3D meshes. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a method, device, equipment and storage medium for converting text into three-dimensional mesh surfaces, so as to improve the accuracy of converting text into three-dimensional mesh surfaces and enhance the conversion effect.
[0005] In order to solve the above technical problems, the embodiment of the present application provides a method for converting text into a three-dimensional mesh surface, comprising:
[0006] Acquire the characters to be processed, and acquire the character contour vector paths of the characters to be processed, and group the character contour vector paths to obtain contour groups, wherein the contour groups are divided into outer contour groups and inner contour groups;
[0007] Based on the outer contour group and the inner contour group, the character contour vector path is used to generate a character triangular mesh, and a missing triangular face condition of an edge fitting straight line segment in the character triangular mesh is identified, wherein the missing triangular face condition is divided into a partial missing condition and a complete missing condition;
[0008] Identify the missing edge line corresponding to the partial missing condition, and based on the missing edge line, regenerate the triangular face corresponding to the partial missing condition to obtain a first complementary triangular face, and merge the first complementary triangular face into the text triangular mesh;
[0009] Identify the starting point and the end point of the broken edge line corresponding to the complete missing state, and construct the triangular face corresponding to the complete missing state based on the starting point and the end point of the broken edge line to obtain a second complementary triangular face, and merge the second complementary triangular face into the text triangular mesh;
[0010] Calculating the centroid of the triangular faces in the text triangular mesh, and based on the centroid, removing the triangular faces outside the outline of the text triangular mesh to obtain an initial text triangular mesh;
[0011] Identify the incomplete triangular face in the initial text triangular mesh, complete the incomplete triangular face to obtain a third completed triangular face, and merge the third completed triangular face into the initial text triangular mesh;
[0012] The order of vertices in the initial text triangular mesh is corrected to obtain a target text triangular mesh, and a target three-dimensional mesh facet is generated based on the target text triangular mesh.
[0013] In order to solve the above technical problems, the embodiment of the present application provides a device for converting text into a three-dimensional mesh surface, including:
[0014] A module for acquiring characters to be processed, used for acquiring characters to be processed, acquiring character contour vector paths of the characters to be processed, and grouping the character contour vector paths to obtain contour groups, wherein the contour groups are divided into outer contour groups and inner contour groups;
[0015] A text triangular mesh generation module is used to generate a text triangular mesh from the text contour vector path based on the outer contour group and the inner contour group, and identify the missing condition of the triangular face of the edge fitting straight line segment in the text triangular mesh, wherein the missing condition of the triangular face is divided into a partial missing condition and a complete missing condition;
[0016] A missing edge line completion module is used to identify the missing edge line corresponding to the partial missing condition, and based on the missing edge line, regenerate the triangular face corresponding to the partial missing condition to obtain a first completed triangular face, and merge the first completed triangular face into the text triangular mesh;
[0017] A broken edge line completion module, used for identifying the starting point and the end point of the broken edge line corresponding to the complete missing state, and constructing the triangular face corresponding to the complete missing state based on the starting point and the end point of the broken edge line to obtain a second completed triangular face, and merging the second completed triangular face into the text triangular mesh;
[0018] The module for removing triangular faces outside the outline is used to calculate the centroid of the triangular faces in the text triangular mesh, and based on the centroid, remove the triangular faces outside the outline in the text triangular mesh to obtain an initial text triangular mesh;
[0019] An incomplete triangle face completion module, used for identifying incomplete triangle faces in the initial text triangle mesh, completing the incomplete triangle faces to obtain third completed triangle faces, and merging the third completed triangle faces into the initial text triangle mesh;
[0020] The target three-dimensional mesh patch generation module is used to correct the order of vertices in the initial text triangular mesh to obtain a target text triangular mesh, and generate a target three-dimensional mesh patch based on the target text triangular mesh.
[0021] In order to solve the above technical problems, a technical solution adopted by the present invention is: to provide a computer device, including one or more processors; a memory for storing one or more programs, so that one or more processors can implement any of the above methods for converting text into three-dimensional mesh surfaces.
[0022] In order to solve the above technical problems, a technical solution adopted by the present invention is: a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method of converting text into a three-dimensional mesh face as described in any one of the above items is implemented.
[0023] The embodiment of the present invention provides a method, device, equipment and storage medium for converting text into three-dimensional mesh facets. The embodiment of the present invention obtains the text contour vector path corresponding to the to-be-processed text, divides the text contour vector path into an outer contour group and an inner contour group, and then generates a text triangular mesh, which is conducive to improving the accuracy of converting text into triangular mesh facets, and identifies the missing triangular faces of the text triangular mesh, and based on the missing conditions, completes the text triangular mesh, and at the same time removes the triangular faces outside the contour, and regenerates new triangular faces, which is conducive to perfecting all triangular faces in the text triangular mesh, and correcting based on the perfected initial text triangular mesh, and then generating a target three-dimensional mesh facet, thereby improving the accuracy of converting text into three-dimensional mesh facets and enhancing the effect of converting text into three-dimensional mesh facets. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0025] Figure 1 This is a flowchart of a method for converting text into three-dimensional mesh facets provided in an embodiment of the present application;
[0026] Figure 2 It is another implementation flow chart of a sub-process in the method for converting text into a three-dimensional mesh surface provided in an embodiment of the present application;
[0027] Figure 3 It is another implementation flow chart of a sub-process in the method for converting text into a three-dimensional mesh surface provided in an embodiment of the present application;
[0028] Figure 4 It is another implementation flow chart of a sub-process in the method for converting text into a three-dimensional mesh surface provided in an embodiment of the present application;
[0029] Figure 5 It is another implementation flow chart of a sub-process in the method for converting text into a three-dimensional mesh surface provided in an embodiment of the present application;
[0030] Figure 6 It is another implementation flow chart of a sub-process in the method for converting text into a three-dimensional mesh surface provided in an embodiment of the present application;
[0031] Figure 7 It is another implementation flow chart of a sub-process in the method for converting text into a three-dimensional mesh surface provided in an embodiment of the present application;
[0032] Figure 8 It is a schematic diagram of a device for converting text into three-dimensional mesh facets provided in an embodiment of the present application;
[0033] Fig. 9 It is a schematic diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0035] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0036] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0037] The present invention is described in detail below with reference to the accompanying drawings and embodiments.
[0038] It should be noted that the method for converting text into three-dimensional mesh facets provided in the embodiment of the present application is generally executed by a server, and accordingly, the device for converting text into three-dimensional mesh facets is generally configured in the server.
[0039] See also Figure 1 , Figure 1 A specific implementation of the method for converting text into three-dimensional mesh facets is shown.
[0040] It should be noted that if there are substantially the same results, the method of the present invention is not limited to Figure 1 The process sequence shown is limited to the following steps:
[0041] S1: Obtain the text to be processed, obtain the text contour vector path of the text to be processed, and group the text contour vector paths to obtain contour groups.
[0042] Among them, the contour group is divided into outer contour group and inner contour group.
[0043] Specifically, when the text to be processed needs to be converted into a three-dimensional mesh surface, the text to be processed is first obtained, and the text contour vector path of the text to be processed is obtained, and then the text contour vector path is grouped according to the inner and outer contours to obtain contour groups. Among them, the contour groups are divided into outer contour groups and inner contour groups.
[0044] See also Figure 2 , Figure 2 A specific implementation of step S1 is shown, which is described in detail as follows:
[0045] S11: Obtain the text to be processed and obtain the initial text outline vector path of the text to be processed.
[0046] S12: Fitting the initial text contour vector path through straight line segments to obtain the text contour vector path.
[0047] S13: Obtain a vertex sequence in the text outline vector path, and calculate directions of the vertices in the vertex sequence to obtain vertex directions, wherein the vertex directions include clockwise and counterclockwise directions.
[0048] S14: Grouping the text contour vector paths based on vertex directions to obtain contour groups, wherein the clockwise direction corresponds to the outer contour group and the counterclockwise direction corresponds to the inner contour group.
[0049] Specifically, because each character may have 1 to more outer contour paths, and each outer contour may have 0 to more inner contours. So first group all the contours of the text. Take an outer contour path and its inner contour path as a group. The method to determine the outer contour and the inner contour is to determine whether the vertex sequence is clockwise. Clockwise is the outer contour, otherwise it is the inner contour. Because the contour vector path of the text will not cross, to determine whether an inner contour is inside an outer contour, you only need to determine whether the first point of the inner contour is inside the outer contour. There is no need to determine whether all the points are inside the contour, which is conducive to improving the judgment efficiency. To determine whether a vertex is inside a contour, you can call the pointPolygonTest function of opencv to make a judgment. At the same time, the direction of the vertices in the vertex sequence is calculated as follows: When i=n, then i+1=0, where cw represents the vertex direction, X i and X i+1 Indicates the direction of the i-th and i+1-th vertices on the X axis, Y i and Y i+1 Indicates the direction of the i-th and i+1-th vertices on the Y axis, n represents the number of vertices, and i represents the i-th vertex. If cw>0, the vertex direction is clockwise, otherwise the vertex direction is counterclockwise.
[0050] Specifically, the text contour corresponding to the text to be processed can be obtained from the FreeType library. After obtaining the text contour, the text contour is vectorized to obtain the initial text contour vector path. Among them, the FreeType library is a completely free (open source), high-quality and portable font engine, which provides a unified interface to access multiple font format files, including TrueType, OpenType, Type1, CID, CFF, Windows FON / FNT, X11 PCF, etc.
[0051] S2: Based on the outer contour group and the inner contour group, the text contour vector path is used to generate a text triangular mesh, and the missing triangular faces of the edge fitting straight line segments in the text triangular mesh are identified.
[0052] Among them, the missing triangle surface condition is divided into partial missing condition and complete missing condition.
[0053] Specifically, the Delaunay algorithm is used to generate a text triangular mesh from the text contour vector path based on the outer contour group and the inner contour group. The Delaunay algorithm refers to the Delaunay triangulation algorithm, which is a triangulation of point sets and is an extremely important preprocessing technology for numerical analysis (such as finite element analysis) and graphics. In an embodiment of the present application, the Subdiv2D function in the Delaunay algorithm is called to generate a text triangular mesh from the text contour vector path. Since the generated text triangular mesh has missing or incomplete triangular faces, it is necessary to identify the missing triangular faces of the edge fitting straight line segments in the text triangular mesh in order to complete them. The embodiment of the present application searches all edge-fitted straight line segments in the text triangular mesh in sequence to see whether there is a triangular face that contains the edge-fitted straight line segment; if not, it means that the triangular face of the line segment is missing; if it is found that there is a triangular face near the line, but there is no triangular face with this straight line segment as an edge, that is, there is an intersection of the broken edge lines, then the triangular face missing status is considered to be partially missing; if it is found that there is no triangular face near the line segment, that is, there is no intersection of the broken edge lines, then the triangular face missing status is considered to be completely missing.
[0054] S3: Identify the missing edge line corresponding to the partial missing condition, and based on the missing edge line, regenerate the triangular surface corresponding to the partial missing condition to obtain a first complementary triangular surface, and merge the first complementary triangular surface into the text triangular mesh.
[0055] See also Figure 3 , Figure 3 A specific implementation of step S3 is shown, which is described in detail as follows:
[0056] S31: Obtain the missing edge line corresponding to the partial missing condition, and obtain the triangular face intersecting the missing edge line to obtain the missing triangular face, and obtain the vertex and two endpoints corresponding to the missing triangular face as the completion points.
[0057] S32: Eliminate missing triangular faces from the text triangular mesh, and calculate the cross product of the completed points to obtain a cross product result.
[0058] S33: Based on the cross product result, generate a first complementary triangle face, and merge the first complementary triangle face into the text triangle mesh.
[0059] Specifically, obtain the missing edge lines corresponding to the partial missing conditions, and obtain the triangles that intersect the missing edge lines to obtain the missing triangles, and remove the missing triangles from the text triangle mesh. According to the right-hand rule, the vertices of the partially eliminated triangles are gathered together, and the vertices that do not conform to the right-hand rule are excluded, because the triangles connected to the vertices are outside the text outline. Among them, the right-hand rule means that the right thumb points to the inside of the text, and the other fingers point in the direction of the path. Then obtain the vertices and two endpoints corresponding to the missing triangles as the completion points; then use the endpoint of the right palm as the starting point a of the edge segment, the vertex in the direction of the right thumb as the target point c to be tested, and the endpoints of the other fingers pointing in the direction of the path as the end point b of the edge segment, and then calculate the vector and The cross product of Calculate the cross product of the completion point and obtain the cross product result. If the cross product result is outside the text outline, the target point does not meet the requirements; if the cross product result is inside the text outline, the target point meets the requirements. Then, the target point required by the service number is used to generate a triangular face through the Delaunay algorithm to obtain the first completion triangular face, and the first completion triangular face is incorporated into the text triangular mesh to complete the triangular face of this part.
[0060] S4: Identify the starting point and the end point of the broken edge line corresponding to the complete missing state, and based on the starting point and the end point of the broken edge line, construct the triangular face corresponding to the complete missing state, obtain the second complementary triangular face, and merge the second complementary triangular face into the text triangular mesh.
[0061] See also Figure 4 , Figure 4 A specific implementation of step S4 is shown, which is described in detail as follows:
[0062] S41: Identify the starting point and the end point of the fracture edge line corresponding to the complete missing state.
[0063] S42: Identify the triangular face corresponding to the starting point and the triangular face corresponding to the end point respectively, and obtain the starting point triangular face and the end point triangular face.
[0064] S43: Obtain an edge line segment connected to the starting point in the initial point triangle surface as the starting point connected line segment, and obtain an edge line segment connected to the end point in the end point triangle surface as the end point connected line segment.
[0065] S44: calculating the angle between the starting point and the line segment connected to the starting point to obtain the starting point angle, and calculating the angle between the end point and the line segment connected to the end point to obtain the end point angle.
[0066] S45: Based on the starting point angle and the end point angle, a target vertex that meets the preset conditions is obtained, and based on the target vertex, a triangular face corresponding to the full missing state is constructed to obtain a second complementary triangular face, and the second complementary triangular face is incorporated into the text triangular mesh.
[0067] Specifically, because the edge line segment in the complete missing state is broken and has no intersecting triangles, it is impossible to filter out the appropriate vertices based on the vertices of the intersecting triangles. Therefore, the embodiment of the present application identifies the triangles to which the starting point and the end point of the broken edge line belong, and then identifies the appropriate edges corresponding to the triangles to which they belong, and performs local Delaunay triangulation on the vertices on the appropriate edges to complete the triangles. In an embodiment of the present application, the starting point and the end point of the broken edge line corresponding to the full missing state are identified, and the triangular face corresponding to the starting point and the triangular face corresponding to the end point are identified respectively to obtain the starting point triangular face and the end point triangular face, and then the edge line segment connected to the starting point is obtained in the initial point triangular face as the starting point connected line segment, and the edge line segment connected to the end point is obtained in the end point triangular face as the end point connected line segment, and then the angle between the starting point and the starting point connected line segment is calculated to obtain the starting point angle, and the angle between the end point and the end point connected line segment is calculated to obtain the end point angle, and then based on the starting point angle and the end point angle, the target vertex that meets the preset conditions is obtained, and based on the target vertex, the triangular face corresponding to the full missing state is constructed to obtain the second completed triangular face, and the second completed triangular face is incorporated into the text triangular mesh.
[0068] If s is the starting point, e is the end point, b is the point on the line segment connected to the starting point, c is the point on the line segment connected to the end point, and θ is the required angle (i.e. the starting point angle or the end point angle), then the calculation formula for the starting point angle θ is:
[0069] If cross<0, then θ=360-θ;
[0070] The calculation formula for the end point angle θ is:
[0071] ; If cross<0, then θ=360-θ;
[0072] Among them, when the starting angle or the ending angle is the smallest in the counterclockwise direction (that is, it meets the preset conditions), the point on the line segment connected to the starting point or the point on the line segment connected to the end point at this time is obtained as the target vertex, and based on the target vertex, the Delaunay algorithm is used to construct the triangular face corresponding to the full missing condition to obtain the second completed triangular face, and the second completed triangular face is incorporated into the text triangular mesh.
[0073] S5: Calculate the centroid of the triangular faces in the text triangular mesh, and based on the centroid, remove the triangular faces outside the outline of the text triangular mesh to obtain an initial text triangular mesh.
[0074] See also Figure 5 , Figure 5 A specific implementation of step S5 is shown, which is described in detail as follows:
[0075] S51: taking any three vertices in the text triangle mesh as a group of vertex combinations, and constructing a triangle face combination based on the vertex combination, wherein the triangle face combination includes three triangle faces.
[0076] S52: Calculate the centroid of each triangle in the triangle combination, and determine whether the centroid meets the preset requirements.
[0077] S53: If any centroid point does not meet the preset requirements, the triangular faces are combined as triangular faces outside the outline, and the triangular faces outside the outline are removed from the text triangular mesh to obtain an initial text triangular mesh.
[0078] Specifically, the preset requirement is that the centroid of the triangular face needs to fall inside the outer contour and outside the inner contour. In the embodiment of the present application, any three vertices in the text triangular mesh are taken as a group of vertex combinations, and a triangular face combination is constructed based on the vertex combination, wherein the triangular face combination includes three triangular faces, and then the centroid of each triangular face in the triangular face combination is calculated, and it is determined whether the centroid meets the preset requirements. If any centroid does not meet the preset requirements, the triangular face combination is regarded as a triangular face outside the contour, and the triangular face outside the contour is removed from the text triangular mesh to obtain the initial text triangular mesh. Assuming that a, b, and c are three vertices of a set of vertex combinations, the centroid of the triangle surface is calculated by the following formula; O1 = (a+(a+b) / 2+(a+c) / 2) / 3; O2 = (b+(b+a) / 2+(b+c) / 2) / 3; O3 = (c+(c+a) / 2+(c+b) / 2) / 3; where O1, O2, and O3 are the centroids of the three triangle surfaces.
[0079] It should be noted that in order to prevent the triangular faces generated by local Delaunay in the algorithm from not meeting the requirements, after executing step S5, steps S3-S5 are re-executed, and after completion, subsequent steps S6-S7 are executed.
[0080] S6: Identify the incomplete triangular faces in the initial text triangular mesh, and complete the incomplete triangular faces to obtain third completed triangular faces, and merge the third completed triangular faces into the initial text triangular mesh.
[0081] See also Figure 6 , Figure 6A specific implementation of step S6 is shown, which is described in detail as follows:
[0082] S61: Obtain any edge segment combination in the initial text triangulation network, wherein the edge segment combination is two associated edge segments.
[0083] S62: Calculate the angle between two edge line segments in the edge line segment combination through a preset algorithm to obtain the edge line segment combination angle, and obtain an incomplete triangle face based on the edge line segment combination angle, wherein the incomplete triangle face includes the two target edge line segments.
[0084] S63: Obtain the vertices of the incomplete triangle except the two target edge segments as initial assembly vertices.
[0085] S64: Obtain target component vertices according to the number of occurrences of the initial component vertices, and based on the target component vertices, complete the incomplete triangular faces to obtain third completed triangular faces, and merge the third completed triangular faces into the initial text triangular mesh.
[0086] Specifically, after the triangular faces outside the outline are removed in the text triangular mesh in step S5, incomplete triangular faces may appear, but the edge segments are not broken, so they cannot be completed by steps S3 and S4.
[0087] The two associated edge line segments refer to two line segments whose starting point of one edge line segment is the end point of the other edge line segment. Assuming that the starting point of one edge line segment in the edge line segment combination is a and the end point is b, and the starting point of the other edge line segment is b and the end point is c, and the angle between the two edge line segments is θ or θ′, the preset algorithm is used to calculate the angle, wherein the preset algorithm includes the calculation methods of the dot product method and the cross product method.
[0088] Calculate the angle θ using the dot product method:
[0089] If cross<0, then θ=360-θ;
[0090] Calculate the angle θ′ using the cross product method: (the path is the outer contour); (The path is the inner contour); when θ′<0, then θ′=360+θ; (the path is the outer contour); (path is inner contour);
[0091] If it appears and If any of the above conditions is found, it means that there is an incomplete triangle face, and the incomplete triangle face is obtained; then the vertices after the two target edge segments in the incomplete triangle face are obtained as the initial building vertices. In a specific implementation, all vertices except vertices a, b, and c are recorded, that is, (d1, d1', d2, d3, d4, d4', d5, d5'), where d1 and d1', d4 and d4', d5 and d5' are the same points, which means that they appear twice, while d2 and d3 only appear once, so they are used as target building vertices, that is, (d2, b, d3) to form the third complementary triangle face, and the third complementary triangle face is incorporated into the initial text triangle mesh.
[0092] S7: Correcting the order of vertices in the initial text triangular mesh to obtain a target text triangular mesh, and generating a target three-dimensional mesh patch based on the target text triangular mesh.
[0093] See also Figure 7 , Figure 7 A specific implementation of step S7 is shown, which is described in detail as follows:
[0094] S71: Calculate the vertex cross product of each triangle face in the initial text triangle mesh.
[0095] S72: Based on the vertex cross product, the vertices in the initial text triangle mesh are corrected sequentially in the same direction to obtain the target text triangle mesh.
[0096] S73: Generate a target three-dimensional mesh patch based on the target text triangular mesh.
[0097] Specifically, the vertex cross product of each triangle in the initial text triangle mesh is calculated. Based on the vertex cross product, the vertices in the initial text triangle mesh are corrected in sequence in the same direction to obtain the target text triangle mesh. The same direction can be clockwise or counterclockwise. If the three vertices of the triangle face are a, b, and c, the method for calculating the vertex cross product is:
[0098]
[0099] If cross<0, the order of the first two points is swapped to (b, a, c) so that the vertices in the initial text triangle mesh are corrected in the same direction. The target text triangle mesh obtained at this time is a two-dimensional graphic. The target text triangle mesh is translated and copied, and the vertical three-dimensional triangle mesh is completed to obtain the target three-dimensional mesh face.
[0100] It should be noted that the text types in the embodiment of the present application can be simplified and traditional Chinese, English, Hindi, Sanskrit, Korean, etc.; because the structure of Chinese characters is more complex than other characters, if Chinese characters can be converted into target three-dimensional mesh faces, other characters can also be converted. Furthermore, the embodiment of the present application is not limited to the conversion of three-dimensional mesh faces of characters, but can also convert three-dimensional mesh faces for other targets with contours, such as the conversion of logos and other targets.
[0101] In this embodiment, by obtaining the text to be processed and the text contour vector path of the text to be processed, and grouping the text contour vector path, a contour group is obtained, wherein the contour group is divided into an outer contour group and an inner contour group; based on the outer contour group and the inner contour group, the text contour vector path is used to generate a text triangular mesh, and the missing state of the triangular face of the edge fitting straight line segment in the text triangular mesh is identified, wherein the missing state of the triangular face is divided into a partial missing state and a full missing state; the missing edge line corresponding to the partial missing state is identified, and based on the missing edge line, the triangular face corresponding to the partial missing state is regenerated to obtain a first completed triangular face, and the first completed triangular face is incorporated into the text triangular mesh; the missing edge line corresponding to the full missing state is identified The starting point and the end point of the broken edge line are determined, and based on the starting point and the end point of the broken edge line, the triangular face corresponding to the completely missing state is constructed to obtain the second completed triangular face, and the second completed triangular face is incorporated into the text triangular mesh; the centroid point of the triangular face in the text triangular mesh is calculated, and based on the centroid point, the triangular faces outside the outline in the text triangular mesh are removed to obtain the initial text triangular mesh; the incomplete triangular face in the initial text triangular mesh is identified, and the incomplete triangular face is completed to obtain the third completed triangular face, and the third completed triangular face is incorporated into the initial text triangular mesh; the vertex order in the initial text triangular mesh is corrected to obtain the target text triangular mesh, and the target three-dimensional mesh face is generated based on the target text triangular mesh. The embodiment of the present invention obtains the text contour vector path corresponding to the text to be processed, divides the text contour vector path into an outer contour group and an inner contour group, and then generates a text triangular mesh, which is beneficial to improving the accuracy of converting text into triangular mesh facets, and identifies the missing triangular faces of the text triangular mesh, and based on the missing conditions, completes the text triangular mesh, and at the same time removes the triangular faces outside the expanded outline and regenerates new triangular faces, which is beneficial to perfecting all the triangular faces in the text triangular mesh, and correcting based on the perfected initial text triangular mesh, and then generating a target three-dimensional mesh facet, thereby improving the accuracy of converting text into three-dimensional mesh facets and enhancing the effect of converting text into three-dimensional mesh facets.
[0102] Please refer to Figure 8 , as a response to the above Figure 1The present application provides an embodiment of a device for converting text into a three-dimensional mesh surface. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0103] like Figure 8 As shown, the device for converting text into a three-dimensional mesh surface in this embodiment includes: a to-be-processed text acquisition module 81, a text triangular mesh generation module 82, a missing edge line completion module 83, a broken edge line completion module 84, an outer contour triangular surface removal module 85, a defective triangular surface completion module 86 and a target three-dimensional mesh surface generation module 87, wherein:
[0104] The to-be-processed text acquisition module 81 is used to acquire the to-be-processed text and the text contour vector path of the to-be-processed text, and group the text contour vector path to obtain contour groups, wherein the contour groups are divided into outer contour groups and inner contour groups;
[0105] The text triangular mesh generation module 82 is used to generate a text triangular mesh from the text contour vector path based on the outer contour group and the inner contour group, and identify the missing condition of the triangular face of the edge fitting straight line segment in the text triangular mesh, wherein the missing condition of the triangular face is divided into a partial missing condition and a complete missing condition;
[0106] A missing edge line completion module 83 is used to identify missing edge lines corresponding to the partial missing condition, and based on the missing edge lines, regenerate the triangular face corresponding to the partial missing condition to obtain a first completed triangular face, and merge the first completed triangular face into the text triangular mesh;
[0107] A broken edge line completion module 84 is used to identify the starting point and the end point of the broken edge line corresponding to the complete missing state, and construct a triangular face corresponding to the complete missing state based on the starting point and the end point of the broken edge line to obtain a second completed triangular face, and merge the second completed triangular face into the text triangular mesh;
[0108] The module 85 for removing triangles outside the outline is used to calculate the centroid of the triangles in the text triangle mesh, and based on the centroid, remove the triangles outside the outline in the text triangle mesh to obtain an initial text triangle mesh;
[0109] The incomplete triangle face completion module 86 is used to identify the incomplete triangle face in the initial text triangle mesh, complete the incomplete triangle face to obtain a third completed triangle face, and merge the third completed triangle face into the initial text triangle mesh;
[0110] The target three-dimensional mesh patch generation module 87 is used to correct the order of vertices in the initial text triangle mesh to obtain a target text triangle mesh, and generate a target three-dimensional mesh patch based on the target text triangle mesh.
[0111] Furthermore, the to-be-processed text acquisition module 81 includes:
[0112] A vector path acquisition unit, used to acquire the text to be processed and to acquire the initial text outline vector path of the text to be processed;
[0113] A straightness fitting unit is used to fit the initial text contour vector path through a straight line segment to obtain the text contour vector path;
[0114] A vertex direction calculation unit, used for obtaining a vertex sequence in a character outline vector path, and performing direction calculation on the vertices in the vertex sequence to obtain vertex directions, wherein the vertex directions include clockwise and counterclockwise directions;
[0115] The contour group generating unit is used to group the text contour vector paths based on the vertex directions to obtain contour groups, wherein the clockwise direction corresponds to the outer contour group and the counterclockwise direction corresponds to the inner contour group.
[0116] Furthermore, the missing edge line completion module 83 includes:
[0117] A completion point acquisition unit is used to acquire the missing edge line corresponding to the partial missing condition, and acquire the triangular face intersecting the missing edge line to obtain the missing triangular face, and acquire the vertex and two endpoints corresponding to the missing triangular face as the completion points;
[0118] A cross product result calculation unit is used to remove missing triangles from the text triangle mesh and calculate the cross product of the completed points to obtain a cross product result;
[0119] The first complement triangle surface generation unit is used to generate a first complement triangle surface based on the cross product result, and merge the first complement triangle surface into the text triangle mesh.
[0120] Furthermore, the broken edge line completion module 84 includes:
[0121] A starting point recognition unit, used to recognize the starting point and the end point of the fracture edge line corresponding to the complete missing state;
[0122] A triangular face recognition unit, used to respectively recognize the triangular face corresponding to the starting point and the triangular face corresponding to the end point, and obtain the starting point triangular face and the end point triangular face;
[0123] A connected line segment acquisition unit, used to acquire an edge line segment connected to the starting point in the initial point triangle surface as the starting point connected line segment, and to acquire an edge line segment connected to the end point in the end point triangle surface as the end point connected line segment;
[0124] An angle calculation unit is used to calculate the angle between the starting point and the line segment connected to the starting point to obtain the starting point angle, and to calculate the angle between the end point and the line segment connected to the end point to obtain the end point angle;
[0125] The second completed triangle surface generation unit is used to obtain the target vertex that meets the preset conditions based on the starting point angle and the end point angle, and to construct a triangle surface corresponding to the full missing condition based on the target vertex to obtain the second completed triangle surface, and merge the second completed triangle surface into the text triangle mesh.
[0126] Furthermore, the contour outer triangle surface removal module 85 includes:
[0127] A triangle face combination construction unit, used for taking any three vertices in the text triangle mesh as a group of vertex combinations, and constructing a triangle face combination based on the vertex combination, wherein the triangle face combination includes three triangle faces;
[0128] A centroid calculation unit, used to calculate the centroid of each triangle in the triangle combination and determine whether the centroid meets the preset requirements;
[0129] The initial text triangular mesh generation unit is used to combine the triangular faces as triangular faces outside the outline if any centroid point does not meet the preset requirements, and remove the triangular faces outside the outline from the text triangular mesh to obtain the initial text triangular mesh.
[0130] Furthermore, the incomplete triangle surface completion module 86 includes:
[0131] An edge segment combination acquisition unit, used to acquire any edge segment combination in the initial text triangulation network, wherein the edge segment combination is two associated edge segments;
[0132] An incomplete triangle surface acquisition unit is used to calculate the angle between two edge line segments in the edge line segment combination by a preset algorithm to obtain the edge line segment combination angle, and obtain the incomplete triangle surface based on the edge line segment combination angle, wherein the incomplete triangle surface includes two target edge line segments;
[0133] The initial assembly vertex unit is used to obtain the vertices of the incomplete triangle except the two target edge segments as the initial assembly vertices;
[0134] The third completed triangle face generation unit is used to obtain the target component vertex according to the number of times the initial component vertex appears, and based on the target component vertex, complete the incomplete triangle face to obtain the third completed triangle face, and merge the third completed triangle face into the initial text triangle mesh.
[0135] Furthermore, the target three-dimensional mesh patch generation module 87 includes:
[0136] A vertex cross product calculation unit, used to calculate the vertex cross product of each triangle face in the initial text triangle mesh;
[0137] A target text triangular mesh generation unit is used to sequentially correct the vertices in the initial text triangular mesh in the same direction based on the vertex cross product to obtain the target text triangular mesh;
[0138] The target text triangular mesh conversion unit is used to generate a target three-dimensional mesh patch based on the target text triangular mesh.
[0139] To solve the above technical problems, the present application also provides a computer device. Fig. 9 , Fig. 9 This is a basic structural block diagram of the computer device in this embodiment.
[0140] The computer device 9 includes a memory 92, a processor 92, and a network interface 93 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 9 having three components, a memory 92, a processor 92, and a network interface 93, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASIC), programmable gate arrays (FPGA), digital signal processors (DSP), embedded devices, etc.
[0141] Computer devices can be computing devices such as desktop computers, notebooks, PDAs, and cloud servers. Computer devices can interact with users through keyboards, mice, remote controls, touch pads, or voice control devices.
[0142] The memory 92 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 92 can be an internal storage unit of the computer device 9, such as a hard disk or memory of the computer device 9. In other embodiments, the memory 92 can also be an external storage device of the computer device 9, such as a plug-in hard disk equipped on the computer device 9, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 92 can also include both the internal storage unit of the computer device 9 and its external storage device. In this embodiment, the memory 92 is generally used to store the operating system and various application software installed on the computer device 9, such as the program code of the method of converting text into a three-dimensional mesh surface patch, etc. In addition, the memory 92 can also be used to temporarily store various types of data that have been output or are to be output.
[0143] In some embodiments, the processor 92 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 92 is generally used to control the overall operation of the computer device 9. In this embodiment, the processor 92 is used to run the program code stored in the memory 92 or process data, such as running the program code of the method for converting text into a three-dimensional mesh surface patch, so as to implement various embodiments of the method for converting text into a three-dimensional mesh surface patch.
[0144] The network interface 93 may include a wireless network interface or a wired network interface, and the network interface 93 is generally used to establish a communication connection between the computer device 9 and other electronic devices.
[0145] The present application also provides another embodiment, namely, providing a computer-readable storage medium, which stores a computer program. The computer program can be executed by at least one processor to enable the at least one processor to perform the steps of the method for converting text into a three-dimensional mesh face as described above.
[0146] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods of each embodiment of the present application.
[0147] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A method for converting text into three-dimensional mesh surfaces. It is characterized in that include: Acquire the characters to be processed, and acquire the character contour vector paths of the characters to be processed, and group the character contour vector paths to obtain contour groups, wherein the contour groups are divided into outer contour groups and inner contour groups; Based on the outer contour group and the inner contour group, the character contour vector path is used to generate a character triangular mesh, and a missing triangular face condition of an edge fitting straight line segment in the character triangular mesh is identified, wherein the missing triangular face condition is divided into a partial missing condition and a complete missing condition; Obtaining the missing edge line corresponding to the partially missing condition, and obtaining the triangular face intersecting the missing edge line to obtain the missing triangular face, and obtaining the vertex and two endpoints corresponding to the missing triangular face as the completion points; Eliminate the missing triangular faces from the text triangular mesh, and calculate the cross product of the completed points to obtain a cross product result; Based on the cross product result, generate a first complementary triangular face, and merge the first complementary triangular face into the text triangular mesh; Identify the starting point and the end point of the fracture edge line corresponding to the complete loss condition; Respectively identify the triangular face corresponding to the starting point and the triangular face corresponding to the end point to obtain the starting point triangular face and the end point triangular face; Acquire an edge line segment connected to the starting point in the initial point triangular face as a starting point connected line segment, and acquire an edge line segment connected to the end point in the end point triangular face as an end point connected line segment; Calculating the angle between the starting point and the line segment connected to the starting point to obtain the starting point angle, and calculating the angle between the end point and the line segment connected to the end point to obtain the end point angle; Based on the starting point angle and the end point angle, a target vertex that meets a preset condition is obtained, and based on the target vertex, a triangular face corresponding to the complete missing condition is constructed to obtain a second complementary triangular face, and the second complementary triangular face is incorporated into the text triangular mesh; Calculating the centroid of the triangular faces in the text triangular mesh, and based on the centroid, removing the triangular faces outside the outline of the text triangular mesh to obtain an initial text triangular mesh; Acquire any edge segment combination in the initial text triangulation network, wherein the edge segment combination is two associated edge segments; By using a preset algorithm, the angle between two edge line segments in the edge line segment combination is calculated to obtain the edge line segment combination angle, and based on the edge line segment combination angle, an incomplete triangular face is obtained, wherein the incomplete triangular face includes two target edge line segments; Obtaining the vertices of the incomplete triangular face except the two target edge segments as initial assembly vertices; According to the number of occurrences of the initial component vertex, a target component vertex is obtained, and based on the target component vertex, the incomplete triangular face is completed to obtain a third completed triangular face, and the third completed triangular face is incorporated into the initial text triangular mesh; The order of vertices in the initial text triangular mesh is corrected to obtain a target text triangular mesh, and a target three-dimensional mesh facet is generated based on the target text triangular mesh.
2. The method for converting text into three-dimensional mesh surfaces according to claim 1, It is characterized in that The step of obtaining the characters to be processed, obtaining the character outline vector paths of the characters to be processed, and grouping the character outline vector paths includes: Obtain the text to be processed, and obtain the initial text outline vector path of the text to be processed; Fitting the initial character outline vector path through straight line segments to obtain the character outline vector path; Acquire a vertex sequence in the character outline vector path, and perform direction calculation on the vertices in the vertex sequence to obtain vertex directions, wherein the vertex directions include clockwise and counterclockwise directions; The character outline vector paths are grouped based on the vertex directions to obtain the outline groups, wherein the clockwise direction corresponds to the outer outline group, and the counterclockwise direction corresponds to the inner outline group.
3. The method for converting text into three-dimensional mesh surface according to claim 1, It is characterized in that The step of calculating the centroid of the triangular faces in the text triangular mesh and removing the triangular faces outside the outline of the text triangular mesh based on the centroid to obtain an initial text triangular mesh includes: Taking any three vertices in the text triangle mesh as a group of vertex combinations, and constructing a triangle face combination based on the vertex combination, wherein the triangle face combination includes three triangle faces; Calculate the centroid of each triangle in the triangle combination, and determine whether the centroid meets the preset requirements; If any of the centroid points does not meet the preset requirements, the triangular faces are combined as triangular faces outside the outline, and the triangular faces outside the outline are removed from the text triangular mesh to obtain the initial text triangular mesh.
4. The method for converting text into three-dimensional mesh surface according to any one of claims 1 to 3, It is characterized in that The method of correcting the order of vertices in the initial text triangular mesh to obtain a target text triangular mesh, and generating a target three-dimensional mesh face based on the target text triangular mesh, comprises: Calculating the vertex cross product of each triangle face in the initial text triangle mesh; Based on the vertex cross product, the vertices in the initial text triangle mesh are corrected sequentially in the same direction to obtain the target text triangle mesh; The target three-dimensional mesh patch is generated based on the target text triangular mesh.
5. A device for converting text into three-dimensional mesh surfaces, It is characterized in that include: A module for acquiring characters to be processed, used for acquiring characters to be processed, acquiring character contour vector paths of the characters to be processed, and grouping the character contour vector paths to obtain contour groups, wherein the contour groups are divided into outer contour groups and inner contour groups; A text triangular mesh generation module is used to generate a text triangular mesh from the text contour vector path based on the outer contour group and the inner contour group, and identify the missing condition of the triangular face of the edge fitting straight line segment in the text triangular mesh, wherein the missing condition of the triangular face is divided into a partial missing condition and a complete missing condition; A completion point acquisition unit is used to acquire the missing edge line corresponding to the partial missing condition, and acquire the triangular face intersecting the missing edge line to obtain the missing triangular face, and acquire the vertex and two endpoints corresponding to the missing triangular face as the completion points; A cross product result calculation unit, used for removing the missing triangular faces from the text triangular mesh, and calculating the cross product of the completion points to obtain a cross product result; A first complement triangle surface generating unit, configured to generate a first complement triangle surface based on the cross product result, and merge the first complement triangle surface into the text triangle mesh; A starting point identification unit, used to identify the starting point and the end point of the fracture edge line corresponding to the complete missing state; A triangular face recognition unit, used to respectively recognize the triangular face corresponding to the starting point and the triangular face corresponding to the end point, and obtain the starting point triangular face and the end point triangular face; A connected line segment acquisition unit, used to acquire an edge line segment connected to the starting point in the initial point triangular face as a starting point connected line segment, and to acquire an edge line segment connected to the end point in the end point triangular face as an end point connected line segment; An angle calculation unit, used to calculate the angle between the starting point and the line segment connected to the starting point to obtain the starting point angle, and to calculate the angle between the end point and the line segment connected to the end point to obtain the end point angle; A second complementary triangle surface generation unit is used to obtain a target vertex that meets a preset condition based on the starting point angle and the end point angle, and to construct a triangle surface corresponding to the full missing state based on the target vertex to obtain a second complementary triangle surface, and to merge the second complementary triangle surface into the text triangle mesh; The module for removing triangular faces outside the outline is used to calculate the centroid of the triangular faces in the text triangular mesh, and based on the centroid, remove the triangular faces outside the outline in the text triangular mesh to obtain an initial text triangular mesh; An edge segment combination acquisition unit, used to acquire any edge segment combination in the initial text triangulation network, wherein the edge segment combination is two associated edge segments; an incomplete triangular face acquisition unit, configured to calculate the angle between two edge line segments in the edge line segment combination by a preset algorithm, obtain the edge line segment combination angle, and acquire the incomplete triangular face based on the edge line segment combination angle, wherein the incomplete triangular face includes two target edge line segments; An initial building vertex unit, used to obtain the vertices of the incomplete triangle except the two target edge segments as initial building vertices; A third complement triangle face generation unit is used to obtain a target component vertex according to the number of occurrences of the initial component vertex, and based on the target component vertex, to complement the incomplete triangle face to obtain a third complement triangle face, and to merge the third complement triangle face into the initial text triangle mesh; The target three-dimensional mesh patch generation module is used to correct the order of vertices in the initial text triangular mesh to obtain a target text triangular mesh, and generate a target three-dimensional mesh patch based on the target text triangular mesh.
6. A computer device, It is characterized in that The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the method for converting text into three-dimensional mesh facets as claimed in any one of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for converting text into a three-dimensional mesh surface according to any one of claims 1 to 4 is implemented.
