Three-dimensional model generation method and device, equipment, medium and program product
By automatically generating 3D models using CAD software, the problem of lack of stereoscopic and realistic 3D models in traditional methods is solved, realizing efficient and low-cost 3D model construction, which is suitable for mass display in 3D virtual exhibition halls.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-29
- Publication Date
- 2026-04-10
AI Technical Summary
When generating 3D models of virtual exhibition halls, existing technologies often lack a sense of depth and realism due to traditional methods. Furthermore, manual modeling is time-consuming and difficult to apply to the large-scale display of a vast number of products.
CAD software is used to automatically generate 3D models based on planar images. By generating front, back, and side meshes and mapping the texture of the planar images to the 3D meshes, a 3D model with obvious thickness characteristics is formed.
It significantly improves the spatial depth and realism of 3D models, reduces time and labor costs, and is suitable for the real-time generation of batch modeling objects.
Smart Images

Figure CN121837545A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to one or more embodiments in the field of computer-aided design technology, and more particularly to a method, apparatus, device, medium, and program product for generating three-dimensional models. Background Technology
[0002] In the retail and e-commerce sectors, 3D virtual showroom technology has been used to build online virtual stores, using 3D modeling and real-time rendering to display products in a three-dimensional way, thereby improving the efficiency of users obtaining product information.
[0003] Building a 3D virtual showroom requires a large number of 3D models. Traditional methods involve pasting 2D images onto a 3D plane for display, but the resulting models lack depth and realism, leading to a poor user experience. While professional modelers can create models manually using 3D modeling software to achieve a similar appearance to the real object, the process is time-consuming. For example, creating a model of a single complex garment can take hours to days, resulting in very high time and labor costs, making it unsuitable for large-scale displays of a vast number of products. Summary of the Invention
[0004] In view of the above, one or more embodiments of this specification provide the following technical solutions: According to a first aspect of one or more embodiments of this specification, a method for generating a three-dimensional model is proposed, the method being applied to CAD software, comprising: Obtain the planar image and model thickness of the object being modeled; Generate a planar mesh for the modeling object based on the planar image; Generate a front mesh, a back mesh, and a side mesh for the modeling object based on the planar mesh and the model thickness; The front mesh, the back mesh, and the side mesh are merged into a three-dimensional mesh, and the texture of the planar image is mapped onto the three-dimensional mesh to obtain the three-dimensional model of the modeling object.
[0005] Optionally, generating a planar mesh for the modeling object based on the planar image includes: Determine the modeling outline of the modeling object based on the planar image; A planar mesh is generated for the modeling object within the contour area corresponding to the modeling contour line.
[0006] Optionally, determining the modeling outline of the modeling object based on the planar image includes: The number of eroded pixels is calculated based on the model thickness and the resolution of the planar image, and the number of eroded pixels is positively correlated with the model thickness; Starting from the edge of the planar image, the planar image is eroded inward based on the number of eroded pixels; The contour lines are extracted from the eroded planar image to obtain the modeling contour lines.
[0007] Optionally, generating a front mesh and a back mesh for the modeling object based on the planar mesh and the model thickness includes: Calculate the mesh translation distance based on the model thickness; Based on the mesh translation distance, each vertex in the planar mesh is translated along the normal direction to generate the frontal mesh; Based on the mesh translation distance, each vertex in the planar mesh is translated in the opposite direction of the normal to generate the back face mesh, wherein the triangle index order of the back face mesh is the reverse of the triangle index order of the front face mesh.
[0008] Optionally, generating a side mesh for the modeling object based on the planar mesh and the model thickness includes: For each vertex on the modeling contour line, a side 3D point array is constructed for the vertex according to the model thickness. The side 3D point array includes multiple sampling points, and the number of sampling points is positively correlated with the model thickness. Connect the sampling points in the adjacent 3D point arrays on the side to generate a continuous side mesh.
[0009] Optionally, constructing a 3D point array for the side of the vertex based on the model thickness includes: The direction of the bisector of the exterior angle of the vertex is defined as the outward expansion direction of the vertex. Based on the model thickness, circular arc sampling interpolation is performed in the plane determined by the outward expansion direction and the normal to construct the three-dimensional point sequence of the side of the vertex.
[0010] Optionally, the step of connecting sampling points in adjacent 3D point columns of the side surfaces to generate a continuous side surface mesh includes: Connect adjacent sampling points in the adjacent three-dimensional point arrays on the adjacent sides in sequence to construct a quadrilateral region; The quadrilateral region is divided into triangular facets to obtain the side mesh.
[0011] Optionally, mapping the texture of the planar image to the three-dimensional mesh includes: For each vertex in the front and back meshes, the UV coordinates of the vertex are determined based on the pixel coordinates of the vertex; For each vertex in the side mesh, determine the projection point of the vertex in the opposite direction of the plane normal, and determine the UV coordinates of the vertex based on the pixel coordinates of the projection point; The UV coordinates are used to determine the position of the corresponding vertex on the planar image. During rendering, the planar image is color sampled based on the UV coordinates to achieve texture mapping.
[0012] According to a second aspect of one or more embodiments of this specification, a three-dimensional model generation apparatus is provided, the apparatus being applied to CAD software, comprising: Get the unit, and obtain the planar image and model thickness of the modeling object; The first generation unit generates a planar mesh for the modeling object based on the planar image; The second generation unit generates a front mesh, a back mesh, and a side mesh for the modeling object based on the planar mesh and the model thickness. The merging mapping unit merges the front mesh, the back mesh, and the side mesh into a three-dimensional mesh, and maps the texture of the planar image onto the three-dimensional mesh to obtain the three-dimensional model of the modeling object.
[0013] According to a third aspect of one or more embodiments of this specification, an electronic device is provided, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor performs the steps of the method as described above by executing the executable instructions.
[0014] According to a fourth aspect of one or more embodiments of this specification, a computer-readable storage medium is provided that stores computer instructions thereon, which, when executed by a processor, implement the steps of the method described above.
[0015] According to a fifth aspect of one or more embodiments of this specification, a computer program product is provided, comprising a computer program / instructions that, when executed by a processor, implement the steps of the method as described above.
[0016] As can be seen from the above embodiments, by adopting the technical solution provided in this specification, CAD software can generate planar meshes for the modeling object based on its planar image, and generate front, back, and side meshes based on the planar meshes and the model thickness. The texture of the planar image is then mapped onto the three-dimensional meshes to obtain a three-dimensional model of the modeling object. Using this method, the combination of side meshes and front / back meshes creates a double-sided structure, resulting in a three-dimensional model with distinct thickness characteristics, significantly enhancing the spatial depth and realism of the three-dimensional model. Furthermore, this method automatically generates corresponding three-dimensional models for the modeling object using CAD software, which, compared to traditional manual modeling, greatly reduces the time and labor costs of constructing three-dimensional models, making it suitable for the real-time generation of three-dimensional models for batch modeling objects. Attached Figure Description
[0017] Figure 1 This is a flowchart of a three-dimensional model generation method provided in an exemplary embodiment.
[0018] Figure 2 This is a flowchart of a modeling contour generation method provided in an exemplary embodiment.
[0019] Figure 3 This is a flowchart of a method for generating a front and back mesh, provided in an exemplary embodiment.
[0020] Figure 4 This is a flowchart of a side mesh generation method provided in an exemplary embodiment.
[0021] Figure 5 This is a schematic diagram of the outward expansion direction of a vertex provided in an exemplary embodiment.
[0022] Figure 6 This is a schematic diagram of a three-dimensional point array on the side provided in an exemplary embodiment.
[0023] Figure 7 This is a schematic diagram of a side mesh vertex mapping provided in an exemplary embodiment.
[0024] Figure 8 This is a schematic diagram of a planar grid for a garment, provided as an exemplary embodiment.
[0025] Figure 9 This is a schematic diagram of a three-dimensional mesh of a garment provided in an exemplary embodiment.
[0026] Figure 10 This is a comparison image of a two-dimensional image and a three-dimensional model of a garment provided in an exemplary embodiment.
[0027] Figure 11This is a comparison image of a two-dimensional picture and a three-dimensional model of another garment provided in an exemplary embodiment.
[0028] Figure 12 This is a schematic diagram of the structure of a device provided in an exemplary embodiment.
[0029] Figure 13 This is a block diagram of a three-dimensional model generation apparatus provided in an exemplary embodiment. Detailed Implementation
[0030] In the retail and e-commerce sectors, 3D virtual showroom technology has been used to build online virtual stores, using 3D modeling and real-time rendering to display products in a three-dimensional way, thereby improving the efficiency of users obtaining product information.
[0031] Building a 3D virtual showroom requires a large number of 3D models. Traditional methods involve pasting 2D images onto a 3D plane for display, but the resulting models lack depth and realism, leading to a poor user experience. While professional modelers can create models manually using 3D modeling software to achieve a similar appearance to the real object, the process is time-consuming. For example, creating a model of a single complex garment can take hours to days, resulting in very high time and labor costs, making it unsuitable for large-scale displays of a vast number of products.
[0032] This manual provides a 3D model generation solution that automatically generates 3D models from 2D images using CAD (Computer-Aided Design) software. This significantly reduces the time and labor costs of 3D model construction and is suitable for the real-time generation of 3D models for mass-produced goods. Furthermore, the 3D models generated by the CAD software possess distinct thickness characteristics, which can significantly improve the spatial three-dimensionality and realism of the products.
[0033] Figure 1 This is a flowchart of a three-dimensional model generation method provided in an exemplary embodiment.
[0034] Please refer to Figure 1 The described 3D model generation method can be applied to CAD software, that is, the CAD software executes the steps of the 3D model generation method described in this specification, specifically including the following steps: Step 102: Obtain the planar image of the modeling object and the model thickness.
[0035] In some embodiments, the modeling object refers to an object for which a 3D model needs to be constructed. Examples include clothing, bags, and other merchandise; it can also be artwork, architecture, human organs, skeletons, etc., without limitation. The planar image of the modeling object refers to a 2D image of the modeling object, such as an image of clothing or a photograph of a bag.
[0036] In some embodiments, the model thickness refers to the thickness of the generated 3D model, which can be manually set by the user in advance. For example, the user can upload the planar image in CAD software and manually set the model thickness. Taking clothing as an example, the model thickness can be set to 5cm, 10cm, etc.
[0037] In some embodiments, the model thickness can also be built into the CAD software, and the built-in model thickness can be obtained when generating the 3D model. In a simpler case, the CAD software can have only one built-in model thickness. In a more flexible case, the CAD software can have multiple built-in model thicknesses, each corresponding to a type of product. For example, summer clothing might have a model thickness of 6cm, winter clothing might have a model thickness of 10cm, etc. After uploading a 2D image, the user can manually select the product type, and the CAD software can obtain the corresponding model thickness based on the product type. Of course, the CAD software can also automatically identify the product type and determine the corresponding model thickness without requiring manual selection by the user; this is not a limitation.
[0038] In some embodiments, the planar image may be an image that retains only the area where the modeling object is located.
[0039] For example, after obtaining the original image of the object to be modeled, the user can use a deep learning-based image segmentation model to perform foreground-background separation on the original image, obtaining a probability map that represents the confidence level of each pixel belonging to the object to be modeled. Then, the probability map can be converted into a binary image according to a set threshold, and Gaussian filtering and morphological closing operations can be combined to eliminate edge noise and small holes, preserving the main body region of the object to be modeled. Furthermore, the background region of the original image is assigned transparent pixels, completing the accurate extraction of the main body region of the object to be modeled, resulting in the planar image of the object to be modeled. The background portion of the planar image is composed of transparent pixel values (Alpha = 0), which effectively prevents color distortion from appearing at the edges of the object to be modeled during subsequent texture mapping.
[0040] For example, after obtaining the original image of the modeling object, the user can also crop the original image after identifying the main area of the modeling object, that is, only retain the main area of the modeling object as the planar image, without setting transparent pixel values for the background part, which is not restricted here.
[0041] In some embodiments, users may also directly upload the original image of the modeling object to the CAD software, which will then perform the aforementioned precise extraction of the main body area of the modeling object; no restrictions are imposed here.
[0042] Step 104: Generate a planar mesh for the modeling object based on the planar image.
[0043] In some embodiments, after obtaining the planar image, the planar image can be converted into a binary image to facilitate subsequent operations.
[0044] In some embodiments, the boundary contour lines of the planar image converted into a binary image can be extracted to obtain the modeling contour lines of the modeling object, and then a planar mesh can be generated for the modeling object based on the modeling contour lines.
[0045] In some embodiments, in order to facilitate texture mapping on the sides of the 3D model later, it is necessary to reserve a texture mapping area at the edge of the planar image of the modeling object. Then, the planar image converted into a binary image can be eroded first. After the erosion, the boundary contour line is extracted as the modeling contour line, and then a planar mesh is generated, etc. There are no restrictions here.
[0046] Step 106: Generate a front mesh, a back mesh, and a side mesh for the modeling object based on the planar mesh and the model thickness.
[0047] In some embodiments, the mesh translation distance can be calculated based on the model thickness, and then the planar mesh can be translated in the opposite direction based on the mesh translation distance to generate the front mesh and side mesh of the modeled object.
[0048] In some embodiments, an arc-shaped side surface can be generated between the edges of the generated front and back meshes based on the modeling outline and the model thickness to obtain a side mesh. The specific generation method will be described in detail in subsequent embodiments.
[0049] Step 108: Merge the front mesh, the back mesh, and the side mesh into a three-dimensional mesh, and map the texture of the planar image onto the three-dimensional mesh to obtain the three-dimensional model of the modeling object.
[0050] In some embodiments, the front mesh, the back mesh, and the side mesh generated in the preceding steps can be merged to obtain a three-dimensional mesh, which is the geometric basis of the three-dimensional model.
[0051] In some embodiments, the UV coordinates of each vertex in the three-dimensional mesh can be saved. When rendering the three-dimensional model, the planar image is color sampled based on the UV coordinates to map the texture of the planar image to the three-dimensional mesh, thereby realizing texture mapping and obtaining the three-dimensional model of the modeling object.
[0052] As can be seen from the above description, by adopting the technical solution provided in this specification, CAD software can generate planar meshes for the modeling object based on its planar image, and generate front, back, and side meshes based on the planar meshes and the model thickness. The texture of the planar image is then mapped onto the three-dimensional meshes to obtain a three-dimensional model of the modeling object. Using this method, the combination of side meshes and front / back meshes creates a double-sided structure, resulting in a three-dimensional model with distinct thickness characteristics, significantly enhancing the spatial depth and realism of the three-dimensional model. Furthermore, this method automatically generates corresponding three-dimensional models for the modeling object using CAD software, which, compared to traditional manual modeling, significantly reduces the time and labor costs of constructing three-dimensional models, making it suitable for the real-time generation of three-dimensional models for batch modeling objects.
[0053] The implementation process of this specification will be described in detail below with reference to specific embodiments, focusing on three aspects: the generation of planar meshes, the generation of three-dimensional meshes, and texture mapping.
[0054] I. Generation of Planar Meshes In some embodiments, a corresponding modeling outline can be generated for the modeling object first, and then a planar mesh can be generated for the modeling object within the outline area corresponding to the modeling outline.
[0055] Please refer to Figure 2 The process of generating the modeling contour line may include the following steps: Step 202: Calculate the number of eroded pixels based on the model thickness and the resolution of the planar image. The number of eroded pixels is positively correlated with the model thickness.
[0056] In some embodiments, in order to leave areas for texture mapping on the sides of the 3D model, the planar image can be eroded first. Before performing the erosion process, the number of eroded pixels can be calculated.
[0057] Generally, the thicker the model, the larger the area required for texture mapping, and the more eroded pixels are needed. In other words, the number of eroded pixels is positively correlated with the model thickness. Specifically, the number of eroded pixels can be calculated using the following formula: E = (D / 2) × DPI Where E represents the number of eroded pixels, D represents the model thickness, D / 2 represents half the thickness of the 3D model, and DPI (Dots Per Inch) represents the image resolution. The side of the subsequently generated 3D model is a semicircular arc with a diameter of D. The above formula multiplies D / 2 by the image resolution, converting the physical size (i.e., D) into the number of pixels to be indented. This ensures that the blank area left after erosion can cover the side mesh of the corresponding thickness, effectively preventing problems such as pattern blurring caused by texture stretching during subsequent texture mapping.
[0058] Step 204: Starting from the edge of the planar image, perform erosion processing on the planar image inward based on the number of eroded pixels.
[0059] In some embodiments, after determining the number of eroded pixels, the planar image can be eroded inwards from its edges after being converted into a binary image, with the number of eroded pixels being the previously calculated number of eroded pixels. The erosion process can be based on morphological erosion algorithms, etc., and is not limited thereto.
[0060] Therefore, through erosion processing, the edges of the binary map of the planar image will shrink inward by E pixels (E is the number of eroded pixels mentioned above), reserving a corresponding area for the texture mapping of the subsequent three-dimensional model side network.
[0061] Step 206: Extract the contour lines from the eroded planar image to obtain the modeling contour lines.
[0062] In some embodiments, contour lines can be extracted from the binary image of the eroded planar image to obtain modeling contour lines for constructing a three-dimensional model.
[0063] The extraction of the modeling contours can be performed using algorithms such as Canny edge detection, Sobel edge detection, and contour finding algorithms (e.g., OpenCV's findContours algorithm), without any restrictions.
[0064] In some embodiments, there may be holes inside the outer contour of the modeling object. Using the contour extraction algorithm described above, the internal modeling contour can be extracted in advance, and the contour level and topology information can be recorded.
[0065] Therefore, this embodiment performs erosion processing on the planar image before determining the modeling outline of the modeling object, which can reserve the corresponding area for the texture mapping of the side network of the 3D model and ensure the normal mapping of subsequent textures.
[0066] In some embodiments, after extracting the modeling contour lines of the modeling object, a planar mesh can be generated for the modeling object within the contour region corresponding to the modeling contour lines. For example, the planar mesh can be generated using a constrained Delaunay triangulation algorithm, or a polygon constraint-based triangulation algorithm, etc. The planar mesh is typically a triangular mesh, which is a planar model of the modeling object, including the two-dimensional coordinates of each vertex and an index list of triangular facets. The index list can be used to determine which three vertices constitute each triangular mesh.
[0067] II. Generation of 3D Meshes In some embodiments, a front mesh and a back mesh can be generated for the modeling object based on the aforementioned planar mesh and model thickness. Specifically, the planar mesh can be expanded into two parallel planes in three-dimensional space based on the model thickness to obtain the front mesh and the back mesh.
[0068] Please refer to Figure 3 The generation process of the front mesh and the back mesh may include the following steps: Step 302: Calculate the mesh translation distance based on the model thickness.
[0069] In some embodiments, D is still used to represent the model thickness, which refers to the distance between the front and back sides of the model. A simpler approach is to calculate half of D as the mesh translation distance, i.e., calculate D / 2 to obtain the mesh translation distance.
[0070] Step 304: Based on the mesh translation distance, translate each vertex in the planar mesh along the normal to generate a frontal mesh.
[0071] Based on step 302 above, after determining the mesh translation distance, each vertex in the planar mesh can be translated along the normal direction. The translation distance is equal to the previously calculated mesh translation distance, thereby generating the frontal mesh of the modeling object. The spatial coordinates of each vertex in the frontal mesh are (x, y, D / 2), where the values of x and y are consistent with their coordinates in the planar mesh, representing pixel positions. In other words, when generating the frontal mesh, the spatial coordinates of each vertex change from (x, y, 0) to (x, y, D / 2), and the index list of the frontal mesh is the same as the index list of the planar mesh.
[0072] Step 306: Based on the mesh translation distance, translate each vertex in the planar mesh in the opposite direction of the normal to generate a back face mesh, wherein the triangle index order of the back face mesh is the opposite of that of the front face mesh.
[0073] Based on step 302 above, after determining the mesh translation distance, each vertex in the planar mesh can be translated along the opposite direction of the normal, with the translation distance equal to the previously calculated mesh translation distance, thereby generating the back face mesh of the modeling object. The spatial coordinates of each vertex in the back face mesh are (x, y, -D / 2), where the values of x and y are consistent with their coordinate values in the planar mesh. In other words, when generating the back face mesh, the spatial coordinates of each vertex change from (x, y, 0) to (x, y, -D / 2).
[0074] In this embodiment, the index list of the back mesh and the index list of the planar mesh are not exactly the same. Specifically, to ensure that the normal orientation is correct, the triangle index order of the back mesh is the opposite of the triangle index order of the front mesh, that is, the triangle index order of the back mesh is the opposite of the triangle index order of the planar mesh, so that the normal of the back mesh is opposite to the normal of the front mesh.
[0075] For example, suppose the vertex index of a triangle in the planar mesh is (0, 1, 2), and the vertex index of a triangle in the back mesh is (0, 2, 1), so that the normal direction of the back mesh is opposite to that of the normal direction of the planar mesh.
[0076] Therefore, this embodiment can first calculate the mesh translation distance based on the model thickness, and then generate the front and back meshes for the modeling object by translating the planar mesh based on the mesh translation distance, which is simple and fast.
[0077] Of course, the above translation method is only an example. In other examples, the translation distance of the planar mesh can be different when generating the front and back meshes. For example, each vertex in the planar mesh can be translated D / 3 along the normal to generate the front mesh, and each vertex in the planar mesh can be translated 2D / 3 in the opposite direction of the normal to generate the back mesh, etc. There are no restrictions here.
[0078] In some embodiments, a side mesh can be generated for the modeling object based on the aforementioned planar mesh and model thickness. Specifically, an arc-shaped side surface can be generated based on the outline of the planar mesh, i.e., the aforementioned modeling outline line between the edges of the front mesh and the back mesh, thereby obtaining the side mesh.
[0079] Please refer to Figure 4 The process of generating the side mesh may include the following steps: Step 402: For each vertex on the modeling contour line, construct a side three-dimensional point column for the vertex according to the model thickness. The side three-dimensional point column includes multiple sampling points, and the number of sampling points is positively correlated with the model thickness.
[0080] In some embodiments, the determined modeling contour line is composed of edges in a planar mesh, and the intersection of two edges is a vertex; that is, the modeling contour line includes multiple vertices in the planar mesh. For each vertex, a three-dimensional point array of the side surface can be constructed based on the model thickness as the basis for generating the side surface mesh.
[0081] In some embodiments, when constructing a three-dimensional point array on the side of each vertex, the direction of the bisector of the outer angle of the vertex can be determined as the outward expansion direction of the vertex. Then, based on the model thickness, circular arc sampling interpolation is performed in the plane determined by the outward expansion direction and the normal to construct the three-dimensional point array on the side of the vertex.
[0082] The exterior angle bisector refers to the exterior angle formed by the vertex and the two adjacent sides. Please refer to [reference needed]. Figure 5 Taking vertex P as an example, AP and BP are two adjacent sides of vertex P on the modeling contour line, the outward expansion direction M is the direction of the external angle bisector of angle APB, and N represents the normal direction. Then, circular arc sampling interpolation can be performed in the plane determined by M and N according to the model thickness D.
[0083] Please continue to refer to this. Figure 6 In the plane defined by the outward expansion direction M and the normal direction N, interpolation sampling is performed on the arc trajectory with vertex P as the center and radius D / 2 to obtain multiple sampling points (such as point Q, where the length of PQ is D / 2), thereby obtaining the three-dimensional point sequence of the side of the vertex, which includes the multiple sampling points obtained by interpolation.
[0084] The number of sampling points can be positively correlated with the model thickness; that is, the thicker the model, the more sampling points are needed. For example, assuming the model thickness is 10cm, the number of sampling points could be 5. (See reference...) Figure 6 Five sampling points are shown on the circular arc trajectory.
[0085] In some embodiments, when generating the side mesh, the user can also adjust the curvature of the arc trajectory. Specifically, in the example above, the distance between vertex P and its boundary sampling point Q is D / 2, i.e. Given D / 2, in this example, a bending factor can be introduced. , Users can set the curvature coefficient as needed. After receiving the curvature coefficient set by the user, the CAD software can determine the arc trajectory for performing sampling interpolation based on the curvature coefficient, and then perform sampling interpolation on the arc trajectory to construct the three-dimensional point sequence of the side of the vertex.
[0086] In some embodiments, after generating a 3D model of the modeling object, the user can adjust the curvature coefficient to modify the side profile. For example, if the user feels that the side profile of the 3D model is too prominent, the curvature coefficient can be reduced. The CAD software can then regenerate the side mesh based on the adjusted curvature coefficient to regenerate the corresponding 3D model, thus enabling real-time adjustment of the side profile of the 3D model.
[0087] Step 404: Connect the sampling points in the adjacent three-dimensional point arrays of the side surfaces to generate a continuous side surface mesh.
[0088] In some embodiments, after constructing the side three-dimensional point array of each vertex on the modeling contour line, the side three-dimensional point array of all vertices can form a side three-dimensional point array, and a side mesh can be generated for the modeling object based on the side three-dimensional point array.
[0089] Specifically, adjacent sampling points in the three-dimensional point array of adjacent sides can be connected sequentially to construct a quadrilateral region, and then the quadrilateral region can be divided into triangular patches to obtain the side mesh.
[0090] For example, with vertices and For example, assuming that each vertex has S sampling points in the 3D point array on its side, then the vertex can be... The k-th sampling point and vertex in the 3D point sequence of the side Connect the k-th sampling point in the 3D point sequence on the side, and connect the vertices. The (k+1)th sampling point and vertex in the side 3D point sequence Connecting the (k+1)th sampling point in the 3D point array on the side of the grid constructs a quadrilateral region, which is then divided into two triangles as two triangular facets. The value of k ranges from 1 to S-1. By traversing all vertices, a continuous arc-shaped side mesh composed of triangular facets can be generated.
[0091] In some embodiments, when the extracted modeling contour lines also include the modeling contour lines corresponding to the hole regions, a similar approach can be used to construct the side mesh. In this case, the outward expansion direction of each vertex on the modeling contour line corresponding to the hole region points towards the center of the hole.
[0092] Therefore, this embodiment can generate a side mesh for the modeling object based on the aforementioned planar mesh and model thickness, so that the subsequently generated 3D model has obvious thickness characteristics, thus significantly improving the spatial three-dimensionality and realism of the 3D model.
[0093] III. Texture Mapping In some embodiments, the aforementioned front mesh, back mesh, and side mesh can be merged to obtain a three-dimensional mesh of the modeling object. Then, through texture mapping, the three-dimensional model can present realistic patterns and designs during rendering.
[0094] To achieve texture mapping, the UV coordinates of each vertex in the 3D mesh are first determined. The UV coordinates typically range from [0,1] and are used to determine the position of the corresponding vertex on the planar image. During model rendering, color sampling can be performed on the planar image based on these UV coordinates to achieve texture mapping. Specifically, interpolation can be performed based on the UV coordinates of each vertex to generate texture sampling coordinates for each pixel. Color data (such as RGB values) is then sampled from the planar image based on these texture sampling coordinates to achieve texture mapping and present realistic patterns and designs.
[0095] In some embodiments, for each vertex in the front and back meshes, the UV coordinates of the vertex can be determined based on the vertex's pixel coordinates. Specifically, the pixel coordinates can be normalized to obtain the corresponding UV coordinates. The pixel coordinates are typically (x, y) in the vertex space coordinates (x, y, z).
[0096] In some embodiments, for each vertex in the side mesh, the projection point of the vertex in the opposite direction of the plane normal can be determined, and then the UV coordinates of the vertex can be determined based on the pixel coordinates of the projection point.
[0097] Specifically, the vertices in the side mesh are the sampling points in the aforementioned 3D point array on the side. Please refer to [reference needed]. Figure 7 Taking vertex K of the side mesh as an example, we can determine that the projection point of point K in the opposite direction of the plane normal N is point K1. Then, we can normalize the pixel coordinates of point K1 to obtain the UV coordinates of point K. Assume that the pixel coordinates of point P are... The pixel coordinates of the projection point K1 of vertex K are , DPI, where DPI still stands for image resolution, and M is the outward expansion direction per unit length. Let's take the vertex Q (also a boundary point) of the side mesh as an example again. ,and If it is D / 2, then That is, when viewed from the front, the boundaries of the 3D model are consistent with the 2D image.
[0098] In some embodiments, after obtaining the 3D model, the user can also modify the model thickness. Upon receiving the new model thickness, the CAD software can rewrite and generate the corresponding 3D model using the methods provided in this specification. For example, if a user views the rendering effect of the 3D model generated for the modeling object in the CAD software and finds that the model is too thick and the visual effect is poor, they can input a new model thickness. The CAD software can then regenerate the corresponding 3D model based on the original planar image and the new model thickness for the user to view.
[0099] Therefore, using the 3D model generation method provided in this manual, CAD software can regenerate the corresponding 3D model based on the new model thickness input by the user, offering high flexibility. Furthermore, compared to manual remodeling, it is faster and enables real-time updates of the 3D model.
[0100] The following explanation uses clothing as an example to illustrate the concept.
[0101] Assuming the object being modeled is a pair of jeans, using the method described above, users can input a flat image of the jeans and the model's thickness (e.g., 10cm) into CAD software, which can then generate a model of the jeans. Figure 8 The planar mesh shown is used by CAD software to generate front, back, and side meshes for the jeans, which are then merged into a single mesh. Figure 9 The 3D mesh shown is for reference only. Figure 9 In the generated 3D mesh, the mesh is relatively sparse in the middle part of the front face, while it is relatively dense around the edges.
[0102] Figure 10 The right side shows a 2D image of the jeans, while the left side shows a rendered 3D model of the jeans. Figure 10 As can be seen, the planar image on the right is flatter, while the three-dimensional model on the left has smoother boundaries and a more prominent sense of three-dimensionality.
[0103] Figure 11 The images show a 2D image and a 3D model of jeans viewed at a 45-degree side angle. The right side shows the 2D image, and the left side shows the 3D model. Figure 11 As can be seen, the 3D model on the left has thickness, a stronger sense of three-dimensionality, and is more realistic.
[0104] As can be seen from the above description, using the technical solution provided in this specification, CAD software can generate planar meshes for clothing based on planar images, and generate front, back, and side meshes based on the planar meshes and model thickness. The texture of the planar image is then mapped onto the three-dimensional meshes to obtain a three-dimensional model of the clothing. This method, combining the side meshes with the front and back meshes in a double-sided structure, gives the resulting three-dimensional model a distinct thickness characteristic, significantly enhancing the spatial depth and realism of the clothing's three-dimensional model. Furthermore, this method automatically generates corresponding three-dimensional models for clothing using CAD software, which, compared to traditional manual modeling, greatly reduces the time and labor costs of constructing three-dimensional models, making it suitable for the real-time generation of batch clothing three-dimensional models in 3D virtual showrooms.
[0105] Figure 12 This is a schematic structural diagram of a device provided in an exemplary embodiment. Please refer to... Figure 12 At the hardware level, the device includes a processor 1202, an internal bus 1204, a network interface 1206, memory 1208, and non-volatile memory 1210, and may also include other hardware required for its functions. One or more embodiments of this specification can be implemented in software, for example, the processor 1202 reads the corresponding computer program from the non-volatile memory 1210 into memory 1208 and then runs it. Of course, besides software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution entity of the following processing flow is not limited to individual logic units, but can also be hardware or logic devices.
[0106] Please refer to Figure 13 The 3D model generation device 1300 can be applied to, for example... Figure 12 The device shown is used to implement the technical solution of this specification. The three-dimensional model generation device 1300 may include: Get unit 1301 to obtain the planar image and model thickness of the modeling object; The first generation unit 1302 generates a planar mesh for the modeling object based on the planar image; The second generation unit 1303 generates a front mesh, a back mesh, and a side mesh for the modeling object based on the planar mesh and the model thickness. The merging mapping unit 1304 merges the front mesh, the back mesh, and the side mesh into a three-dimensional mesh, and maps the texture of the planar image onto the three-dimensional mesh to obtain the three-dimensional model of the modeling object.
[0107] Optionally, generating a planar mesh for the modeling object based on the planar image includes: Determine the modeling outline of the modeling object based on the planar image; A planar mesh is generated for the modeling object within the contour area corresponding to the modeling contour line.
[0108] Optionally, determining the modeling outline of the modeling object based on the planar image includes: The number of eroded pixels is calculated based on the model thickness and the resolution of the planar image, and the number of eroded pixels is positively correlated with the model thickness; Starting from the edge of the planar image, the planar image is eroded inward based on the number of eroded pixels; The contour lines are extracted from the eroded planar image to obtain the modeling contour lines.
[0109] Optionally, generating a front mesh and a back mesh for the modeling object based on the planar mesh and the model thickness includes: Calculate the mesh translation distance based on the model thickness; Based on the mesh translation distance, each vertex in the planar mesh is translated along the normal direction to generate the frontal mesh; Based on the mesh translation distance, each vertex in the planar mesh is translated in the opposite direction of the normal to generate the back face mesh, wherein the triangle index order of the back face mesh is the reverse of the triangle index order of the front face mesh.
[0110] Optionally, generating a side mesh for the modeling object based on the planar mesh and the model thickness includes: For each vertex on the modeling contour line, a side 3D point array is constructed for the vertex according to the model thickness. The side 3D point array includes multiple sampling points, and the number of sampling points is positively correlated with the model thickness. Connect the sampling points in the adjacent 3D point arrays on the side to generate a continuous side mesh.
[0111] Optionally, constructing a 3D point array for the side of the vertex based on the model thickness includes: The direction of the bisector of the exterior angle of the vertex is defined as the outward expansion direction of the vertex. Based on the model thickness, circular arc sampling interpolation is performed in the plane determined by the outward expansion direction and the normal to construct the three-dimensional point sequence of the side of the vertex.
[0112] Optionally, the step of connecting sampling points in adjacent 3D point columns of the side surfaces to generate a continuous side surface mesh includes: Connect adjacent sampling points in the adjacent three-dimensional point arrays on the adjacent sides in sequence to construct a quadrilateral region; The quadrilateral region is divided into triangular facets to obtain the side mesh.
[0113] Optionally, mapping the texture of the planar image to the three-dimensional mesh includes: For each vertex in the front and back meshes, the UV coordinates of the vertex are determined based on the pixel coordinates of the vertex; For each vertex in the side mesh, determine the projection point of the vertex in the opposite direction of the plane normal, and determine the UV coordinates of the vertex based on the pixel coordinates of the projection point; The UV coordinates are used to determine the position of the corresponding vertex on the planar image. During rendering, the planar image is color sampled based on the UV coordinates to achieve texture mapping.
[0114] Based on the same concept as the methods described above, this specification also provides an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor performs the steps of the method as described in any of the above embodiments by executing the executable instructions.
[0115] Based on the same concept as the methods described above, this specification also provides a computer-readable storage medium having computer instructions stored thereon that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.
[0116] Based on the same concept as the methods described above, this specification also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.
Claims
1. A three-dimensional model generation method characterized by comprising: The method is applied to CAD software and includes: Obtain the planar image and model thickness of the object being modeled; Generate a planar mesh for the modeling object based on the planar image; Generate a front mesh, a back mesh, and a side mesh for the modeling object based on the planar mesh and the model thickness; The front mesh, the back mesh, and the side mesh are merged into a three-dimensional mesh, and the texture of the planar image is mapped onto the three-dimensional mesh to obtain the three-dimensional model of the modeling object.
2. The method according to claim 1, characterized in that, The step of generating a planar mesh for the modeling object based on the planar image includes: Determine the modeling outline of the modeling object based on the planar image; A planar mesh is generated for the modeling object within the contour area corresponding to the modeling contour line.
3. The method according to claim 2, characterized in that, Determining the modeling outline of the modeling object based on the planar image includes: The number of eroded pixels is calculated based on the model thickness and the resolution of the planar image, and the number of eroded pixels is positively correlated with the model thickness; Starting from the edge of the planar image, the planar image is eroded inward based on the number of eroded pixels; The contour lines are extracted from the eroded planar image to obtain the modeling contour lines.
4. The method according to claim 2, characterized in that, The step of generating a front mesh and a back mesh for the modeling object based on the planar mesh and the model thickness includes: Calculate the mesh translation distance based on the model thickness; Based on the mesh translation distance, each vertex in the planar mesh is translated along the normal direction to generate the frontal mesh; Based on the mesh translation distance, each vertex in the planar mesh is translated in the opposite direction of the normal to generate the back face mesh, wherein the triangle index order of the back face mesh is the reverse of the triangle index order of the front face mesh.
5. The method according to claim 2, characterized in that, The step of generating a side mesh for the modeling object based on the planar mesh and the model thickness includes: For each vertex on the modeling contour line, a side 3D point array is constructed for the vertex according to the model thickness. The side 3D point array includes multiple sampling points, and the number of sampling points is positively correlated with the model thickness. Connect the sampling points in the adjacent 3D point arrays on the side to generate a continuous side mesh.
6. The method according to claim 5, characterized in that, The step of constructing a 3D point array for the side of the vertex based on the model thickness includes: The direction of the bisector of the exterior angle of the vertex is defined as the outward expansion direction of the vertex. Based on the model thickness, circular arc sampling interpolation is performed in the plane determined by the outward expansion direction and the normal to construct the three-dimensional point sequence of the side of the vertex.
7. The method according to claim 5, characterized in that, The method of connecting sampling points in adjacent 3D point columns on the side surfaces to generate a continuous side surface mesh includes: Connect adjacent sampling points in the adjacent three-dimensional point arrays on the adjacent sides in sequence to construct a quadrilateral region; The quadrilateral region is divided into triangular facets to obtain the side mesh.
8. The method according to claim 5, characterized in that, The step of mapping the texture of the planar image to the three-dimensional mesh includes: For each vertex in the front and back meshes, the UV coordinates of the vertex are determined based on the pixel coordinates of the vertex; For each vertex in the side mesh, determine the projection point of the vertex in the opposite direction of the plane normal, and determine the UV coordinates of the vertex based on the pixel coordinates of the projection point; The UV coordinates are used to determine the position of the corresponding vertex on the planar image. During rendering, the planar image is color sampled based on the UV coordinates to achieve texture mapping.
9. A three-dimensional model generation device, characterized in that, The device is applied to CAD software and includes: Get the unit, and obtain the planar image and model thickness of the modeling object; The first generation unit generates a planar mesh for the modeling object based on the planar image; The second generation unit generates a front mesh, a back mesh, and a side mesh for the modeling object based on the planar mesh and the model thickness. The merging mapping unit merges the front mesh, the back mesh, and the side mesh into a three-dimensional mesh, and maps the texture of the planar image onto the three-dimensional mesh to obtain the three-dimensional model of the modeling object.
10. An electronic device, characterized in that, include: processor; A memory for storing processor-executable instructions; wherein the processor implements the steps of the method as described in any one of claims 1-8 by executing the executable instructions.
11. A computer-readable storage medium, characterized in that, It stores computer instructions that, when executed by a processor, implement the steps of the method as described in any one of claims 1-8.
12. A computer program product, characterized in that, Includes a computer program / instructions that, when executed by a processor, implement the steps of the method as described in any one of claims 1-8.
Citation Information
Cited By
Hierarchical 3D refrigerator sticker digital model generation method based on single image
CN122023728A