Animation Special Effect Generation Method, Device, Electronic Device, and Storage Medium

By obtaining the key points and grid points of the dressing elements from the modeling material images, performing deformation operations, and generating multiple material images with different degrees of deformation, solving the problems of long animation special effects production cycle and high labor costs, and achieving fast and efficient animation special effects generation.

CN117372580BActive Publication Date: 2025-07-08GUANGZHOU HUYA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311380940.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-23
Publication Date
2025-07-08
Estimated Expiration
2043-10-23

AI Technical Summary

Technical Problem

In the prior art, the production cycle of animation special effects is long and labor costs are high, mainly because the artist has a long time to draw each material image.

Method used

By obtaining the rectangular area of the dressing element from the modeling material image, determining the key points and grid points, deformation operations are performed according to the preset animation parameters, multiple target material images with different degrees of deformation are generated, and animation special effects are finally generated.

Benefits of technology

It simplifies the operation process, shortens the production cycle of animation special effects, and improves production efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117372580B_ABST
    Figure CN117372580B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image processing technology, and provides an animation special effect generation method, device, electronic device and storage medium. The method includes: first, obtaining a rectangular area containing dressing elements from a styling material image for dressing a portrait; then determining a plurality of key points for representing the shape characteristics of the dressing elements and a plurality of grid points for representing the deformation range of the dressing elements according to the rectangular area; then performing a deformation operation on the dressing elements according to the plurality of key points and the plurality of grid points of the dressing elements according to preset animation parameters to obtain a plurality of target material images with different degrees of deformation; and finally generating an animation special effect according to the styling material image and all the target material images. By performing a deformation operation on the dressing elements according to their shape characteristics and deformation range, a plurality of material images with different degrees of deformation are obtained and an animation special effect is generated, thereby simplifying the operation, shortening the production cycle of the animation special effect and improving the production efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to an animation special effect generation method, device, electronic device and storage medium. Background Art

[0002] To make the video more interesting, users can add animation effects to their portraits when shooting, such as dynamic ears, tails, beards, etc. These animation effects are generated based on the serialized material image set used to dress up the portrait. Currently, the material image set is usually drawn by an artist, but it takes a long time for an artist to draw each material image, which will lead to a long production cycle of animation effects, affect production efficiency, and also cost a lot of manpower costs. Summary of the invention

[0003] In view of this, an object of the present invention is to provide a method, device, electronic device and storage medium for generating animation special effects.

[0004] In order to achieve the above object, the technical solution adopted by the present invention is as follows:

[0005] In a first aspect, the present invention provides a method for generating an animation special effect, the method comprising:

[0006] Obtaining a rectangular area containing dressing elements from a modeling material image used for dressing a portrait;

[0007] Determining a plurality of key points and a plurality of grid points of the dressing element according to the rectangular area; the plurality of key points are used to represent the shape characteristics of the dressing element, and the plurality of grid points are used to represent the deformation range of the dressing element;

[0008] According to preset animation parameters, the dress element is deformed according to a plurality of key points and a plurality of grid points of the dress element to obtain a plurality of target material images with different deformation degrees;

[0009] Animation special effects are generated according to the modeling material image and all target material images.

[0010] In an optional implementation, the step of determining a plurality of key points and a plurality of grid points of the dressing element according to the rectangular area comprises:

[0011] Performing corner point detection on the decoration element to obtain each corner point, and performing edge detection on the decoration element to obtain the outline of the decoration element;

[0012] When the preset animation effect is horizontal motion, the rectangular area is divided equally by a plurality of horizontal dividing lines;

[0013] Obtain the intersection points of each horizontal equidivision line and the contour of the dressing element to obtain each contour point, and use each corner point and each contour point as the key points of the dressing element to obtain the multiple key points;

[0014] Use the intersection points of each horizontal equidivision line and the boundary line of the rectangular area and the vertices of the rectangular area as grid points to obtain the multiple grid points.

[0015] In an alternative embodiment, the step of determining multiple key points and multiple grid points of the dressing element according to the rectangular area includes:

[0016] Perform corner point detection on the dressing element to obtain each corner point, and perform edge detection on the dressing element to obtain the contour of the dressing element;

[0017] When the preset animation effect is vertical movement, equally divide the rectangular area by multiple vertical equidivision lines;

[0018] Obtain the intersection points of each vertical equidivision line and the contour of the dressing element to obtain each contour point, and use each corner point and each contour point as the key points of the dressing element to obtain the multiple key points;

[0019] Use the intersection points of each vertical equidivision line and the boundary line of the rectangular area and the vertices of the rectangular area as grid points to obtain the multiple grid points.

[0020] In an alternative embodiment, the animation parameters include multiple animation durations, and one animation duration corresponds to one target material image;

[0021] The step of deforming the dressing element according to the multiple key points and multiple grid points of the dressing element according to the preset animation parameters to obtain multiple target material images with different deformation degrees includes:

[0022] Determine the movement direction and movement speed of each key point according to the preset animation effect;

[0023] Use any one of the animation durations as the target animation duration;

[0024] Calculate the offset of each key point according to the movement direction and movement speed of each key point and the target animation duration;

[0025] Obtain the target position of each key point according to the position of each key point in the modeling material image and its offset;

[0026] Perform a deformation operation on the dressing element according to the target position of each key point and the position of each grid point in the styling material image to obtain a target material image corresponding to the target animation duration;

[0027] Traverse each animation duration to obtain each target material image.

[0028] In an alternative embodiment, the animation parameters further include a first reference direction and a first reference speed;

[0029] The step of determining the movement direction and movement speed of each key point according to a preset animation effect includes:

[0030] In the case where the preset animation effect is horizontal movement, determine the movement amplitude of each row of key points according to the position of each row of key points in the dressing element to obtain the speed adjustment coefficient of each row of key points;

[0031] Multiply the speed adjustment coefficient of each row of key points by the first reference speed as the movement speed of each row of key points;

[0032] If the preset animation effect is horizontal swing, use the first reference direction as the movement direction of each row of key points;

[0033] If the preset animation effect is horizontal shake, use the first reference direction as the movement direction of the key points in odd rows, and use the direction opposite to the first reference direction as the movement direction of the key points in even rows.

[0034] In an alternative embodiment, the animation parameters further include a second reference direction and a second reference speed;

[0035] The step of determining the movement direction and movement speed of each key point according to a preset animation effect includes:

[0036] In the case where the preset animation effect is vertical movement, determine the movement amplitude of each column of key points according to the position of each column of key points in the dressing element to obtain the speed adjustment coefficient of each column of key points;

[0037] Multiply the speed adjustment coefficient of each column of key points by the second reference speed as the movement speed of each column of key points;

[0038] If the preset animation effect is vertical swing, use the second reference direction as the movement direction of each column of key points;

[0039] If the preset animation effect is vertical shake, use the second reference direction as the movement direction of the key points in odd columns, and use the direction opposite to the second reference direction as the movement direction of the key points in even columns.

[0040] In a second aspect, the present invention provides an animation special effect generating device, and the animation special effect generating device includes:

[0041] An obtaining module, configured to obtain a rectangular area containing dressing elements from a styling material image for dressing a portrait;

[0042] A processing module, configured to determine a plurality of key points and a plurality of grid points of the dressing element according to the rectangular area; the plurality of key points are used to represent the shape characteristics of the dressing element, and the plurality of grid points are used to represent the deformation range of the dressing element;

[0043] Perform a deformation operation on the dressing element according to the plurality of key points and the plurality of grid points of the dressing element according to preset animation parameters to obtain a plurality of target material images with different degrees of deformation;

[0044] A generating module, configured to generate an animation special effect according to the styling material image and all the target material images.

[0045] In an optional implementation manner, the processing module is further configured to:

[0046] Perform corner detection on the dressing element to obtain each corner point, and perform edge detection on the dressing element to obtain the contour of the dressing element;

[0047] When the preset animation effect is horizontal movement, equally divide the rectangular area by a plurality of horizontal equidistant lines;

[0048] Obtain each contour point by obtaining the intersection points of each horizontal equidistant line and the contour of the dressing element, and use each corner point and each contour point as the key points of the dressing element to obtain the plurality of key points;

[0049] Use the intersection points of each horizontal equidistant line and the boundary line of the rectangular area and the vertices of the rectangular area as grid points to obtain the plurality of grid points.

[0050] In a third aspect, the present invention provides an electronic device, including a processor and a memory, where the memory stores a computer program, and when the processor executes the computer program, the animation special effect generating method described in any one of the foregoing embodiments is implemented.

[0051] In a fourth aspect, the present invention provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the animation special effect generating method described in any one of the foregoing embodiments is implemented.

[0052] The animation special effect generation method, device, electronic device, and storage medium provided by the present invention, the method includes: First, obtain a rectangular area containing dressing elements from the styling material images for dressing a portrait; Then, determine a plurality of key points and a plurality of grid points of the dressing elements according to the rectangular area, and these plurality of key points are used to represent the shape characteristics of the dressing elements and these plurality of grid points are used to represent the deformation range of the dressing elements; Next, according to the preset animation parameters, perform a deformation operation on the dressing elements according to the plurality of key points and the plurality of grid points of the dressing elements to obtain a plurality of target material images with different degrees of deformation; Finally, generate an animation special effect according to the styling material image and all the target material images. By performing a deformation operation on the dressing elements according to their shape characteristics and deformation range to obtain a plurality of material images with different degrees of deformation and generate an animation special effect, the operation is simplified, the material images can be quickly generated, the production cycle of the animation special effect is shortened, and the production efficiency of the animation special effect is improved.

[0053] To make the above objects, features, and advantages of the present invention more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, makes a detailed description as follows. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for use in the embodiments. It should be understood that the following drawings only show some embodiments of the present invention, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.

[0055] Figure 1 Shows a block diagram of an electronic device provided by an embodiment of the present invention;

[0056] Figure 2 Shows a flowchart of an animation special effect generation method provided by an embodiment of the present invention;

[0057] Figure 3 Shows one of the example diagrams of the animation special effect generation method provided by an embodiment of the present invention;

[0058] Figure 4 Shows a second example diagram of the animation special effect generation method provided by an embodiment of the present invention;

[0059] Figure 5 Shows a third example diagram of the animation special effect generation method provided by an embodiment of the present invention;

[0060] Figure 6 Shows a fourth example diagram of the animation special effect generation method provided by an embodiment of the present invention;

[0061] Figure 7The figure shows a functional block diagram of an animation special effect generation device provided by an embodiment of the present invention.

[0062] Icons: 100 - electronic device; 110 - bus; 120 - processor; 130 - memory; 150 - I / O module; 170 - communication interface; 300 - animation special effect generation device; 310 - acquisition module; 330 - processing module; 350 - generation module. Detailed implementation manners

[0063] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Usually, the components of the embodiments of the present invention described and illustrated in the accompanying drawings here can be arranged and designed in various different configurations.

[0064] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed present invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present invention.

[0065] It should be noted that relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the phrase "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the element.

[0066] Please refer to Figure 1 , which is a block diagram of an electronic device 100 provided by an embodiment of the present invention. The electronic device 100 includes a bus 110, a processor 120, a memory 130, an I / O module 150, and a communication interface 170.

[0067] The bus 110 can be a circuit that interconnects the above elements and transmits communication (such as control messages) between the above elements.

[0068] The processor 120 can receive commands from the other components described above (such as the memory 130, the I / O module 150, the communication interface 170, etc.) via the bus 110, can interpret the received commands, and can perform calculations or data processing according to the interpreted commands.

[0069] The processor 120 can be an integrated circuit chip with signal processing capabilities. The processor 120 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0070] The memory 130 can store commands or data received from the processor 120 or other components (such as the I / O module 150, the communication interface 170, etc.) or commands or data generated by the processor 120 or other components.

[0071] The memory 130 can be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM).

[0072] The I / O module 150 can receive commands or data input by the user via input-output means (such as sensors, keyboards, touchscreens, etc.) and can transmit the received commands or data to the processor 120 or the memory 130 via the bus 110. And it is used to display various information received, stored, and processed from the above components (such as multimedia data, text data), and can display videos, images, data, etc. to the user.

[0073] The communication interface 170 can be used for signaling or data communication with other devices.

[0074] It can be understood that Figure 1 The structure shown is only a schematic diagram of the structure of the electronic device 100, and the electronic device 100 may also include more or fewer components than those Figure 1 shown, or have a structure different from thatFigure 1 The different configurations shown. Figure 1 Each component shown in can be implemented using hardware, software, or a combination thereof.

[0075] The electronic device provided by an embodiment of the present invention may be a smart phone, a personal computer, a tablet computer, a wearable device, an Ultra-Mobile Personal Computer (UMPC), a netbook, a Personal Digital Assistant (PDA), etc. The embodiments of the present invention do not impose any restrictions thereon.

[0076] Next, taking the above-mentioned electronic device 100 as the execution subject, each step in each method provided by the embodiments of the present invention will be executed, and the corresponding technical effects will be achieved. Please refer to Figure 2 , Figure 2 which is a schematic flowchart of a method for generating an animation special effect provided by an embodiment of the present invention.

[0077] Step S202: Obtain a rectangular area containing dressing elements from the styling material images for dressing a portrait;

[0078] In this embodiment, the original material images can be obtained. These original material images are used for dressing a portrait, such as different types of ear stickers, i.e., cat ears, dog ears, etc., and different types of beards, tails, etc. Then, according to the size of the dressing elements in the styling material images, a rectangular area containing the dressing elements can be obtained.

[0079] Step S204: Determine a plurality of key points and a plurality of grid points of the dressing elements according to the rectangular area; the plurality of key points are used to represent the shape characteristics of the dressing elements, and the plurality of grid points are used to represent the deformation range of the dressing elements;

[0080] In this embodiment, since the rectangular area contains the dressing elements, a plurality of key points for representing the shape characteristics of the dressing elements and a plurality of grid points for representing the deformation range of the dressing elements can be determined according to the rectangular area. A preset detection algorithm can be used to determine the key points and grid points of the dressing elements, a pre-trained model can also be used to identify the key points and grid points of the dressing elements, or the key points and grid points of the dressing elements can be selected in a custom manner.

[0081] Step S206: According to the preset animation parameters, perform a deformation operation on the dressing elements according to the plurality of key points and the plurality of grid points of the dressing elements to obtain a plurality of target material images with different degrees of deformation;

[0082] Step S208: Generate an animation special effect according to the styling material images and all the target material images;

[0083] In this embodiment, animation parameters can be preset. These animation parameters can be understood as parameters for controlling the movement trajectories of key points. Then, according to the preset animation parameters, within the deformation range represented by multiple grid points, deformation operations can be performed on the dressing elements based on multiple key points to obtain multiple target material images with different degrees of deformation. Then, serialization is performed based on the original modeling material image and all the target material images, and the corresponding animation special effects can be obtained.

[0084] It can be understood that in the embodiment of the present invention, by determining the shape characteristics and deformation range of the dressing elements and performing deformation operations on them, multiple material images with different degrees of deformation are obtained to generate animation special effects. Thereby, the operation is simplified, the material images can be quickly generated, the production cycle of the animation special effects is shortened, and the production efficiency of the animation special effects is improved.

[0085] It can be seen that based on the above steps, first, a rectangular area containing the dressing elements is obtained from the modeling material image for dressing a portrait; then, multiple key points and multiple grid points of the dressing elements are determined according to the rectangular area, and these multiple key points are used to represent the shape characteristics of the dressing elements and these multiple grid points are used to represent the deformation range of the dressing elements; then, according to the preset animation parameters, deformation operations are performed on the dressing elements based on the multiple key points and multiple grid points of the dressing elements to obtain multiple target material images with different degrees of deformation; finally, animation special effects are generated according to the modeling material image and all the target material images. By performing deformation operations on the dressing elements according to their shape characteristics and deformation range to obtain multiple material images with different degrees of deformation and generate animation special effects, the operation is simplified, the material images can be quickly generated, the production cycle of the animation special effects is shortened, and the production efficiency of the animation special effects is improved.

[0086] Optionally, for different animation effects, the embodiment of the present invention provides two implementation manners for step S204. The first implementation manner will be introduced below.

[0087] Step S204A-1: Perform corner detection on the dressing elements to obtain each corner point, and perform edge detection on the dressing elements to obtain the contour of the dressing elements;

[0088] In this embodiment, a preset algorithm can be used to perform corner detection on the dressing elements to obtain each corner point of the dressing elements. The corner points can be understood as points that can represent the shape characteristics of the dressing elements. For example, taking the dressing element as cat ears, the embodiment of the present invention provides an example diagram. As Figure 3 shown is a rectangular area containing cat ears. Perform corner detection on the cat ears within this rectangular area, and the obtained corner points of the dressing element, that is, the cat ears, are like Figure 4 the point A1 shown.

[0089] Moreover, the outline of the dressing element can be obtained by performing edge detection on the dressing element through binarization, or a pre-trained model can be used to identify the outline of the dressing element. As Figure 4 shown, the outline of the dressing element, i.e., the cat ears, is the connecting line between point A1 and point S1 and the connecting line between point A1 and point S2.

[0090] Step S204A-3, when the preset animation effect is horizontal movement, equally divide the rectangular area by multiple horizontal equally-spaced lines;

[0091] Step S204A-5, obtain the intersection points of each horizontal equally-spaced line and the outline of the dressing element to get each outline point, and regard each corner point and each outline point as the key points of the dressing element to obtain multiple key points;

[0092] Step S204A-7, regard the intersection points of each horizontal equally-spaced line and the boundary line of the rectangular area and the vertices of the rectangular area as grid points to obtain multiple grid points;

[0093] In this embodiment, if the preset animation effect is horizontal movement, that is, it is expected that the dressing element moves horizontally, then multiple horizontal equally-spaced lines are used to equally divide the rectangular area, and then the intersection points of each horizontal equally-spaced line and the outline of the dressing element are obtained to get each outline point, and each corner point and each outline point are regarded as the key points of the dressing element, that is, multiple key points are obtained, and the intersection points of each horizontal equally-spaced line and the boundary line of the rectangular area and the vertices of the rectangular area are regarded as grid points, that is, multiple grid points are obtained.

[0094] Continuing with the above Figure 4 shown rectangular area as an example, use two horizontal equally-spaced lines to equally divide the rectangular area, obtain the intersection points of each horizontal equally-spaced line and the outline of the cat ears, and get 4 outline points such as Figure 5 shown points A2 to A5, and regard each corner point and each outline point as the key points of the dressing element, that is, get 5 key points such as Figure 5 shown points A1 to A5; and regard the intersection points of each horizontal equally-spaced line and the boundary line of the rectangular area and the vertices of the rectangular area as grid points, that is, get 8 grid points such as Figure 5 shown points B1 to B8.

[0095] The following introduces the second implementation method provided by the embodiment of the present invention for step S204.

[0096] Step S204B-1, perform corner detection on the dressing element to obtain each corner point, and perform edge detection on the dressing element to obtain the outline of the dressing element;

[0097] In this embodiment, the implementation manner of step S204B-1 is the same as that of step S204A-1, that is, a preset algorithm can be used to detect the corner points of the dressing element to obtain each corner point of the dressing element. A corner point can be understood as a point that can represent the shape characteristics of the dressing element. Moreover, the edge detection of the dressing element can be performed by means of binarization to obtain the contour of the dressing element, or a pre-trained model can also be used to identify the contour of the dressing element.

[0098] Step S204B-3, when the preset animation effect is vertical movement, equally divide the rectangular area by multiple longitudinal equally dividing lines;

[0099] Step S204B-5, obtain the intersection points of each longitudinal equally dividing line and the contour of the dressing element to get each contour point, and regard each corner point and each contour point as the key points of the dressing element to obtain multiple key points;

[0100] Step S204B-7, regard the intersection points of each longitudinal equally dividing line and the boundary line of the rectangular area and the vertices of the rectangular area as grid points to obtain multiple grid points;

[0101] In this embodiment, if the preset animation effect is vertical movement, that is, it is expected that the dressing element moves longitudinally, such as a dressing element like a beard, then multiple longitudinal equally dividing lines are used to equally divide the rectangular area, and then the intersection points of each longitudinal equally dividing line and the contour of the dressing element are obtained to get each contour point, and each corner point and each contour point are regarded as the key points of the dressing element, that is, multiple key points are obtained, and the intersection points of each longitudinal equally dividing line and the boundary line of the rectangular area and the vertices of the rectangular area are regarded as grid points, that is, multiple grid points are obtained.

[0102] It can be understood that the implementation manner of steps S204B-3 to S204B-7 is similar to that of steps S204A-3 to S204A-7. The difference between the two is whether the preset animation effect expects the dressing element to move horizontally or vertically. If it is horizontal movement, transverse equally dividing lines are used, and if it is vertical movement, longitudinal equally dividing lines are used.

[0103] Optionally, for step S206, an embodiment of the present invention provides a possible implementation manner.

[0104] Step S206-1, determine the movement direction and movement speed of each key point according to the preset animation effect;

[0105] In this embodiment, since different animation effects expect different movement modes of the dressing element, the movement direction and movement speed of each key point can be determined according to the preset animation effect.

[0106] Step S206-3: Take any one of the animation durations as the target animation duration;

[0107] It can be understood that the preset animation parameters include multiple animation durations, which can be obtained according to the preset frame rate, and one animation duration corresponds to one target material image. Since the processing methods using each animation duration are similar, for simplicity, any one of the animation durations will be taken as the target animation duration for exemplary illustration below.

[0108] Step S206-5: Calculate the offset of each key point according to the movement direction and movement speed of each key point and the target animation duration;

[0109] Step S206-7: Obtain the target position of each key point according to the position of each key point in the modeling material image and its offset;

[0110] In this embodiment, the processing methods for each key point are similar. For simplicity, one key point will be taken as an example for illustration below.

[0111] The product of the movement speed of the key point and the target animation duration can be calculated, and combined with the movement direction of the key point, the displacement of the key point, that is, the offset, can be obtained. Then, based on the offset of the key point and its position in the modeling material image, the target position of the key point can be obtained.

[0112] This target position can be understood as the position of the key point in the animation frame displayed after the target animation duration from the start of the display of the first animation frame of the animation effect, that is, the modeling material image. By processing each key point in a similar manner, the positions of each key point in the same animation frame after the target animation duration, that is, the target positions of each key point, can be obtained.

[0113] Step S206-9: Perform a deformation operation on the dressing element according to the target position of each key point and the position of each grid point in the modeling material image to obtain a target material image corresponding to the target animation duration;

[0114] In this embodiment, based on one target animation duration, the target positions of each key point can be calculated. Then, the deformation range of the dressing element can be determined according to the position of each grid point in the modeling material image, and the dressing element can be deformed within this deformation range according to the target positions of all key points, that is, a target material image corresponding to the target animation duration can be obtained.

[0115] Step S206-11: Traverse each animation duration to obtain each target material image;

[0116] In this embodiment, for each animation duration, the above similar method is adopted for processing, and thus each target material image can be obtained.

[0117] Optionally, based on the above method of dividing the rectangular area by the horizontal dividing line to obtain multiple key points, the embodiment of the present invention provides a corresponding implementation manner for step S206-1.

[0118] Step S206-1A-1, when the preset animation effect is horizontal movement, determine the movement amplitude of each row of key points according to the positions of each row of key points in the dressing element, and obtain the speed adjustment coefficient of each row of key points;

[0119] Step S206-1A-3, use the product of the speed adjustment coefficient of each row of key points and the first reference speed as the movement speed of each row of key points;

[0120] In this embodiment, the animation parameters further include a first reference direction and a first reference speed. If the preset animation effect is horizontal movement, that is, it is expected that the dressing element moves horizontally, then the rectangular area is equally divided by the horizontal dividing line to obtain multiple key points, and then the movement direction and movement speed of the key points can be determined row by row.

[0121] For the movement speed of each row of key points, the movement amplitude of each row of key points can be determined according to the positions of each row of key points in the dressing element to obtain the speed adjustment coefficient of each row of key points, and the product of the speed adjustment coefficient of each row of key points and the first reference speed is used as the movement speed of each row of key points, that is, the movement speed of each key point is obtained.

[0122] For the sake of easy understanding, continue with the above Figure 5 shown dressing element, that is, the cat ears, as an example, assuming that the first reference speed is v1. In the Figure 5 shown dressing element, that is, the cat ears, the first row of key points, that is, point A1, is located at the top of the cat ears, and its movement amplitude is large; the second row of key points, that is, points A2 and A3, is located in the middle of the cat ears, and its movement amplitude is medium; the third row of key points, that is, points A4 and A5, is located at the bottom of the cat ears, and its movement amplitude is small. Then the speed adjustment coefficients of the first row of key points, that is, point A1, the second row of key points, that is, points A2 and A3, and the third row of key points, that is, points A4 and A5, can be 3, 2, and 1 respectively.

[0123] Then multiply the speed adjustment coefficient of each row of key points by the first reference speed, that is, v1, to obtain the movement speed of each row of key points. That is, the movement speed of the first row of key points, that is, point A1, is 3v1, the movement speed of the second row of key points, that is, points A2 and A3, is 2v1, and the movement speed of the third row of key points, that is, points A4 and A5, is v1, that is, the movement speed of each key point is obtained.

[0124] It should be understood that the numerical values of the speed adjustment coefficients of each key point in the above examples are only examples, which do not limit the embodiments of the present invention. The speed adjustment coefficients of each key point can be set according to the actual situation, but the rule that the greater the movement amplitude, the greater the speed adjustment coefficient should be followed.

[0125] Step S206-1A-5, if the preset animation effect is horizontal swing, then take the first reference direction as the movement direction of each key point in each row;

[0126] Step S206-1A-7, if the preset animation effect is horizontal sway, then take the first reference direction as the movement direction of the key points in odd rows, and take the direction opposite to the first reference direction as the movement direction of the key points in even rows;

[0127] In this embodiment, for the movement direction of each key point in each row, it can be determined according to the preset animation effect. If the preset animation effect is horizontal swing, that is, it is expected that the animation special effect corresponding to the dressing element is in an overall horizontal straight line shape, then take the first reference direction as the movement direction of each key point in each row. For example, assume that the expected animation special effect corresponding to the dressing element such as cat ears is to swing to the right, then take the first reference direction, that is, horizontally to the right, as the movement direction of each key point in each row, that is, make the movement directions of all key points the same, so as to achieve the effect that the overall movement of the dressing element is in a straight line.

[0128] If the preset animation effect is horizontal sway, that is, it is expected that the animation special effect corresponding to the dressing element is in an overall horizontal wave shape, then take the first reference direction as the movement direction of the key points in odd rows, and take the direction opposite to the first reference direction as the movement direction of the key points in even rows.

[0129] For example, taking the dressing element such as cat ears as shown in Figure 5 as an example, assume that the expected animation special effect corresponding to the cat ears is to bend to the right, then take the first reference direction, that is, horizontally to the right, as the movement direction of the key points in the first row and the third row, and take the direction opposite to the first reference direction, that is, horizontally to the left, as the direction of the key points in the second row, that is, make the movement directions of the key points in adjacent rows opposite, so as to achieve the effect that the overall movement of the dressing element is in a wavy line, as shown in Figure 6 shown.

[0130] Optionally, based on the above method of dividing the rectangular area by the longitudinal bisector to obtain multiple key points, the embodiments of the present invention provide a corresponding implementation manner for step S206-1.

[0131] Step S206-1B-1, when the preset animation effect is vertical movement, determine the movement amplitude of each column of key points according to the positions of the key points in the dressing element, and obtain the speed adjustment coefficient of each column of key points;

[0132] Step S206-1B-3, use the product of the speed adjustment coefficient of each column of key points and the second reference speed as the movement speed of each column of key points;

[0133] In this embodiment, the animation parameters further include a second reference direction and a second reference speed. If the preset animation effect is vertical movement, that is, it is expected that the dressing element moves longitudinally, then a rectangular area will be equally divided by longitudinal equidistant lines to obtain multiple key points, and then the movement direction and movement speed of the key points can be determined column by column.

[0134] For the movement speed of each column of key points, the implementation manners of steps S206-1B-1 to S206-1B-3 are similar to those of steps S206-1A-1 to S206-1A-3. That is, the movement amplitude of each column of key points can be determined according to the positions of the key points in the dressing element to obtain the speed adjustment coefficient of each column of key points, and the product of the speed adjustment coefficient of each column of key points and the second reference speed is used as the movement speed of each column of key points, that is, the movement speed of each key point is obtained.

[0135] Similarly, the speed adjustment coefficient of each column of key points can be set according to the actual situation, but it should follow the rule that the larger the movement amplitude, the larger the speed adjustment coefficient.

[0136] Step S206-1B-5, if the preset animation effect is vertical swing, use the second reference direction as the movement direction of each column of key points;

[0137] Step S206-1B-7, if the preset animation effect is vertical shake, use the second reference direction as the movement direction of the key points in odd columns, and use the direction opposite to the second reference direction as the movement direction of the key points in even columns;

[0138] In this embodiment, the implementation manners of steps S206-1B-5 to S206-1B-7 are similar to those of steps S206-1A-5 to S206-1A-7, that is, for the movement direction of each column of key points, it can be determined according to the preset animation effect.

[0139] If the preset animation effect is vertical swinging, that is, it is expected that the animation special effect corresponding to the dressing element is in an overall vertical straight line shape, then the second reference direction is used as the movement direction of the key points in each column. For example, assuming that the animation special effect corresponding to the dressing element such as a beard is upward swinging, then the second reference direction, that is, vertically upward, is used as the movement direction of the key points in each column, that is, the movement directions of all the key points are made the same, so as to achieve the effect that the overall movement of the dressing element is in a straight line.

[0140] If the preset animation effect is vertical shaking, that is, it is expected that the animation special effect corresponding to the dressing element is in an overall vertical wavy shape, then the second reference direction is used as the movement direction of the key points in the odd-numbered columns, and the direction opposite to the second reference direction is used as the movement direction of the key points in the even-numbered columns.

[0141] For example, assuming that the animation special effect corresponding to the dressing element such as a beard is upward bending, then the second reference direction, that is, vertically upward, is used as the movement direction of the key points in the odd-numbered columns, and the direction opposite to the second reference direction, that is, vertically downward, is used as the movement direction of the key points in the even-numbered columns, that is, the movement directions of the key points in adjacent columns are made opposite, so as to achieve the effect that the overall movement of the dressing element is in a wavy line.

[0142] To execute the corresponding steps in the above embodiments and various possible ways, an implementation manner of an animation special effect generation device 300 is given below. Please refer to Figure 7 , Figure 7 FIG. 300 is a functional module diagram of an animation special effect generation device 300 provided by an embodiment of the present invention. It should be noted that the basic principle and the technical effects generated by the animation special effect generation device 300 provided in this embodiment are the same as those in the above embodiments. For the sake of brief description, for the parts not mentioned in this embodiment, reference may be made to the corresponding content in the above embodiments. The animation special effect generation device 300 includes:

[0143] An obtaining module 310, configured to obtain a rectangular area including a dressing element from a modeling material image for dressing a portrait;

[0144] A processing module 330, configured to determine a plurality of key points and a plurality of grid points of the dressing element according to the rectangular area; the plurality of key points are used to represent the shape characteristics of the dressing element, and the plurality of grid points are used to represent the deformation range of the dressing element;

[0145] According to the preset animation parameters, perform a deformation operation on the dressing element according to the plurality of key points and the plurality of grid points of the dressing element to obtain a plurality of target material images with different deformation degrees;

[0146] A generating module 350, configured to generate an animation special effect according to the modeling material image and all the target material images.

[0147] Optionally, the processing module 330 is further configured to: perform corner detection on the dressing element to obtain each corner point, and perform edge detection on the dressing element to obtain the contour of the dressing element; in the case where the preset animation effect is horizontal movement, equally divide the rectangular area by multiple horizontal equidistant lines; obtain the intersection points of each horizontal equidistant line and the contour of the dressing element to obtain each contour point, and use each corner point and each contour point as key points of the dressing element to obtain multiple key points; use the intersection points of each horizontal equidistant line and the boundary line of the rectangular area and the vertices of the rectangular area as grid points to obtain multiple grid points.

[0148] Optionally, the processing module 330 is further configured to: perform corner detection on the dressing element to obtain each corner point, and perform edge detection on the dressing element to obtain the contour of the dressing element; in the case where the preset animation effect is vertical movement, equally divide the rectangular area by multiple vertical equidistant lines; obtain the intersection points of each vertical equidistant line and the contour of the dressing element to obtain each contour point, and use each corner point and each contour point as key points of the dressing element to obtain multiple key points; use the intersection points of each vertical equidistant line and the boundary line of the rectangular area and the vertices of the rectangular area as grid points to obtain multiple grid points.

[0149] Optionally, the processing module 330 is further configured to: determine the movement direction and movement speed of each key point according to the preset animation effect; use any one animation duration as the target animation duration; calculate the offset of each key point according to the movement direction and movement speed of each key point and the target animation duration; obtain the target position of each key point according to the position of each key point in the modeling material image and its offset; perform a deformation operation on the dressing element according to the target position of each key point and the position of each grid point in the modeling material image to obtain a target material image corresponding to the target animation duration; traverse each animation duration to obtain each target material image.

[0150] Optionally, the processing module 330 is further configured to: in the case where the preset animation effect is horizontal movement, determine the movement amplitude of each row of key points according to the position of each row of key points in the dressing element to obtain the speed adjustment coefficient of each row of key points; use the product of the speed adjustment coefficient of each row of key points and the first reference speed as the movement speed of each row of key points; if the preset animation effect is horizontal swing, use the first reference direction as the movement direction of each row of key points; if the preset animation effect is horizontal sway, use the first reference direction as the movement direction of the key points in odd rows, and use the direction opposite to the first reference direction as the movement direction of the key points in even rows.

[0151] Optionally, the processing module 330 is further configured to: when the preset animation effect is vertical movement, determine the movement amplitude of each column of key points according to the positions of each column of key points in the dressing element, and obtain the speed adjustment coefficient of each column of key points; use the product of the speed adjustment coefficient of each column of key points and the second reference speed as the movement speed of each column of key points; if the preset animation effect is vertical swing, use the second reference direction as the movement direction of each column of key points; if the preset animation effect is vertical shake, use the second reference direction as the movement direction of the key points in the odd columns, and use the direction opposite to the second reference direction as the movement direction of the key points in the even columns.

[0152] An embodiment of the present invention further provides an electronic device, including a processor and a memory. The memory stores a computer program. When the processor executes the computer program, the animation effect generation method disclosed in the embodiments of the present invention is implemented.

[0153] An embodiment of the present invention further provides a storage medium, on which a computer program is stored. When the computer program is executed by a processor, the animation effect generation method disclosed in the embodiments of the present invention is implemented.

[0154] In several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0155] In addition, in each embodiment of the present invention, the various functional modules may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.

[0156] When the above-mentioned functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.

[0157] The foregoing are only the preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for generating animation special effects, characterized in that, The described animation effect generation method includes: Obtain a rectangular area containing dressing elements from the styling material image for dressing a portrait; Determine multiple key points and multiple grid points of the dressing elements according to the rectangular area, including: performing corner detection on the dressing elements to obtain each corner point, and performing edge detection on the dressing elements to obtain the contour of the dressing elements; When the preset animation effect is vertical movement, equally divide the rectangular area by multiple longitudinal equal division lines; Obtain each contour point by getting the intersection points of each longitudinal equal division line and the contour of the dressing element, and take each corner point and each contour point as the key points of the dressing element to obtain the multiple key points; Take the intersection points of each longitudinal equal division line and the boundary line of the rectangular area and the vertices of the rectangular area as grid points to obtain the multiple grid points; the multiple key points are used to represent the shape characteristics of the dressing elements, and the multiple grid points are used to represent the deformation range of the dressing elements; According to the preset animation parameters, perform deformation operations on the dressing elements according to the multiple key points and multiple grid points of the dressing elements to obtain multiple target material images with different deformation degrees; Generate animation effects according to the styling material image and all target material images.

2. The animation special effect generation method according to claim 1, wherein The step of determining multiple key points and multiple grid points of the dressing elements according to the rectangular area further includes: When the preset animation effect is horizontal movement, equally divide the rectangular area by multiple transverse equal division lines; Obtain each contour point by getting the intersection points of each transverse equal division line and the contour of the dressing element, and take each corner point and each contour point as the key points of the dressing element to obtain the multiple key points; Take the intersection points of each transverse equal division line and the boundary line of the rectangular area and the vertices of the rectangular area as grid points to obtain the multiple grid points.

3. The animation special effect generation method according to claim 1 or 2, characterized in that The animation parameters include multiple animation durations, and one animation duration corresponds to one target material image; The step of performing deformation operations on the dressing elements according to the multiple key points and multiple grid points of the dressing elements according to the preset animation parameters to obtain multiple target material images with different deformation degrees includes: Determine the movement direction and movement speed of each key point according to the preset animation effect; Take any one of the animation durations as the target animation duration; Calculate the offset of each key point according to the movement direction and movement speed of each key point and the target animation duration; Obtain the target position of each key point according to the position of each key point in the styling material image and its offset; Perform deformation operations on the dressing elements according to the target positions of each key point and the positions of each grid point in the styling material image to obtain the target material image corresponding to the target animation duration; Traverse each animation duration to obtain each target material image.

4. The animation special effect generation method according to claim 3, wherein The animation parameters further include a first reference direction and a first reference speed; The step of determining the movement direction and movement speed of each key point according to the preset animation effect includes: When the preset animation effect is horizontal movement, determine the movement amplitude of each row of key points according to the positions of the key points in each row in the dressing element, and obtain the speed adjustment coefficient of each row of key points; Take the product of the speed adjustment coefficient of each row of key points and the first reference speed as the movement speed of each row of key points; If the preset animation effect is horizontal swing, use the first reference direction as the movement direction of each row of key points; If the preset animation effect is horizontal sway, use the first reference direction as the movement direction of the key points in odd rows, and use the direction opposite to the first reference direction as the movement direction of the key points in even rows.

5. The animation special effect generation method according to claim 3, characterized in that The animation parameters further include a second reference direction and a second reference speed; The step of determining the movement direction and movement speed of each key point according to the preset animation effect includes: When the preset animation effect is vertical movement, determine the movement amplitude of each column of key points according to the positions of the key points in each column in the dressing element, and obtain the speed adjustment coefficient of each column of key points; Take the product of the speed adjustment coefficient of each column of key points and the second reference speed as the movement speed of each column of key points; If the preset animation effect is vertical swing, use the second reference direction as the movement direction of each column of key points; If the preset animation effect is vertical sway, use the second reference direction as the movement direction of the key points in odd columns, and use the direction opposite to the second reference direction as the movement direction of the key points in even columns.

6. An animation special effect generation device, characterized in that, The animation special effect generating device includes: An acquisition module, configured to acquire a rectangular area including a dressing element from a modeling material image for dressing a portrait; A processing module, configured to determine a plurality of key points and a plurality of grid points of the dressing element according to the rectangular area, including: performing corner detection on the dressing element to obtain each corner point, and performing edge detection on the dressing element to obtain the contour of the dressing element; when the preset animation effect is vertical movement, equally divide the rectangular area by a plurality of longitudinal dividing lines; obtain the intersection points of each longitudinal dividing line and the contour of the dressing element to obtain each contour point, and use each corner point and each contour point as the key points of the dressing element to obtain the plurality of key points; use the intersection points of each longitudinal dividing line and the boundary line of the rectangular area and the vertices of the rectangular area as grid points to obtain the plurality of grid points; the plurality of key points are used to represent the shape characteristics of the dressing element, and the plurality of grid points are used to represent the deformation range of the dressing element; Perform a deformation operation on the dressing element according to the plurality of key points and the plurality of grid points of the dressing element according to the preset animation parameters to obtain a plurality of target material images with different deformation degrees; A generation module, configured to generate an animation special effect according to the modeling material image and all the target material images.

7. The animation special effect generating device according to claim 6, wherein The processing module is further configured to: When the preset animation effect is horizontal movement, equally divide the rectangular area by a plurality of horizontal dividing lines; Obtain the intersection points of each horizontal equidistant line and the contour of the dressing element to obtain each contour point, and use each corner point and each contour point as the key points of the dressing element to obtain the multiple key points; Use the intersection points of each horizontal equidistant line and the boundary line of the rectangular area and the vertices of the rectangular area as grid points to obtain the multiple grid points.

8. An electronic device, characterized in that, It includes a processor and a memory. The memory stores a computer program. When the processor executes the computer program, it implements the animation special effect generation method according to any one of claims 1 to 5.

9. A storage medium, characterized in that, A computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the animation special effect generation method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method for digitally beautifying eyebrows, electronic equipment and storage medium

    CN113689325A