Model compression method and device, electronic equipment and computer readable medium
Through the analysis, geometric data extraction, format conversion and compression processing of the three-dimensional model, the model distortion problem caused by parallel compression algorithms is solved, and the lightweighting of the three-dimensional model and the retention of structural logic are achieved.
Patent Information
- Application Number
- CN202411884271.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-15
AI Technical Summary
When lightening the three-dimensional model, parallel compression algorithms lead to excessive compression of model details, resulting in compressed model distortion, and block compression may change the structural logic design of the model, further causing distortion.
A model compression method is proposed, including obtaining the initial three-dimensional model, analytical processing to generate three-dimensional model analysis data, extracting model geometric data, performing format conversion and compression processing, generating compressed three-dimensional models, and rendering and displaying them in the preset model page.
This method can avoid the compressed three-dimensional model distortion, ensure that the lightweight model is the same as the initial model's structural logic and can run smoothly on multiple platforms.
Smart Images

Figure CN119832137A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer technology, and in particular to a model compression method, device, electronic device, and computer-readable medium. Background Art
[0002] With the development of 3D model technology, how to better lighten 3D models has become an important research topic. At present, when lightening models, the commonly used method is to compress the 3D model into blocks through a parallel compression algorithm and merge the results of the block compression.
[0003] However, when using the above method to lightweight the model, the following technical problems often occur: When compressing the model through a parallel compression algorithm, the details of the three-dimensional model are compressed too much, resulting in distortion of the compressed three-dimensional model. When merging the compression results, the block compression may cause changes in the structural logic design of the model, further causing model distortion.
[0004] The above information disclosed in this Background section is only for enhancement of understanding of the background of the inventive concept and therefore it may contain information that does not form the prior art that is already known in this country to a person of ordinary skill in the art. Summary of the invention
[0005] The content of this disclosure is used to introduce concepts in a brief form, which will be described in detail in the detailed implementation section below. The content of this disclosure is not intended to identify the key features or essential features of the technical solution claimed for protection, nor is it intended to limit the scope of the technical solution claimed for protection.
[0006] Some embodiments of the present disclosure propose a model compression method, an apparatus, an electronic device, and a computer-readable medium to solve one or more of the technical problems mentioned in the above background technology section.
[0007] In a first aspect, some embodiments of the present disclosure provide a model compression method, the method comprising: obtaining an initial three-dimensional model, and loading the initial three-dimensional model; parsing the initial three-dimensional model to generate three-dimensional model parsing data, wherein the three-dimensional model parsing data includes at least one model mesh; performing data extraction processing on at least one model mesh included in the three-dimensional model parsing data to generate a model geometry data set, wherein the model geometry data set in the model geometry data set includes one of the following: vertex data, face data and material information; performing format conversion processing on each model geometry data set in the model geometry data set to generate at least one converted data set; compressing each generated converted data set to generate a compressed data set, and generating a compressed three-dimensional model based on the compressed data set; rendering and displaying the compressed three-dimensional model in a preset model page.
[0008] In a second aspect, some embodiments of the present disclosure provide a model compression device, the device comprising: an acquisition unit, configured to acquire an initial three-dimensional model and load the initial three-dimensional model; a parsing unit, configured to parse the initial three-dimensional model to generate three-dimensional model parsing data, wherein the three-dimensional model parsing data comprises at least one model mesh; a data extraction unit, configured to perform data extraction on at least one model mesh included in the three-dimensional model parsing data to generate a model geometry data set, wherein the model geometry data set in the model geometry data set comprises one of the following: vertex data, face data and material information; a format conversion unit, configured to perform format conversion on each model geometry data set in the model geometry data set to generate at least one converted data set; a compression unit, configured to perform compression on each generated converted data set to generate a compressed data set, and generate a compressed three-dimensional model based on the compressed data set; a model rendering unit, configured to render and display the compressed three-dimensional model in a preset model page.
[0009] In a third aspect, some embodiments of the present disclosure provide an electronic device comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner of the above-mentioned first aspect.
[0010] In a fourth aspect, some embodiments of the present disclosure provide a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method described in any implementation manner of the above-mentioned first aspect is implemented.
[0011] The above-mentioned embodiments of the present disclosure have the following beneficial effects: through the model compression method of some embodiments of the present disclosure, the distortion of the compressed three-dimensional model is avoided. Specifically, the reason for the inaccuracy of the segmentation result of the relevant segmentation model is that when the model is compressed by the parallel compression algorithm, the details of the three-dimensional model are compressed too much, resulting in the distortion of the compressed three-dimensional model, and when the compression results are merged, the structural logic design of the model may change due to the block compression, further causing the model distortion. Based on this, the model compression method of some embodiments of the present disclosure first obtains the initial three-dimensional model and loads the initial three-dimensional model. Thus, the initial three-dimensional model can be determined. Secondly, the initial three-dimensional model is parsed to generate three-dimensional model parsing data; at least one model grid included in the three-dimensional model parsing data is extracted to generate a model geometry data set. Thus, various model data for constructing the three-dimensional model can be determined. Then, each model geometry data set in the model geometry data set is format converted to generate at least one converted data set. Thus, the geometry data of the three-dimensional model can be extracted. Afterwards, each generated converted data group is compressed to generate a compressed data group set, and a compressed three-dimensional model is generated based on the compressed data group set. Thus, the three-dimensional model can be lightweighted by a compression algorithm, so that the model can be run on multiple platform processes without distortion, thereby ensuring that the data structure logic of the lightweight three-dimensional model is the same as that of the initial three-dimensional model. Finally, the compressed three-dimensional model is rendered and displayed in a preset model page. Thus, the lightweighting of the three-dimensional model is completed, the distortion of the three-dimensional model during the compression process is reduced, and the data structure logic of the lightweight three-dimensional model is ensured to be the same as that of the initial three-dimensional model. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that components and elements are not necessarily drawn to scale.
[0013] Figure 1 is a flow chart of some embodiments of the model compression method according to the present disclosure; Figure 2 is a schematic structural diagram of some embodiments of the model compression device according to the present disclosure; Figure 3 is a schematic diagram of the structure of an electronic device suitable for implementing some embodiments of the present disclosure; Figure 4 1 is a model compression test diagram according to some embodiments of the model compression method disclosed herein. DETAILED DESCRIPTION
[0014] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0015] It should also be noted that, for ease of description, only the parts related to the invention are shown in the drawings. In the absence of conflict, the embodiments and features in the embodiments of the present disclosure can be combined with each other.
[0016] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0017] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0018] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0019] The present disclosure will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0020] Figure 1 The flow chart 100 of some embodiments of the model compression method according to the present disclosure is shown. The model compression method comprises the following steps: Step 101: Obtain an initial three-dimensional model and load the initial three-dimensional model.
[0021] In some embodiments, the execution subject (e.g., server) of the model compression method may obtain the initial three-dimensional model and load the initial three-dimensional model. In practice, the model file uploaded to the execution subject may be obtained through the upload interface, and the initial three-dimensional model may be loaded through a preset loading function. The preset loading function may be a pre-set function for loading the three-dimensional model. For example, the preset loading function may be an aiImportFile function.
[0022] Step 102: Analyze the initial three-dimensional model to generate three-dimensional model analysis data.
[0023] In some embodiments, the execution subject may parse the initial 3D model to generate 3D model parsing data. In practice, the parsed 3D model data may be constructed as an aiScene object as the 3D model parsing data.
[0024] In practice, the above initial three-dimensional model can be parsed through the following steps to generate three-dimensional model parsing data: In the first step, for each model file in each model file corresponding to the above initial three-dimensional model, perform the following parsing steps: The first parsing step is to determine the file extension corresponding to the above model file.
[0025] The second parsing step is to determine the file type corresponding to the model file according to the file extension. In practice, first, a file extension group set can be obtained. Among them, the file extension group in the file extension group set corresponds to a file type. Second, the file type corresponding to the file extension is determined according to the file extension group set.
[0026] The third parsing step is to parse the model file according to the file type to generate parsing model data.
[0027] The second step is to combine the generated analytical model data into three-dimensional model analytical data.
[0028] Step 103: perform data extraction processing on at least one model mesh included in the three-dimensional model analysis data to generate a model geometry data set.
[0029] In some embodiments, the execution subject may perform data extraction processing on at least one model mesh included in the three-dimensional model analysis data to generate a model geometry data set. In practice, the geometry data of the three-dimensional model may be extracted from the aiScene object as the model geometry data set.
[0030] In some optional implementations of some embodiments, the execution subject may perform data extraction processing on at least one model grid included in the three-dimensional model analysis data through the following steps: In the first step, for each model grid in the at least one model grid, the following extraction steps are performed: The first extraction step is to determine the vertex data corresponding to the model mesh, wherein the vertex data may include: vertex position, normal direction and texture coordinates.
[0031] The second extraction step is to determine the vertex index of each vertex corresponding to the above model mesh, and obtain a vertex index group as the surface data corresponding to the above model mesh.
[0032] The third extraction step is to determine the material index corresponding to the model mesh, wherein the material index is used to represent the material information of the model mesh, and the material information includes color and texture path.
[0033] In the second step, the determined vertex data, the determined surface data and the determined material indexes are combined and processed to obtain model geometry data groups representing the vertex data, the surface data and the texture path respectively as a model geometry data group set.
[0034] Step 104: Perform format conversion processing on each model geometry data group in the model geometry data group set to generate at least one converted data group.
[0035] In some embodiments, the execution entity may perform format conversion processing on each model geometry data set in the model geometry data set to generate at least one converted data set. In practice, the model geometry data in the model geometry data set may be converted into model data conforming to the GLTF format.
[0036] In practice, the format conversion process can be performed on each model geometry data group in the model geometry data group set by following the steps below: In the first step, a model geometry data set representing vertex data and face data is selected from the above model geometry data set as a target data set.
[0037] In the second step, the target data included in the target data set are combined to generate a model data set that meets the preset model data format as a converted data set. In practice, the vertex data and the face data can be combined into a data set in the accessor format of GLTF to obtain the converted data set.
[0038] The third step is to convert the model geometry data group that collectively represents the material information into a material format to generate a converted material information group as a converted data group. In practice, the format of the model geometry data group that represents the material information can be converted into a GLTF material format to generate a converted data group.
[0039] Step 4: for each converted material information in the converted material information group, perform the following association steps: In the first associating step, a model mesh corresponding to the converted material information is selected from the at least one model mesh as a target mesh.
[0040] The second associating step is to perform an associating operation on the converted material information and the target mesh to generate material associating information.
[0041] Optionally, after step 104, the following steps are further included: The first step is to generate a three-dimensional model to display the scene.
[0042] The second step is to add a perspective camera plug-in and a light source plug-in to the above three-dimensional model display scene to generate a display scene after adding. The perspective camera plug-in is used to facilitate users to observe the three-dimensional model from different angles. The light source plug-in is used to ensure that the model can be properly illuminated and show details.
[0043] The third step is to render the added display scene in real time to obtain a 3D model scene file. In practice, a pre-set renderer can be used to continuously update the scene and camera position through a rendering loop to achieve real-time rendering.
[0044] Step 105 , compressing each generated converted data group to generate a compressed data group set, and generating a compressed three-dimensional model according to the compressed data group set.
[0045] In some embodiments, the execution subject may compress each generated converted data set to generate a compressed data set, and generate a compressed three-dimensional model based on the compressed data set. Figure 4 As shown, a model compression test diagram of some embodiments of the model compression method of the present disclosure is shown. Figure 4 It can be seen that the texture and normals of the optimized model are significantly simplified, and the optimized model data completely corresponds to the structural logic design and ERP order number of the original engineering file, retaining the actual business information of the machine tool products to the greatest extent.
[0046] In practice, the following steps may be used to compress each generated converted data set, and generate a compressed three-dimensional model based on the compressed data set: In the first step, the converted data group including vertex data is split to generate a vertex position data group, a normal data group and a texture coordinate data group.
[0047] In the second step, each vertex position data in the above vertex position data group is input into a pre-trained encoder to obtain an encoded vertex position group.
[0048] In practice, it is found that when only the vertex position data is encoded through an encoder, the amount of encoded data generated by the encoding is large, resulting in a long time to load the compressed three-dimensional model, and the compression effect is poor.
[0049] Here, each vertex position data in the above vertex position data group can be input into a pre-trained encoder through the following sub-steps to obtain an encoded vertex position group: The first sub-step is to select a preset number of vertex position data at each interval from the vertex position data group as a target vertex position data sequence, wherein the preset number may be the number of vertex position data at a preset interval.
[0050] The second sub-step is to perform the following prediction steps for each two adjacent target vertex position data in the target vertex position data sequence: The first prediction step is to input the position data of the two adjacent target vertices into the data prediction model included in the encoder to obtain a preset number of predicted vertex position data. The data prediction model may be a logistic regression model.
[0051] The second prediction step is to determine the error value between the predicted vertex position data and the corresponding vertex position data for each of the preset number of predicted vertex position data. In practice, the error value between the predicted vertex position data and the corresponding vertex position data can be determined by the mean absolute error.
[0052] The third sub-step is to sort the target vertex position data and the determined error values in the target vertex position data sequence to generate a sorted data sequence. In practice, the target vertex position data and the determined error values in the target vertex position data sequence can be sorted according to the position of the corresponding vertex position data in the vertex position data group.
[0053] The fourth sub-step is to encode each sorted data in the sorted data sequence to generate an encoded vertex position group. The encoding process may be to encode each sorted data in the sorted data sequence into binary data.
[0054] The first sub-step to the fourth sub-step as an inventive point of an embodiment of the present disclosure, combined with the following step "step 106", solves the technical problem "When the vertex position data is encoded only by the encoder, the amount of the encoded data generated by the encoding is large, resulting in a long time to load the compressed three-dimensional model, and the compression effect is poor". The reasons why it takes a long time to load the compressed three-dimensional model and the compression effect is poor are as follows: When the vertex position data is encoded only by the encoder, the amount of the encoded data generated by the encoding is large, resulting in a long time to load the compressed three-dimensional model, and the compression effect is poor. If the above factors are solved, the effect of reducing the loading of the compressed three-dimensional model and improving the compression effect can be achieved. In order to achieve this effect, the present disclosure first selects a preset number of vertex position data at each interval from the above vertex position data group as the target vertex position data sequence. In this way, part of the vertex data can be selected for original data compression. Second, for each two adjacent target vertex position data in the above target vertex position data sequence, the following prediction step is performed: the above two adjacent target vertex position data are input into the data prediction model included in the above encoder to obtain a preset number of predicted vertex position data. Thus, the vertex data between every two selected vertex data can be predicted. Third, for each predicted vertex position data in the above-mentioned preset number of predicted vertex position data, determine the error value between the above-mentioned predicted vertex position data and the corresponding vertex position data. Thus, the error value between the predicted vertex data and the original vertex data can be determined. Fourth, sort the target vertex position data and the determined error values in the above-mentioned target vertex position data sequence to generate a sorted data sequence. Thus, the order of the original vertex data can be sorted. Fifth, encode the sorted data in the above-mentioned sorted data sequence to generate an encoded vertex position group. Thus, the vertex data and the error value can be encoded, and the amount of encoded data can be significantly reduced. Combined with step "step 106", the above-mentioned compressed three-dimensional model is rendered and displayed in the preset model page. Thus, the time for rendering and loading the compressed three-dimensional model can be reduced, thereby improving the compression effect.
[0055] The third step is to perform octahedral projection processing on each normal data included in the above normal data set to generate a projected normal data set.
[0056] The fourth step is to fold the above-mentioned post-projection normal data set to generate a folded normal data set. In practice, each post-projection normal data in the post-projection normal data set can be folded and placed on a preset square to obtain a folded normal data set.
[0057] The fifth step is to perform texture folding processing on each texture coordinate data in the above texture coordinate data group to generate a folded texture coordinate data group.
[0058] In the sixth step, the encoded vertex position group, the folded normal data group and the folded texture coordinate data group are determined as a compressed data group set.
[0059] Optionally, after the sixth step, the following steps are further included: The seventh step is to embed each compressed data group included in the compressed data group set into the three-dimensional model scene file to generate an embedded scene file.
[0060] In the eighth step, the embedded scene file is subjected to parameter adjustment processing to generate a parameter-adjusted scene file as a compressed three-dimensional model. The parameter adjustment processing may be to modify the parameters of the mesh nodes of the GLTF model.
[0061] In practice, it is found that when compressing and simplifying a three-dimensional model, it is usually assumed that each vertex in the model corresponds to only one texture coordinate. However, in fact, the three-dimensional model has texture discontinuity, that is, the texture image has multiple areas, and a single vertex may correspond to multiple texture coordinates. When compressing the three-dimensional model, certain geometric and topological constraints may be violated, and texture distortion may occur, which in turn causes distortion of the compressed three-dimensional model.
[0062] In some optional implementations of some embodiments, the execution subject may compress each of the converted data groups generated above by the following steps: The first step is to classify the generated converted data groups to generate classified vertex data groups, classified triangle data groups and classified relationship data groups. The classified vertex data in the classified vertex data groups may be vertex data of a mesh. The classified triangle data may be triangle data in a mesh. The classified relationship data in the classified relationship data groups may be data for characterizing the association relationship between vertices and triangles.
[0063] The second step is to construct the structures of the above-mentioned classified vertex data group, the above-mentioned classified triangle data group and the above-mentioned classified relationship data group respectively to organize the data structure and obtain the vertex data structure, the triangle data structure and the classified relationship data structure.
[0064] The third step is to determine the error matrix corresponding to each vertex data in the above vertex data structure to obtain an error matrix group.
[0065] The fourth step is to inversely map each triangle data in the above triangle data structure to a pre-generated texture feature map, and determine the texture feature information value corresponding to each vertex data corresponding to each triangle data. In practice, the texture feature information value corresponding to each vertex data can be determined by a gray level co-occurrence matrix. The above pre-generated texture feature map can be a texture feature map generated by a gray level co-occurrence matrix.
[0066] The fifth step is to determine the vertex curvature corresponding to each vertex data. In practice, the vertex curvature corresponding to each vertex data can be determined by a curvature algorithm based on the triangle normal vector.
[0067] The sixth step is to optimize the folding cost according to the texture feature information value corresponding to each vertex data and the corresponding vertex curvature, and establish a minimum heap data structure to sort the folding cost.
[0068] The seventh step is to select the edge of the triangle with the smallest folding cost to perform half-edge folding operation, adjust the texture coordinates of the affected triangle patch vertices, and update other affected elements. According to the half-edge folding result of the model, recalculate all folding costs.
[0069] In the eighth step, it is determined whether the simplification rate corresponding to the folded initial three-dimensional model is greater than or equal to a preset simplification rate threshold.
[0070] In a ninth step, in response to determining that the simplification rate corresponding to the folded initial three-dimensional model is greater than or equal to the preset simplification rate threshold, the folded initial three-dimensional model is determined as the compressed three-dimensional model.
[0071] In the tenth step, in response to determining that the simplification rate corresponding to the folded initial three-dimensional model is less than the above-mentioned preset simplification rate threshold, the edge of the triangle with the smallest folding cost is again selected to perform a half-edge folding operation.
[0072] The above-mentioned first step to the tenth step, as an inventive point of an embodiment of the present disclosure, solves the technical problem that "when compressing and simplifying a three-dimensional model, it is usually assumed that each vertex in the model corresponds to only one texture coordinate, but in fact the three-dimensional model has texture discontinuity, that is, the texture image has multiple regions, and a single vertex may correspond to multiple texture coordinates. When compressing the three-dimensional model, certain geometric and topological constraints may be violated, and the texture may be distorted, which in turn causes the compressed three-dimensional model to be distorted". The reasons for the distortion of the compressed three-dimensional model are as follows: when compressing and simplifying a three-dimensional model, it is usually assumed that each vertex in the model corresponds to only one texture coordinate, but in fact the three-dimensional model has texture discontinuity, that is, the texture image has multiple regions, and a single vertex may correspond to multiple texture coordinates. When compressing the three-dimensional model, certain geometric and topological constraints may be violated, and the texture may be distorted, which in turn causes the compressed three-dimensional model to be distorted. If the above-mentioned factors are solved, the effect of avoiding the distortion of the compressed three-dimensional model can be achieved. In order to achieve this effect, the present disclosure firstly classifies each generated converted data group to generate a classified vertex data group, a classified triangle data group and a classified relationship data group; constructs of the above-mentioned classified vertex data group, the above-mentioned classified triangle data group and the above-mentioned classified relationship data group respectively to organize the data structure and obtain the vertex data structure, the triangle data structure and the classified relationship data structure. Thus, the association between the vertex data, the triangle data and the vertex and the triangle can be determined. Second, the error matrix corresponding to each vertex data in the above-mentioned vertex data structure is determined to obtain an error matrix group. Thus, the error matrix of each vertex can be determined to provide data support for subsequent compression. Third, each triangle data in the above-mentioned triangle data structure is inversely mapped to a pre-generated texture feature map, and the texture feature information value corresponding to each vertex data corresponding to each triangle data is determined according to the above-mentioned classified relationship data structure; the vertex curvature corresponding to each vertex data is determined; according to the texture feature information value corresponding to each vertex data and the corresponding vertex curvature, the folding cost is optimized, and a minimum heap data structure is established to sort the folding cost. Therefore, the folding cost can be determined by the texture feature information value and the vertex curvature, and the folding can be performed at the minimum cost, and then the situation where a single vertex corresponds to multiple texture coordinates can be considered, thereby avoiding the distortion of the compressed three-dimensional model. Fourth, the edge of the triangle with the smallest folding cost is selected to perform the half-edge folding operation, and the texture coordinates of the affected triangle patch vertices are adjusted, and other affected elements are updated. According to the half-edge folding result of the model, all folding costs are recalculated. In this way, all affected coordinates can be adjusted.Fifth, determine whether the simplification rate corresponding to the folded initial three-dimensional model is greater than or equal to a preset simplification rate threshold; in response to determining that the simplification rate corresponding to the folded initial three-dimensional model is greater than or equal to the preset simplification rate threshold, determine the folded initial three-dimensional model as a compressed three-dimensional model; in response to determining that the simplification rate corresponding to the folded initial three-dimensional model is less than the preset simplification rate threshold, select the edge of the triangle with the smallest folding cost again to perform a half-edge folding operation. In this way, the compression processing of the three-dimensional model can be completed, and the situation where a single vertex corresponds to multiple texture coordinates can be considered, thereby avoiding distortion of the compressed three-dimensional model.
[0073] Step 106: Render and display the compressed three-dimensional model in a preset model page.
[0074] In some embodiments, the execution entity may render and display the compressed three-dimensional model in a preset model page.
[0075] Optionally, after step 106, the following steps are further included: The first step is to obtain download information corresponding to the download request in response to receiving a download request for the compressed three-dimensional model sent by the target terminal, wherein the download information may be information indicating the download format selected by the target terminal.
[0076] The second step is to convert the compressed 3D model into a format represented by the download information to generate a converted 3D model. The conversion may be to convert the compressed 3D model into a download format represented by the download information.
[0077] The third step is to generate a download address for the converted 3D model.
[0078] The fourth step is to send the download address to the target terminal for downloading.
[0079] The above-mentioned embodiments of the present disclosure have the following beneficial effects: through the model compression method of some embodiments of the present disclosure, the distortion of the compressed three-dimensional model is avoided. Specifically, the reason for the inaccuracy of the segmentation result of the relevant segmentation model is that when the model is compressed by the parallel compression algorithm, the details of the three-dimensional model are compressed too much, resulting in the distortion of the compressed three-dimensional model, and when the compression results are merged, the structural logic design of the model may change due to the block compression, further causing the model distortion. Based on this, the model compression method of some embodiments of the present disclosure first obtains the initial three-dimensional model and loads the initial three-dimensional model. Thus, the initial three-dimensional model can be determined. Secondly, the initial three-dimensional model is parsed to generate three-dimensional model parsing data; at least one model grid included in the three-dimensional model parsing data is extracted to generate a model geometry data set. Thus, various model data for constructing the three-dimensional model can be determined. Then, each model geometry data set in the model geometry data set is format converted to generate at least one converted data set. Thus, the geometry data of the three-dimensional model can be extracted. Afterwards, each generated converted data group is compressed to generate a compressed data group set, and a compressed three-dimensional model is generated based on the compressed data group set. Thus, the three-dimensional model can be lightweighted by a compression algorithm, so that the model can be run on multiple platform processes without distortion, thereby ensuring that the data structure logic of the lightweight three-dimensional model is the same as that of the initial three-dimensional model. Finally, the compressed three-dimensional model is rendered and displayed in a preset model page. Thus, the lightweighting of the three-dimensional model is completed, the distortion of the three-dimensional model during the compression process is reduced, and the data structure logic of the lightweight three-dimensional model is ensured to be the same as that of the initial three-dimensional model.
[0080] Further references Figure 2 As an implementation of the methods shown in the above figures, the present disclosure provides some embodiments of a model compression device. These device embodiments are similar to Figure 1 Corresponding to the method embodiments shown, the model compression device can be specifically applied to various electronic devices.
[0081] like Figure 2As shown, the model compression device 200 of some embodiments includes: an acquisition unit 201, a parsing unit 202, a data extraction unit 203, a format conversion unit 204, a compression unit 205 and a model rendering unit 206. Among them, the acquisition unit 201 is configured to acquire an initial three-dimensional model and load the above-mentioned initial three-dimensional model; the parsing unit 202 is configured to parse the above-mentioned initial three-dimensional model to generate three-dimensional model parsing data, wherein the above-mentioned three-dimensional model parsing data includes at least one model mesh; the data extraction unit 203 is configured to perform data extraction processing on at least one model mesh included in the above-mentioned three-dimensional model parsing data to generate a model geometry data set, wherein the model geometry data set in the above-mentioned model geometry data set includes one of the following: vertex data, face data and material information; the format conversion unit 204 is configured to perform format conversion processing on each model geometry data set in the above-mentioned model geometry data set to generate at least one converted data set; the compression unit 205 is configured to compress each generated converted data set to generate a compressed data set, and generate a compressed three-dimensional model based on the above-mentioned compressed data set; the model rendering unit 206 is configured to render and display the above-mentioned compressed three-dimensional model in a preset model page.
[0082] It is understood that the units described in the model compression device 200 are similar to those described in the reference Figure 1 Therefore, the operations, features and beneficial effects described above for the method are also applicable to the model compression device 200 and the units included therein, and will not be described in detail here.
[0083] Reference below Figure 3 , which shows a schematic diagram of the structure of an electronic device 300 suitable for implementing some embodiments of the present disclosure. The electronic devices in some embodiments of the present disclosure may include but are not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 3 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0084] like Figure 3As shown, the electronic device 300 may include a processing device 301 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage device 308 to a random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device 300 are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0085] Typically, the following devices may be connected to the I / O interface 305: an input device 306 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 308 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 309. The communication device 309 may allow the electronic device 300 to communicate with other devices wirelessly or by wire to exchange data. Figure 3 The electronic device 300 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 3 Each block shown in the figure may represent one device, or may represent multiple devices as required.
[0086] In particular, according to some embodiments of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, some embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In some such embodiments, the computer program can be downloaded and installed from the network through the communication device 309, or installed from the storage device 308, or installed from the ROM 302. When the computer program is executed by the processing device 301, the above-mentioned functions defined in the method of some embodiments of the present disclosure are executed.
[0087] It should be noted that the computer-readable medium recorded in some embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In some embodiments of the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In some embodiments of the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0088] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0089] The computer-readable medium may be included in the electronic device; or it may exist independently without being assembled into the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains an initial three-dimensional model, and loads the initial three-dimensional model. The initial three-dimensional model is parsed to generate three-dimensional model parsing data, wherein the three-dimensional model parsing data includes at least one model mesh. The at least one model mesh included in the three-dimensional model parsing data is subjected to data extraction to generate a model geometry data set, wherein the model geometry data set in the model geometry data set includes one of the following: vertex data, face data, and material information. The model geometry data sets in the model geometry data set are subjected to format conversion to generate at least one converted data set. The generated converted data sets are compressed to generate a compressed data set, and a compressed three-dimensional model is generated according to the compressed data set. The compressed three-dimensional model is rendered and displayed in a preset model page.
[0090] Computer program code for performing the operations of some embodiments of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0091] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession 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 square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0092] The units described in some embodiments of the present disclosure may be implemented by software or by hardware. The described units may also be arranged in a processor, for example, may be described as: a processor includes an acquisition unit, a parsing unit, a data extraction unit, a format conversion unit, a compression unit and a model rendering unit. The names of these units do not constitute a limitation on the units themselves in certain cases, for example, the acquisition unit may also be described as "a unit for acquiring an initial three-dimensional model and loading the above-mentioned initial three-dimensional model".
[0093] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0094] The above descriptions are only some preferred embodiments of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above inventive concept. For example, the above features are replaced with (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure.
Claims
1. A model compression method, comprising: Acquiring an initial three-dimensional model, and loading the initial three-dimensional model; Performing analysis processing on the initial three-dimensional model to generate three-dimensional model analysis data, wherein the three-dimensional model analysis data includes at least one model grid; Performing data extraction processing on at least one model mesh included in the three-dimensional model analysis data to generate a model geometry data set, wherein the model geometry data set in the model geometry data set includes one of the following: vertex data, face data, and material information; Performing format conversion processing on each model geometry data group in the model geometry data group set to generate at least one converted data group; Performing compression processing on each generated converted data group to generate a compressed data group set, and generating a compressed three-dimensional model based on the compressed data group set; The compressed three-dimensional model is rendered and displayed in a preset model page.
2. The method according to claim 1, wherein: The method further comprises: In response to receiving a download request for the compressed three-dimensional model sent by a target terminal, obtaining download information corresponding to the download request; According to the downloaded information, performing format conversion processing on the compressed three-dimensional model to generate a converted three-dimensional model; Generating a download address for the converted three-dimensional model; The download address is sent to the target terminal for downloading by the target terminal.
3. The method according to claim 1, wherein: The parsing process of the initial three-dimensional model to generate three-dimensional model parsing data includes: For each model file in each model file corresponding to the initial three-dimensional model, the following parsing steps are performed: Determine the file extension corresponding to the model file; Determine the file type corresponding to the model file according to the file extension; According to the file type, the model file is parsed to generate parsed model data; The generated analytical model data are combined into three-dimensional model analytical data.
4. The method according to claim 1, wherein: The step of performing data extraction processing on at least one model grid included in the three-dimensional model analysis data to generate a model geometry data set includes: For each model grid in the at least one model grid, the following extraction steps are performed: Determine vertex data corresponding to the model mesh, wherein the vertex data includes: vertex position, normal direction and texture coordinates; Determine the vertex index of each vertex corresponding to the model mesh, and obtain a vertex index group as the surface data corresponding to the model mesh; Determine a material index corresponding to the model mesh, wherein the material index is used to represent material information of the model mesh, and the material information includes color and texture path; The determined vertex data, the determined surface data and the determined material indexes are combined and processed to obtain model geometry data groups representing the vertex data, the surface data and the texture path respectively as a model geometry data group set.
5. The method according to claim 1, wherein: The step of performing format conversion processing on each model geometry data group in the model geometry data group set to generate at least one converted data group comprises: Selecting a model geometry data set representing vertex data and face data from the model geometry data set as a target data set; Combining and processing the target data included in the target data set to generate a model data set that meets a preset model data format as a converted data set; Performing material format conversion processing on the model geometry data group that collectively represents the material information of the model geometry data group to generate a converted material information group as a converted data group; For each converted material information in the converted material information group, the following association steps are performed: Selecting a model mesh corresponding to the converted material information from the at least one model mesh as a target mesh; An association operation is performed on the converted material information and the target mesh to generate material association information.
6. The method according to claim 1, wherein: After performing format conversion processing on each model geometry data group in the model geometry data group set to generate at least one converted data group, the method further includes: Generate a 3D model to display the scene; Adding a perspective camera plug-in and a light source plug-in to the three-dimensional model display scene to generate a display scene after the addition; The added display scene is rendered in real time to obtain a three-dimensional model scene file.
7. The method according to claim 1, wherein: The step of compressing each of the generated converted data groups to generate a compressed data group set includes: Splitting the converted data group including vertex data to generate a vertex position data group, a normal data group and a texture coordinate data group; Inputting each vertex position data in the vertex position data group into a pre-trained encoder to obtain an encoded vertex position group; Performing octahedral projection processing on each normal data included in the normal data group to generate a projected normal data group; Folding the projected normal data set to generate a folded normal data set; Performing texture folding processing on each texture coordinate data in the texture coordinate data group to generate a folded texture coordinate data group; The encoded vertex position group, the folded normal data group and the folded texture coordinate data group are determined as a compressed data group set.
8. A model compression device, comprising: an acquisition unit, configured to acquire an initial three-dimensional model and load the initial three-dimensional model; A parsing unit, configured to perform parsing processing on the initial three-dimensional model to generate three-dimensional model parsing data, wherein the three-dimensional model parsing data includes at least one model grid; A data extraction unit is configured to perform data extraction processing on at least one model mesh included in the three-dimensional model analysis data to generate a model geometry data set, wherein the model geometry data set in the model geometry data set includes one of the following: vertex data, surface data and material information; A format conversion unit is configured to perform format conversion processing on each model geometry data group in the model geometry data group set to generate at least one converted data group; A compression unit, configured to perform compression processing on each generated converted data group to generate a compressed data group set, and generate a compressed three-dimensional model according to the compressed data group set; The model rendering unit is configured to render and display the compressed three-dimensional model in a preset model page.
9. An electronic device, comprising: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Compressed ray direction data in a ray tracing system
CN109087384A
BIM data lightweight method and system
CN116756796A
Data processing method and device, computing device cluster, medium and program product
CN117710546A
Three-dimensional grid sequence encoding and decoding method and device
CN118803256A
Data format conversion method and system, storage medium and program product
CN119088759A