A method for realizing dynamic expression changes based on vector paths
By obtaining facial vector graphic data and calculating deformation parameters with expression change instructions, and using interpolation means to generate intermediate state data, the problem of unnatural expression transition in traditional methods is solved, diversified expression change effects and flexible user input adaptation are achieved, and the user experience is improved.
Patent Information
- Application Number
- CN202510637116.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-19
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2045-05-19
AI Technical Summary
Traditional methods are difficult to achieve delicate and changeable facial expression effects, and the expression transition is unnatural, resulting in poor user experience and lack of flexibility. It is difficult to adjust the details and degree of change of expressions in real time according to different scenarios and user inputs.
By obtaining facial vector graphic data, determining the initial shape, and calculating deformation parameters with expression change instructions, using the interpolation device to generate intermediate state data, controlling the dynamic changes of expressions through the attribute animation frame, and selecting different interpolation devices to adapt to different scenes and user input.
It realizes flexible adjustment of the details and degree of change of expressions according to different scenarios and user input, improves the flexibility and nature of expression changes, reduces performance overhead, and improves user experience.
Smart Images

Figure CN120182439B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method for realizing dynamic changes of facial expressions based on vector paths. Background Art
[0002] In modern fields such as graphical interface design, game development, and virtual character interaction, dynamic facial expressions are crucial for enhancing user experience and character interactivity. Traditional methods often rely on pre-set expression templates, making it difficult to achieve nuanced and varied expressions. Relying solely on real-time computation also incurs excessive performance overhead. Furthermore, improperly handled transitions between different expressions can easily create abrupt and abrupt effects, impacting the user experience. Furthermore, traditional methods struggle to adjust the detail and degree of expression in real time based on different scenarios and user input, resulting in a lack of flexibility. Summary of the Invention
[0003] In order to overcome the defects of the prior art, the present invention provides a method for realizing dynamic changes of facial expressions based on vector paths to solve the above problems.
[0004] The technical solution adopted by the present invention to solve the technical problem is: a method for realizing dynamic changes of facial expressions based on vector paths, comprising the following steps:
[0005] S1: Acquire vector graphics data containing various parts of the face, wherein the vector graphics data defines an initial shape through path elements;
[0006] S2: receiving an expression change instruction, the expression change instruction including target expression information; and determining a deformation parameter of the path element according to the expression change instruction;
[0007] S3: generating intermediate state data of the path element by interpolation calculation according to the deformation parameters;
[0008] S4: updating the vector graphics data according to the intermediate state data and displaying a dynamically changing expression.
[0009] Specifically, in step S1, the initial path elements of each part of the face are defined by a vector graphics file; for the initial path elements, the key path point coordinate values of each part under different expression states are determined, and the key path point coordinate values are associated with the initial path elements and stored.
[0010] Specifically, the step of receiving the expression change instruction in step S2 includes: obtaining user input data through an external input device; performing semantic analysis on the user input data to determine the corresponding emotional state; and generating an expression change instruction with target expression information according to the emotional state.
[0011] Specifically, in step S2, after receiving the expression change instruction, the key path point coordinate values of the path element in the current expression state are obtained; the key path point coordinate values of the path element in the target expression state are extracted according to the target expression information; the displacement and angle between the corresponding key path point coordinate values of the path element in the current expression state and the target expression state are calculated to obtain deformation parameters.
[0012] It is worth noting that in step S3, the key path point coordinate values and deformation parameters of the path element are obtained; for the key path point coordinate values of the path element in the current expression state and the key path point coordinate values of the path element in the target expression state, a preset interpolator is used to calculate the intermediate state coordinates of the two key path point coordinate values, and the intermediate state data of the path element is generated according to the intermediate state coordinates.
[0013] Optionally, the preset interpolator is divided into a linear interpolator and a nonlinear interpolator according to the interpolator type. In step S3, the emotional state is obtained from the expression change instruction, and the interpolator type related to the target expression is obtained according to the emotional state.
[0014] Preferably, in step S3, if the emotional state indicates that the target expression needs a smooth transition, a linear interpolator is used to calculate the intermediate state coordinates; if the emotional state indicates that the target expression needs to change rapidly, a nonlinear interpolator is used to calculate the intermediate state coordinates.
[0015] Specifically, in step S3, for the Bezier curve in the path element, the initial coordinates of the control points of the Bezier curve are obtained; the displacement vector after interpolation at the current moment is obtained according to the input strength of the user at the current moment and the deformation parameter at the current moment; the dynamic coordinates of the control point are calculated as the intermediate state coordinates according to the displacement vector after interpolation at the current moment; and the intermediate state data of the Bezier curve corresponding to the path element are generated through the intermediate state coordinates.
[0016] Preferably, in step S3, the dynamic coordinates of the control point ,in represents the initial coordinates of the control points, represents the steepness coefficient of the Sigmoid function, Indicates deformation delay time; represents the displacement after interpolation at the current time t, ,in represents the displacement in the deformation parameter at the current time t, represents the expression intensity coefficient, Indicates the user's input strength at the current moment. Indicates the input sensitivity corresponding to the user's input at the current moment. represents the damping coefficient.
[0017] Specifically, in step S4, the step of updating the vector graphics data and displaying dynamically changing expressions includes: obtaining the current frame time of the attribute animation framework; updating the coordinate value of the path element according to the current frame time and the intermediate state data; applying the updated path element to the vector graphics data through the attribute animation framework and rendering and displaying it.
[0018] The beneficial effects of the present invention lie in the following: the method for achieving dynamic expression changes based on vector paths obtains vector graphics data containing a face, determines an initial shape based on a preset expression state, and calculates deformation parameters based on expression change instructions. A preset interpolator is used to interpolate the path deformation data to generate intermediate state path data, which is then updated through a property animation framework to ultimately generate a dynamic expression change animation. This allows for flexible adjustment of the interpolator selection based on different scenarios and user input, achieving diverse expression change effects. This allows for real-time adjustment of the expression details and degree of change based on different scenarios and user input, thus improving flexibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 Flowchart of a method for implementing dynamic expression changes based on vector paths in one embodiment of the present invention;
[0020] Figure 2 This is a flow chart for obtaining deformation parameters in one embodiment of the present invention. DETAILED DESCRIPTION
[0021] The following is a further description of specific embodiments of the present invention in conjunction with the accompanying drawings. It should be noted that the description of these embodiments is intended to facilitate understanding of the present invention and does not constitute a limitation of the present invention. In addition, the technical features involved in the various embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
[0022] like Figure 1 and 2 As shown, a method for realizing dynamic changes of facial expressions based on vector paths includes the following steps:
[0023] S1: Acquire vector graphics data containing various parts of the face, wherein the vector graphics data defines an initial shape through a path element (Path);
[0024] S2: receiving an expression change instruction, the expression change instruction including target expression information; and determining a deformation parameter of the path element according to the expression change instruction;
[0025] S3: generating intermediate state data of the path element by interpolation calculation according to the deformation parameters;
[0026] S4: updating the vector graphics data according to the intermediate state data and displaying a dynamically changing expression.
[0027] The method for achieving dynamic expression changes based on vector paths obtains vector graphics data containing a face, determines an initial shape based on a preset expression state, and calculates deformation parameters based on expression change instructions. A preset interpolator is then used to interpolate the path deformation data to generate intermediate path data. This data is then updated using a property animation framework, ultimately generating a dynamic expression change animation. This allows for flexible adjustment of the interpolator selection based on different scenarios and user input, achieving diverse expression change effects. This allows for real-time adjustment of expression details and degree of change based on different scenarios and user input, improving flexibility.
[0028] It is worth noting that in step S1, the initial path elements of each part of the face are defined by a vector graphics file. For example, the eyes are represented by an elliptical initial path element, and the mouth can be represented by a curved initial path element. For the initial path elements, the key path point coordinate values of each part under different expression states are determined. Specifically, the key path points of each part of the face that need to be deformed can be analyzed according to different expressions (such as happiness, sadness, anger, etc.), and the coordinate values of these key path points under different expression states can be recorded to obtain the corresponding key path point coordinate values. For example, in a happy expression, the two ends of the mouth may be raised, and the eyes may be narrowed into a line. These changed coordinate values are recorded; the key path point coordinate values are associated with the initial path elements and stored. Each key path point coordinate corresponds to a label for the expression of the initial path element. In this way, the key path point coordinate values can be found through the initial path elements and labels.
[0029] The vector graphics file is a VectorDrawable XML file. In this embodiment, the code of the vector graphics file corresponding to the smiley face is as follows:
[0030] <path
[0031] android:name="smile"
[0032] android:pathData="M 100,200 Q 150,250 200,200"
[0033] android:strokeColor="#000"
[0034] android:strokeWidth="5" / >
[0035] The code for the vector graphics file corresponding to the crying face is as follows:
[0036] <path
[0037] android:name="sad"
[0038] android:pathData="M 100,200 Q 150,150 200,200"
[0039] android:strokeColor="#000"
[0040] android:strokeWidth="5" / >
[0041] The code for the vector graphics file corresponding to the lips is as follows:
[0042] <path
[0043] android:name="lips"
[0044] android:pathData="M 100,250 L 200,250"
[0045] android:fillColor="#FF0000"
[0046] android:strokeWidth="5" / >
[0047] Then define the expression changes through the following code
[0048] <animated-vector
[0049] xmlns:android="http: / / schemas.android.com / apk / res / android"
[0050] android:drawable="@drawable / face">
[0051] <target
[0052] android:name="smile"
[0053] android:animation="@animator / smile_to_sad" / >
[0054] <target
[0055] android:name="lips"
[0056] android:animation="@animator / red_to_blue" / >
[0057]
[0058] Preferably, the step of receiving an expression change instruction in step S2 includes: obtaining user input data (such as voice commands or text input) through an external input device; performing semantic analysis on the user input data to determine the corresponding emotional state (for example, if a user inputs the text "I am very happy", the emotional trend is determined to be "positive"); and generating an expression change instruction containing target expression information based on the emotional state. Specifically, performing semantic analysis on the user input data is a prior art and will not be described in detail here. In addition, in another embodiment, the purpose of receiving an expression change instruction can also be achieved through internal program logic (such as changes in the character's emotional state).
[0059] Specifically, in step S2, after receiving the expression change instruction, the coordinate values of the key path points of the path element in the current expression state are obtained; the coordinate values of the key path points of the path element in the target expression state are extracted based on the target expression information; and the displacement and angle between the corresponding key path point coordinate values of the path element in the current expression state and the target expression state are calculated to obtain the deformation parameters. For example, if the expression changes from normal to happy, the angle and distance of the upward movement of the mouth are calculated, and the displacement and angle of the upward movement of the mouth are the deformation parameters.
[0060] Optionally, in step S3, the key path point coordinate values and deformation parameters of the path element are obtained; for the key path point coordinate values of the path element in the current expression state and the key path point coordinate values of the path element in the target expression state, a preset interpolator is used to calculate the intermediate state coordinates of the two key path point coordinate values, and the intermediate state data of the path element is generated according to the intermediate state coordinates.
[0061] In this embodiment, an object or group is used as a control unit to control changes in key path points, color, and transparency of path elements. Control parameters are used as input variables for interpolators, and different preset interpolators are selected to control the corresponding controlled objects, achieving a more realistic simulation effect. Specifically, a single emotion can correspond to multiple interpolators, and an interpolator is randomly selected each time the face changes, making the facial changes more dynamic. The control parameters are user input data such as volume and touch screen force obtained through external input devices. By adjusting the intermediate state coordinates, the intermediate state data can be changed according to the user input.
[0062] The pathData of the VectorDrawable is a string composed of a series of commands (such as M and Q) and coordinate points. During the animation process, the system performs interpolation calculations on the coordinate points in the pathData to generate intermediate state data. The interpolator is used to control the progress change of the animation. Through the interpolator, a non-linear effect of expression change can be achieved, such as the gradual change process from a smiling face to a crying face.
[0063] In this embodiment, the code of the interpolator corresponding to the path animation is as follows:
[0064] <objectAnimator
[0065] xmlns:android="http: / / schemas.android.com / apk / res / android"
[0066] android:propertyName="pathData"
[0067] android:valueFrom="M 100,200 Q 150,250 200,200"
[0068] android:valueTo="M 100,200 Q 150,150 200,200"
[0069] android:duration="1000"
[0070] android:interpolator="@android:anim / accelerate_decelerate_interpolator" / >
[0071] The code of the interpolator corresponding to the color animation is as follows:
[0072] <objectAnimator
[0073] xmlns:android="http: / / schemas.android.com / apk / res / android"
[0074] android:propertyName="fillColor"
[0075] android:valueFrom="#FF0000"<!-- Red -->
[0076] android:valueTo="#0000FF"<!-- Blue -->
[0077] android:duration="1000"
[0078] android:interpolator="@android:anim / accelerate_decelerate_interpolator" / >
[0079] It should be noted that the preset interpolators are divided into linear interpolators and non - linear interpolators according to the interpolator type. In step S3, the emotional state is obtained from the expression change instruction, and the interpolator type related to the target expression is obtained according to the emotional state.
[0080] Preferably, in step S3, if the emotional state indicates that the target expression needs a smooth transition, a linear interpolator is used to calculate the intermediate state coordinates; if the emotional state indicates that the target expression needs a rapid change, a non - linear interpolator is used to calculate the intermediate state coordinates.
[0081] In this embodiment, the emotional state is obtained from the generation process of the expression change instruction. By semantic analysis of the user's text input in the user input data, the emotional state is determined. For example, for the text "I am very happy" input by the user, the emotional trend is "positive". According to the emotional state, the interpolator type related to the target expression is obtained. For example, if the "positive" emotion indicates that the target expression needs a smooth transition, a linear interpolator is used. For calculating the intermediate state coordinates (x(t), y(t)) using a linear interpolator, the calculation formula is: , , where (x1, y1) is the key path point coordinate value of the path element in the current expression state, and (x2, y2) is the key path point coordinate value of the path element in the target expression state.
[0082] It should be noted that in step S3, for the Bezier curve in the path element, the initial coordinates of the control points of the Bezier curve are obtained; according to the input intensity of the user at the current moment (in this embodiment, the input intensity of the user at the current moment is obtained from an external input device, such as the value after normalizing the touch pressure and voice volume) and the deformation parameter at the current moment, the interpolated displacement vector at the current moment is obtained; the dynamic coordinates of the control points are calculated according to the interpolated displacement vector at the current moment as the intermediate state coordinates; the intermediate state data of the Bezier curve corresponding to the path element is generated through the intermediate state coordinates.
[0083] The formula for generating the Bezier curve path as the intermediate state data according to the dynamic coordinates is: , ; where Represents the coordinates of a point on the Bezier curve, Indicates the dynamic coordinates of the control points, represents the Bernstein basis function, n represents the order of the Bezier curve, i represents the index of the control point, x represents the parameter variable, is the binomial coefficient, .
[0084] Optionally, in step S3, the dynamic coordinates of the control point ,in represents the initial coordinates of the control points, Represents the steepness coefficient of the Sigmoid function, which simulates the nonlinear response of muscle movement to control the deformation smoothness. Represents deformation delay time (simulating muscle response delay); represents the displacement after interpolation at the current time t, ,in represents the displacement in the deformation parameter at the current time t, Indicates the expression intensity coefficient, with a value of [0,1], which is determined by the target expression. Indicates the current user input strength. The current user input strength includes the normalized value of touch pressure and the normalized value of voice volume. Touch pressure takes precedence over voice volume. When touch pressure and voice volume exist at the same time, the normalized value of touch pressure is selected as the input strength. Indicates the input sensitivity corresponding to the user's input at the current moment. Represents the damping coefficient, which is used to control motion smoothness. For example, when a user is excited, they may touch the screen harder or raise their voice volume. The intensity of the user's input at that moment is used to adjust the change in expression to better match the user's current mood.
[0085] By comprehensively considering the physical characteristics of facial muscle movement and the user's input intensity at the current moment, they are used as interpolation to adjust the changes in expression, making the expression transition more natural.
[0086] Specifically, in step S4, the step of updating the vector graphics data and displaying dynamically changing expressions includes: obtaining the current frame time of the attribute animation framework; updating the coordinate value of the path element according to the current frame time and the intermediate state data; applying the updated path element to the vector graphics data through the attribute animation framework and rendering and displaying it.
[0087] In this example, Android's property animation framework (e.g., ValueAnimator) is used to control the path deformation process. The calculated deformation parameters are used as the animation target values, and the path data is updated in each frame of the animation. In each frame, the vector graphics data is redrawn based on the updated path data and displayed on the interface, achieving a smooth transition of facial expressions.
[0088] In this solution, since VectorDrawable is used to represent facial graphics, only a single XML file is required, eliminating the need to store numerous images of different expressions. This significantly reduces the application's installation package size and memory usage. The property animation framework enables smooth path deformation, creating natural and fluid expression transitions and enhancing the user experience. The details and degree of expression can be adjusted in real time based on different scenarios and user input, meeting diverse needs.
[0089] The embodiments of the present invention are described in detail above with reference to the accompanying drawings, but the present invention is not limited to the described embodiments. It is apparent to those skilled in the art that various changes, modifications, substitutions, and variations to these embodiments may be made without departing from the principles and spirit of the present invention, and these changes and modifications still fall within the scope of protection of the present invention.
Claims
1. A method for realizing dynamic changes of facial expressions based on vector paths, characterized by: The following steps are involved: S1: Acquire vector graphics data containing various parts of the face, wherein the vector graphics data defines an initial shape through path elements; S2: Obtain user input data through an external input device; perform semantic analysis on the user input data to determine a corresponding emotional state; generate an expression change instruction with target expression information according to the emotional state; the expression change instruction includes the target expression information; After receiving the expression change instruction, obtaining the key path point coordinate values of the path element in the current expression state; Extracting the key path point coordinate values of the path element in the target expression state according to the target expression information; Calculate the displacement and angle between the coordinate values of the key path points corresponding to the current expression state and the target expression state of the path element to obtain the deformation parameters; S3: Generate intermediate state data of the path element using interpolation calculation based on the deformation parameters; obtain initial coordinates of control points of the Bezier curve in the path element; obtain the displacement vector after interpolation at the current moment based on the user's input intensity and the deformation parameters at the current moment; calculate the dynamic coordinates of the control point as intermediate state coordinates based on the interpolated displacement vector at the current moment; and generate intermediate state data of the Bezier curve corresponding to the path element using the intermediate state coordinates; In step S3, the dynamic coordinates of the control points ,in represents the initial coordinates of the control points, represents the steepness coefficient of the Sigmoid function, Indicates deformation delay time; represents the displacement after interpolation at the current time t, ,in represents the displacement in the deformation parameter at the current time t, represents the expression intensity coefficient, Indicates the user's input strength at the current moment. Indicates the input sensitivity corresponding to the user's input at the current moment. represents the damping coefficient; S4: updating the vector graphics data according to the intermediate state data and displaying a dynamically changing expression.
2. A method for realizing dynamic changes in facial expressions based on vector paths according to claim 1, characterized in that: In step S1, the initial path elements of each part of the face are defined by a vector graphics file; for the initial path elements, the key path point coordinate values of each part under different expression states are determined, and the key path point coordinate values are associated with the initial path elements and stored.
3. The method for realizing dynamic changes of facial expressions based on vector paths according to claim 1, wherein: In step S3, the key path point coordinate values and deformation parameters of the path element are obtained; for the key path point coordinate values of the path element in the current expression state and the key path point coordinate values of the path element in the target expression state, a preset interpolator is used to calculate the intermediate state coordinates of the two key path point coordinate values, and the intermediate state data of the path element is generated according to the intermediate state coordinates.
4. The method for realizing dynamic changes of facial expressions based on vector paths according to claim 1, wherein: The preset interpolators are divided into linear interpolators and nonlinear interpolators according to the interpolator type. In step S3, the emotional state is obtained from the expression change instruction, and the interpolator type related to the target expression is obtained according to the emotional state.
5. A method for realizing dynamic changes of facial expressions based on vector paths according to claim 4, characterized in that: In step S3, if the emotional state indicates that the target expression needs a smooth transition, a linear interpolator is used to calculate the intermediate state coordinates; if the emotional state indicates that the target expression needs a rapid change, a nonlinear interpolator is used to calculate the intermediate state coordinates.
6. The method for realizing dynamic changes of facial expressions based on vector paths according to claim 1, wherein: In step S4, the steps of updating the vector graphics data and displaying dynamically changing expressions include: obtaining the current frame time of the attribute animation framework; updating the coordinate value of the path element according to the current frame time and the intermediate state data; applying the updated path element to the vector graphics data through the attribute animation framework and rendering and displaying it.
Citation Information
Patent Citations
Expression generation method and device of virtual character, equipment and storage medium
CN116958340A