Plane model enclosing polygon generation method, device and furniture contour recognition method
By constructing a rectangular enclosure box and using an algorithm with constrained conditions to process the mesh model, a smooth and distance-constrained enclosure polygon is generated, which solves the problems of self-intersection and low fit of enclosure polygons in the prior art, and realizes efficient model editing and furniture contour recognition.
Patent Information
- Application Number
- CN202111163451.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2041-09-30
AI Technical Summary
The prior art is difficult to generate planar models that strictly meet the encirclement and have no self-intersecting constraints, especially in complex models and furniture outline recognition.
By obtaining the mesh model of the plane model, a rectangular bounding box is constructed, and the mesh model and bounding box are processed using an algorithm with constraints to generate smooth, distance-constrained bounding polygons. Specific steps include judging the connectivity of the mesh model, selecting the appropriate Delaunay triangulation algorithm, iteratively optimizing the triangle set to generate the surrounding polygon, and reducing the number of vertices and improving smoothness through topological optimization and local energy optimization.
The generated enclosing polygon has smoothness, distance constraints and high fit, which can effectively enclose flat models and be suitable for complex models and furniture outline recognition, improving the efficiency of model editing and graphics processing.
Smart Images

Figure CN114119804B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computer graphics, and in particular to a method and device for generating enclosing polygons of a plane model and a method for recognizing furniture contours. Background Art
[0002] With the rapid development of plane model acquisition technology, the accuracy and complexity of models processed by computer graphics are getting higher and higher. The previous geometric processing algorithms are facing new challenges in universality and computational complexity. It is a trend to use enclosing meshes with similar shapes to the original model but fewer vertices as enclosing polygons to connect complex models and algorithms. In the field of model editing, generating an enclosing polygon for a complex model can greatly improve efficiency. By manipulating the enclosing polygon, the original model can be deformed in real time and smoothly. Enclosing polygons are widely used in deformation migration, collision detection, home detection and other fields.
[0003] In the prior art, the enclosing polygons of the plane model are usually constructed in an interactive or manual manner. The existing method of generating enclosing polygons cannot theoretically guarantee strict enclosing properties, and there is no self-intersection constraint. For complex models, the algorithm may fail or the enclosing polygons may self-intersect or intersect with the input model. The generated enclosing polygons are quite different from the plane model. In the field of home furnishings, in order to construct a good home furnishing rendering, it is necessary to simulate the movement of the home furnishings, which requires the generation of good enclosing polygons for the furniture, but the existing generation methods are not effective. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a method and device for generating an enclosing polygon of a plane model and a method for recognizing furniture contours, which can generate an enclosing polygon that is smooth, has distance constraints, and is close to the actual plane model.
[0005] In a first aspect, an embodiment of the present application provides a method for generating an enclosing polygon of a plane model, comprising:
[0006] Get the mesh model of the plane model;
[0007] Constructing a rectangular bounding box of the grid model;
[0008] The grid model and the rectangular bounding box are processed using an algorithm with constraints to generate an enclosing polygon of the grid model; the enclosing polygon encloses the grid model and has no intersection with the grid model.
[0009] In the above implementation process, firstly, by obtaining the mesh model of the plane model, the plane model can be two-dimensionalized, and a rectangular bounding box of the mesh model is constructed to form a preliminary construction basis. The algorithm of the condition to be constrained is used for the mesh model and the rectangular bounding box to generate the enclosing polygon. Compared with the prior art, by constructing the rectangular bounding box and using the algorithm of the condition to be constrained, the generated enclosing polygon can be distance-constrained and smooth.
[0010] Furthermore, the step of using an algorithm with constraints on the mesh model to generate enclosing polygons of the mesh model comprises:
[0011] Determining whether the grid model is a simply connected graph;
[0012] If yes, triangulate the rectangular bounding box and the outer boundary of the mesh model using a constrained Delaunay triangulation algorithm to obtain a first triangle set; generate the enclosing polygon according to the first triangle set;
[0013] If not, use a constrained Delaunay triangulation algorithm to triangulate the inner boundary of the mesh model, the outer boundary of the mesh model and the outer boundary of the rectangular bounding box to obtain a second triangle set; and generate the enclosing polygon according to the second triangle set.
[0014] In the above implementation process, the rectangular bounding box and the mesh model are processed by a constrained Delaunay triangulation algorithm, and the obtained first triangle set has a higher degree of fit to the mesh model.
[0015] Furthermore, the step of generating the enclosing polygon according to the first triangle set includes:
[0016] Step 1: Obtaining the boundary of the grid model;
[0017] Step 2: removing triangles in the first triangle set that are not adjacent to the boundary of the mesh model, to obtain a first triangle set after removal;
[0018] Step 3, obtaining all boundary points in the first triangle set after the removal to form a first boundary point set;
[0019] Step 4: Obtain a first Hausdorff distance from the first boundary point set to the grid model and a second Hausdorff distance from the grid model to the first boundary point set;
[0020] Step 5: Determine whether the first Hausdorff distance is greater than the second Hausdorff distance; if so, execute step 6; if not, execute step 7;
[0021] Step 6: Determine whether the first Hausdorff distance is greater than a first preset value, if so, execute step 8; if not, execute step 10;
[0022] Step 7: Determine whether the second Hausdorff distance is greater than a second preset value, if so, execute step 9, if not, execute step 10;
[0023] Step 8: Update the first triangle set after removal: connect the midpoints of all sides of each triangle in the first triangle set after removal; use the first triangle set after removal as the first triangle set; and execute step 2;
[0024] Step nine: obtaining the first boundary point farthest from the first boundary point set in the mesh model, and obtaining the first shortest path from the first boundary point to the second boundary point set; the first shortest path is composed of the edges of the triangles in the first triangle set after removal; updating the first triangle set after removal: connecting the midpoints of all the edges of the triangles where the edges constituting the first shortest path are located to obtain multiple triangles; using the first triangle set after removal as the first triangle set; executing step two;
[0025] Step 10: Determine that the figure formed by the boundary of the first triangle set after the removal is the enclosing polygon.
[0026] In the above implementation process, triangles in the first triangle set that are not adjacent to the boundary of the grid model are removed, so that the boundary composed of the edges of the remaining triangles can be aligned with the boundary of the grid model. The Hausdorff distance can reflect the degree of discreteness of two point sets. On this basis, the first Hausdorff distance from the first boundary point set to the grid model and the second Hausdorff distance from the grid model to the first boundary point set are obtained, and thresholds are set according to the first Hausdorff distance and the second Hausdorff distance. The first triangle set is iterated, and finally the graphics composed of the outer boundary of the iterated first triangle set can be highly aligned with the grid model.
[0027] Furthermore, the step of generating the enclosing polygon according to the second triangle set includes:
[0028] Step 1: Obtaining the boundary of the grid model;
[0029] Step 2: removing triangles in the second triangle set that are not adjacent to the boundary of the mesh model to obtain a second triangle set after removal;
[0030] Step 3, obtaining all boundary points in the removed second triangle set to form a second boundary point set;
[0031] Step 4: obtaining a third Hausdorff distance from the second boundary point set to the grid model and a fourth Hausdorff distance from the grid model to the second boundary point set;
[0032] Step 5: Determine whether the third Hausdorff distance is greater than the fourth Hausdorff distance; if so, execute step 6; if not, execute step 7;
[0033] Step 6: Determine whether the third Hausdorff distance is greater than a third preset value, if so, execute step 8; if not, execute step 10;
[0034] Step 7: Determine whether the fourth Hausdorff distance is greater than a fourth preset value, if so, execute step 9, if not, execute step 10;
[0035] Step 8: Update the removed second triangle set: connect the midpoints of all sides of each triangle in the removed second triangle set; use the removed second triangle set as the second triangle set, and execute step 2;
[0036] Step nine: obtaining the second boundary point farthest from the second boundary point set in the mesh model, and obtaining the second shortest path from the second boundary point to the second boundary point set; the second shortest path is composed of the edges of the triangles in the removed second triangle set; updating the removed second triangle set: connecting the midpoints of all the edges of the triangles where the edges constituting the second shortest path are located to obtain a plurality of triangles; using the removed second triangle set as the second triangle set; executing step two;
[0037] Step 10: Determine that the figure formed by the boundary of the second triangle set after the removal is the enclosing polygon.
[0038] In the above implementation process, triangles in the second triangle set that are not adjacent to the boundary of the grid model are removed, so that the boundary composed of the edges of the remaining triangles can be aligned with the boundary of the grid model. The Hausdorff distance can reflect the degree of discreteness of the two point sets. On this basis, the third Hausdorff distance from the second boundary point set to the grid model and the fourth Hausdorff distance from the grid model to the second boundary point set are obtained, and thresholds are set according to the third Hausdorff distance and the fourth Hausdorff distance. The second triangle set is iterated, and finally the graphics composed of the outer boundary of the iterated second triangle set can be highly aligned with the grid model.
[0039] Furthermore, after the step of generating the enclosing polygons of the mesh model, the method further comprises:
[0040] The enclosing polygon is processed using the topology optimization algorithm to obtain an enclosing polygon with a reduced number of vertices.
[0041] In the above process, by using the optimization algorithm, it is possible to iterate the enclosing polygon, obtain the enclosing polygon with a reduced number of vertices, and reduce the complexity of the enclosing polygon.
[0042] Furthermore, the step of processing the enclosing polygon using a topology optimization algorithm to obtain an enclosing polygon with a reduced number of vertices includes:
[0043] Traverse the vertices of the enclosing polygon and perform the following operations on each vertex of the enclosing polygon:
[0044] Connect the left vertex and the right vertex of the current traversal vertex to obtain a new enclosing polygon;
[0045] Determine whether the bidirectional Hausdorff distance from the new enclosing polygon to the grid model meets a preset condition;
[0046] If yes, delete the currently traversed vertex;
[0047] If not, retain the currently traversed vertex;
[0048] All retained vertices are connected in sequence to obtain an enclosing polygon with a reduced number of vertices.
[0049] In the above implementation process, by traversing the vertices, deleting the currently traversed vertices, and determining whether the degree of fit between the enclosing polygon and the mesh model is affected after deleting the currently traversed vertices, if the fit is not affected, retaining the vertices. Based on the above implementation, the low complexity of the enclosing polygon can be maintained when the enclosing polygon fits the mesh model.
[0050] Furthermore, the step of processing the enclosing polygon using a topology optimization algorithm to obtain an enclosing polygon with a reduced number of vertices includes:
[0051] Traverse the vertices of the enclosing polygon and perform the following operations on each vertex of the enclosing polygon:
[0052] Connect the left vertex and the right vertex of the current traversal vertex to obtain the first pending edge;
[0053] Obtaining the normal direction of the first undetermined edge;
[0054] Move the left vertex and the right vertex of the currently traversed vertex along the normal direction by a preset distance;
[0055] Determine whether the bidirectional Hausdorff distance from the enclosing polygon to the mesh model after moving the right vertex and the left vertex meets a preset condition;
[0056] If so, update the coordinates of the left vertex and the right vertex, and delete the currently traversed vertex;
[0057] If not, traverse the next vertex;
[0058] The updated vertices are connected in sequence to obtain the enclosing polygon with a reduced number of vertices.
[0059] In the above implementation process, the first pending edge is the line connecting the left vertex and the right vertex of the currently traversed vertex. If the distance constraint of the newly generated enclosing polygon still holds after moving in the normal direction of the first pending edge, it means that the vertex is not very meaningful to the enclosing polygon and can be deleted. Based on the above implementation, the low complexity of the enclosing polygon can be maintained when the enclosing polygon fits the mesh model.
[0060] Furthermore, before the step of traversing the next vertex, the method further includes:
[0061] Determine whether the movement times of the left vertex and the right vertex have reached a preset maximum value;
[0062] If so, update the coordinates of the left vertex and the right vertex according to the coordinates of the currently traversed vertex, the coordinates of the left vertex, and the coordinates of the right vertex;
[0063] If not, the current traversal vertex continues to be moved along the normal direction by the preset distance.
[0064] In the above implementation process, the maximum moving distance set for each vertex traversal on the first pending edge can prevent each vertex from moving too far and affecting the fit between the enclosing polygon and the mesh model.
[0065] Furthermore, after the step of using a topology optimization algorithm to process the enclosing polygon to obtain an enclosing polygon with a reduced number of vertices, the method further includes:
[0066] The surrounding polygon with reduced number of vertices is optimized using a local energy optimization algorithm to obtain a smooth surrounding polygon.
[0067] In the above implementation process, the enclosing polygon can be made smoother by using the local energy optimization algorithm.
[0068] In a second aspect, an embodiment of the present application provides a method for recognizing the outline of furniture, which uses the method for generating an enclosing polygon of a plane model as described in the first aspect; wherein:
[0069] Before the step of obtaining the grid model of the plane model, the step further includes: obtaining a plane model of furniture;
[0070] After the step of generating the enclosing polygon of the mesh model, the method further includes: determining the enclosing polygon as the outline of the furniture.
[0071] In a third aspect, an embodiment of the present application provides a device for generating an enclosing polygon, including:
[0072] An acquisition module, used to acquire a mesh model;
[0073] A construction module, used to construct a rectangular bounding box of the grid model;
[0074] A generation module is used to process the grid model and the rectangular bounding box using an algorithm with constraints to generate an enclosing polygon of the grid model; the enclosing polygon encloses the grid model and has no intersection with the grid model.
[0075] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0077] Figure 1 A schematic diagram of a flow chart of a method for generating an enclosing polygon of a plane model provided in an embodiment of the present application;
[0078] Figure 2 A schematic flow chart of another method for generating an enclosing polygon of a plane model provided in an embodiment of the present application;
[0079] Figure 3 A schematic diagram of a process for generating enclosing polygons of a mesh model provided in an embodiment of the present application;
[0080] Figure 4 A schematic diagram of a process of generating an enclosing polygon according to a first triangle set provided in an embodiment of the present application;
[0081] Figure 5 A schematic diagram of a process of generating an enclosing polygon according to a second triangle set provided in an embodiment of the present application;
[0082] Figure 6 A schematic diagram of a process for obtaining an enclosing polygon with a reduced number of vertices provided in an embodiment of the present application;
[0083] Figure 7 Another schematic diagram of a process for obtaining an enclosing polygon with a reduced number of vertices provided in an embodiment of the present application;
[0084] Figure 8 A schematic diagram of a process flow of a furniture contour recognition method provided in an embodiment of the present application;
[0085] Fig. 9 A schematic diagram of the structure of a device for generating an enclosing polygon provided in an embodiment of the present application. DETAILED DESCRIPTION
[0086] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0087] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0088] Example 1
[0089] See also Figure 1 The present application provides a method for generating an enclosing polygon of a plane model, comprising:
[0090] S11: Obtaining a mesh model of the plane model;
[0091] S12: construct a rectangular bounding box of the mesh model;
[0092] S13: Processing the mesh model and the rectangular bounding box using an algorithm with constraints to generate an enclosing polygon of the mesh model; the enclosing polygon encloses the mesh model and has no intersection with the mesh model.
[0093] In the above embodiment, the plane model may be a home model, a character model, etc. The size of the rectangular bounding box is determined according to the size of the specifically generated grid model.
[0094] In the above embodiment, the plane model is firstly obtained by obtaining the mesh model of the plane model, the plane model is two-dimensionalized, and a rectangular bounding box of the mesh model is constructed to form a preliminary construction basis. The algorithm of the condition to be constrained is used for the mesh model and the rectangular bounding box to generate the enclosing polygon. Compared with the prior art, by constructing the rectangular bounding box and using the algorithm of the condition to be constrained, the generated enclosing polygon can be constrained by distance and smooth.
[0095] Example 2
[0096] See also Figure 2 , the embodiment of the present application provides another method for generating an enclosing polygon of a plane model, comprising:
[0097] S21: Obtaining a mesh model of the plane model;
[0098] S22: construct a rectangular bounding box of the mesh model;
[0099] S23: using an algorithm with constraints on the mesh model and the rectangular bounding box to generate an enclosing polygon of the mesh model; the enclosing polygon encloses the mesh model and has no intersection with the mesh model;
[0100] S24: using a topology optimization algorithm to process the enclosing polygon to obtain an enclosing polygon with a reduced number of vertices;
[0101] S25: optimizing the enclosing polygon with reduced vertex number using a local energy optimization algorithm to obtain a smooth enclosing polygon;
[0102] By using an optimization algorithm, it is possible to iterate the enclosing polygon to obtain an enclosing polygon with a reduced number of vertices, thereby reducing the complexity of the enclosing polygon.
[0103] In one embodiment, see Figure 3 , S23 further comprises:
[0104] S231: Determine whether the mesh model is a simply connected graph; if so, execute S232; if not, execute S233;
[0105] S232: triangulate the rectangular bounding box and the outer boundary of the mesh model using a constrained Delaunay triangulation algorithm to obtain a first triangle set; and generate an enclosing polygon according to the first triangle set;
[0106] S233: triangulate the inner boundary of the mesh model, the outer boundary of the mesh model and the outer boundary of the rectangular bounding box using a constrained Delaunay triangulation algorithm to obtain a second triangle set; and generate an enclosing polygon based on the second triangle set.
[0107] In S232, the rectangular bounding box and the mesh model are processed using a constrained Delaunay triangulation algorithm, and the obtained first triangle set has a higher degree of fit to the mesh model.
[0108] In the above embodiment, the constrained Delaunay triangulation algorithm refers to combining some unstructured scattered points into a triangular mesh, and the triangulation satisfies the empty circularity, the minimum angle maximization property, and the given edge constraints. The prior art has been documented and will not be repeated here.
[0109] Further, see Figure 4 , which is a possible implementation of step S232, including:
[0110] S2321: Get the boundary of the grid model;
[0111] S2322: removing triangles in the first triangle set that are not adjacent to the boundary of the mesh model, to obtain a first triangle set after removal;
[0112] S2323: Acquire all boundary points in the first triangle set after removal to form a first boundary point set;
[0113] S2324: Obtain a first Hausdorff distance from the first boundary point set to the grid model and a second Hausdorff distance from the grid model to the first boundary point set;
[0114] S2325: Is the first Hausdorff distance greater than the second Hausdorff distance? If so, execute S2326; if not, execute S2327;
[0115] S2326: Is the first Hausdorff distance greater than the first preset value? If so, execute S2328; if not, execute S23210;
[0116] S2327: Is the second Hausdorff distance greater than the second preset value? If so, execute S2329; if not, execute S23210;
[0117] S2328: Update the first triangle set after removal: connect the midpoints of all sides of each triangle in the first triangle set after removal; use the first triangle set after removal as the first triangle set; execute S2322;
[0118] S2329: Obtain the first boundary point farthest from the first boundary point set in the mesh model, and obtain the first shortest path from the first boundary point to the first boundary point set; the first shortest path is composed of the edges of the triangles in the first triangle set after removal; update the first triangle set after removal: connect the midpoints of all the edges of the triangles where the edges constituting the first shortest path are located to obtain multiple triangles; use the first triangle set after removal as the first triangle set; execute step 2;
[0119] S23210: Determine whether the figure formed by the boundary of the first triangle set after the current removal is an enclosing polygon.
[0120] Removing triangles in the first triangle set that are not adjacent to the boundary of the mesh model can make the boundary composed of the edges of the remaining triangles fit the boundary of the mesh model. The Hausdorff distance can reflect the degree of discreteness of the two point sets. On this basis, the first Hausdorff distance from the first boundary point set to the mesh model and the second Hausdorff distance from the mesh model to the first boundary point set are obtained, and a threshold is set according to the first Hausdorff distance and the second Hausdorff distance. The first triangle set is iterated, and finally the graphics composed of the outer boundary of the iterated first triangle set can be highly fitted with the mesh model.
[0121] Further, see Figure 5 , S233 can be implemented in the following ways, including:
[0122] S2331: Get the boundary of the mesh model; (the boundary consists of the edges on the periphery)
[0123] S2332: removing triangles in the second triangle set that are not adjacent to the boundary of the mesh model, to obtain a second triangle set after removal;
[0124] S2333: Acquire all boundary points in the removed second triangle set to form a second boundary point set;
[0125] S2334: Obtain a third Hausdorff distance from the second boundary point set to the grid model and a fourth Hausdorff distance from the grid model to the second boundary point set;
[0126] S2335: Determine whether the third Hausdorff distance is greater than the fourth Hausdorff distance; if so, execute S2336; if not, execute S2337;
[0127] S2336: Determine whether the third Hausdorff distance is greater than a third preset value, if so, execute S2338; if not, execute S23310;
[0128] S2337: Determine whether the fourth Hausdorff distance is greater than a fourth preset value, if so, execute S2339; if not, execute S23310;
[0129] S2338: Update the removed second triangle set: connect the midpoints of all sides of each triangle in the removed second triangle set; use the removed second triangle set as the second triangle set, and execute S2332;
[0130] S2339: Obtain the second boundary point farthest from the second boundary point set in the mesh model, and obtain the second shortest path from the second boundary point to the second boundary point set; the second shortest path is composed of the edges of the triangles in the removed second triangle set; update the removed second triangle set: connect the midpoints of all the edges of the triangles where the edges constituting the second shortest path are located to obtain multiple triangles; use the removed second triangle set as the second triangle set; execute step 2;
[0131] S23310: Determine whether the figure formed by the boundary of the second triangle set after the current removal is an enclosing polygon.
[0132] In the above embodiment, removing the triangles in the second triangle set that are not adjacent to the boundary of the grid model can make the boundary composed of the edges of the remaining triangles fit the boundary of the grid model. The Hausdorff distance can reflect the degree of discreteness of the two point sets. On this basis, the third Hausdorff distance from the second boundary point set to the grid model and the fourth Hausdorff distance from the grid model to the second boundary point set are obtained, and a threshold is set according to the third Hausdorff distance and the fourth Hausdorff distance. The second triangle set is iterated, and finally the graphics composed of the outer boundary of the iterated second triangle set can be highly fit with the grid model.
[0133] Further, see Figure 6 , which is a possible implementation of S24, traverses the vertices of the enclosing polygon and performs the following operations on each vertex of the enclosing polygon:
[0134] S2411: Connect the left vertex and the right vertex of the current traversal vertex to obtain a new enclosing polygon;
[0135] S2412: Determine whether the bidirectional Hausdorff distance from the new enclosing polygon to the mesh model meets the preset condition; if so, execute S2413; if not, execute S2414;
[0136] The bidirectional Hausdorff distance is the maximum value of the Hausdorff distance from the new enclosing polygon to the mesh model and the distance from the mesh model to the new enclosing polygon. Thresholds are set for the two Hausdorff distances. For the judgment steps, refer to the judgment method of the Hausdorff distance in S232 and S233.
[0137] S2413: Delete the current traversal vertex;
[0138] S2414: keep the current traversal vertex;
[0139] Connect all retained vertices in sequence to obtain an enclosing polygon with a reduced number of vertices.
[0140] Further, see Figure 7 , which is another possible implementation of S24, traverses the vertices of the enclosing polygon and performs the following operations on each vertex of the enclosing polygon:
[0141] S2421: Connect the left vertex and the right vertex of the current traversal vertex to obtain the first pending edge;
[0142] S2422: Obtain the normal direction of the first undetermined edge;
[0143] S2423: Move the left vertex and / or the right vertex of the currently traversed vertex along the normal direction by a preset distance;
[0144] S2424: Determine whether the bidirectional Hausdorff distance from the enclosing polygon to the mesh model after moving the right vertex and / or the left vertex meets a preset condition; if so, execute S2425; if not, execute S426;
[0145] S2425: Update the coordinates of the left vertex and the right vertex, and delete the current traversal vertex;
[0146] S2426: Traverse the next vertex.
[0147] Before S2426, the method further includes: determining whether the movement times of the left vertex and the right vertex have reached a preset maximum value;
[0148] If so, update the coordinates of the left vertex and the right vertex according to the coordinates of the current traversal vertex, the coordinates of the left vertex, and the coordinates of the right vertex; if not, continue to move the current traversal vertex along the normal direction by a preset distance.
[0149] Update the coordinates of the left and right vertices according to the coordinates of the current traversal vertex, the coordinates of the left vertex, and the coordinates of the right vertex; this can be achieved in the following ways:
[0150] Project the right vertex onto the straight line connecting the left vertex and the current traversal vertex to obtain a new right vertex; determine whether the bidirectional Hausdorff distance from the enclosing polygon to the mesh model after moving the right vertex meets the preset conditions;
[0151] If so, update the coordinates of the right vertex and delete the currently traversed vertex;
[0152] If not, update the coordinates of the left vertex of the current traversal vertex according to the right vertex of the current traversal vertex after the move and the current traversal vertex after the move: project the left vertex onto the straight line connecting the right vertex and the current traversal vertex, and determine whether the new enclosing polygon after updating the left vertex satisfies the distance constraint. If so, update the coordinates of the left vertex and delete the current traversal vertex; if not, do not update the left vertex.
[0153] Repeat the process multiple times, each time finding the vertex on the enclosing polygon whose angle is closest to π, and use the above strategy to delete the vertex until it is confirmed that all vertices in the cage cannot be deleted using the above strategy.
[0154] The updated vertices are connected in sequence to obtain an enclosing polygon with a reduced number of vertices.
[0155] In a possible implementation, in S25, local smooth energy optimization and local approximate energy optimization are performed.
[0156] In order to make the enclosing polygon as smooth as possible, the coordinates of each vertex on the enclosing polygon are optimized in turn to minimize the following local smoothing energy:
[0157] E1=||x i -x i-1 || 2 +||x i -x i+1 || 2 -||x i-1 -x i+1 || 2
[0158] where x i is the vertex coordinate of the i-th vertex on the enclosing polygon, x i-1 is the coordinate of the left vertex of the i-th vertex, x i+1is the coordinate of the left vertex of the i-th vertex. Traverse each vertex of the enclosing polygon, find the negative gradient direction that makes the energy decrease at the vertex, and apply the line search method until the new enclosing polygon satisfies the Armijo-Goldstein criterion and the enclosing property, no self-intersection, and bounded Hausdorff distance constraints.
[0159] In order to make the enclosing polygon as close to the original model as possible, the coordinates of each vertex on the enclosing polygon are optimized in turn to minimize the following local approximation energy:
[0160]
[0161] where d(·,·) is the distance operator, e j are the left and right edges adjacent to the current traversal vertex to be optimized, x i is a boundary point of the mesh model and the closest point on its corresponding enclosing polygon falls on e j Traverse each vertex on the enclosing polygon, find the negative gradient direction that causes the energy to drop at the vertex, and do a line search.
[0162] Example 3
[0163] See also Figure 8 The present application provides a furniture contour recognition method, using the method in Example 1, the furniture contour recognition method includes:
[0164] S31: Obtaining a plane model of furniture;
[0165] S32: Obtaining a mesh model of the plane model;
[0166] S33: using an algorithm with constraint conditions to process the mesh model and the rectangular bounding box to generate an enclosing polygon of the mesh model; the enclosing polygon encloses the mesh model and has no intersection with the mesh model;
[0167] S34: Determine the enclosing polygon as the outline of the furniture.
[0168] Example 4
[0169] See also Fig. 9 , an embodiment of the present application provides a device for generating an enclosing polygon of a plane model, comprising:
[0170] Acquisition module 1, used for acquiring a grid model;
[0171] Construction module 2, used to construct a rectangular bounding box of the grid model;
[0172] The generation module 3 is used to process the grid model and the rectangular bounding box using an algorithm with constraints to generate an enclosing polygon of the grid model; the enclosing polygon encloses the grid model and has no intersection with the grid model.
[0173] The generating module 3 is also used to process the enclosing polygon using a topology optimization algorithm to obtain an enclosing polygon with a reduced number of vertices.
[0174] Generation module 3 is also used to determine whether the mesh model is a simply connected graph; if so, use a constrained Delaunay triangulation algorithm to triangulate the outer boundary of the rectangular bounding box and the mesh model to obtain a first triangle set; generate an enclosing polygon based on the first triangle set; if not, use a constrained Delaunay triangulation algorithm to triangulate the inner boundary of the mesh model, the outer boundary of the mesh model and the outer boundary of the rectangular bounding box to obtain a second triangle set; generate an enclosing polygon based on the second triangle set.
[0175] The generation module 3 is also used to execute the following method: Step 1: obtain the boundary of the grid model; Step 2: remove the triangles in the first triangle set that are not adjacent to the boundary of the grid model to obtain the first triangle set after removal; Step 3: obtain all boundary points in the first triangle set after removal to form a first boundary point set; Step 4: obtain a first Hausdorff distance from the first boundary point set to the grid model and a second Hausdorff distance from the grid model to the first boundary point set; Step 5: determine whether the first Hausdorff distance is greater than the second Hausdorff distance; if so, execute step 6, if not, execute step 7; Step 6: determine whether the first Hausdorff distance is greater than a first preset value, if so, execute step 8; if not, execute step 10; Step 7: determine whether the second Hausdorff distance is greater than The second preset value, if yes, execute step nine, if not, execute step ten; step eight: update the first triangle set after removal: connect the midpoints of all edges of each triangle in the first triangle set after removal; use the first triangle set after removal as the first triangle set; execute step two; step nine: obtain the first boundary point farthest from the first boundary point set in the mesh model, and obtain the first shortest path from the first boundary point to the first boundary point set; the first shortest path is composed of the edges of the triangles in the first triangle set after removal; update the first triangle set after removal: connect the midpoints of all edges of the triangles where the edges constituting the first shortest path are located to obtain multiple triangles; use the first triangle set after removal as the first triangle set; execute step two; execute step two; step ten: determine that the figure composed of the boundaries of the current first triangle set after removal is an enclosing polygon.
[0176] The generation module 3 is also used to execute the following method: step 1: obtain the boundary of the grid model; step 2: remove the triangles in the second triangle set that are not adjacent to the boundary of the grid model to obtain the second triangle set after removal; step 3: obtain all boundary points in the second triangle set after removal to form a second boundary point set; step 4: obtain the third Hausdorff distance from the second boundary point set to the grid model and the fourth Hausdorff distance from the grid model to the second boundary point set; step 5: determine whether the third Hausdorff distance is greater than the fourth Hausdorff distance; if so, execute step 6, if not, execute step 7; step 6: determine whether the third Hausdorff distance is greater than the third preset value, if so, execute step 8; if not, execute step 10; step 7: determine whether the fourth Hausdorff distance is greater than the third preset value Is the distance greater than the fourth preset value? If so, execute step nine, if not, execute step ten; step eight: update the second triangle set after removal: connect the midpoints of all edges of each triangle in the second triangle set after removal; use the second triangle set after removal as the second triangle set and execute step two; obtain the second boundary point farthest from the second boundary point set in the mesh model, and obtain the second shortest path from the second boundary point to the second boundary point set; the second shortest path is composed of the edges of the triangles in the second triangle set after removal; update the second triangle set after removal: connect the midpoints of all edges of the triangles where the edges constituting the second shortest path are located to obtain multiple triangles; use the second triangle set after removal as the second triangle set; execute step two; step ten: determine whether the figure composed of the boundary of the current second triangle set after removal is an enclosing polygon.
[0177] The generation module 3 is also used to traverse the vertices of the enclosing polygon and perform the following operations on each vertex of the enclosing polygon: connect the left vertex and the right vertex of the current traversal vertex to obtain a new enclosing polygon; determine whether the bidirectional Hausdorff distance from the new enclosing polygon to the grid model meets the preset conditions; if so, delete the current traversal vertex; if not, retain the current traversal vertex; and connect all the retained vertices in turn to obtain an enclosing polygon with a reduced number of vertices.
[0178] The generation module 3 is also used to traverse the vertices of the enclosing polygon and perform the following operations on each vertex of the enclosing polygon:
[0179] Connect the left vertex and the right vertex of the current traversal vertex to obtain the first pending edge; obtain the normal direction of the first pending edge; move the current traversal vertex along the normal direction by a preset distance; obtain the coordinates of the current traversal vertex after the move; move the right vertex of the current traversal vertex according to the coordinates of the current traversal vertex after the move; determine whether the bidirectional Hausdorff distance from the enclosing polygon to the mesh model after the right vertex is moved meets the preset conditions; if so, update the coordinates of the right vertex; if not, update the coordinates of the left vertex of the current traversal vertex according to the updated right vertex of the current traversal vertex and the current traversal vertex after the move; connect the updated vertices in turn to obtain an enclosing polygon with a reduced number of vertices.
[0180] Generation module 3 is also used to determine whether the number of movements connecting the currently traversed vertex has reached a preset maximum value; if so, update the coordinates of the left vertex of the currently traversed vertex based on the updated right vertex of the currently traversed vertex and the moved current traversal vertex; if not, continue to move the current traversal vertex along the normal direction by a preset distance.
[0181] The generating module 3 is further used to optimize the enclosing polygon with reduced number of vertices using a local energy optimization algorithm to obtain a smooth enclosing polygon.
[0182] For the functions that can be realized by the functional modules of this device embodiment, please refer to the description of the corresponding processes of the methods in embodiments 1 and 2, which will not be repeated here.
[0183] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0184] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0185] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.
[0186] The above are only embodiments of the present application and are not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0187] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0188] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for generating an enclosing polygon of a plane model, characterized in that: include: Get the plan model of the furniture; Acquire a grid model of the plane model; Constructing a rectangular bounding box of the grid model; Using an algorithm with constraints to process the grid model and the rectangular bounding box, generating an enclosing polygon of the grid model; the enclosing polygon encloses the grid model and has no intersection with the grid model; The step of processing the mesh model and the rectangular bounding box using an algorithm with constraints to generate an enclosing polygon of the mesh model comprises: Determining whether the grid model is a simply connected graph; If yes, triangulate the rectangular bounding box and the outer boundary of the mesh model using a constrained Delaunay triangulation algorithm to obtain a first triangle set; generate the enclosing polygon according to the first triangle set; The step of generating the enclosing polygon according to the first triangle set comprises: Step 1: Obtaining the boundary of the grid model; Step 2: removing triangles in the first triangle set that are not adjacent to the boundary of the mesh model, to obtain a first triangle set after removal; Step 3, obtaining all boundary points in the first triangle set after the removal to form a first boundary point set; Step 4: Obtain a first Hausdorff distance from the first boundary point set to the grid model and a second Hausdorff distance from the grid model to the first boundary point set; Step 5: Determine whether the first Hausdorff distance is greater than the second Hausdorff distance; if so, execute step 6; if not, execute step 7; Step 6: Determine whether the first Hausdorff distance is greater than a first preset value, if so, execute step 8; if not, execute step 10; Step 7: Determine whether the second Hausdorff distance is greater than a second preset value, if so, execute step 9, if not, execute step 10; Step 8: Update the first triangle set after removal: connect the midpoints of all sides of each triangle in the first triangle set after removal; use the first triangle set after removal as the first triangle set; and execute step 2; Step nine: obtaining the first boundary point farthest from the first boundary point set in the mesh model, obtaining the first shortest path from the first boundary point to the first boundary point set; the first shortest path is composed of the edges of the triangles in the first triangle set after removal; updating the first triangle set after removal: connecting the midpoints of all the edges of the triangles where the edges constituting the first shortest path are located to obtain a plurality of triangles; using the first triangle set after removal as the first triangle set; executing step two; Step 10: Determine that the figure formed by the boundary of the first triangle set after the removal is the enclosing polygon.
2. The method for generating an enclosing polygon of a plane model according to claim 1, characterized in that: The step of processing the mesh model and the rectangular bounding box using an algorithm with constraints to generate an enclosing polygon of the mesh model also includes: Determining whether the grid model is a simply connected graph; If not, triangulate the inner boundary of the mesh model, the outer boundary of the mesh model and the outer boundary of the rectangular bounding box using a constrained Delaunay triangulation algorithm to obtain a second triangle set; and generate the enclosing polygon according to the second triangle set; The step of generating the enclosing polygon according to the second triangle set comprises: Step 1: Obtaining the boundary of the grid model; Step 2: removing triangles in the second triangle set that are not adjacent to the boundary of the mesh model to obtain a second triangle set after removal; Step 3, obtaining all boundary points in the removed second triangle set to form a second boundary point set; Step 4: obtaining a third Hausdorff distance from the second boundary point set to the grid model and a fourth Hausdorff distance from the grid model to the second boundary point set; Step 5: Determine whether the third Hausdorff distance is greater than the fourth Hausdorff distance; if so, execute step 6; if not, execute step 7; Step 6: Determine whether the third Hausdorff distance is greater than a third preset value, if so, execute step 8; if not, execute step 10; Step 7: Determine whether the fourth Hausdorff distance is greater than a fourth preset value, if so, execute step 9, if not, execute step 10; Step 8: Update the removed second triangle set: connect the midpoints of all sides of each triangle in the removed second triangle set; use the removed second triangle set as the second triangle set, and execute step 2; Step nine: obtaining the second boundary point farthest from the second boundary point set in the mesh model, obtaining the second shortest path from the second boundary point to the second boundary point set; the second shortest path is composed of the edges of the triangles in the removed second triangle set; updating the removed second triangle set: connecting the midpoints of all the edges of the triangles where the edges constituting the second shortest path are located to obtain a plurality of triangles; using the removed second triangle set as the second triangle set; executing step two; Step 10: Determine that the figure formed by the boundary of the second triangle set after the removal is the enclosing polygon.
3. The method for generating an enclosing polygon of a plane model according to claim 1, characterized in that: After the step of generating the enclosing polygons of the mesh model, the method further comprises: The enclosing polygon is processed using a topology optimization algorithm to obtain an enclosing polygon with a reduced number of vertices.
4. The method for generating an enclosing polygon of a plane model according to claim 3, characterized in that: The step of processing the enclosing polygon using a topology optimization algorithm to obtain an enclosing polygon with a reduced number of vertices comprises: Traverse the vertices of the enclosing polygon and perform the following operations on each vertex of the enclosing polygon: Connect the left vertex and the right vertex of the current traversal vertex to obtain a new enclosing polygon; Determine whether the bidirectional Hausdorff distance from the new enclosing polygon to the grid model meets a preset condition; If yes, delete the currently traversed vertex; If not, retain the currently traversed vertex; All retained vertices are connected in sequence to obtain the enclosing polygon with a reduced number of vertices.
5. The method for generating an enclosing polygon of a plane model according to claim 3, characterized in that: The step of using a topology optimization algorithm to process the enclosing polygon to obtain an enclosing polygon with a reduced number of vertices comprises: Traverse the vertices of the enclosing polygon and perform the following operations on each vertex of the enclosing polygon: Connect the left vertex and the right vertex of the current traversal vertex to obtain the first pending edge; Obtaining the normal direction of the first undetermined edge; Move the left vertex and the right vertex of the currently traversed vertex along the normal direction by a preset distance; Determine whether the bidirectional Hausdorff distance from the enclosing polygon to the grid model after moving the right vertex and / or the left vertex meets a preset condition; If so, update the coordinates of the left vertex and the right vertex, and delete the currently traversed vertex; If not, traverse the next vertex; The updated vertices are connected in sequence to obtain the enclosing polygon with a reduced number of vertices.
6. The method for generating an enclosing polygon of a plane model according to claim 5, characterized in that: Before the step of traversing the next vertex, it also includes: Determine whether the movement times of the left vertex and the right vertex have reached a preset maximum value; If so, update the coordinates of the left vertex and the right vertex according to the coordinates of the currently traversed vertex, the coordinates of the left vertex, and the coordinates of the right vertex; If not, the current traversal vertex continues to be moved along the normal direction by the preset distance.
7. The method for generating an enclosing polygon of a plane model according to claim 3, characterized in that: After the step of processing the enclosing polygon using a topology optimization algorithm to obtain an enclosing polygon with a reduced number of vertices, the method further comprises: The surrounding polygon with reduced number of vertices is optimized using a local energy optimization algorithm to obtain a smooth surrounding polygon.
8. A method for furniture contour recognition, characterized in that: A method for generating an enclosing polygon of a plane model as described in any one of claims 1 to 7; wherein: After the step of generating the enclosing polygon of the mesh model, the method further includes: determining the enclosing polygon as the outline of the furniture.
9. A device for generating an enclosing polygon of a plane model, characterized in that: include: An acquisition module, used for acquiring a mesh model of a plane model of furniture; A construction module, used to construct a rectangular bounding box of the grid model; A generating module, used for processing the grid model and the rectangular bounding box using an algorithm with constraint conditions to generate an enclosing polygon of the grid model; the enclosing polygon encloses the grid model and has no intersection with the grid model; The generation module is also used for: Determining whether the grid model is a simply connected graph; If yes, triangulate the rectangular bounding box and the outer boundary of the mesh model using a constrained Delaunay triangulation algorithm to obtain a first triangle set; generate the enclosing polygon according to the first triangle set; The generation module is also used to execute the following method: Step 1: Obtaining the boundary of the grid model; Step 2: removing triangles in the first triangle set that are not adjacent to the boundary of the mesh model, to obtain a first triangle set after removal; Step 3, obtaining all boundary points in the first triangle set after the removal to form a first boundary point set; Step 4: Obtain a first Hausdorff distance from the first boundary point set to the grid model and a second Hausdorff distance from the grid model to the first boundary point set; Step 5: Determine whether the first Hausdorff distance is greater than the second Hausdorff distance; if so, execute step 6; if not, execute step 7; Step 6: Determine whether the first Hausdorff distance is greater than a first preset value, if so, execute step 8; if not, execute step 10; Step 7: Determine whether the second Hausdorff distance is greater than a second preset value, if so, execute step 9, if not, execute step 10; Step 8: Update the first triangle set after removal: connect the midpoints of all sides of each triangle in the first triangle set after removal; use the first triangle set after removal as the first triangle set; and execute step 2; Step nine: obtaining a first boundary point in the grid model that is farthest from the first boundary point set, and obtaining a first shortest path from the first boundary point to the first boundary point set; The first shortest path is composed of the edges of the triangles in the first triangle set after removal; updating the first triangle set after removal: connecting the midpoints of all the edges of the triangles where the edges constituting the first shortest path are located to obtain a plurality of triangles; using the first triangle set after removal as the first triangle set; executing step 2; Step 10: Determine that the figure formed by the boundary of the first triangle set after the removal is the enclosing polygon.