A hair model generation method, system, electronic device and storage medium
By obtaining the shape basis of the head and hair model from the 3D deformable model and calculating the motion parameters and vertex weights, the problem of insufficient accuracy, long time consumption and binding difficulties in the existing hair model generation is solved, realizing efficient and flexible hair model generation and improving the user experience.
Patent Information
- Application Number
- CN202511485015.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-17
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2045-10-17
AI Technical Summary
Existing 3D deformable models (3DMMs) suffer from insufficient accuracy, long processing time, difficulty in binding with head models, and poor flexibility when generating hair models, failing to meet the needs of personalized hairstyle design.
By acquiring the head shape base and hair model of the standard head model, calculating the motion parameters and vertex weights of the hair vertices, generating the hair shape base, and combining the shape coefficients to quickly construct the target hair model, the accurate alignment and efficient binding of the hair and head model are ensured.
It achieves high-quality, accurately aligned hair model generation, improving generation efficiency and flexibility, supporting users to freely switch hairstyles, and enhancing user experience and model generalization ability.
Smart Images

Figure CN120953521B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computer vision, and more particularly, to a hair model generation method and system, an electronic device and a storage medium. BACKGROUND
[0002] As a core technology widely used in the field of computer vision face reconstruction, three-dimensional morphable model (3DMM) can quickly generate a 3D digital portrait highly similar to the input face image. The three-dimensional morphable model uses a preset average head shape framework and a set of shape bases to adaptively represent the head shape features, and accurately realizes the head features of different shapes by adjusting the shape bases. However, since the existing 3DMM system only focuses on the geometric modeling of the face and head region, and does not include the hair as a key visual element, the 3D digital portrait generated based on the 3DMM technology often presents a hairless state. In order to improve the realism, a hair model needs to be built separately in practical applications. The current mainstream solution is to directly reconstruct three-dimensional according to the hair distribution in the input image, but this method has significant defects: it is limited by the original image quality, resulting in insufficient accuracy of the generated hair model, and it is difficult to adapt to the subsequent binding requirements with the head model due to the lack of standardized topological structure, and the entire generation process is time-consuming, and this passive modeling method which completely relies on input image data seriously restricts the flexibility of hairstyle design and cannot meet the demand of personalized adjustment of hairstyle. SUMMARY
[0003] The present application provides a hair model generation method, system, electronic device and storage medium, which is used to generate a high-quality, high-matching and high-flexibility hair model, and improve the generation efficiency of the hair model.
[0004] According to a first aspect of the present application, a hair model generation method is provided, the method comprising:
[0005] obtaining a head shape base of a standard head model;
[0006] obtaining a standard hair model;
[0007] obtaining a hair shape base of the standard hair model according to the head shape base and the standard hair model;
[0008] obtaining a shape coefficient of a target head model, the shape coefficient being obtained according to a target face image, and the target head model being obtained according to the standard head model, the head shape base and the shape coefficient;
[0009] obtaining a corresponding target hair model according to the hair shape base and the shape coefficient.
[0010] It can be understood that, based on the standard head model, a head shape base is extracted, and a hair shape base of the standard hair model is parsed according to the standard head model and the standard hair model, to form a reusable deformation template; then, based on a target face image, a shape coefficient is extracted, the standard head model is driven to deform to a target head model, and a predefined hair shape base is combined with the shape coefficient, to quickly generate a target hair model highly fitted to the target head model, which not only ensures accurate alignment of hair and head surface, but also greatly improves generation efficiency relying on parameterized calculation, and has excellent generalization ability and user interaction experience.
[0011] Optionally, the hair shape base of the standard hair model is obtained according to the head shape base and the standard hair model, and the method comprises:
[0012] A hair vertex in the standard hair model is obtained;
[0013] Position information of the hair vertex is obtained, and a nearest neighbor triangular facet in the standard head model to which the hair vertex belongs is obtained according to the position information of the hair vertex;
[0014] A motion amount parameter of the hair vertex is obtained according to the head shape base of the standard head model and the nearest neighbor triangular facet;
[0015] A hair shape base of the hair vertex is obtained according to the motion amount parameter of the hair vertex;
[0016] The hair shape base of the standard hair model is obtained according to the hair shape base of the hair vertex.
[0017] It can be understood that, according to the position information of the hair vertex, the nearest neighbor triangular facet to which the hair vertex belongs is located, and then the motion amount parameter of each hair vertex is calculated based on the spatial relationship between the head shape base and the nearest neighbor triangular facet, so as to deduce the hair shape base of the hair vertex, and finally aggregate to form a complete hair shape base. The mathematical mapping relationship between the hair vertex and the local features of the surface of the standard head model is established, so that the standard hair model can produce natural deformation in accordance with the change of the standard head model, which not only ensures seamless fitting of hair and scalp, but also retains the overall modeling features of the hairstyle, and lays a high-efficiency data foundation for subsequent generation of a high-fidelity target hair model based on different target head models.
[0018] Optionally, the motion amount parameter of the hair vertex is obtained according to the head shape base of the standard head model and the nearest neighbor triangular facet, and the method comprises:
[0019] Three head vertices corresponding to the nearest neighbor triangular facet are obtained;
[0020] Based on the head shape basis of the standard head model, obtain the head shape basis of each head vertex;
[0021] The corresponding motion parameters are obtained based on the head shape base of each head vertex;
[0022] The motion parameters corresponding to the three head vertices are used as the motion parameters of the hair vertices.
[0023] Understandably, the three head vertices corresponding to the nearest neighbor triangular facets associated with the hair vertex are obtained, and the head shape basis components of each head vertex are extracted as motion parameters based on the head shape basis of the standard head model. Then, the motion parameters of these three head vertices are integrated into the comprehensive motion parameters of the hair vertex. By capturing the spatial distribution pattern of the local surface features of the standard head model, the motion trajectory of the hair vertex not only follows the overall shape constraints of the head, but also responds delicately to local curvature changes, thereby ensuring the integrity of the overall hairstyle and significantly improving the physical realism and dynamic expressiveness of the hair.
[0024] Optionally, the motion parameters corresponding to the three head vertices are obtained using the following formula, wherein the three head vertices are related to the first... Each hair vertex corresponds to a nearest neighbor triangle. The three head vertices are defined as the first head vertex, the second head vertex, and the third head vertex. The head vertices are represented using three-dimensional coordinates, and the head shape basis of each head vertex includes several head shape basis components:
[0025]
[0026] in, Represented as the first head vertex The first motion parameter under the basic components of head shape. These represent the three-dimensional coordinates of the first head vertex, respectively. Each head shape basic component; Represented as the second head vertex The second motion parameter under the basic components of head shape. These represent the three-dimensional coordinates of the second head vertex, respectively. Each head shape basic component; Represented as the third head vertex The third motion parameter under the basic components of head shape These represent the three-dimensional coordinates of the third head vertex, respectively. Each head shape is a basic component.
[0027] Understandably, the three head vertices corresponding to the nearest neighbor triangles associated with the hair vertex are respectively assigned their three-dimensional coordinates in their respective positions. The head shape base component is taken as the motion amount parameter, and the calculation mode of the component-by-component and multi-vertex cooperation can not only accurately capture the geometric characteristics of the local surface of the standard head model, but also enable the motion trajectory of the hair vertex to finely respond to the subtle changes in the shape of the standard head model through the linear combination mechanism of the head shape base component, thereby ensuring the natural deformation of the hair and improving the calculation efficiency through the structured mathematical expression, and providing a data basis with physical reality and operation performance for subsequent dynamic hairstyle simulation.
[0028] Optionally, the hair shape base of the hair vertex is obtained according to the motion amount parameter of the hair vertex, and the method comprises the following steps of:
[0029] obtaining three head vertices corresponding to the nearest neighbor triangular facet;
[0030] mapping the hair vertex into the nearest neighbor triangular facet, and calculating vertex weights corresponding to the three head vertices based on the position information of the hair vertex and the position information of the three head vertices;
[0031] obtaining the hair shape base of the hair vertex according to the motion amount parameter and the corresponding vertex weights.
[0032] It can be understood that for the nearest neighbor triangular facet corresponding to each hair vertex, three head vertices are selected as reference points, and vertex weights are calculated for each hair vertex, and then the calculated motion amount parameter and vertex weights of the hair vertex are weighted and fused to generate a hair shape base with local adaptability and global coordination, so that the standard hair model can accurately respond to the curvature change of the surface of the standard head model, and the natural transition of the hairstyle can be realized through weight adjustment, thereby effectively solving the rigid deformation problem caused by single vertex driving in the traditional method, and significantly improving the fit degree and visual reality of the subsequent standard hair model and standard head model.
[0033] Optionally, the hair shape base of the hair vertex comprises a plurality of hair shape base components;
[0034] The hair shape base of the hair vertex is obtained according to the motion amount parameter and the corresponding vertex weights, and the method comprises the following steps of:
[0035] The first hair shape base component of the first hair vertex is obtained by the following formula: three head vertices, including a first head vertex, a second head vertex and a third head vertex, are obtained from the nearest triangular facet corresponding to the first hair vertex.
[0036]
[0037] in, This is represented by the vertex weight corresponding to the first head vertex. This is represented by the vertex weight corresponding to the second head vertex. This is represented by the vertex weight corresponding to the third head vertex. Represented as the first head vertex The first motion parameter under the basic components of head shape. Represented as the second head vertex The second motion parameter under the basic components of head shape. Represented as the third head vertex The third motion parameter under the basic components of head shape;
[0038] According to the first All hair shape base components of the first hair vertex are obtained. The hair shape base at the apex of the hair.
[0039] Understandably, the motion parameters of the three head vertices of the nearest neighbor triangle corresponding to each hair vertex are weighted and fused according to preset vertex weights to generate the first... The first hair vertex The design of multiple hair shape basic components, which involves multi-source data collaboration and weight adjustment, enables the standard hair model to accurately respond to local curvature changes on the head surface and achieve natural transitions in hairstyle through the combination of hair shape basic components. This effectively solves the problem of stiff deformation caused by traditional single-point driving, significantly improves the fit, dynamic adaptability and visual realism of the hairstyle and the target head model, and provides efficient technical support for high-quality 3D character modeling.
[0040] Optionally, the method further includes:
[0041] Obtain the hair vertices of the target hair model, and obtain the corresponding set of neighborhood point positions based on the hair vertices and vertex connection relationships, wherein the vertex connection relationships are obtained based on the standard hair model;
[0042] The corresponding smooth vertex is obtained based on the hair vertex and the set of neighboring points; wherein, the smooth vertex is obtained by the following formula:
[0043]
[0044] in, Represented as the first hair apex The corresponding smooth vertex, Represented as the first hair apex a corresponding neighborhood point position set, a head hair vertex represented as a head hair vertex in the neighborhood point position set;
[0045] moving the head hair vertex to a corresponding smooth vertex to obtain a target hair model after smoothing;
[0046] obtaining a new head hair shape basis according to the target hair model after smoothing, and updating the head hair shape basis of the target hair model with the new head hair shape basis.
[0047] It can be understood that for each head hair vertex, a neighborhood point position set is constructed based on the vertex connection relationship of the standard hair model, and a smooth vertex is calculated, so that the head hair vertex migrates to the smooth vertex, effectively eliminating the grid distortion and local noise of the standard hair model. Then, a smooth target hair model is obtained based on the smooth head hair vertex, and a new head hair shape basis is updated to form a deformation reference with more global consistency, which not only improves the surface smoothness and visual naturalness of the standard hair model and the target hair model, but also enhances the adaptability of the standard hair model to different head shapes through the dynamically updated head hair shape basis.
[0048] According to a second aspect of the present application, a hair model generation system is provided, the system comprising:
[0049] a head shape basis acquisition module configured to acquire a head shape basis of a standard head model;
[0050] a standard hair model acquisition module configured to acquire a standard hair model;
[0051] a hair shape basis acquisition module configured to acquire a hair shape basis of the standard hair model according to the head shape basis and the standard hair model;
[0052] a shape coefficient acquisition module configured to acquire a shape coefficient of a target head model, the shape coefficient being acquired according to a target face image, and the target head model being acquired according to the standard head model, the head shape basis and the shape coefficient;
[0053] a target hair model acquisition module configured to acquire a corresponding target hair model according to the hair shape basis and the shape coefficient.
[0054] According to a third aspect of the present application, an electronic device is provided, comprising:
[0055] a memory configured to store one or more computer programs;
[0056] a processor, when the one or more computer programs are executed by the processor, implements the hair model generation method of the first aspect described above.
[0057] According to a fourth aspect of the present application, a computer readable storage medium is provided, which stores computer instructions for causing a processor to implement the head model generation method of the first aspect when executed.
[0058] Based on any one of the above aspects, the head model generation method, system, electronic device and storage medium provided by the embodiments of the present application can achieve the following benefits:
[0059] The target head model is accurately aligned with the target head model and has high compatibility: the hair shape base of each hair vertex is weighted and synthesized by the head shape base of the three head vertices of the corresponding nearest neighbor triangular facet of the standard head model. This fine adjustment mechanism with vertex-by-vertex and multi-component enables the target head model to closely fit the contour of the target head model. At the same time, based on the high-quality binding basis of the standard head model and the standard head model, the overall structural coordination is further strengthened, avoiding the common penetration or suspension problem in traditional methods, and the finally generated target head model is highly consistent with the target head model in geometric shape.
[0060] Efficiency of generating target head model is improved: in the present application, the corresponding hair shape base can be obtained based on the head shape base and the standard head model. In the actual generation process, only the shape coefficient of the target head model needs to be extracted, and the target head model can be quickly derived through the algorithm, without the need to construct a complex grid from scratch. At the same time, the present application can realize modular design, from the extraction of the head shape base to the output of the target head model, forming an efficient and clear step, combined with the potential of vector operation, significantly shortening the time of generating the target head model at a time, thereby improving the efficiency of generating the target head model.
[0061] Flexible transformation of hair style in target hair model, improve generalization ability and user experience: the present application can support users to freely switch any standard hair model, and realize individual adaptation across target head model through corresponding shape coefficient. Since the hair shape base has pre-encapsulated the core features of the hair style, the user only needs to modify the shape coefficient corresponding to the standard hair model to quickly generate a new hair style that meets the target head shape of the user, and can automatically complete the smooth transition of the hair style, realize the user demand of adapting the same hair style to different face shape and head shape, and the user can enjoy the high-quality rendering effect of the hair model, significantly improve the interaction flexibility and satisfaction. BRIEF DESCRIPTION OF DRAWINGS
[0062] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0063] Figure 1 The schematic application scenario diagram of a hair model generation method provided by the present embodiment.
[0064] Figure 2 The flowchart of a hair model generation method provided by the present embodiment.
[0065] Figure 3 The flowchart of obtaining a hair shape base provided by the present embodiment Figure 1 .
[0066] Figure 4 The flowchart of obtaining a motion amount parameter provided by the present embodiment.
[0067] Figure 5 The flowchart of obtaining a hair shape base provided by the present embodiment Figure 2 .
[0068] Figure 6 The flowchart of smoothing processing provided by the present embodiment.
[0069] Figure 7 The functional module schematic diagram of a hair model generation system provided by the present embodiment.
[0070] Figure 8 The structural schematic diagram of an electronic device provided by the present embodiment. DETAILED DESCRIPTION
[0071] The drawings in the present application are only used for illustrative description, and cannot be understood as limitation to the present application. In order to better illustrate the following embodiments, some components in the drawings may be omitted, enlarged or reduced, and do not represent the actual product size; it is understandable for those skilled in the art that some well-known structures and their descriptions in the drawings may be omitted.
[0072] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should belong to the scope of protection of the present application.
[0073] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0074] The inventor found that in the existing three-dimensional deformable model (3DMM, Three-Dimensional Morphable Models), only the face region of the head or the entire head region is generally concerned, and the hair of the head is rarely modeled. In order to make the generated head model more consistent with reality, the head model needs to be matched with hair. In the prior art, the corresponding target hair model is generally generated directly according to the hair of the target face image, but this method has the disadvantages of poor quality of the generated target hair model, which is not conducive to the binding of the subsequent domain head model, and is time-consuming. At the same time, this method has poor flexibility, and the generated hair model is completely determined by the target face image, and the user cannot flexibly change the hairstyle model.
[0075] The present embodiment provides a technical solution that can solve the above problems. The specific embodiments of the present application will be described in detail below in combination with the drawings.
[0076] Exemplarily, a hair model generation method provided by the present embodiment is applied to a scene. As shown in Figure 1As shown, the application scenario includes at least a server 100 and a terminal 200 that can communicate with the server 100. The server 100 has functions such as data acquisition, data processing, and model generation; the terminal 200 has functions such as data collection, data acquisition, data processing, and model generation.
[0077] Understandably, the server 100 can be an independent electronic device or a cluster of multiple electronic devices; the terminal 200 can be a smartphone terminal, personal computer, tablet computer, vehicle terminal, etc., but is not limited to these.
[0078] In one possible implementation, server 100 and terminal 200 may each execute a hair model generation method provided in the embodiments of this application. Alternatively, the hair model generation method provided in the embodiments of this application may be executed partly in server 100 and partly in terminal 200.
[0079] like Figure 2 As shown, this embodiment provides a method for generating a hair model, which can be further divided into the following steps:
[0080] S100, Obtain the head shape base of the standard head model;
[0081] Understandably, a standard head model is a 3D model with average standard dimensions built by developers based on the basic features and structure of the head using modeling software and other tools. In this embodiment, based on the image processing technology corresponding to the 3DMM 3D variable model, the standard head model can be deformed based on the input target face image to construct a target head model that matches the target face image. The standard head model and / or the target head model contains several head vertices; preferably, the head vertices are represented by 3D coordinates to indicate their positions in the standard head model and / or the target head model.
[0082] In image processing techniques for 3DMM (3D variable model), a head shape base is typically preset for the standard head model. This head shape base is used to control the transformation direction of the 3D coordinates of each head vertex in the standard head model. In this embodiment, shape coefficients are calculated based on the target face image. These shape coefficients indicate the transformations required to convert the standard head model into a target head model that matches the target face image. Finally, based on the standard head model, the head shape base, and the shape coefficients, the corresponding target head model is obtained.
[0083] Understandably, the hair model generated in this application is used to fit and merge with the target head model so that the target head model can be more realistic and the hairstyle of the hair model can be flexibly changed.
[0084] S200, acquire a standard hair model;
[0085] It can be understood that the target hair model of the present application is also generated based on the image processing technology corresponding to the 3DMM three-dimensional variable model, so a standard hair model, a corresponding hair shape base, and a shape coefficient used for subsequent calibration of deformation are also set. In the present embodiment, in order to increase the flexibility of the user to change the hairstyle of the target head model, a plurality of types of standard hair models are correspondingly preset, including but not limited to a long hair standard hair model, a short hair standard hair model, etc. The standard hair model is constructed by a developer or a modeler according to the position data of the standard head model. Since the developer or the modeler fully considers the physical properties and the realistic effect of the hair model in the construction process, the constructed standard hair model can be more realistic and lifelike, and more consistent with the characteristics of the hair in reality. Since each standard hair model is constructed based on the position data of the standard head model, the same shape coefficient as the standard head model is subsequently transformed for the standard hair model, which can make the target hair model obtained by transformation more fit the target head model, prevent the hollow and protruding conditions between the two models, and improve the reliability of generating the target hair model.
[0086] In actual application, when the user constructs the corresponding target hair model, a standard hair model can be selected as the basis for subsequent generation of the target hair model, so that the user can freely select the desired hairstyle.
[0087] S300, acquire a hair shape base of the standard hair model according to the head shape base and the standard hair model;
[0088] In the present embodiment, the head shape base is completed when the standard head model is constructed. When the hair model is constructed, the hair shape base is correspondingly constructed based on the head shape base, so that the hair model and the head model can have strong mapping and connection, facilitating the fitting and merging of the target head model and the target hair model.
[0089] Specifically, as shown in Figure 3 The acquisition of the hair shape base of the standard hair model according to the head shape base and the standard hair model can include the following steps:
[0090] S310, acquire a hair vertex in the standard hair model;
[0091] In the present embodiment, all hair vertices in the standard hair model are acquired, and the position information of the hair vertices is associated with the standard head model to ensure that each hair vertex is associated with the standard head model.
[0092] S320, obtaining, according to the position information of the hair vertex, a nearest neighbor triangular patch of the hair vertex in the standard head model;
[0093] In the embodiment, the standard hair model and the standard head model use the same coordinate system, so that the nearest neighbor triangular patch of the hair vertex in the standard head model can be directly obtained according to the position information of the hair vertex. Specifically, the position information of the hair vertex can be the three-dimensional coordinates of the hair vertex. It can be understood that a plurality of triangular patches can be formed in the standard head model based on all the head vertices. In the embodiment, the bvh (Bounding Volume Hierarchy) technology can be used to traverse all the triangular patches of the standard head model based on the position information of the hair vertex, so as to find the nearest neighbor triangular patch matching the position information of the hair vertex, thereby providing a data basis for obtaining the hair shape basis of the hair vertex.
[0094] S330, obtaining, according to the head shape basis of the standard head model and the nearest neighbor triangular patch, a motion amount parameter of the hair vertex;
[0095] In the embodiment, the position of the nearest neighbor triangular patch in the standard head model is close to that of the hair vertex. According to the head shape basis related to the nearest neighbor triangular patch, the motion amount parameter of the hair vertex can be obtained, thereby providing an accurate data basis for obtaining the hair shape basis of the hair vertex, so that the calculated hair shape basis has a strong correlation with the standard head model.
[0096] Specifically, as shown in Figure 4 obtaining, according to the head shape basis of the standard head model and the nearest neighbor triangular patch, a motion amount parameter of the hair vertex can include the following steps:
[0097] S331, obtaining three head vertices corresponding to the nearest neighbor triangular patch;
[0098] S332, obtaining, according to the head shape basis of the standard head model, a head shape basis of each head vertex;
[0099] S333, obtaining a corresponding motion amount parameter according to the head shape basis of each head vertex;
[0100] In this embodiment, the nearest neighbor triangular facet is a triangular region that corresponds to three head vertices. It is necessary to obtain the three head vertices corresponding to the nearest neighbor triangular facet as the data basis for obtaining the hair shape basis of the hair vertices. Understandably, by obtaining the head shape basis of each head vertex and, based on the head shape basis of each head vertex, obtaining the corresponding motion parameters, and using these motion parameters to obtain the hair shape basis of the hair vertices, the accuracy of obtaining the hair shape basis is improved.
[0101] Specifically, the motion parameters corresponding to the three head vertices are obtained through the following formula, wherein the three head vertices are related to the first... Each hair vertex corresponds to a nearest neighbor triangle. The three head vertices are defined as the first head vertex, the second head vertex, and the third head vertex. The head vertices are represented using three-dimensional coordinates, and the head shape basis of each head vertex includes several head shape basis components:
[0102]
[0103] in, Represented as the first head vertex The first motion parameter under the basic components of head shape. These represent the three-dimensional coordinates of the first head vertex, respectively. Each head shape basic component; Represented as the second head vertex The second motion parameter under the basic components of head shape. These represent the three-dimensional coordinates of the second head vertex, respectively. Each head shape basic component; Represented as the third head vertex The third motion parameter under the basic components of head shape These represent the three-dimensional coordinates of the third head vertex, respectively. Each head shape is a basic component.
[0104] Understandably, the standard head model contains N head vertices, each represented by a three-dimensional coordinate. For example, the three-dimensional coordinate may include a horizontal coordinate, a vertical coordinate, and a depth coordinate. Therefore, a standard head model composed of multiple head vertices can be represented by a column vector of length 3N, where each row of the column vector represents the horizontal, vertical, or depth coordinate corresponding to a certain head vertex.
[0105] Shape factor It is a column vector of length L, recording the shape variables of each of the L dimensions (horizontal, vertical, or depth coordinates). The default head shape basis is a matrix of size (3N, L). ,matrix A single element in the array represents the deformation direction of a head vertex in L dimensions, either its horizontal, vertical, or depth coordinates, used to determine the deformation direction based on the shape factor. The standard head model is deformed to obtain the corresponding target head model.
[0106] Therefore, for the first For each hair vertex, the head shape basis corresponding to the three head vertices of its matching nearest neighbor triangle can be found in the head shape basis of the standard head model. Obtained from [the source]. Among them, the [number]th [item / section]... The first head shape basic component represents the lateral and / or longitudinal and / or depth coordinates of the head vertex. Changes in each dimension. The above is based on the head shape. And obtain the first from the above formula The first hair vertex corresponds to the head vertex. Motion parameters under each head shape base component, and subsequent motion parameters under other head shape base components corresponding to the hair vertex, as well as motion parameters of other head vertices corresponding to the hair vertex, are obtained in the same way, so that the motion parameters corresponding to all the hair vertices can be calculated, thereby obtaining intermediate data for obtaining the hair shape base of the hair vertex.
[0107] S334. The motion parameters corresponding to the three head vertices are used as the motion parameters of the hair vertices.
[0108] S340. Obtain the hair shape base of the hair vertex based on the motion parameters of the hair vertex;
[0109] Specifically, such as Figure 5 As shown, obtaining the hair shape base of the hair vertex based on the motion parameters of the hair vertex may include the following steps:
[0110] S341. Obtain the three head vertices corresponding to the nearest neighbor triangular facet;
[0111] S342. Map the hair vertices to the nearest neighbor triangles, and calculate the vertex weights corresponding to the three head vertices based on the position information of the hair vertices and the position information of the three head vertices.
[0112] In this embodiment, after finding the nearest neighbor triangle corresponding to the hair vertex, the hair vertex needs to be mapped into the nearest neighbor triangle to facilitate the calculation of the vertex weights corresponding to the three head vertices. Specifically, the position information of the hair vertex can be its three-dimensional coordinates, and the position information of the head vertex can be its three-dimensional coordinates. Preferably, based on the position information of the hair vertex and the position information of the three head vertices, the Euclidean distance between each pair of hair vertices and head vertices is obtained. The vertex weight corresponding to each head vertex is calculated based on the Euclidean distance, achieving accurate quantification of the influence of head vertices on the hair vertex. This allows the hair vertex to obtain the hair shape basis influenced by the head vertices, thereby making the generated target hair model more natural and realistic.
[0113] S343. Obtain the hair shape base of the hair vertex according to the motion parameters and the corresponding vertex weights.
[0114] Specifically, the hair shape base at the hair vertex includes several hair shape base components;
[0115] Understandably, the standard hair model contains M hair vertices, each represented by a three-dimensional coordinate. For example, the three-dimensional coordinates may include horizontal, vertical, and depth coordinates. Therefore, a standard hair model composed of multiple hair vertices can be represented by a column vector of length 3N, where each row of the column vector represents the horizontal, vertical, or depth coordinate corresponding to a hair vertex.
[0116] The calculated hair shape basis is a matrix of size (3N, L). ,matrix A single element in the array represents the deformation direction of a hair vertex in L dimensions, either its horizontal, vertical, or depth coordinates. In this embodiment, the deformation of the standard hair model uses the same shape coefficients as the standard head model. This ensures that the deformation of the standard hair model is the same as that of the standard head model, thus enabling a one-to-one correspondence between the target hair model and the target head model. The hair shape is based on a shape coefficient. The standard hair model is deformed to obtain the corresponding target hair model.
[0117] The hair shape base of the hair vertex contains several hair shape base components. Specifically, each coordinate value of each hair vertex, including the horizontal coordinate, vertical coordinate and depth coordinate, has a corresponding L-dimensional transformation direction. Therefore, each coordinate value of the hair vertex has L hair shape base components. All hair shape base components corresponding to each coordinate value of each hair vertex are combined into the hair shape base of a standard hair model.
[0118] The hair shape basis of the hair vertex is obtained according to the motion quantity parameter and the corresponding vertex weight, and the method comprises the following steps:
[0119] The first hair shape basis component of the first hair vertex is obtained according to the first motion quantity parameter and the corresponding vertex weight, and the method comprises the following steps: The first hair shape basis component of the first hair vertex is obtained according to the first motion quantity parameter and the corresponding vertex weight, and the method comprises the following steps: The first hair shape basis component of the first hair vertex is obtained according to the first motion quantity parameter and the corresponding vertex weight, and the method comprises the following steps: The first hair shape basis component of the first hair vertex is obtained according to the first motion quantity parameter and the corresponding vertex weight, and the method comprises the following steps: The first hair shape basis component of the first hair vertex is obtained according to the first motion quantity parameter and the corresponding vertex weight, and the method comprises the following steps:
[0120]
[0121] Wherein, represents the vertex weight corresponding to the first head vertex, represents the vertex weight corresponding to the second head vertex, represents the vertex weight corresponding to the third head vertex, represents the first motion quantity parameter under the first head shape basis component of the first head vertex, represents the second motion quantity parameter under the second head shape basis component of the second head vertex, represents the third motion quantity parameter under the third head shape basis component of the third head vertex.
[0122] The hair shape basis of the first hair vertex is obtained according to all the hair shape basis components of the first hair vertex. In this embodiment, for the first hair vertex, the first hair shape basis component
[0123] The first hair shape basis component of the first hair vertex can be obtained by weighting the corresponding three head vertices and vertex weights. The first hair shape basis component of all the hair vertices in the standard hair model can be represented as:
[0124]
[0125] S350, obtaining the hair shape basis of the standard hair model according to the hair shape basis of the hair vertex.
[0126] In this embodiment, the hair shape basis components of other hair vertices also need to be calculated according to the above formula, and the hair shape basis components of all the hair vertices are summarized to obtain the hair shape basis of the standard hair model.
[0127] S400, obtain a shape coefficient of the target head model, the shape coefficient being obtained according to a target face image, the target head model being obtained according to the standard head model, the head shape base and the shape coefficient;
[0128] In the embodiment, the corresponding shape coefficient can be calculated from the target face image input by the user. In the process of generating the target head model, the target head model matching the target face image is obtained through the following formula:
[0129]
[0130] wherein, represents the target head model, represents the standard head model, represents the head shape base, represents the shape coefficient.
[0131] S500, obtain a corresponding target hair model according to the hair shape base and the shape coefficient.
[0132] In the embodiment, the same shape coefficient can be obtained from the process of generating the target head model. In the process of generating the target hair model, the target hair model matching the target head model is obtained through the following formula:
[0133]
[0134] wherein, represents the target hair model, represents the standard hair model, represents the hair shape base.
[0135] Specifically, as shown in Figure 6 the method further comprises:
[0136] S610, obtain a hair vertex of the target hair model, and obtain a corresponding set of neighborhood point positions based on the hair vertex and a vertex connection relationship, wherein the vertex connection relationship is obtained based on the standard hair model;
[0137] In the embodiment, when the standard hair model is constructed, a vertex connection relationship is correspondingly generated, which can reflect the connection degree between two hair vertices. For each hair vertex, there will be other hair vertices having a connection relationship with it. The positions of the other hair vertices corresponding to the connection relationship of the hair vertex are referred to as a set of neighborhood point positions. It can be understood that the structure of the hair model is not a fixed spherical shape, so the number of hair vertices included in the set of neighborhood point positions corresponding to each hair vertex is different.
[0138] By obtaining the set of neighborhood points of a hair vertex, the corresponding smooth vertex can be calculated, providing accurate data support for the smoothing operation.
[0139] S620. Obtain the corresponding smooth vertex based on the hair vertex and the set of neighboring points; wherein, the smooth vertex is obtained using the following formula:
[0140]
[0141] in, Represented as the first hair apex The corresponding smooth vertex, Represented as the first hair apex The corresponding set of neighborhood point locations, Represented as the th in the set of neighborhood point locations A hair vertex;
[0142] In this embodiment, it is necessary to calculate the corresponding smoothing vertex for all hair vertices according to the above formula so that the subsequent target hair model can complete the smoothing process of all hair vertices.
[0143] S630. Move the hair vertex to the corresponding smooth vertex to obtain the target hair model with smoothing completed;
[0144] S640. Obtain a new hair shape base based on the target hair model that has undergone smoothing, and update the head shape base of the target hair model with the new head shape base.
[0145] In this embodiment, for the first The first hair shape base component also needs to have a corresponding smoothed hair shape base component obtained. Hair shape base component Specifically, it can be obtained using the following formula:
[0146]
[0147] in, This represents the first hair vertex in the smoothed target head model. A changing shape.
[0148] Therefore, the smoothed hair shape base can be represented as:
[0149]
[0150] It can be understood that in actual application, the hair shape bases of various standard hair models have been preset through the above steps, and when the corresponding target head model is obtained for the first time according to the input target face image, the corresponding shape coefficient is also obtained, and the corresponding target hair model is obtained according to the shape coefficient; and the smoothed hair shape base can be obtained according to the smoothed target hair model, and the smoothed hair shape base is updated as the new hair shape base of each standard hair model. When the user still changes the hairstyle based on the same target head model, the corresponding target hair model can be directly obtained according to the shape coefficient, specifically:
[0151]
[0152] That is, the smoothed hair shape base is directly used as the intermediate data for generating the target head model, and the smoothed target hair model can be obtained without the need for smoothing operation again, thereby improving the efficiency of target hair model generation, reducing the delay of platform calculation, and improving the experience of the user.
[0153] As shown in Figure 7 , the embodiment of the present application further provides a hair model generation system. Optionally, the system comprises:
[0154] a head shape base obtaining module 711, a standard hair model obtaining module 712, a hair shape base obtaining module 713, a shape coefficient obtaining module 714, and a target hair model obtaining module 715, wherein:
[0155] The head shape base obtaining module 711 is configured to obtain a head shape base of a standard head model.
[0156] In the embodiment, the head shape base obtaining module 711 can be configured to perform the step S100 shown in Figure 2 , and the specific description of the head shape base obtaining module 711 can refer to the description of the step S100.
[0157] The standard hair model obtaining module 712 is configured to obtain a standard hair model.
[0158] In the embodiment, the standard hair model obtaining module 712 can be configured to perform the step S200 shown in Figure 2 , and the specific description of the standard hair model obtaining module 712 can refer to the description of the step S200.
[0159] The hair shape base obtaining module 713 is configured to obtain a hair shape base of the standard hair model according to the head shape base and the standard hair model.
[0160] In the embodiment, the hair shape base obtaining module 713 can be configured to perform the step S300 shown inFigure 2 The step S300 is shown, and the specific description of the hair shape base obtaining module 713 can refer to the description of the step S300.
[0161] The shape coefficient obtaining module 714 is configured to obtain a shape coefficient of a target head model, the shape coefficient being obtained according to a target face image, and the target head model being obtained according to the standard head model, the hair shape base and the shape coefficient.
[0162] In the embodiment, the shape coefficient obtaining module 714 can be configured to perform Figure 2 The step S400 is shown, and the specific description of the shape coefficient obtaining module 714 can refer to the description of the step S400.
[0163] The target hair model obtaining module 715 is configured to obtain a corresponding target hair model according to the hair shape base and the shape coefficient.
[0164] In the embodiment, the target hair model obtaining module 715 can be configured to perform Figure 2 The step S500 is shown, and the specific description of the target hair model obtaining module 715 can refer to the description of the step S500.
[0165] The embodiment of the present application further provides an electronic device, and the structure thereof is shown as Figure 8 The electronic device includes a memory 811, a processor 812, a communication module 813, an input / output interface 814 and the like. Optionally, the memory 811, the processor 812, the communication module 813 and the input / output interface 814 can be connected and communicated through a bus 815.
[0166] The memory 811 is configured to store one or more computer programs and transmit the codes of the computer programs to the processor 812; when the one or more computer programs are executed by the processor 812, a hair model generation method in the embodiment of the present application is implemented.
[0167] Optionally, the electronic device can be connected to a network through the communication module 813, so as to communicate with other devices such as terminals or servers through the network, and realize the interaction of data. The electronic device can be various forms of digital computers, such as desktop computers, servers, workstations, mainframe computers or other types of computers. The electronic device can also be various forms of mobile terminals, such as smart phones, tablet computers, wearable devices (such as helmets, glasses, watches and the like) and other similar mobile terminals.
[0168] Optionally, the electronic device can connect the required input / output devices, such as a keyboard, a display device, etc., through the input / output interface 814. The electronic device itself can have a display device, and can also be externally connected to other display devices through the input / output interface 814. Optionally, a storage device, such as a hard disk, etc., can also be connected through the input / output interface 814, so that the data in the electronic device can be stored in the storage device, or the data in the storage device can be read, and the data in the storage device can also be stored in the memory 811. It can be understood that the input / output interface 814 can be a wired interface or a wireless interface. According to different actual application scenarios, the devices connected to the input / output interface 814 can be a component of the electronic device, or can be an external device connected to the electronic device when needed.
[0169] Optionally, the memory 811 can be a volatile memory and / or a non-volatile memory. The volatile memory can be a random access memory, etc. The non-volatile memory can be a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, or a flash memory, etc.
[0170] Optionally, the computer program stored in the memory 811 can be divided into one or more modules, which are stored in the memory 811 and executed by the processor 812 to complete the method provided by the embodiment. The one or more modules can be a series of computer program instruction segments capable of completing a specific function, which are used to describe the execution process of the computer program in the electronic device.
[0171] Optionally, the processor 812 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 812 include but are not limited to a central processing unit, a graphics processing unit, a digital signal processor, various special-purpose artificial intelligence computing chips, various processors running machine learning model algorithms, and any appropriate controller, microcontroller, processor, etc. The processor 812 executes various methods and processes of the embodiment, exemplarily such as a hair model generation method of the embodiment of the present application.
[0172] Optionally, the bus 815 can include a channel for transmitting information. According to different functions, the bus 815 can be divided into an address bus, a data bus, a control bus, etc.
[0173] In an alternative implementation, the embodiments of the present application further provide a computer storage medium, which stores a computer program. The computer program is executed by a computer to enable the computer to perform the method of the above-mentioned method embodiments. Part or all of the computer program can be loaded and / or installed on the memory 811 of the electronic device. When the computer program is executed by the processor 812, one or more steps of a hair model generation method of the embodiments of the present application can be performed.
[0174] Optionally, the computer readable storage medium can be random access memory, read-only memory, programmable read-only memory, erasable programmable read-only memory, electrically erasable programmable read-only memory, etc.
[0175] Obviously, the above-mentioned embodiments of the present application are only examples for clearly illustrating the technical solutions of the present application, and are not intended to limit the specific embodiments of the present application. Any modification, equivalent replacement and improvement made within the spirit and principle of the claims of the present application should be included in the protection scope of the claims of the present application.
Claims
1. A method for generating a hair model, characterized in that, The method includes: Obtain the head shape base of the standard head model; Obtain a standard hair model; Obtain the hair vertices in the standard hair model; based on the position information of the hair vertices, obtain the nearest neighbor triangles of the hair vertices in the standard head model; based on the head shape basis of the standard head model and the nearest neighbor triangles, obtain the motion parameters of the hair vertices; obtain the three head vertices corresponding to the nearest neighbor triangles; map the hair vertices to the nearest neighbor triangles, and calculate the vertex weights corresponding to the three head vertices based on the position information of the hair vertices and the position information of the three head vertices; obtain the hair shape basis of the hair vertices based on the motion parameters and the corresponding vertex weights; wherein, the hair shape basis of the hair vertices contains several hair shape basis components, the first... The first hair vertex Hair shape base component It is obtained through the following formula, where from the first We obtain three head vertices from the nearest triangle corresponding to each hair vertex, including the first head vertex, the second head vertex, and the third head vertex: in, This is represented by the vertex weight corresponding to the first head vertex. This is represented by the vertex weight corresponding to the second head vertex. This is represented by the vertex weight corresponding to the third head vertex. Represented as the first head vertex The first motion parameter under the basic components of head shape. Represented as the second head vertex The second motion parameter under the basic components of head shape. Represented as the third head vertex The third motion parameter under the basic components of head shape; according to the first All hair shape base components of the first hair vertex are obtained. A hair shape base for each hair vertex; the hair shape base for the standard hair model is obtained based on the hair shape base for each hair vertex; the shape coefficients for the target head model are obtained based on the target face image, and the target head model is obtained based on the standard head model, the head shape base, and the shape coefficients. The corresponding target hair model is obtained based on the hair shape base and the shape coefficient.
2. The method according to claim 1, characterized in that, The step of obtaining the motion parameters of the hair vertices based on the head shape base of the standard head model and the nearest neighbor triangular facets includes: Obtain the three head vertices corresponding to the nearest neighbor triangle; Based on the head shape basis of the standard head model, obtain the head shape basis of each head vertex; The corresponding motion parameters are obtained based on the head shape base of each head vertex; The motion parameters corresponding to the three head vertices are used as the motion parameters of the hair vertices.
3. The method according to claim 2, characterized in that, The motion parameters corresponding to the three head vertices are obtained by the following formula, wherein the three head vertices are related to the first... Each hair vertex corresponds to a nearest neighbor triangle. The three head vertices are defined as the first head vertex, the second head vertex, and the third head vertex. The head vertices are represented using three-dimensional coordinates, and the head shape basis of each head vertex includes several head shape basis components: in, Represented as the first head vertex The first motion parameter under the basic components of head shape. These represent the three-dimensional coordinates of the first head vertex, respectively. Each head shape basic component; Represented as the second head vertex The second motion parameter under the basic components of head shape. These represent the three-dimensional coordinates of the second head vertex, respectively. Each head shape basic component; Represented as the third head vertex The third motion parameter under the basic components of head shape These represent the three-dimensional coordinates of the third head vertex, respectively. Each head shape is a basic component.
4. The method according to claim 1, characterized in that, The method further includes: Obtain the hair vertices of the target hair model, and obtain the corresponding set of neighborhood point positions based on the hair vertices and vertex connection relationships, wherein the vertex connection relationships are obtained based on the standard hair model; The corresponding smooth vertex is obtained based on the hair vertex and the set of neighboring points; wherein, the smooth vertex is obtained by the following formula: in, Represented as the first hair apex The corresponding smooth vertex, Represented as the first hair apex The corresponding set of neighborhood point locations, Represented as the th in the set of neighborhood point locations A hair vertex; Move the hair vertex to the corresponding smooth vertex to obtain the target hair model with smoothing completed; A new hair shape base is obtained based on the target hair model that has undergone smoothing, and the head shape base of the target hair model is updated with the new head shape base.
5. A hair model generation system, characterized in that, The system includes: The head shape base acquisition module is used to obtain the head shape base of a standard head model; The standard hair model acquisition module is used to acquire standard hair models. A hair shape basis acquisition module is used to acquire hair vertices in the standard hair model; acquire the nearest neighbor triangle facets of the hair vertices in the standard head model based on the position information of the hair vertices; acquire the motion parameters of the hair vertices based on the head shape basis of the standard head model and the nearest neighbor triangle facets; acquire the three head vertices corresponding to the nearest neighbor triangle facets; map the hair vertices to the nearest neighbor triangle facets, and calculate the vertex weights corresponding to the three head vertices based on the position information of the hair vertices and the position information of the three head vertices; acquire the hair shape basis of the hair vertices based on the motion parameters and the corresponding vertex weights; wherein, the hair shape basis of the hair vertices includes several hair shape basis components, the first being... The first hair vertex Hair shape base component It is obtained through the following formula, where from the first We obtain three head vertices from the nearest triangle corresponding to each hair vertex, including the first head vertex, the second head vertex, and the third head vertex: in, This is represented by the vertex weight corresponding to the first head vertex. This is represented by the vertex weight corresponding to the second head vertex. This is represented by the vertex weight corresponding to the third head vertex. Represented as the first head vertex The first motion parameter under the basic components of head shape. Represented as the second head vertex The second motion parameter under the basic components of head shape. Represented as the third head vertex The third motion parameter under the basic components of head shape; according to the first All hair shape base components of the first hair vertex are obtained. A hair shape base for each hair vertex; the hair shape base of the standard hair model is obtained based on the hair shape base of the hair vertex; The shape coefficient acquisition module is used to acquire the shape coefficient of the target head model. The shape coefficient is obtained based on the target face image. The target head model is obtained based on the standard head model, the head shape base, and the shape coefficient. The target hair model acquisition module is used to acquire the corresponding target hair model based on the hair shape base and the shape coefficient.
6. The system according to claim 5, characterized in that, The hair shape base acquisition module also includes: Obtain the three head vertices corresponding to the nearest neighbor triangle; Based on the head shape basis of the standard head model, obtain the head shape basis of each head vertex; The corresponding motion parameters are obtained based on the head shape base of each head vertex; The motion parameters corresponding to the three head vertices are used as the motion parameters of the hair vertices.
7. The system according to claim 6, characterized in that, The hair shape base acquisition module also includes: The motion parameters corresponding to the three head vertices are obtained by the following formula, wherein the three head vertices are related to the first... Each hair vertex corresponds to a nearest neighbor triangle. The three head vertices are defined as the first head vertex, the second head vertex, and the third head vertex. The head vertices are represented using three-dimensional coordinates, and the head shape basis of each head vertex includes several head shape basis components: in, Represented as the first head vertex The first motion parameter under the basic components of head shape. These represent the three-dimensional coordinates of the first head vertex, respectively. Each head shape basic component; Represented as the second head vertex The second motion parameter under the basic components of head shape. These represent the three-dimensional coordinates of the second head vertex, respectively. Each head shape basic component; Represented as the third head vertex The third motion parameter under the basic components of head shape These represent the three-dimensional coordinates of the third head vertex, respectively. Each head shape is a basic component.
8. An electronic device, characterized in that, include: Memory, used to store one or more computer programs; A processor, when the one or more computer programs are executed by the processor, implements a hair model generation method as described in any one of claims 1-4.
9. A computer-readable storage medium storing computer instructions for causing a processor to execute and implement a hair model generation method as described in any one of claims 1-4.
Citation Information
Patent Citations
Footwear style design method based on digital three-dimensional model
CN120317017A
Method and apparauts for suggestion and composition of hair image
KR102375587B1