Image processing method, device, electronic device and storage medium

By collecting images and gravity directions on ordinary terminal devices, and using spring simulation and animation skinning technology, the problem of weakened realism of dynamic bone movement is solved, and the physical regularity and stability of the movement of special effects objects are achieved.

CN113808236BActive Publication Date: 2024-09-06BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010528831.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-11
Publication Date
2024-09-06
Estimated Expiration
2040-06-11

AI Technical Summary

Technical Problem

When the existing technology realizes the motion reality of dynamic skeletons on ordinary terminal devices, the computational complexity and hardware requirements are high. The simplified method leads to the weakening of the motion reality, and the movement of virtual objects does not comply with the laws of physics.

Method used

By collecting images and gravity directions, the target object is identified, spring simulation is used to correct the position of the bone mass points, and animation skinning is performed based on stiffness and elastic coefficients to ensure that the movement of the special effects object conforms to the natural laws of gravity.

Benefits of technology

It improves the realism and stability of dynamic skeletal movement, reduces computational complexity and hardware requirements, and makes the movement of special effects objects more consistent with physical laws.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113808236B
    Figure CN113808236B
Patent Text Reader

Abstract

The present application discloses an image processing method, device, electronic device and storage medium, which are used to solve the problem of poor realism of dynamic control of special effect objects in related technologies. The method includes: collecting images and gravity directions; identifying target objects in images; using target objects as reference objects to determine the initial positions of the particles of each bone of the special effect object in the image; for the particles of each bone, performing spring simulation on the bones according to the gravity direction and the initial positions of the particles, and correcting the initial positions of the particles to obtain the first positions; and, according to the first positions of the particles of each bone, rendering the special effect object into the image. In the present disclosure, based on the actual acquired gravity direction, a spring simulation is performed on the special effect object, so that the movement of the dynamic bones in the special effect object can be referenced with the gravity direction, and the movement can conform to the natural law of gravity, which can improve the realism of controlling the movement of the special effect object under gravity.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] Most current photography applications support special effects, such as adding headwear or interesting plants to people in the picture.

[0003] In the field of image processing, physical simulation is often used to make virtual objects in the picture more realistic. Physical simulation is one of the technical means in computer animation to obtain animation postures through real-time calculations. By modeling and physically calculating the skeleton, the effect of dynamic skeletons can be obtained. In magic expressions based on human faces, dynamic skeletons have an irreplaceable effect of enhancing the realism of actions.

[0004] The most direct solution to realize dynamic skeleton is to use existing rigid body physics engine (such as PhysX or Bullet), create rigid body for each bone, and constrain the rigid body through joints between bones. After simulation calculation, the spatial position and rotation of the rigid body are synchronously assigned to the corresponding bones to generate real-time posture. However, this method is complex to calculate, and it is difficult to apply and popularize to common terminals with high requirements on equipment hardware. Therefore, in order to be able to be applied to common terminal devices, the modeling process is usually simplified in the relevant technology, and the rigid body is no longer used to simulate the bones, but the particles at the position of the bones are calculated, and the bones are simulated by spring simulation, which not only reduces the difficulty of parameter adjustment, but also reduces the amount of calculation, and the calculation result is also more stable, which is more convenient for specific application. However, the inventor found that the sense of reality of the movement of this simplified method is weakened, and due to the relatively rough calculation, the movement of virtual objects often obviously does not conform to the laws of physics. Summary of the invention

[0005] The purpose of the present application is to provide an image processing method, device, electronic device and storage medium for solving the problem that the sense of reality of motion is weakened and the motion of non-virtual objects often clearly does not conform to the laws of physics due to relatively rough calculations.

[0006] In a first aspect, an embodiment of the present application provides an image processing method, comprising:

[0007] Collect images and gravity direction;

[0008] Identify the target object in the image, and determine the initial position of the mass points of each bone of the special effect object in the image with the target object as a reference; the special effect object is obtained in advance through physical modeling, and the special effect object includes a plurality of bones, and each bone has a corresponding mass point;

[0009] For each bone mass point, a spring simulation is performed on the bone according to the gravity direction and the initial position of the mass point, and the initial position of the mass point is corrected to obtain a first position;

[0010] The special effect object is rendered into the image according to the first position of the mass point of each bone.

[0011] In one embodiment, the step of performing spring simulation on the bone according to the gravity direction and the initial position of the mass point and correcting the initial position of the mass point to obtain the first position includes:

[0012] Determine the displacement between the reference position of the particle and the initial position of the particle, wherein, if the image is the first frame image, the reference position is the position of the particle in the initial state of the special effect object; if the image is not the first frame image, the reference position is the position of the particle in the previous frame image of the image;

[0013] Determine the comprehensive force according to the gravity value in the gravity direction and the preset external force;

[0014] The bone is subjected to spring simulation according to the displacement and the comprehensive force, and the initial position of the mass point is corrected to obtain the first position.

[0015] In one embodiment, the step of performing spring simulation on the bone according to the displacement and the comprehensive force and correcting the initial position of the mass point to obtain the first position includes:

[0016] The first position is obtained according to the following formula:

[0017] P1=V*(a-damping)*t+F / (b*M)*(a–force_damping)*t 2

[0018] Among them, V = P – P'; F = F_ext + G;

[0019] Among them, P1 represents the first position, V represents the displacement, P represents the initial position of the particle, P' represents the reference position of the particle, a and b are constants, M represents the preset mass of the particle, F_ext represents the comprehensive force, G represents the gravity, damping represents spring damping, force_damping represents the attenuation coefficient of the force, and t represents the playback time of a frame of the video.

[0020] In one embodiment, rendering the special effect object into the image according to the first position of the mass point of each bone includes:

[0021] Determine the length between the parent node position of the particle and the first position; wherein the parent node is connected to at least one child node, and the position of each child node changes with the change of the parent node position; the particle belongs to a node in the at least one child node;

[0022] When the length is greater than the set length of the bone corresponding to the mass point, the first position is corrected to a second position whose length from the parent node position of the mass point is equal to the set length according to a preset stiffness coefficient;

[0023] The special effect object is rendered into the image after animation skinning based on the second position of the mass point of each bone.

[0024] In one embodiment, when the length is greater than the set length of the bone corresponding to the mass point, the first position is corrected according to a preset stiffness coefficient to obtain a second position, including:

[0025] The first position is corrected according to the following formula to obtain the second position:

[0026] P2=D*(len(D)-max_len) / len(D);

[0027] Where D = P start –P1;max_len=rest_len*(1-stiffness)*c;

[0028] P2 represents the second position, P start represents the parent node position of the particle, P1 represents the first position, len(D) represents the length of the D vector, and rest_len represents the distance from the particle to P when initializing the special effect object. start The length of , stiffness represents the preset stiffness coefficient, and c represents a constant.

[0029] In one embodiment, when the length is less than a set length of the bone corresponding to the mass point, the method further comprises:

[0030] According to a preset elastic coefficient, the first position is corrected to obtain the second position.

[0031] In one embodiment, the step of correcting the first position to obtain the second position according to a preset elastic coefficient includes:

[0032] The first position is corrected according to the following formula to obtain the second position:

[0033] P2=(P start –P1)*elastic;

[0034] P2 represents the second position, elastic represents the preset elastic coefficient, P start represents the parent node position of the particle, and P1 represents the first position.

[0035] In one embodiment, the method further comprises: taking the second position of the mass point of each bone as a reference, and before rendering the special effect object into the image after animation skinning is performed:

[0036] When the particle collides with the target object, obtaining the motion range of the special effect object constructed with the coordinate system of the target object; when the second position is not within the motion range, correcting the second position to be within the motion range; and / or,

[0037] Taking the particle and the target object as the center points of the sphere, construct the sphere of the particle and the target object respectively; when the particle is inside the sphere of the target object, determine the straight line formed by the center of the sphere of the particle and the center of the sphere of the target object; move the particle out of the sphere of the target object along the straight line and in a direction away from the target object.

[0038] In one embodiment, the motion range is a preset motion plane of the special effect object in the coordinate system of the target object; then correcting the second position to be within the motion range includes:

[0039] The second position is corrected to the motion range according to the following formula:

[0040] P 21 =P2-N*dis;

[0041] Where, dis = dot(N,P2)–d_plane; d_plane = dot(N,P start );

[0042] Among them, P 21 represents the corrected second position, P2 represents the second position, N is the normal vector of the plane, P start Indicates the parent node position of the particle.

[0043] In one embodiment, after correcting the second position to within the motion range and before rendering the special effect object into the image after animation skinning based on the second position of the mass point of each bone, the method further includes:

[0044] When the length from the particle to the parent node position of the particle is greater than the set length, the corrected second position is corrected again to obtain the final position of the second position so that the length from the final position to the parent node position of the particle is equal to the set length.

[0045] In one embodiment, the step of correcting the corrected second position again to obtain a final position of the second position includes:

[0046] The final position of the second position is obtained according to the following formula:

[0047] P 22 =D2*(len(D2)–rest_len) / len(D2)

[0048] Where D2 = P start –P 21

[0049] Among them, P 22 represents the final position of the second position, P 21 represents the corrected second position, len(D2) represents the length of the D2 vector, P start represents the parent node position of the particle, rest_len represents the distance from the particle to P when initializing the special effect object. start Length.

[0050] In a second aspect, an embodiment of the present application further provides an image processing device, including:

[0051] An acquisition module is configured to acquire images and gravity directions;

[0052] a target object recognition module configured to recognize a target object in the image, and determine the initial position of the mass points of each bone of the special effect object in the image with the target object as a reference; the special effect object is obtained in advance through physical modeling, and the special effect object includes a plurality of bones, each bone having a corresponding mass point;

[0053] a position processing module, configured to perform a spring simulation on the bone according to the gravity direction and the initial position of the mass point, and to correct the initial position of the mass point to obtain a first position;

[0054] The rendering module is configured to render the special effect object into the image according to the first position of the particle points of each bone.

[0055] In one embodiment, the position processing module includes:

[0056] a displacement determination unit, configured to determine the displacement between the reference position of the mass point and the initial position of the mass point, wherein if the image is a first frame image, the reference position is the position of the mass point in the initial state of the special effect object; if the image is not the first frame image, the reference position is the position of the mass point in the previous frame image of the image;

[0057] an external force determination unit, configured to determine a comprehensive force according to the gravity value in the gravity direction and a preset external force;

[0058] The first position correction unit is configured to perform a spring simulation on the bone according to the displacement and the comprehensive force, and correct the initial position of the mass point to obtain a first position.

[0059] In one embodiment, the first position correction unit is configured to obtain the first position according to the following formula:

[0060] P1=V*(a-damping)*t+F / (b*M)*(a–force_damping)*t 2

[0061] Among them, V = P – P'; F = F_ext + G;

[0062] Among them, P1 represents the first position, V represents the displacement, P represents the initial position of the particle, P' represents the reference position of the particle, a and b are constants, M represents the preset mass of the particle, F_ext represents the sum of preset virtual external forces, G represents the gravity, damping represents spring damping, force_damping represents the attenuation coefficient of the force, and t represents the playback time of a frame of the video.

[0063] In one embodiment, the rendering module includes:

[0064] a length determination unit, configured to determine the length between the parent node position of the mass point and the first position; wherein the parent node is connected to at least one child node, and the position of each child node changes as the position of the parent node changes; and the mass point belongs to a node in the at least one child node;

[0065] a length correction unit configured to correct the first position to a second position whose length with respect to a parent node position of the mass point is equal to the set length according to a preset stiffness coefficient when the length is greater than a set length of a bone corresponding to the mass point;

[0066] The rendering unit is configured to perform animation skinning based on the second position of the mass point of each bone and then render the special effect object into the image.

[0067] In one embodiment, the length correction unit is configured to correct the first position according to the following formula to obtain the second position:

[0068] P2=D*(len(D)-max_len) / len(D);

[0069] Where D = P start –P1;max_len=rest_len*(1-stiffness)*c;

[0070] P2 represents the second position, P start represents the parent node position of the particle, P1 represents the first position, len(D) represents the length of the D vector, and rest_len represents the distance from the particle to P when initializing the special effect object. start The length of , stiffness represents the preset stiffness coefficient, and c represents a constant.

[0071] In one embodiment, when the length is less than a set length of the bone corresponding to the mass point, the length correction unit is further configured to correct the first position according to a preset elastic coefficient to obtain the second position.

[0072] In one embodiment, the length correction unit is configured to correct the first position according to the following formula to obtain the second position:

[0073] P2=(P start –P1)*elastic;

[0074] P2 represents the second position, elastic represents the preset elastic coefficient, P start represents the parent node position of the particle, and P1 represents the first position.

[0075] In one embodiment, the apparatus further comprises:

[0076] a motion limiting module, configured to execute, when the particle collides with the target object, obtaining the motion range of the special effect object constructed with the coordinate system of the target object; and when the second position is not within the motion range, correcting the second position to within the motion range: and / or,

[0077] Taking the particle and the target object as the center points of the sphere, construct the sphere of the particle and the target object respectively; when the particle is inside the sphere of the target object, determine the straight line formed by the center of the sphere of the particle and the center of the sphere of the target object; move the particle out of the sphere of the target object along the straight line and in a direction away from the target object.

[0078] In one embodiment, the motion range is a preset motion plane of the special effect object in the coordinate system of the target object; the motion limiting module is configured to correct the second position to within the motion range according to the following formula:

[0079] P 21 =P2-N*dis;

[0080] Where, dis = dot(N,P2)–d_plane; d_plane = dot(N,P start );

[0081] Among them, P 21 represents the corrected second position, P2 represents the second position, N is the normal vector of the plane, P start Indicates the parent node position of the particle.

[0082] In one embodiment, after correcting the second position to within the motion range and before rendering the special effect object into the image after animation skinning based on the second position of the mass point of each bone, the device further includes:

[0083] The length revision module is configured to execute, when the length from the particle to the parent node position of the particle is greater than the set length, to correct the corrected second position again to obtain the final position of the second position so that the length from the final position to the parent node position of the particle is equal to the set length.

[0084] In one embodiment, the length revision module is configured to execute:

[0085] The final position of the second position is obtained according to the following formula:

[0086] P 22 =D2*(len(D2)–rest_len) / len(D2)

[0087] Where D2 = P start –P 21

[0088] Among them, P 22 represents the final position of the second position, P 21 represents the corrected second position, len(D2) represents the length of the D2 vector, P start represents the parent node position of the particle, rest_len represents the distance from the particle to P when initializing the special effect object. start Length.

[0089] In the third aspect, another embodiment of the present application also provides an electronic device, comprising at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any image processing method provided in the embodiment of the present application.

[0090] In a fourth aspect, another embodiment of the present application further provides a non-temporary computer-readable storage medium, wherein, when the instructions in the storage medium are executed by the processor of the electronic device, the electronic device executes any image processing method in the embodiments of the present application.

[0091] In the embodiment of the present application, a spring simulation is performed on the special effects object based on the actually obtained direction of gravity, so that the movement of the dynamic bones in the special effects object can be referenced in the opposite direction of gravity, the movement can conform to the natural law of gravity, and the realism of controlling the movement of the special effects object under gravity can be improved.

[0092] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0093] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. Obviously, the drawings introduced below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0094] Figure 1 is a schematic diagram of an application environment according to an embodiment of the present application;

[0095] Figure 2 A schematic diagram of an image processing flow according to an embodiment of the present application;

[0096] Figure 3-Figure 5 A schematic diagram of the effect of image processing according to an embodiment of the present application;

[0097] Figure 6 A schematic diagram of the effect of moving the collision body after the collision according to an embodiment of the present application;

[0098] Figure 7 is a schematic diagram of another image processing flow according to an embodiment of the present application;

[0099] Figure 8 is a schematic diagram of an image processing device according to an embodiment of the present application;

[0100] Fig. 9 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0101] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0102] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0103] As mentioned above, in response to the problem mentioned in the background technology that simply calculating through the particles at the bone positions and simulating the bones with springs weakens the realism of the movement, and the movement of the virtual objects often obviously does not conform to the laws of physics due to the relatively rough calculations, the inventors have proposed a solution to enhance the realism of the movement.

[0104] In order to make the purpose, technical solution and advantages of the embodiment of the present application clearer, the technical solution in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. It should be understood that in the following description, the "magic expression" is used as an example to describe the recommended solution of the present application in detail.

[0105] Figure 1 It is a schematic diagram of an application environment according to an embodiment of the present application.

[0106] like Figure 1As shown, the application environment may include, for example, at least one server 20 and a plurality of terminal devices 30. Among them, each terminal device 30 may be used for any suitable electronic device for network access, including but not limited to a computer, a laptop, a smart phone, a tablet computer or other types of terminals. The server 20 is any server that can be accessed through the network and provides information required for interactive services. The terminal device 30 can send and receive information with the server 20 via the network 40, for example, downloading a magic expression package from the server 20 for special effects processing of the collected images. The server 20 can obtain and provide the content required by the terminal device 30 by accessing the database 50, such as shooting application software, multimedia resources, etc. The terminal devices (for example, between 30_1 and 30_2 or 30_N) can also communicate with each other via the network 40. The network 40 can be a network for information transmission in a broad sense, and may include one or more communication networks, such as a wireless communication network, the Internet, a private area network, a local area network, a metropolitan area network, a wide area network or a cellular data network.

[0107] In the subsequent description, only a single server or terminal device is described in detail, but it should be understood by those skilled in the art that the single server 20, terminal device 30 and database 50 shown are intended to indicate that the technical solution of the present application involves the operation of the terminal device, server and database. The single terminal device and the single server and database are described in detail at least for the convenience of explanation, and do not imply any restrictions on the type or location of the terminal device and server. It should be noted that if additional modules are added to the illustrated environment or individual modules are removed therefrom, the underlying concepts of the example embodiments of the present application will not be changed. In addition, although a bidirectional arrow from the database 50 to the server 20 is shown in the figure for the convenience of explanation, it should be understood by those skilled in the art that the sending and receiving of the above data can also be achieved through the network 40.

[0108] In the disclosed embodiment, a particle modeling method is adopted. Each bone of the special effect object is assumed to have a corresponding particle with mass. The connection relationship of the particles is the same as that of the bones in the skeleton. The skeleton does not have scaling. In the calculation of each frame of the image, the positions of the particles and bones are always kept consistent, and the rotation is kept consistent.

[0109] The process of adding special effects to videos may include the following aspects:

[0110] 1. Initialize the special effect object.

[0111] Taking the shooting of short videos by a terminal device as an example, after the terminal device starts the shooting software according to the user's operation, it waits for further instructions from the user. For example, after receiving the operation instruction of the image acquisition interface, it enters the image acquisition interface and determines the special effect object to be used based on the special effect selection instruction. After determining the special effect object, the special effect object can be initialized. For example, the initialization posture of the bone is completely assigned to the mass point. The initialization formula can be shown as formula (1):

[0112] M c =M bone (1)

[0113] In formula (1), M c The matrix representing the position and rotation of the particle; M bone Represents the matrix of the corresponding bone. The matrix of each bone mass point is not allowed to include scaling information, that is, the scaling value can be 1.0 by default.

[0114] For example, the 4*4 matrix of the mass point corresponding to a bone can be expressed as:

[0115] First row: a 00 ,a 01, a 02, a 03

[0116] Second row: a 10 ,a 11 ,a 12, a 13

[0117] The third row: a 20 ,a 21 ,a 22 ,a 23

[0118] Fourth row: a 30 ,a 31 ,a 32 ,a 33

[0119] The last element of the four elements in the last row (ie, the fourth row) is scaling information, which can be set to 1, and the first three are position information. The first to third rows are used to represent rotation and translation.

[0120] Of course, the initialization of the special effect object can be performed after selecting the special effect object, or can be performed after downloading the special effect object and before selecting the special effect object. Of course, as long as the initialization is completed before processing the first frame of image, the present disclosure does not limit this.

[0121] 2. Introduce special effects optimization of gravity

[0122] like Figure 2As shown, after determining the special effect object and starting to collect video, in step 201, collect images and gravity direction. The gravity direction can be obtained in real time by the gravity sensor of the terminal device. Then in step 202, identify the target object in the image; use the target object as a reference to determine the initial position of the mass points of each bone of the special effect object in the image; the special effect object is obtained in advance through physical modeling, and the special effect object includes multiple bones, each bone has a corresponding mass point. For example, if a sapling is added to the head of a person, the sapling is a special effect object, and the sapling can shake with the shaking of the head. Therefore, the head is the target object. Then, in step 203, for the mass points of each bone, the bone is simulated by spring simulation according to the gravity direction and the initial position of the mass point, and the initial position of the mass point is corrected to obtain the first position. Then, in step 204, according to the first position of the mass points of each bone, the special effect object is rendered into the image.

[0123] For example, Figure 3 As described above, add a hairpin flower special effect to the character's head. When the actual gravity direction is parallel to the long side of the screen, the bead curtain in the hairpin flower special effect droops along the gravity direction. When the head shakes, the direction of the head is no longer parallel to the long side of the screen, such as Figure 4 As shown, the bead curtain with the hairpin flower effect droops along the actual gravity direction. That is, it is consistent with the gravity direction collected by the gravity sensor. In order to be able to compare and immediately, Figure 5 As shown, a schematic diagram of the bead curtain drooping along the direction of gravity closely following the rotation of the face in the related art is given. Figure 5 The middle bead curtain only rotates with the rotation of the head and is not affected by gravity, which is not consistent with the actual situation.

[0124] Therefore, in the embodiment of the present application, the actual direction of gravity is collected, and the special effects object can be adjusted accordingly according to the actual reverse direction of gravity to keep it consistent with the direction of gravity, thereby solving the effect of distortion of dynamic skeletal movements under the effect of gravity.

[0125] In one embodiment, in order to make the dynamic movement of the special effect object appear more natural and realistic, the initial position is corrected according to the gravity direction to obtain the first position, which can be implemented as follows:

[0126] Step A1: determining the displacement between the reference position of the particle and the initial position of the particle, wherein if the image is the first frame image, the reference position is the position of the particle in the initial state of the special effect object; if the image is not the first frame image, the reference position is the position of the particle in the previous frame image of the image;

[0127] Step A2: determining a comprehensive force according to the gravity value in the gravity direction and a preset external force;

[0128] Step A2: performing spring simulation on the bone according to the displacement and the comprehensive force, and correcting the initial position of the mass point to obtain the first position.

[0129] That is, the first frame image uses the position of the bone obtained by initializing the special effects object as the reference position, and the middle frame image uses the position of the same bone in the previous frame image as the reference position. This makes it easy to determine the position of the next state based on the previous state, making the action of the special effects object continuous, thereby making the movement of the special effects object more realistic.

[0130] In another embodiment, in order to simplify the calculation and reduce the calculation complexity, the bone is subjected to spring simulation according to the displacement and the comprehensive force, and the initial position of the mass point is corrected to obtain the first position, which can be implemented as obtaining the first position according to the following formula (2):

[0131] P1=V*(a-damping)*t+F / (b*M)*(a–force_damping)*t 2 (2)

[0132] Among them, V = P – P'; F = F_ext + G;

[0133] Wherein, in formula (2), P1 represents the first position, V represents the displacement, P represents the initial position of the mass point, P' represents the reference position of the mass point, a and b are constants (for example, both can be 1), M represents the preset mass of the mass point, F_ext represents the comprehensive force, G represents the gravity, damping represents the spring damping, force_damping represents the attenuation coefficient of the force, and t represents the playback time of one frame of the video. For example, if the frame rate of a video is 30 / second, then the playback time of one frame is (1 / 30) seconds.

[0134] In formula (2), an external force F_ext is introduced. The external force can be wind force or resistance, or the sum of external forces, such as the combined force of wind force and resistance. This allows the dynamic graph to refer to more external forces for dynamic movement without appearing rigid. The spring simulation through the spring damping of the spring makes the movement more in line with the laws of nature. The introduction of gravity makes physics more able to meet the effect of gravity. At the same time, through the attenuation coefficient of the force, without introducing complex parameters and calculation methods, the calculation does not need to be overly complicated, and the requirements for hardware performance for calculation processing do not need to be so strict. Therefore, gravity can be introduced in a simple way to ensure that the movement effect of the skeleton of the special effect object under the action of gravity is consistent with the macroscopic visual effect.

[0135] 3. Rigidity constraints of the introduced spring

[0136] In one embodiment, in order to make the dynamic motion effect of the special effect object more realistic and the computational complexity as applicable as possible to devices of various performances, a simplified rigid constraint condition is proposed in the embodiment of the present disclosure.

[0137] For example, in one embodiment, the dynamic skeleton display effect can be optimized by using a simplified method to ensure that the large outline is as undistorted as possible. As described above, according to the first position of the mass point of each bone, the special effect object is rendered into the image, which can be executed as follows:

[0138] Step B1: determining the length between the parent node position of the particle and the first position;

[0139] The parent node refers to the node that drives the bone to move, that is, the bone mass will move with the movement of the parent node. Each parent node is connected to at least one child node, and the position of each child node changes with the change of the parent node position; the mass point belongs to a node in the at least one child node.

[0140] Step B2: when the length is greater than the set length of the bone corresponding to the mass point, the first position is corrected to a second position whose length from the parent node position of the mass point is equal to the set length according to a preset stiffness coefficient;

[0141] Step B3: Based on the second position of the mass point of each bone, the special effect object is rendered into the image after animation skinning.

[0142] That is, the dynamic effect of the bone is corrected by comparing the original bone length before and after the special effect adjustment. Here, the original length of the bone is not distorted as much as possible. Therefore, after dynamically adjusting the position of each bone, the bone length is appropriately kept consistent with the original length as much as possible.

[0143] In another embodiment, a simple calculation method is to correct the first position according to the following formula (3) to obtain the second position:

[0144] P2=D*(len(D)-max_len) / len(D), if len(D)>max_len; (3)

[0145] Where D = P start –P1;max_len=rest_len*(1-stiffness)*c;

[0146] In formula (3), P2 represents the second position, P startrepresents the parent node position of the particle, P1 represents the first position, len(D) represents the length of the D vector, and rest_len represents the distance from the particle to P when initializing the special effect object. start The length of , stiffness represents the preset stiffness coefficient, and c represents a constant (for example, c is 2).

[0147] Formula (3) can correct the bone length only through simple basic operations, with small amount of calculation and can be applied to terminal devices with different processing performances.

[0148] On the other hand, in another embodiment, when the length is less than the set length of the bone corresponding to the particle, the first position can be further corrected to obtain the second position based on the rigid constraint condition and a preset elastic coefficient, so that the movement of the dynamic skeleton is more realistic.

[0149] Among them, a simple implementation method realizes repair according to a preset elastic coefficient, which can be performed with reference to the following formula (4), including:

[0150] P2=(P start –P1)*elastic; (4)

[0151] P2 represents the second position, elastic represents the preset elastic coefficient, P start represents the parent node position of the particle, and P1 represents the first position.

[0152] 4. About the handling of collision

[0153] In order to make the dynamic skeletal movement of the special effects object more in line with the laws of natural movement, in the embodiment of the present disclosure, before rendering the special effects object into the image after animation skinning based on the second position of the particle of each bone, if a collision occurs, a simpler constraint method is introduced for the handling of the collision. For example, it can be implemented as a simple limitation on the range of motion or a simple translation operation so that the movement direction of the dynamic bones after the collision occurs in a direction that conforms to the laws of nature, without the need to determine the movement law according to the complex conditions of the real environment such as the actual collision size and all the related forces in the environment. It can be implemented as one of the following two methods or a combination:

[0154] Method 1: When the particle collides with the target object, the motion range of the special effect object constructed with the coordinate system of the target object is obtained; when the second position is not within the motion range, the second position is corrected to be within the motion range.

[0155] The setting of the motion range is based on the actual requirements of the bones of the special effect object, and this application does not limit this. It should be noted that the motion range can be a three-dimensional space, or a motion plane that limits the special effect object relative to the target object (such as the human head) as a reference. For example, Figure 3-Figure 4 The front of the hairpin flower is parallel to the front of the human face, that is, the front of the hairpin flower is limited to the plane where the front of the human face is located. In the present disclosure, the movement range can be set to a rough range, which is used to limit the special effect object not to exceed a certain range, and there is no need to build a complex model based on a complex environment to calculate the real movement situation.

[0156] To simplify the calculation complexity, in the embodiment of the present disclosure, the second position may be corrected to within the motion range according to the following formula (5):

[0157] P 21 =P2-N*dis; (5)

[0158] Where, dis = dot(N,P2)–d_plane; d_plane = dot(N,P start );

[0159] In formula (5), P 21 represents the corrected second position, P2 represents the second position, N is the normal vector of the plane, P start Indicates the parent node position of the particle.

[0160] Method 2 may include the following steps:

[0161] Step C1: Taking the mass point and the target object as the center points of the spheres, constructing the spheres of the mass point and the target object respectively.

[0162] Step C2: When the particle is inside the sphere of the target object, determine the straight line formed by the center of the sphere of the particle and the center of the sphere of the target object.

[0163] Step C3: Move the particle along the straight line and out of the sphere of the target object in a direction away from the target object.

[0164] For example, Figure 6 As shown in the figure, a sphere is constructed with the mass point of the target object as the center, and another sphere is constructed with the mass point of the bone of the special effect object as the center. When the bone in the special effect object collides with the target object, the bone of the special effect object moves in the direction of the reaction force given by the target object, that is, along the straight line formed by the two sphere centers, moving away from the target object.

[0165] The fusion of method 1 and method 2 means that the movement of the special effect object meets the constraints of method 1 and method 2, that is, the sphere of the special effect object is moved along the center of the sphere toward the reaction force, and it moves within a limited range of motion. The motion constraints use the movement direction and range constraints, and there is no need to simulate every detail of the motion process, so the post-collision processing can be relatively simple.

[0166] Similarly, as described above, after the position information is corrected, there is still a possibility of abnormal bone deformation, such as bone length growth. Therefore, in the embodiment of the present disclosure, after the second position is corrected to the range of motion, and before the special effects object is rendered into the image after animation skinning based on the second position of the particle of each bone, the bone position can be further corrected. For example, when the length from the particle to the parent node position of the particle is greater than the set length, the corrected second position is corrected again to obtain the final position of the second position, so that the length from the final position to the parent node position of the particle is equal to the set length.

[0167] A simple method can be implemented as obtaining the final position of the second position according to the following formula (6):

[0168] P 22 =D2*(len(D2)–rest_len) / len(D2) (6)

[0169] Where D2 = P start –P 21

[0170] Among them, P 22 represents the final position of the second position, P 21 represents the corrected second position, len(D2) represents the length of the D2 vector, P start represents the parent node position of the particle, rest_len represents the distance from the particle to P when initializing the special effect object. start Length.

[0171] To facilitate the understanding of the system, the image processing method provided by the embodiment of the present disclosure is described below in conjunction with Figure 7 To illustrate this, the following steps are included:

[0172] Step 701: Collect images and gravity direction.

[0173] Step 702: Identify the target object in the image; and, using the target object as a reference, determine the initial position of the particle points of each bone of the special effect object in the image.

[0174] Step 703: For each bone mass point, determine the displacement between the reference position of the mass point and the initial position of the mass point.

[0175] Step 704: Determine the comprehensive force according to the gravity value in the gravity direction and the preset external force, perform spring simulation on the bone according to the displacement and the comprehensive force, and correct the initial position of the particle to obtain the first position.

[0176] Step 705: Determine the length between the parent node position of the particle and the first position.

[0177] Step 706: When the length is greater than the set length of the bone corresponding to the mass point, the first position is corrected according to a preset stiffness coefficient to obtain a second position.

[0178] Step 707: When the length is less than the set length of the bone corresponding to the mass point, the first position is corrected according to a preset elastic coefficient to obtain the second position.

[0179] The second position indicates that the length between the particle and its parent node position is equal to the set length.

[0180] Step 708: When the particle collides with the target object, the motion range of the special effect object constructed with the coordinate system of the target object is obtained; when the second position is not within the motion range, the second position is corrected to be within the motion range.

[0181] Step 709: When the length from the particle to the parent node position of the particle is greater than the set length, the corrected second position is corrected again to obtain the final position of the second position.

[0182] Step 710: Based on the final position of the second position of each bone mass point, perform animation skinning and render the special effect object into the image.

[0183] Based on the same concept, an embodiment of the present application also proposes an image processing device.

[0184] Figure 8 Schematic diagram of an image processing device according to an embodiment of the present application.

[0185] like Figure 8 As shown, the recommendation device 800 may include:

[0186] The acquisition module 801 is configured to acquire images and gravity direction;

[0187] The target object recognition module 802 is configured to recognize the target object in the image, and determine the initial position of the mass points of each bone of the special effect object in the image with the target object as a reference; the special effect object is obtained in advance through physical modeling, and the special effect object includes a plurality of bones, and each bone has a corresponding mass point;

[0188] A position processing module 803 is configured to perform a spring simulation on the bone according to the gravity direction and the initial position of the mass point, and correct the initial position of the mass point to obtain a first position;

[0189] The rendering module 804 is configured to render the special effect object into the image according to the first position of the particle of each bone.

[0190] In one embodiment, the position processing module includes:

[0191] a displacement determination unit, configured to determine the displacement between the reference position of the mass point and the initial position of the mass point, wherein if the image is a first frame image, the reference position is the position of the mass point in the initial state of the special effect object; if the image is not the first frame image, the reference position is the position of the mass point in the previous frame image of the image;

[0192] an external force determination unit, configured to determine a comprehensive force according to the gravity value in the gravity direction and a preset external force;

[0193] The first position correction unit is configured to perform a spring simulation on the bone according to the displacement and the comprehensive force, and correct the initial position of the mass point to obtain a first position.

[0194] In one embodiment, the first position correction unit is configured to obtain the first position according to the following formula:

[0195] P1=V*(a-damping)*t+F / (b*M)*(a–force_damping)*t 2

[0196] Among them, V = P – P'; F = F_ext + G;

[0197] Among them, P1 represents the first position, V represents the displacement, P represents the initial position of the particle, P' represents the reference position of the particle, a and b are constants, M represents the preset mass of the particle, F_ext represents the sum of preset virtual external forces, G represents the gravity, damping represents spring damping, force_damping represents the attenuation coefficient of the force, and t represents the playback time of a frame of the video.

[0198] In one embodiment, the rendering module includes:

[0199] a length determination unit, configured to determine the length between the parent node position of the mass point and the first position; wherein the parent node is connected to at least one child node, and the position of each child node changes as the position of the parent node changes; and the mass point belongs to a node in the at least one child node;

[0200] a length correction unit configured to correct the first position to a second position whose length with respect to a parent node position of the mass point is equal to the set length according to a preset stiffness coefficient when the length is greater than a set length of a bone corresponding to the mass point;

[0201] The rendering unit is configured to perform animation skinning based on the second position of the mass point of each bone and then render the special effect object into the image.

[0202] In one embodiment, the length correction unit is configured to correct the first position according to the following formula to obtain the second position:

[0203] P2=D*(len(D)-max_len) / len(D);

[0204] Where D = P start –P1;max_len=rest_len*(1-stiffness)*c;

[0205] P2 represents the second position, P start represents the parent node position of the particle, P1 represents the first position, len(D) represents the length of the D vector, and rest_len represents the distance from the particle to P when initializing the special effect object. start The length of , stiffness represents the preset stiffness coefficient, and c represents a constant.

[0206] In one embodiment, when the length is less than a set length of the bone corresponding to the mass point, the length correction unit is further configured to correct the first position according to a preset elastic coefficient to obtain the second position.

[0207] In one embodiment, the length correction unit is configured to correct the first position according to the following formula to obtain the second position:

[0208] P2=(P start –P1)*elastic;

[0209] P2 represents the second position, elastic represents the preset elastic coefficient, P start represents the parent node position of the particle, and P1 represents the first position.

[0210] In one embodiment, the apparatus further comprises:

[0211] a motion limiting module, configured to execute, when the particle collides with the target object, obtaining the motion range of the special effect object constructed with the coordinate system of the target object; and when the second position is not within the motion range, correcting the second position to within the motion range: and / or,

[0212] Taking the particle and the target object as the center points of the sphere, construct the sphere of the particle and the target object respectively; when the particle is inside the sphere of the target object, determine the straight line formed by the center of the sphere of the particle and the center of the sphere of the target object; move the particle out of the sphere of the target object along the straight line and in a direction away from the target object.

[0213] In one embodiment, the motion range is a preset motion plane of the special effect object in the coordinate system of the target object; the motion limiting module is configured to correct the second position to within the motion range according to the following formula:

[0214] P 21 =P2-N*dis;

[0215] Where, dis = dot(N,P2)–d_plane; d_plane = dot(N,P start );

[0216] Among them, P 21 represents the corrected second position, P2 represents the second position, N is the normal vector of the plane, P start Indicates the parent node position of the particle.

[0217] In one embodiment, after correcting the second position to within the motion range and before rendering the special effect object into the image after animation skinning based on the second position of the mass point of each bone, the device further includes:

[0218] The length revision module is configured to execute, when the length from the particle to the parent node position of the particle is greater than the set length, to correct the corrected second position again to obtain the final position of the second position so that the length from the final position to the parent node position of the particle is equal to the set length.

[0219] In one embodiment, the length revision module is configured to execute:

[0220] The final position of the second position is obtained according to the following formula:

[0221] P 22 =D2*(len(D2)–rest_len) / len(D2)

[0222] Where D2 = P start –P 21

[0223] Among them, P 22 represents the final position of the second position, P 21 represents the corrected second position, len(D2) represents the length of the D2 vector, P start represents the parent node position of the particle, rest_len represents the distance from the particle to P when initializing the special effect object. start Length.

[0224] The implementation and beneficial effects of each operation in the image processing device can be found in the description of the method above, which will not be repeated here.

[0225] After introducing an image processing method and apparatus according to an exemplary embodiment of the present application, next, an electronic device according to another exemplary embodiment of the present application is introduced.

[0226] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.

[0227] In some possible implementations, the electronic device according to the present application may include at least one processor and at least one memory. The memory stores program code, and when the program code is executed by the processor, the processor executes the steps of the image processing method according to various exemplary implementations of the present application described above in this specification. For example, the processor may execute the following steps: Figure 2 or Figure 7 Steps shown.

[0228] Refer to the following Fig. 9 The electronic device 130 according to this embodiment of the present application is described. Fig. 9 The electronic device 130 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0229] like Fig. 9 As shown, the electronic device 130 is in the form of a general electronic device. The components of the electronic device 130 may include but are not limited to: the at least one processor 131, the at least one memory 132, and a bus 133 connecting different system components (including the memory 132 and the processor 131).

[0230] Bus 133 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a processor, or a local bus using any of a variety of bus architectures.

[0231] The memory 132 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 1321 and / or a cache memory 1322 , and may further include a read-only memory (ROM) 1323 .

[0232] The memory 132 may also include a program / utility 1325 having a set (at least one) of program modules 1324, such program modules 1324 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0233] The electronic device 130 may also communicate with one or more external devices 134 (e.g., keyboards, pointing devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 130, and / or communicate with any device that enables the electronic device 130 to communicate with one or more other electronic devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 135. Furthermore, the electronic device 130 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 136. As shown, the network adapter 136 communicates with other modules for the electronic device 130 via a bus 133. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 130, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0234] In some possible implementations, various aspects of an image processing method provided by the present application may also be implemented in the form of a program product, which includes a program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of an image processing method according to various exemplary implementations of the present application described above in this specification. For example, the computer device may execute the following steps: Figure 2 or Figure 7 Steps shown.

[0235] The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0236] The program product for image processing of the embodiment of the present application can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on an electronic device. However, the program product of the present application is not limited to this. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.

[0237] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein readable program code is carried. Such propagated data signals may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium other than a readable storage medium, which may transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0238] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0239] The program code for performing the operation of the present application can be written in any combination of one or more programming languages, including object-oriented programming languages, such as Java, C++, etc., and also conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user electronic device, partially on the user device, as an independent software package, partially on the user electronic device and partially on the remote electronic device, or completely on the remote electronic device or server. In the case of a remote electronic device, the remote electronic device can be connected to the user electronic device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external electronic device (for example, using an Internet service provider to connect through the Internet).

[0240] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.

[0241] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0242] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0243] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0244] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0245] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0246] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0247] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. An image processing method, characterized in that: The method comprises: Collect images and gravity direction; Identify the target object in the image, and determine the initial position of the mass points of each bone of the special effect object in the image with the target object as a reference; the special effect object is obtained in advance through physical modeling, and the special effect object includes a plurality of bones, and each bone has a corresponding mass point; For each bone mass point, a spring simulation is performed on the bone according to the gravity direction and the initial position of the mass point, and the initial position of the mass point is corrected to obtain a first position; Rendering the special effect object into the image according to the first position of the mass point of each bone; The step of performing spring simulation on the bone according to the gravity direction and the initial position of the mass point and correcting the initial position of the mass point to obtain the first position includes: Determine the displacement between the reference position of the particle and the initial position of the particle, wherein, if the image is the first frame image, the reference position is the position of the particle in the initial state of the special effect object; if the image is not the first frame image, the reference position is the position of the particle in the previous frame image of the image; Determine the comprehensive force according to the gravity value in the gravity direction and the preset external force; Performing spring simulation on the bone according to the displacement and the comprehensive force, and correcting the initial position of the mass point to obtain a first position; The rendering of the special effect object into the image according to the first position of the mass point of each bone comprises: Determine the length between the parent node position of the particle and the first position; wherein the parent node is connected to at least one child node, and the position of each child node changes with the change of the parent node position; the particle belongs to a node in the at least one child node; When the length is greater than the set length of the bone corresponding to the mass point, the first position is corrected to a second position whose length from the parent node position of the mass point is equal to the set length according to a preset stiffness coefficient; The special effect object is rendered into the image after animation skinning based on the second position of the mass point of each bone.

2. The method according to claim 1, characterized in that The step of performing spring simulation on the bone according to the displacement and the comprehensive force and correcting the initial position of the mass point to obtain the first position includes: The first position is obtained according to the following formula: P1=V*(a-damping)*t+F / (b*M)*(a-force_damping)*t 2 Among them, V = P-P'; F = F_ext + G; Among them, P1 represents the first position, V represents the displacement, P represents the initial position of the particle, P' represents the reference position of the particle, a and b are constants, M represents the preset mass of the particle, F_ext represents the comprehensive force, G represents the gravity, damping represents spring damping, force_damping represents the attenuation coefficient of the force, and t represents the playback time of a frame of the video.

3. The method according to claim 1, characterized in that When the length is greater than the set length of the bone corresponding to the mass point, the first position is corrected according to a preset stiffness coefficient to obtain a second position, comprising: The first position is corrected according to the following formula to obtain the second position: P2=D*(len(D)-max_len) / len(D); Where D = P start -P1;max_len=rest_len*(1-stiffness)*c; P2 represents the second position, P start represents the parent node position of the particle, P1 represents the first position, len(D) represents the length of the D vector, and rest_len represents the distance from the particle to P when initializing the special effect object. start The length of , stiffness represents the preset stiffness coefficient, and c represents a constant.

4. The method according to claim 1, characterized in that: When the length is less than a set length of the bone corresponding to the mass point, the method further includes: According to a preset elastic coefficient, the first position is corrected to obtain the second position.

5. The method according to claim 4, characterized in that The step of correcting the first position to obtain the second position according to the preset elastic coefficient includes: The first position is corrected according to the following formula to obtain the second position: P2=(P start -P1)*elastic; P2 represents the second position, elastic represents the preset elastic coefficient, P start represents the parent node position of the particle, and P1 represents the first position.

6. The method according to claim 1, characterized in that The method further comprises: taking the second position of the mass point of each bone as a reference, performing animation skinning and rendering the special effect object into the image. When the particle collides with the target object, obtaining the motion range of the special effect object constructed with the coordinate system of the target object; when the second position is not within the motion range, correcting the second position to be within the motion range; and / or, Taking the particle and the target object as the center points of the sphere, construct the sphere of the particle and the target object respectively; when the particle is inside the sphere of the target object, determine the straight line formed by the center of the sphere of the particle and the center of the sphere of the target object; move the particle out of the sphere of the target object along the straight line and in a direction away from the target object.

7. The method according to claim 6, characterized in that The motion range is a preset motion plane of the special effect object in the coordinate system of the target object; then correcting the second position to within the motion range includes: The second position is corrected to the motion range according to the following formula: P 21 =P2-N*dis; Where, dis=dot(N,P2)-d_plane; d_plane=dot(N,P start ); Among them, P 21 represents the corrected second position, P2 represents the second position, N is the normal vector of the plane, P start Indicates the parent node position of the particle.

8. The method according to claim 6, characterized in that After correcting the second position to within the motion range and before rendering the special effect object into the image after animation skinning based on the second position of the mass point of each bone, the method further includes: When the length from the particle to the parent node position of the particle is greater than the set length, the corrected second position is corrected again to obtain the final position of the second position so that the length from the final position to the parent node position of the particle is equal to the set length.

9. The method according to claim 8, characterized in that The step of correcting the corrected second position again to obtain a final position of the second position includes: The final position of the second position is obtained according to the following formula: P 22 =D2*(len(D2)-rest_len) / len(D2) Where D2 = P start -P 21 Among them, P 22 represents the final position of the second position, P 21 represents the corrected second position, len(D2) represents the length of the D2 vector, P start represents the parent node position of the particle, rest_len represents the distance from the particle to P when initializing the special effect object. start Length.

10. An image processing device, characterized in that: The device comprises: An acquisition module is configured to acquire images and gravity directions; a target object recognition module configured to recognize a target object in the image, and determine the initial position of the mass points of each bone of the special effect object in the image with the target object as a reference; the special effect object is obtained in advance through physical modeling, and the special effect object includes a plurality of bones, each bone having a corresponding mass point; a position processing module, configured to perform a spring simulation on the bone according to the gravity direction and the initial position of the mass point, and to correct the initial position of the mass point to obtain a first position; A rendering module, configured to render the special effect object into the image according to the first position of the mass point of each bone; The position processing module comprises: a displacement determination unit, configured to determine the displacement between the reference position of the mass point and the initial position of the mass point, wherein if the image is a first frame image, the reference position is the position of the mass point in the initial state of the special effect object; if the image is not the first frame image, the reference position is the position of the mass point in the previous frame image of the image; an external force determination unit, configured to determine a comprehensive force according to the gravity value in the gravity direction and a preset external force; A first position correction unit is configured to perform a spring simulation on the bone according to the displacement and the comprehensive force, and correct the initial position of the mass point to obtain a first position; The rendering module includes: a length determination unit, configured to determine the length between the parent node position of the mass point and the first position; wherein the parent node is connected to at least one child node, and the position of each child node changes as the position of the parent node changes; and the mass point belongs to a node in the at least one child node; a length correction unit configured to correct the first position to a second position whose length with respect to a parent node position of the mass point is equal to the set length according to a preset stiffness coefficient when the length is greater than a set length of a bone corresponding to the mass point; The rendering unit is configured to perform animation skinning based on the second position of the mass point of each bone and then render the special effect object into the image.

11. The device according to claim 10, characterized in that The first position correction unit is configured to obtain the first position according to the following formula: P1=V*(a-damping)*t+F / (b*M)*(a-force_damping)*t 2 Among them, V = P-P'; F = F_ext + G; Among them, P1 represents the first position, V represents the displacement, P represents the initial position of the particle, P' represents the reference position of the particle, a and b are constants, M represents the preset mass of the particle, F_ext represents the sum of preset virtual external forces, G represents the gravity, damping represents spring damping, force_damping represents the attenuation coefficient of the force, and t represents the playback time of a frame of the video.

12. The device according to claim 10, characterized in that The length correction unit is configured to correct the first position according to the following formula to obtain the second position: P2=D*(len(D)-max_len) / len(D); Where D = P start -P1;max_len=rest_len*(1-stiffness)*c; P2 represents the second position, P start represents the parent node position of the particle, P1 represents the first position, len(D) represents the length of the D vector, and rest_len represents the distance from the particle to P when initializing the special effect object. start The length of , stiffness represents the preset stiffness coefficient, and c represents a constant.

13. The device according to claim 10, characterized in that When the length is less than a set length of the bone corresponding to the mass point, the length correction unit is further configured to correct the first position according to a preset elastic coefficient to obtain the second position.

14. The device according to claim 13, characterized in that The length correction unit is configured to correct the first position according to the following formula to obtain the second position: P2=(P start -P1)*elastic; P2 represents the second position, elastic represents the preset elastic coefficient, P start represents the parent node position of the particle, and P1 represents the first position.

15. The device according to claim 10, characterized in that The device further comprises: a motion limiting module, configured to execute, when the particle collides with the target object, obtaining the motion range of the special effect object constructed with the coordinate system of the target object; and when the second position is not within the motion range, correcting the second position to within the motion range: and / or, Taking the particle and the target object as the center points of the sphere, construct the sphere of the particle and the target object respectively; when the particle is inside the sphere of the target object, determine the straight line formed by the center of the sphere of the particle and the center of the sphere of the target object; move the particle out of the sphere of the target object along the straight line and in a direction away from the target object.

16. The device according to claim 15, characterized in that The motion range is a preset motion plane of the special effect object in the coordinate system of the target object; the motion limiting module is configured to correct the second position to within the motion range according to the following formula: P 21 =P2-N*dis; Where, dis=dot(N,P2)-d_plane; d_plane=dot(N,P start ); Among them, P 21 represents the corrected second position, P2 represents the second position, N is the normal vector of the plane, P start Indicates the parent node position of the particle.

17. The device according to claim 15, characterized in that After the second position is corrected to the range of motion and before the special effect object is rendered into the image after animation skinning based on the second position of the mass point of each bone, the device further includes: The length revision module is configured to execute, when the length from the particle to the parent node position of the particle is greater than the set length, to correct the corrected second position again to obtain the final position of the second position so that the length from the final position to the parent node position of the particle is equal to the set length.

18. The device according to claim 17, characterized in that The length revision module is configured to perform: The final position of the second position is obtained according to the following formula: P 22 =D2*(len(D2)-rest_len) / len(D2) Where D2 = P start -P 21 Among them, P 22 represents the final position of the second position, P 21 represents the corrected second position, len(D2) represents the length of the D2 vector, P start represents the parent node position of the particle, rest_len represents the distance from the particle to P when initializing the special effect object. start Length.

19. An electronic device, characterized in that: It comprises at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1-9.

20. A non-transitory computer-readable storage medium, characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device executes the method as claimed in any one of claims 1 to 9.