Three-dimensional model lightweight method, device and equipment and storage medium
By constructing a cloth mesh for agricultural scenes and performing dynamic gravity simulation and high-ratio simplification, combined with JPEG compression and hierarchical marking, a lightweight 3D model is generated. This solves the problems of large data volume and slow rendering speed of 3D models in agricultural scenes, and achieves efficient data management and visual effects.
Patent Information
- Application Number
- CN202510800628.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-16
- Publication Date
- 2025-11-07
AI Technical Summary
The existing 3D models of agricultural scenarios have a huge amount of data, resulting in slow transmission, storage and real-time rendering speeds. Existing lightweight methods have failed to effectively optimize the data volume and visual quality of the models.
By acquiring point cloud data from agricultural scenes to construct a cloth mesh, performing gravity dynamic simulation and collision detection, and determining the target mesh, high-ratio simplification and texture optimization are performed, including JPEG compression and hierarchical marking processing, to generate a lightweight 3D model.
It improves data transfer rate and loading/rendering speed, retains rich texture information and visual realism, adapts to different scene characteristics, reduces storage space requirements, and maintains good image quality.
Smart Images

Figure CN120912757A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of three-dimensional model processing, and particularly relates to a three-dimensional model lightweight method, device, equipment and storage medium. BACKGROUND
[0002] Three-dimensional model lightweight generally adopts a face reduction algorithm, and common methods such as progressive mesh simplification and edge folding technology can greatly reduce the number of polygons while preserving the geometric details of the model. However, the current three-dimensional model lightweight method does not distinguish between scenes, resulting in excessive loss of details, which is not conducive to practical application. In addition, the current lightweight scheme mostly simplifies the model itself and does not use LOD for further optimization.
[0003] With the continuous development of computer technology and three-dimensional modeling technology, the agricultural field has gradually begun to use three-dimensional models for scene simulation, planning and design, production management and other activities. However, the existing three-dimensional models of agricultural scenes have the following problems: agricultural scenes contain a large amount of complex geographic information and plant growth information, resulting in a huge amount of three-dimensional model data, which is not conducive to transmission, storage and real-time rendering. In addition, under the premise of ensuring model accuracy, the existing technology cannot realize real-time rendering of the three-dimensional model of the agricultural scene, limiting its promotion in practical applications.
[0004] Therefore, there is an urgent need for an innovative three-dimensional model lightweight method that targets the challenges of large-scale farmland real scene three-dimensional model data volume and performance optimization, explores key technologies such as data compression, fast indexing and quality evaluation of real scene three-dimensional models, to reduce model storage requirements, improve loading speed, improve rendering performance, and achieve model lightweight without compromising visual quality, while achieving more efficient data management and faster model retrieval on large-scale, large-scale, and large-data three-dimensional real scene model libraries, ultimately improving the loading and rendering speed of real scene three-dimensional models in agricultural scenes. SUMMARY
[0005] In view of the deficiencies of the prior art, the purpose of the present application is to provide a three-dimensional model lightweight method, device, equipment and storage medium to solve the problem of slow three-dimensional data loading speed and rendering speed in the prior art agricultural scene.
[0006] According to one aspect of the present application, a three-dimensional model lightweight method is disclosed, the method comprising:
[0007] Obtaining a plurality of point cloud data of a target agricultural scene, constructing a cloth mesh based on the point cloud data, the initial position of the cloth mesh being located above the point cloud data, the cloth mesh comprising a plurality of interconnected particles, and the cloth mesh being mapped with texture information of a plurality of point cloud data;
[0008] performing gravity dynamic simulation on the cloth mesh, and obtaining a cloth shape of the cloth mesh when the cloth mesh reaches a target stable state;
[0009] determining a target mesh based on the cloth shape and the plurality of point cloud data, the target mesh being a three-dimensional model with a plurality of ground points in the plurality of point cloud data as a base, and a surface of the target mesh including a target texture;
[0010] performing high-ratio simplification on the target mesh and texture optimization on the high-ratio simplified mesh to obtain a lightweight three-dimensional model.
[0011] In some embodiments, the performing gravity dynamic simulation on the cloth mesh, and obtaining a cloth shape of the cloth mesh when the cloth mesh reaches a target stable state includes:
[0012] performing gravity dynamic simulation on the cloth mesh based on a gravity simulation formula;
[0013] The gravity simulation formula is:
[0014]
[0015] where v i is a particle velocity, Δt is a time step, p i (t+1) is a position of an i-th particle at t+1, p i (t) is a position of the i-th particle at t.
[0016] performing collision detection between the cloth mesh and the point cloud data during a process in which the cloth mesh falls under the action of gravity;
[0017] adjusting a target particle in the cloth mesh when it is detected that the target particle in the cloth mesh and a target particle in the plurality of point cloud data have a possibility of collision, until the cloth mesh satisfies the target stable state;
[0018] obtaining a cloth shape of the target mesh when the target mesh reaches the target stable state.
[0019] In some embodiments, the determining a target mesh based on the cloth shape and the plurality of point cloud data includes:
[0020] determining a target vertical distance between each of the point cloud data and the cloth mesh;
[0021] obtaining a distance threshold;
[0022] determining a point cloud corresponding to the target vertical distance as a ground point when the target vertical distance is less than the distance threshold.
[0023] In some embodiments, the high-ratio simplification of the target mesh comprises:
[0024] performing edge and patch optimization on the target mesh to obtain an initial simplified mesh;
[0025] performing vertex iterative shrinking on the initial simplified mesh to obtain a target simplified mesh, the surface of the target simplified mesh comprising a target simplified texture determined based on the target texture;
[0026] the texture optimization of the high-ratio simplified mesh comprises:
[0027] the optimization of the target simplified texture of the target simplified mesh by JPEG compression comprises:
[0028] extracting texture information of the target simplified texture to determine a target simplified texture picture;
[0029] performing color quantization and dithering on the target simplified texture picture in sequence.
[0030] In some embodiments, the edge and patch optimization of the target mesh to obtain an initial simplified mesh comprises:
[0031] performing initialization normal processing on each patch of the target mesh based on an initialization normal formula to obtain a plurality of initial patch normals;
[0032] the initialization normal formula is:
[0033]
[0034] wherein v1, v2, v3 are edges of f i , and f i is the i-th patch;
[0035] refining the processed patch normal direction based on a bilateral filtering algorithm to obtain a plurality of target patch normals;
[0036] updating the position of the target mesh based on a vertex displacement formula to obtain a target position;
[0037] determining the initialization simplified mesh based on the plurality of target patch normals and the target position;
[0038] the vertex displacement formula is:
[0039]
[0040] wherein, is the weight of the i-th vertex for normalizing displacement calculation. ei,k is the vector between vertex v i and its adjacent vertex v k , is the normal vector of vertex v i , representing the normal direction of the surface on which the vertex lies, h i,k is the projection of e i,k in direction. σ i is a parameter that controls the smoothness, used to adjust the width of the Gaussian function, thereby affecting the smoothing effect of vertex displacement.
[0041] is the set of adjacent vertices related to vertex v i .
[0042] In some embodiments, the vertex iterative contraction processing of the initial simplified mesh to obtain the target simplified mesh includes:
[0043] Step one: obtain a plurality of candidate vertex pairs;
[0044] Step two: assign a contraction cost to each of the candidate pairs;
[0045] Step three: enter a plurality of the candidate vertex pairs into a cost-keyed heap, wherein the candidate vertex pair with the minimum cost corresponds to the top of the heap in the heap;
[0046] Step four: remove the vertex pair with the minimum cost from the heap;
[0047] Step five: contract the vertex pair with the minimum cost;
[0048] Step six: update the weights of all candidate vertex pairs;
[0049] Step seven: repeat steps four to five until contraction to the target value.
[0050] In some embodiments, the method further includes:
[0051] The hierarchical marking processing of the target simplified mesh includes:
[0052] Reading and parsing the script file of the target simplified mesh to obtain a set of texture images;
[0053] Traversing the set to obtain the width value and height value of the texture image;
[0054] Setting the hierarchical level, scaling ratio, and determining the scaling ratio formula of the texture;
[0055] Exporting the texture image to the target directory based on the scaling ratio.
[0056] According to another aspect of the present application, a three-dimensional model lightweight device is also disclosed, the device comprising:
[0057] an acquisition module configured to acquire a plurality of point cloud data of a target agricultural scene, construct a cloth mesh based on the point cloud data, the initial position of the cloth mesh being above the point cloud data, the cloth mesh comprising a plurality of interconnected particles, and the cloth mesh being mapped with texture information of the plurality of point cloud data;
[0058] a gravity dynamic simulation module configured to perform gravity dynamic simulation on the cloth mesh and acquire a cloth shape when the cloth mesh reaches a target stable state;
[0059] a target mesh determination module configured to determine a target mesh based on the cloth shape and the plurality of point cloud data, the target mesh being a three-dimensional model with a plurality of ground points in the plurality of point cloud data as a base, and the surface of the target mesh comprising a target texture;
[0060] an optimization processing module configured to perform high-ratio simplification on the target mesh and perform texture optimization processing on the mesh after high-ratio simplification to obtain a lightweight three-dimensional model.
[0061] According to another aspect of the present application, an electronic device is also disclosed, the electronic device comprising a memory and at least one processor, the memory storing instructions; the at least one processor invoking the instructions in the memory to enable the electronic device to perform each step of the three-dimensional model lightweight method as described above.
[0062] According to another aspect of the present application, a computer readable storage medium is also disclosed, the computer readable storage medium storing instructions, wherein the instructions are executed by a processor to implement each step of the three-dimensional model lightweight method as described above.
[0063] The present application includes but is not limited to the following benefits: (1) The present application obtains a plurality of point cloud data of a target agricultural scene, constructs a cloth grid based on the point cloud data, the initial position of the cloth grid is located above the point cloud data, the cloth grid includes a plurality of connected particles, and the cloth grid is mapped with texture information of a plurality of point cloud data; gravity dynamic simulation is performed on the cloth grid, and the cloth form when the cloth grid reaches a target stable state is obtained; based on the cloth form and the plurality of point cloud data, a target grid is determined, the target grid is a three-dimensional model with a plurality of ground points in the plurality of point cloud data as a base, and the surface of the target grid includes a target texture; high-ratio simplification is performed on the target grid, and texture optimization processing is performed on the grid after high-ratio simplification, to obtain a lightweight three-dimensional model. The data transmission rate and the loading rendering speed are improved.(2) The present application can retain rich texture information by mapping the texture information of the point cloud data onto the cloth grid, so that the lightweight model is more realistic and rich in vision; (3) By using the cloth grid based on the point cloud data, the shape and characteristics of the target agricultural scene can be better adapted; (4) Through gravity dynamic simulation, the form of the cloth grid in the target stable state can be accurately obtained, the realism of the generated three-dimensional model in physical characteristics is ensured, further, by adjusting the form of the cloth grid in real time, the stability and reliability of the model under various conditions can be improved; (5) By optimizing the edges and facets of the target grid, preliminary simplification can be realized, the complexity of the model is reduced, and the processing efficiency is improved, in the simplification process, the structure and characteristics of the target grid can be retained through vertex transmission and contraction processing, so that effective simplification is realized, further, by performing texture processing on the target grid, the visual effect can be improved to ensure that the simplified model still has rich details and realism in vision, further, the texture of the target grid is optimized by using JPEG compression technology, which can effectively reduce the storage space requirement while maintaining good image quality. BRIEF DESCRIPTION OF DRAWINGS
[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows.
[0065] Figure 1 is a flow chart of the three-dimensional model lightweight method of the present application embodiment;
[0066] Figure 2 is a flow chart of the contraction algorithm of the present application embodiment;
[0067] Figure 3 is a structural block diagram of the three-dimensional model lightweight device of the present application embodiment;
[0068] Figure 4Fig. 1 is a structural schematic diagram of an electronic device provided by an embodiment of the present application;
[0069] Figure 5 Fig. 4 is a schematic diagram of patch optimization processing;
[0070] Figure 6 Fig. 5 is a schematic diagram of texture optimization processing;
[0071] Figure 7 Fig. 6 is a schematic diagram of a hierarchical marking structure. DETAILED DESCRIPTION
[0072] The embodiment of the present application provides a three-dimensional model lightening method, and the method comprises the following steps: acquiring a plurality of point cloud data of a target agricultural scene, constructing a cloth grid based on the point cloud data, an initial position of the cloth grid is located above the point cloud data, the cloth grid comprises a plurality of mutually connected particles, and the cloth grid is mapped with texture information of a plurality of the point cloud data; performing gravity dynamic simulation on the cloth grid, and acquiring a cloth shape when the cloth grid reaches a target stable state; determining a target grid based on the cloth shape and the plurality of point cloud data, the target grid is a three-dimensional model taking a plurality of ground points in the plurality of point cloud data as a base, and a target texture is included on a surface of the target grid; performing high-ratio simplification on the target grid and performing texture optimization processing on the grid after the high-ratio simplification, so as to obtain a lightened three-dimensional model. The scheme improves data transmission rate and loading rendering speed.
[0073] The terms "first", "second", "third", "fourth" and the like in the description, claims, as well as throughout the figures of the present application, where they occur, are used as identifiers to distinguish between similar objects, and are not necessarily intended to denote a particular order or sequence among the objects. It will be understood that the use of these terms in the description is merely intended to distinguish between two similar objects for convenience and the use of these terms is interchangeable as appropriate, so that the embodiments described herein can be implemented in other sequences than those illustrated or described herein. Furthermore, the terms "comprise" or "have" and any variations thereof are intended to cover a non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a list of steps or units is not necessarily limited to those steps or units that are clearly listed, but can include other steps or units that are not clearly listed or inherent to such processes, methods, products, or apparatuses.
[0074] For the convenience of understanding, the specific flow of the embodiment of the present application is described below, and specifically, Figure 1 Fig. 1 is a flowchart of a three-dimensional model optimization method, as shown in the figure, comprising the following steps: Figure 1
[0075] S100, acquiring a plurality of point cloud data of a target agricultural scene, and constructing a cloth grid based on the point cloud data.
[0076] The initial position of the cloth mesh is above the point cloud data, and the cloth mesh includes a plurality of connected particles, and the cloth mesh is mapped with texture information of the plurality of point cloud data.
[0077] Specifically, the cloth mesh can be a planar mesh including a plurality of vertices and faces. Each vertex has its coordinates (x, y, z) in three-dimensional space. The shape of the cloth mesh can be a rectangular or square plane containing a plurality of rows and columns of vertices. Each vertex is connected to another vertex by an edge to form a face. The positions of the vertices of the cloth mesh can be set according to the distribution of the point cloud data. Generally, the spacing and number of vertices should be adjusted according to the complexity of the region to be processed to ensure that the mesh can fully cover the region. For example, the vertices can be uniformly distributed in a specified region to form a regular mesh structure. When there is point cloud data, the positions of the vertices can be determined by analyzing the spatial distribution of the points in the point cloud so that the mesh can better adapt to the actual terrain. It can be understood that when generating the mesh, it is necessary to ensure that the mesh can cover the region to be processed. For example, a bounding box can be defined to determine the outer boundary of the mesh. The vertices of the mesh should be located within the bounding box.
[0078] S102, performing gravity dynamic simulation on the cloth mesh, and obtaining a cloth shape when the cloth mesh reaches a target stable state.
[0079] Specifically, first, gravity dynamic simulation can be performed on the cloth mesh based on a gravity simulation formula.
[0080] wherein the gravity simulation formula is:
[0081]
[0082] wherein v i is the particle velocity, Δt is the time step, p i (t+1) is the position of the i-th particle at t+1, p i (t) is the position of the i-th particle at t.
[0083] Further, during the process of the cloth mesh falling under the action of gravity, collision detection between the cloth mesh and the point cloud data is performed; when it is detected that a target particle in the cloth mesh and a target particle in the plurality of point cloud data have a collision possibility, the target particle in the cloth mesh is adjusted until the cloth mesh satisfies the target stable state; further, the cloth shape when the target mesh reaches the target stable state is obtained.
[0084] Exemplarily, in the collision detection process, if the distance between a particle and a point is less than a set threshold ∈, it is considered that a collision occurs, the cloth is blocked at the point and its position is adjusted.
[0085] It can be understood that the cloth has flexibility, and therefore a normal constraint needs to be applied on the cloth mesh to ensure that the cloth shape conforms to the terrain. The constraint condition can generally be achieved by adjusting the distance between the cloth particles to avoid excessive penetration of the cloth into the terrain. The specific iteration process is as follows: traverse the particle pairs composed of two particles, compare the height difference of the two particles, try to move them to the same horizontal plane, if both connected particles are movable, move them in opposite directions, if one of them is not movable, the other will be moved. Otherwise, if the two particles have the same height value, neither of them will be moved, therefore, the displacement of each particle can be calculated by the following formula:
[0086]
[0087] wherein represents the particle displacement vector, b is 1 when the particle is movable, otherwise 0, respectively represent the current positions of the particle and its adjacent particles, represents a unit vector perpendicular to the ground; the update is completed when a set number of iterations is reached.
[0088] It can be understood that the cloth shape is determined based on the positions and states of the particles in the target stable state. The target stable state of the cloth mesh can refer to the ability of the cloth mesh to maintain its shape and position during simulation. A stable cloth mesh will not deform dramatically or exhibit unnatural motion due to external forces such as gravity, wind, etc.
[0089] S104, determining a target mesh based on the cloth shape and the plurality of point cloud data.
[0090] wherein the target mesh is a three-dimensional model based on a plurality of ground points in the plurality of point cloud data, and the surface of the target mesh includes a target texture.
[0091] Specifically, after the cloth is stabilized, the target vertical distance of each point cloud data from the cloth mesh can be determined; and a distance threshold is obtained; when the target vertical distance is less than the distance threshold, the point cloud corresponding to the target vertical distance is determined as a ground point. Exemplarily, each point cloud can be denoted as X j , and the target vertical distance can be d, based on d = |X j -P i | to classify ground points and non-ground points. When d < δ (where δ is a set distance threshold), the point is marked as a ground point; otherwise, it is a non-ground point.
[0092] S106, high-ratio simplification is performed on the target mesh, and texture optimization is performed on the high-ratio simplified mesh to obtain a lightweight three-dimensional model.
[0093] Specifically, this step first performs edge and patch optimization on the target mesh to obtain an initial simplified mesh.
[0094] The method comprises the following steps:
[0095] Given a mesh M, i.e., a target mesh, it is represented as a vertex set V(M) = {v i ; i = 1,..., n} and an edge set E(M) = {e i,j = v j -v i ; v i , v j ∈ V}. e i,j represents an edge connecting two vertices v i v j . Since the basic operation target is a triangular face, the initial normal of each face is defined as a unit vector perpendicular to the face plane. Given a triangular face f i , its initial normal is calculated by the following formula:
[0096]
[0097] where v1, v2, v3 are the edges of f i . After initializing the normal of each face, a bilateral filtering algorithm is applied to refine the normal direction. It involves two types of weights: (1) a spatial distance-based weight α fifj ; (2) a normal proximity-based weight β fifj . The spatial distance f i and f j of two faces are calculated by the Euclidean distance between their centroids α fi and α fj . Let the normals of the two faces be n fj and n fj . Both weight functions are defined in a similar form of Gaussian function, as follows:
[0098]
[0099] where σ dist represents the variance parameter of distance proximity, and θ is a preset angle threshold. A smaller θ value can produce better difference effects. In addition, two non-negative functions α fifj and β fifj are used to calculate the weight values. The value of α fifj rapidly decreases as the distance of adjacent faces increases, while the value of β fifjThe influence is provided according to the difference of the normal vectors of the two faces. When the normal difference is larger, the influence of β fifj is smaller, and vice versa. Therefore, smaller weight value will suppress the mutual influence between two adjacent faces, and thus more accurate results can be obtained. When extracting the neighborhood of a face, the face in the folding area should be avoided, and for this purpose, an adaptive topology neighborhood query scheme is used. Each neighborhood set is composed of multiple faces with similar normal direction. Let N fi denote the neighborhood set of f i , each element in it satisfies two conditions: (1) it shares at least one vertex with the query face f i ; (2) the dot product of the neighborhood normal and the normal of f i is larger than cosθ. In addition, the query face itself is also included in N fi . The filtered normal of face f i is denoted as n , and its calculation formula is as follows:
[0100]
[0101] where w i is a normalization term to ensure the result is a unit vector. A fi is the area of face f i .
[0102] is the weighted average of the normals in the neighborhood N fi . For the mesh with uneven face size, topology neighborhood can provide better query results than range-based neighborhood query, because it only includes the adjacent faces with similar direction. The first formula above can be explained as a smoothing operation on the face normal. After refining the face normal, the vertex position needs to be updated accordingly, and the noise and overlapping faces are eliminated. To calculate the vertex displacement, a discrete anisotropic Laplacian operator is adopted, and the vertex displacement Δv i is given by the following formula:
[0103]
[0104] where w is the weight of the i-th vertex, used for normalization of displacement calculation. e i,k is the vector between vertex v i and its adjacent vertex v k , is the normal vector of vertex v i , representing the normal direction of the surface where the vertex is located, and h i,k is the projection of e i,k in the direction of . σ iis a parameter that controls the degree of smoothing, used to adjust the width of the Gaussian function, thus affecting the smoothing effect of the vertex displacement. is a parameter that controls the degree of smoothing, used to adjust the width of the Gaussian function, thus affecting the smoothing effect of the vertex displacement. i is a parameter that controls the degree of smoothing, used to adjust the width of the Gaussian function, thus affecting the smoothing effect of the vertex displacement.
[0105] A schematic diagram of the patch optimization is shown in Figure 5 .
[0106] Further, the initial simplified mesh is subjected to vertex iterative shrinking processing to obtain a target simplified mesh, and a target simplified texture is included on the surface of the target simplified mesh, and the target simplified texture is determined based on the target texture.
[0107] Specifically, vertex iterative shrinking processing is performed based on an iterative vertex shrinking algorithm. The algorithm is essentially an extraction algorithm that removes vertices and faces from the model by iteration starting from the initial surface. Each iteration applies a single atomic operation, namely vertex pair contraction. Figure 2 A flowchart of the contraction algorithm is shown. A vertex pair contraction, denoted as , modifies the surface through the following three steps: 1. Move vertices i and j to positions 2. Replace all occurrences of j with i ; 3. Remove j and all degenerate faces so that there are no longer three different vertices. The first step changes the geometry of the surface, and the second step changes the connectivity of the mesh. Depending on the structure of the mesh, this can also change the topological structure of the surface. The last step simply removes elements that are no longer needed on the surface. Vertex pair contraction is a generalization of edge contraction, where vertices i and j are not connected by an edge. The outline of the algorithm is as follows:
[0108] Step one: obtain a plurality of candidate vertex pairs;
[0109] Step two: assign a contraction cost to each of the candidate pairs;
[0110] Step three: enter a plurality of the candidate vertex pairs into a heap with cost as the key, wherein the candidate vertex pair with the minimum cost corresponds to the top of the heap in the heap;
[0111] Step four: remove the vertex pair with the minimum cost from the heap;
[0112] Step five: contract the vertex pair with the minimum cost;
[0113] Step six: update the weights of all candidate vertex pairs;
[0114] Step seven: repeat steps four to five until the contraction reaches the target value.
[0115] The shrinkage cost is achieved by a quadratic error metric. First introduce a plane, associate a set of planes with each vertex of the model; the standard representation of a plane is n T v + d = 0, where n = [a, b, c] is the unit normal vector (i.e. a2+ b2+ c2= 1), and d is a scalar constant. Given such a plane, the distance of a vertex v = [x, y, z] T from the plane can be expressed as follows
[0116] D 2 (v) = (n T v + d) 2 = (v T nn T v + 2(dn) T v + d 2 )
[0117] where nn T is the outer product matrix:
[0118]
[0119] A quadratic surface is represented as follows: Q = (A, b, c). Where A is a 3*3 matrix, b is a three-dimensional vector, and c is a constant. The quadratic surface Q assigns a value Q(v) to each point v in space by the second order equation: Q(v) = v T Av + 2b T v + c. The quadratic surface provides a very convenient representation for the squared distance D2(v) of a point v to a given plane. For a given plane n T v + d = 0, define its fundamental quadratic surface Q as: Q = (nn T , dn, d 2 ). From the distance formula mentioned earlier, it can be found that the value of the quadratic surface for v is the distance of v to the given plane, denoted as Q(v) = D 2 (v). The addition of quadratic surfaces can be naturally defined component-wise: Q i (v) + Q j (v) = (Q i + Q j )(v), where (Q i + Q j ) = (A i + A j ; b i + b j ; c i + c j ). Thus, given a set of fundamental quadratic surfaces determined by a set of planes, the quadratic surface error E Q is completely determined by the sum of the quadratic surfaces Q i :
[0120]
[0121] where Q = ∑ i Q i , in other words, to calculate the sum of the square of the distance to a set of planes, only a quadratic surface consisting of the sum of the quadratic surfaces defined by each individual plane in the set is needed, when shrinking the edge (v i , v j ) the resulting quadratic surface is Q = Q i + Q j . Furthermore, the cost of shrinking (v i , v j ) → v is Q(v) = Q i (v) + Q j (v).
[0122] It can be understood that by selecting and reducing the vertices of the initial simplified mesh, the number of vertices of the model can be effectively reduced, the calculation complexity can be reduced, a reduction cost is assigned to each candidate vertex pair, the optimal vertex for simplification can be better evaluated and selected, and reasonable use of resources is ensured. Further, by evaluating the criticality of the candidate vertices, the vertices that have the least influence on the shape of the model can be identified, and more targeted simplification can be performed. In the simplification process, the cost of each vertex can be evaluated in real time, and the structural integrity and visual effect of the model can be ensured during the simplification process. Further, by removing the vertex with the largest cost, the model can be gradually optimized, and it is ensured that each step of simplification is within an acceptable range. In the simplification process, the weights of the candidate vertices can be updated in real time, and the real-time and accuracy of the simplification decision can be ensured. Further, the process from step four to step seven can be flexibly adjusted to adjust the simplification strategy until the target simplification degree is reached, and the final model can meet the requirements.
[0123] Further, the target simplified texture of the target simplified mesh is optimized by using JPEG compression. Specifically, texture information of the target simplified texture is extracted, and a target simplified texture picture is determined. The target simplified texture picture is sequentially subjected to color quantization processing and dithering processing, and a schematic diagram of the optimization processing is shown in Figure 6 .
[0124] First, apply color quantization based on the median cut algorithm to the image. The purpose of color quantization is to reduce the number of colors in the image. Since transparent textures are usually small areas with relatively single colors, color quantization can better compress the storage of textures while maintaining visual effects. The median cut algorithm is the main algorithm for color quantization, and its principle is as follows: a. Color space division: map all colors in the image to a three-dimensional color space (such as RGB). b. Initial division: find the axis with the most colors in the color space (R, G, or B), and divide the color space into two parts along the median of this axis. This step will roughly divide the color number into two equal parts. c. Recursive division: continue to perform the above steps on each part until the desired number of color boxes (usually 256) is divided. d. Color box representative color: each color box is represented by the average or median color in it, and these representative colors form the final palette. Then perform dithering. The main purpose of dithering is to reduce the banding effect caused by color quantization by introducing noise, thereby improving the visual effect. When the number of colors in the image is reduced, for example, from millions of colors to 256 colors, the color transition part of the image may appear obvious bands, which is the banding effect. This effect is particularly evident in smooth gradient areas, affecting visual quality. Dithering introduces small noise into the image to make color transitions more natural and smooth, thereby reducing banding.
[0125] The basic principle of dithering is to simulate more colors by introducing certain errors between pixels, so that the image looks smooth in vision. This section uses Floyd-Steinberg dithering, whose basic steps are as follows:
[0126] B1, initialization: traverse each pixel of the image from left to right and from top to bottom.
[0127] B2, quantize color: quantize the color value of the current pixel to the closest color in the target palette.
[0128] B3, calculate error: calculate the error between the original color and the quantized color.
[0129] B4, diffuse error: distribute the error to the four adjacent pixels as follows:
[0130] a. The pixel to the right of the current row: 7 / 16 of the error.
[0131] b. The pixel to the left of the next row: 3 / 16 of the error.
[0132] c. The pixel of the next row: 5 / 16 of the error.
[0133] d. The pixel to the right of the next row: 1 / 16 of the error.
[0134] B5, updating color values: updating the color values of pixels assigned with errors to reflect the adjusted values.
[0135] B6, repeating the steps: repeating the above steps for each pixel in the image until all pixels are processed.
[0136] Through dithering processing, even in the case of significant color reduction, the visual quality of the image can be significantly improved. Dithering processing can effectively eliminate color banding, making the color transition of the image more natural and continuous, thus improving the overall visual effect.
[0137] Further, the method further comprises a hierarchical marking process on the target simplified grid, and a schematic diagram of the hierarchical marking process is shown in Figure 7 .
[0138] Specifically, the following steps are included:
[0139] a. Read and parse the script file of the model to obtain the texture set;
[0140] b. Traverse the set to obtain the width, height values of the texture, set the LOD level, scale, and calculate the scaling formula of the w texture as scale = 2 -level ;
[0141] c. The LOD texture resolution of the current level is
[0142] width = width x scale, height = height x scale, and then export the texture picture to the specified directory according to the calculated scaling.
[0143] After the texture picture is processed according to the LOD level, the LOD distance of each level is calculated. The calculation formula of the LOD distance of the 0th level is:
[0144] zerodistance = (height > width? height: width) x 0.25, and the calculation formula of the higher level is distance = zerodistance x 2 level , and the relevant information is saved in the script file and the configuration file.
[0145] Step 4.2: The model processed in step 4.1 is divided into different model tiles, and the model tiles are divided based on a quadtree for more efficient model scheduling.
[0146] The steps for constructing a quadtree LOD are as follows:
[0147] C1, create an initial node: divide the entire scene or model into a root node that covers the entire range.
[0148] C2, get the detail level of the node:
[0149] C3, create child nodes: for the current node, determine whether further subdivision into four child nodes is needed based on the detail level and the total number of model faces within the node. If the detail level of the current node is sufficient and the total number of faces does not exceed the set threshold P of the current level, stop subdividing; otherwise, subdivide the current node into four child nodes.
[0150] C4, recursively subdivide child nodes: for each child node, repeat steps C2 and C3 until the preset detail level is reached or subdivision cannot continue.
[0151] C5, optimize nodes: optimize nodes as needed, such as merging, culling, etc., to reduce redundant data and improve rendering performance.
[0152] By marking the target simplified grid with a hierarchical label, the grid data can be effectively organized and managed, providing structured support for subsequent simplification and optimization. By reading and analyzing the script file of the target simplified grid, relevant layer information can be obtained, which provides basic data for further processing and optimization.
[0153] Further, Figure 3 The structural diagram of the three-dimensional model lightening device is shown in Figure 3 The device comprises:
[0154] The acquisition module is configured to acquire a plurality of point cloud data of a target agricultural scene, construct a cloth grid based on the point cloud data, and map the cloth grid with texture information of the plurality of point cloud data.
[0155] The gravity dynamic simulation module is configured to perform gravity dynamic simulation on the cloth grid and obtain a cloth form when the cloth grid reaches a target stable state.
[0156] The target grid determination module is configured to determine a target grid based on the cloth form and the plurality of point cloud data, the target grid being a three-dimensional model with a plurality of ground points in the plurality of point cloud data as a base, and the surface of the target grid including a target texture.
[0157] The optimization processing module is configured to perform high-ratio simplification on the target grid and perform texture optimization processing on the high-ratio simplified grid to obtain a lightened three-dimensional model.
[0158] The application of the related modules of the device in this example can refer to the related description of the method principle above, which will not be repeated here.
[0159] According to another aspect of the present application, the present application also discloses an electronic device, which comprises a memory and at least one processor, the memory stores instructions; the at least one processor invokes the instructions in the memory to enable the electronic device to perform the steps of the three-dimensional model lightening method as above.
[0160] The above Figure 3 The three-dimensional model lightening device in the embodiment of the present application is described in detail from the perspective of the modular functional entity, and the electronic device in the embodiment of the present application is described in detail from the perspective of hardware processing.
[0161] Figure 4 is a structural schematic diagram of an electronic device provided by the embodiment of the present application. The electronic device 400 can have great differences due to different configurations or performances, and can comprise one or more processors (central processing units, CPUs) 410 (for example, one or more processors) and a memory 420, and one or more storage media 430 (for example, one or more mass storage devices) storing application programs 433 or data 432. The memory 420 and the storage media 430 can be temporary storage or persistent storage. The programs stored in the storage media 430 can comprise one or more modules (not shown in the figure), and each module can comprise a series of instruction operations in the electronic device 400. Furthermore, the processor 410 can be configured to communicate with the storage media 430, and execute the series of instruction operations in the storage media 430 on the electronic device 400.
[0162] The electronic device 400 can also comprise one or more power supplies 440, one or more wired or wireless network interfaces 450, one or more input and output interfaces 460, and / or one or more operating systems 431, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art can understand that the electronic device 400 can also comprise other components, which will not be described in detail here. Figure 4 The electronic device structure shown does not constitute a limitation based on the electronic device, and can comprise more or fewer components than shown, or combine certain components, or different component arrangements.
[0163] The application further provides a computer readable storage medium, which can be a nonvolatile computer readable storage medium or a volatile computer readable storage medium, and the computer readable storage medium stores instructions, and when the instructions are executed on a computer, the computer executes the steps of the three-dimensional model lightweight method.
[0164] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system or device, unit can refer to the corresponding process in the foregoing method embodiments, and will not be described here.
[0165] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the application or the whole or part of the technical solutions that make essential contributions to the prior art can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the embodiments of the method of the application. The foregoing storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various program code storage media.
[0166] The above, the above embodiments are only used to illustrate the technical solutions of the application, and not to limit them; although the application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the application.
Claims
1. A three-dimensional model lightweightening method characterized by comprising: The method comprises: obtaining a plurality of point cloud data of a target agricultural scene, constructing a cloth grid based on the point cloud data, the initial position of the cloth grid being above the point cloud data, the cloth grid comprising a plurality of interconnected particles, and the cloth grid being mapped with a plurality of texture information of the point cloud data; performing gravity dynamic simulation on the cloth grid, and obtaining a cloth shape when the cloth grid reaches a target stable state; determining a target grid based on the cloth shape and a plurality of the point cloud data, the target grid being a three-dimensional model with a plurality of ground points in the plurality of point cloud data as a base, and the surface of the target grid comprising a target texture; performing high-ratio simplification on the target grid and texture optimization processing on the high-ratio simplified grid to obtain a lightweight three-dimensional model.
2. The three-dimensional model light-weightening method according to claim 1, characterized by, The gravity dynamic simulation on the cloth grid and the obtaining of the cloth shape when the cloth grid reaches the target stable state comprise: performing gravity dynamic simulation on the cloth grid based on a gravity simulation formula; the gravity simulation formula is: where v i is the particle velocity, Δt is the time step, g is the gravity, p i (t+1) is the position of the i-th particle at time t+1, p i (t) is the position of the i-th particle at time t; performing collision detection between the cloth grid and the point cloud data during the descent of the cloth grid under the action of gravity; when it is detected that a target particle in the cloth grid and a target particle in a plurality of the point cloud data have a collision possibility, adjusting the target particle in the cloth grid until the cloth grid satisfies the target stable state; obtaining the cloth shape when the target grid reaches the target stable state.
3. The three-dimensional model light-weightening method according to claim 1, characterized by, The determination of the target grid based on the cloth shape and a plurality of the point cloud data comprises: determining a target vertical distance between each of the point cloud data and the cloth grid; obtaining a distance threshold; when the target vertical distance is less than the distance threshold, determining that the point cloud corresponding to the target vertical distance is a ground point.
4. The three-dimensional model light-weightening method according to claim 1, characterized by, The high-ratio simplification on the target grid comprises: performing edge and face optimization processing on the target grid to obtain an initial simplified grid; performing vertex iterative contraction processing on the initial simplified grid to obtain a target simplified grid, the surface of the target simplified grid comprising a target simplified texture, and the target simplified texture being determined based on the target texture; the texture optimization processing on the high-ratio simplified grid comprises: performing optimization processing on the target simplified texture of the target simplified grid by using JPEG compression, comprising: extracting texture information of the target simplified texture to determine a target simplified texture picture; sequentially performing color quantization processing and dithering processing on the target simplified texture picture.
5. The three-dimensional model light-weightening method according to claim 4, characterized by, The edge and face optimization processing on the target grid to obtain the initial simplified grid comprises: performing initialization normal processing on each of the faces of the target grid based on an initialization normal formula to obtain a plurality of initial face normals; the initialization normal formula is: where v1, v2, v3 are the edges of f i i, and f i is the ith face. refining the processed face normal direction based on a bilateral filtering algorithm to obtain a plurality of target face normals; updating the position of the target grid based on a vertex displacement formula to obtain a target position; determining the initialization simplified grid based on a plurality of the target face normals and the target position; the vertex displacement formula is: where, is the weight of the ith vertex, used for normalizing the displacement calculation. e i,k is the vector between vertex v i and its adjacent vertex v k , is the normal vector of vertex v i , representing the normal direction of the surface that the vertex lies on, h i,k is the projection of e i,k in the direction of σ i is a parameter that controls the degree of smoothness, used to adjust the width of the Gaussian function, thereby affecting the smoothing effect of the vertex displacement. A set of adjacent vertices related to vertex v i A set of adjacent vertices related to vertex v 6. The three-dimensional model light-weightening method according to claim 4, characterized by, The vertex iterative shrinking processing on the initial simplified mesh to obtain a target simplified mesh comprises: Step one: obtaining a plurality of candidate vertex pairs; Step two: assigning a shrinking cost to each of the candidate pairs; Step three: entering the plurality of candidate vertex pairs into a heap with the cost as the key, wherein the candidate vertex pair with the minimum cost corresponds to the top of the heap; Step four: removing the vertex pair with the minimum cost from the heap; Step five: shrinking the vertex pair with the minimum cost; Step six: updating the weights of all candidate vertex pairs; Step seven: repeating steps four to five until the target value is reached.
7. The three-dimensional model light-weightening method according to claim 1, characterized by, The method further comprises: The hierarchical marking processing on the target simplified mesh comprises: reading and parsing a script file of the target simplified mesh to obtain a set of texture pictures; traversing the set to obtain the width value and the height value of the texture pictures; setting the hierarchical level, the scaling ratio, and determining the scaling ratio formula of the texture; exporting the texture pictures to a target directory based on the scaling ratio.
8. A three-dimensional model light-weighting apparatus, characterized by comprising: The device comprises: an acquisition module configured to acquire a plurality of point cloud data of a target agricultural scene, construct a cloth mesh based on the point cloud data, and set an initial position of the cloth mesh above the point cloud data, wherein the cloth mesh comprises a plurality of interconnected particles, and the cloth mesh is mapped with texture information of the plurality of point cloud data; a gravity dynamic simulation module configured to perform gravity dynamic simulation on the cloth mesh and acquire a cloth shape when the cloth mesh reaches a target stable state; a target mesh determination module configured to determine a target mesh based on the cloth shape and the plurality of point cloud data, wherein the target mesh is a three-dimensional model with a plurality of ground points in the plurality of point cloud data as a base, and a surface of the target mesh comprises a target texture; an optimization processing module configured to perform high-ratio simplification on the target mesh and perform texture optimization processing on the mesh after high-ratio simplification to obtain a lightweight three-dimensional model.
9. An electronic device, comprising: The electronic device comprises a memory and at least one processor, and the memory stores instructions; the at least one processor invokes the instructions in the memory to enable the electronic device to perform each step of the model lightweight method according to any one of claims 1-7.
10. A computer-readable storage medium having stored thereon instructions, the computer-readable storage medium comprising: The instructions are executed by the processor to implement each step of the model lightweight method according to any one of claims 1-7.
Citation Information
Cited By
Virtual scene data processing method and device, equipment, storage medium and program product
CN122089925A