A method and device for generating dynamic images

By rotating screenshot and sampling the 3D model, dynamic pictures in the apng format are generated, which solves the problem that 3D models cannot be converted into the apng format in the prior art, and realizes dynamic picture conversion with small size and high efficiency.

CN114821011BActive Publication Date: 2025-05-16BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210372345.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-11
Publication Date
2025-05-16
Estimated Expiration
2042-04-11

AI Technical Summary

Technical Problem

The prior art cannot convert 3D models into dynamic pictures in Apng format, and the gif dynamic pictures are large in size, low in conversion efficiency, and complex in operation.

Method used

By rotating the 3D model according to the static image interception parameters, intercepting multiple static pictures, and sampling each static picture according to the preset sampling algorithm, obtaining the sampled static pictures, and finally generating dynamic pictures from these static pictures.

Benefits of technology

The 3D model is converted into dynamic pictures in the apng format, which reduces the volume of the dynamic pictures, improves the conversion efficiency, and simplifies operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114821011B_ABST
    Figure CN114821011B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for generating dynamic images, and relates to the field of computer technology. A specific implementation of the method includes: rotating a 3D model according to a static image interception parameter, intercepting multiple static images of the 3D model during the rotation process, wherein the static image interception parameter includes a model rotation angle, wherein a static image is intercepted for each rotation of the 3D model by the model rotation angle; after intercepting each static image of the 3D model, sampling each intercepted static image according to a preset sampling algorithm to obtain a corresponding sampled static image; and combining the sampled static images corresponding to each static image to obtain a dynamic image of the 3D model. This implementation can realize the conversion of a 3D model into a dynamic image in apng format, reduce the volume of the dynamic image, have high conversion efficiency, and be simple to operate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating a dynamic picture. Background Art

[0002] Currently, 3D model conversion to dynamic images only supports dynamic images in gif format, and cannot be converted to dynamic images in apng format. The libpng library only supports reading and writing apng, and apng production is completed by operating png images.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] The size of gif dynamic images is large, the conversion efficiency is low, the operation is complicated, and it is impossible to convert 3D models into dynamic images in apng format. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a dynamic picture generation method and device, which can realize the conversion of 3D models into dynamic pictures in apng format, reduce the volume of dynamic pictures, have high conversion efficiency and simple operation.

[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for generating a dynamic picture is provided.

[0007] A method for generating a dynamic image comprises: rotating a 3D model according to static image capture parameters, and capturing multiple static images of the 3D model during the rotation process, wherein the static image capture parameters include a model rotation angle, wherein a static image is captured each time the 3D model rotates by the model rotation angle; after capturing each static image of the 3D model, sampling each captured static image according to a preset sampling algorithm to obtain a corresponding sampled static image; and obtaining a dynamic image of the 3D model by combining the sampled static images corresponding to the respective static images.

[0008] Optionally, the static image capture parameters also include the number of static images, the pixel width and pixel height of the static images; before rotating the 3D model according to the static image capture parameters, it includes: obtaining configuration parameters, the configuration parameters including the configured number of dynamic image frames, image height, image width, and pixel density; subtracting 1 from the number of dynamic image frames to obtain the number of static images; calculating the difference between the number of static images and 1, and dividing the difference by a preset total model rotation angle to calculate the angle between the two static images as the model rotation angle; multiplying the image height and the image width by the pixel density, respectively, to obtain the pixel height and pixel width of the static image.

[0009] Optionally, when the number of the captured static images reaches the number of static images, or the angle of rotation of the 3D model reaches the preset total rotation angle of the model, the rotation process is stopped.

[0010] Optionally, each time the 3D model is rotated by the model rotation angle, a static image is captured, including: each time the 3D model is rotated by the model rotation angle, a canvas is created based on the pixel width and the pixel height, the 3D model is drawn into the canvas, and pixel information is obtained from the canvas to form a typed array file corresponding to the static image; each of the captured static images is sampled according to a preset sampling algorithm to obtain a corresponding sampled static image, including: according to a diagonal weight sampling method, the typed array file is sampled to obtain a sampled typed array file, and the sampled typed array file is a typed array file corresponding to the sampled static image.

[0011] Optionally, the sampling of the typed array file according to the diagonal weight sampling method to obtain the sampled typed array file includes: dividing all pixels in the typed array file into one or more sampling pixel groups according to a preset rule; for each sampling pixel group, selecting a pixel as the sampling pixel of the sampling pixel group, calculating the sum of the first weights of all pixels in the sampling pixel group, and respectively calculating the proportion of the weight of each pixel except the sampling pixel to the sum of the first weights, deleting the weights of all pixels, and saving the proportion corresponding to each pixel except the sampling pixel and the sum of the first weights to the information of the sampling pixel; and obtaining the sampled typed array file according to the information of each sampling pixel.

[0012] Optionally, the dynamic image of the 3D model is obtained by combining the sampled static images corresponding to each static image, including: transcoding the sampled static images to obtain sampled static images of a set format; performing restoration calculation on the sampled static images of the set format through a color palette to generate a static image of the set format; and obtaining the dynamic image of the 3D model based on the combination of the static images of the set format.

[0013] Optionally, the restoring calculation of the sampled static image of the set format through the color palette to generate the static image of the set format includes: for each sampling pixel group, obtaining the color value corresponding to the sum of the first weights through the color palette, multiplying the proportions corresponding to each pixel point other than the sampling pixel point by the color value corresponding to the sum of the first weights, respectively, to obtain the color value corresponding to each pixel point other than the sampling pixel point, and subtracting the color value corresponding to all pixels in the sampling pixel group other than the sampling pixel point from the color value corresponding to the sum of the first weights to obtain the color value of the sampling pixel point; based on the color values ​​corresponding to each pixel point other than the sampling pixel point in each sampling pixel group and the color value of the sampling pixel point, the sampled static image of the set format is restored to generate the static image of the set format.

[0014] Optionally, the sampled typed array file also includes information about verification pixels; the sampling of the typed array file according to the diagonal weight sampling method to obtain the sampled typed array file also includes: determining one or more verification pixel groups from the typed array file according to predetermined pixels to be verified, the pixels to be verified are the sampling pixels in the sampling pixel group or pixels other than the sampling pixels, and the verification pixel group includes the pixels to be verified; for each verification pixel group, selecting a pixel as the verification pixel of the verification pixel group, calculating the sum of the second weights of all pixels in the verification pixel group, and respectively calculating the proportion of the weight of each pixel except the verification pixel to the sum of the second weights, deleting the weight information of all pixels, and saving the proportion corresponding to each pixel except the verification pixel and the sum of the second weights to the information of the verification pixel.

[0015] Optionally, the restoring of the sampled static image of the set format based on the color values ​​corresponding to each pixel other than the sampled pixel in each sampling pixel group and the color value of the sampling pixel, before generating the static image of the set format, includes: for each verification pixel group of the pixels to be verified, obtaining the verification color value corresponding to the sum of the second weights through a color palette, multiplying the proportions corresponding to each pixel other than the verification pixel by the verification color value corresponding to the sum of the second weights, respectively, to obtain the verification color value corresponding to each pixel other than the verification pixel, and subtracting the verification color value corresponding to all pixels other than the verification pixel in the verification pixel group from the verification color value corresponding to the second weight to obtain the verification color value of the verification pixel; for each pixel to be verified, weighted averaging the color value of the pixel to be verified and the verification color value of the pixel to be verified, so as to update the color value of the pixel to be verified according to the obtained weighted average value, wherein the verification color value of the pixel to be verified is the verification color value corresponding to the pixel other than the verification pixel or the verification color value of the verification pixel.

[0016] Optionally, the configuration parameters also include dynamic picture duration; the dynamic picture of the 3D model is obtained by combining the static pictures in the set format, including: according to the dynamic picture generation parameters, combining the static pictures in the set format corresponding to each static picture through the libpng library to generate a dynamic portable network graphic to obtain the dynamic picture of the 3D model, and the dynamic picture generation parameters include: the picture height, the picture width, the number of static pictures and the time interval between two static pictures, and the time interval between two static pictures is equal to the dynamic picture duration divided by the number of static pictures.

[0017] According to another aspect of an embodiment of the present invention, a dynamic picture generating device is provided.

[0018] A dynamic picture generating device comprises: a static picture capturing module, used for rotating a 3D model according to static picture capturing parameters, capturing multiple static pictures of the 3D model during the rotation process, wherein the static picture capturing parameters comprise a model rotation angle, wherein a static picture is captured each time the 3D model rotates by the model rotation angle; a sampling module, used for sampling each static picture captured according to a preset sampling algorithm after capturing each static picture of the 3D model, to obtain a corresponding sampled static picture; and a dynamic picture generating module, used for combining the sampled static pictures corresponding to each static picture to obtain a dynamic picture of the 3D model.

[0019] Optionally, the static image capture parameters also include the number of static images, the pixel width and pixel height of the static images; and also include a parameter calculation module, which is used to: obtain configuration parameters, the configuration parameters including the configured number of dynamic image frames, image height, image width, and pixel density; subtract 1 from the number of dynamic image frames to obtain the number of static images; calculate the difference between the number of static images and 1, and divide the difference by a preset total model rotation angle to calculate the angle between the two static images as the model rotation angle; multiply the image height and the image width by the pixel density, respectively, to obtain the pixel height and pixel width of the static image.

[0020] Optionally, when the number of the captured static images reaches the number of static images, or the angle of rotation of the 3D model reaches the preset total rotation angle of the model, the rotation process is stopped.

[0021] Optionally, the static image capture module is used to: create a canvas based on the pixel width and the pixel height each time the 3D model is rotated by the model rotation angle, draw the 3D model into the canvas, and obtain pixel information from the canvas to form a typed array file corresponding to the static image; the sampling module is also used to: sample the typed array file according to the diagonal weight sampling method to obtain a sampled typed array file, and the sampled typed array file is the typed array file corresponding to the sampled static image.

[0022] Optionally, the sampling module is also used to: divide all pixel points in the typed array file into one or more sampling pixel groups according to preset rules; for each sampling pixel group, select a pixel point as the sampling pixel point of the sampling pixel group, calculate the sum of the first weights of all pixel points in the sampling pixel group, and respectively calculate the proportion of the weight of each pixel point other than the sampling pixel point to the sum of the first weights, delete the weights of all pixel points, and save the proportion corresponding to each pixel point other than the sampling pixel point and the sum of the first weights to the information of the sampling pixel points; and obtain the sampled typed array file according to the information of each sampling pixel point.

[0023] Optionally, the dynamic image generation module is also used to: transcode the sampled static image to obtain a sampled static image of a set format; perform restoration calculation on the sampled static image of the set format through a color palette to generate a static image of a set format; and obtain a dynamic image of the 3D model based on a combination of static images of the set format.

[0024] Optionally, the dynamic image generation module is also used to: for each sampling pixel group, obtain the color value corresponding to the sum of the first weights through the color palette, multiply the proportions corresponding to each pixel point other than the sampling pixel point by the color value corresponding to the sum of the first weights, respectively, to obtain the color value corresponding to each pixel point other than the sampling pixel point, subtract the color value corresponding to all pixels in the sampling pixel group other than the sampling pixel point from the color value corresponding to the sum of the first weights, to obtain the color value of the sampling pixel point; based on the color values ​​corresponding to each pixel point other than the sampling pixel point in each sampling pixel group and the color value of the sampling pixel point, restore the sampled static image of the set format to generate the static image of the set format.

[0025] Optionally, the sampled typed array file also includes information on verification pixels; the sampling module is further used to: determine one or more verification pixel groups from the typed array file according to predetermined pixels to be verified, the pixels to be verified are the sampling pixels in the sampling pixel group or pixels other than the sampling pixels, and the verification pixel group includes the pixels to be verified; for each verification pixel group, select a pixel as the verification pixel of the verification pixel group, calculate the sum of the second weights of all pixels in the verification pixel group, and calculate the proportion of the weight of each pixel other than the verification pixel to the sum of the second weights, delete the weight information of all pixels, and save the proportion corresponding to each pixel other than the verification pixel and the sum of the second weights to the information of the verification pixel.

[0026] Optionally, the sampling module is also used to: for each verification pixel group of the pixel points to be verified, obtain the verification color value corresponding to the sum of the second weights through the color palette, multiply the proportions corresponding to each pixel point other than the verification pixel point by the verification color value corresponding to the sum of the second weights, obtain the verification color value corresponding to each pixel point other than the verification pixel point, subtract the verification color value corresponding to all pixels in the verification pixel group other than the verification pixel point from the verification color value corresponding to the sum of the second weights, and obtain the verification color value of the verification pixel point; for each pixel point to be verified, perform a weighted average of the color value of the pixel point to be verified and the verification color value of the pixel point to be verified, so as to update the color value of the pixel point to be verified according to the obtained weighted average value, wherein the verification color value of the pixel point to be verified is the verification color value corresponding to the pixel point other than the verification pixel point or the verification color value of the verification pixel point.

[0027] Optionally, the configuration parameters also include dynamic picture duration; the dynamic picture generation module is also used to: according to the dynamic picture generation parameters, combine the static pictures of a set format corresponding to each static picture through the libpng library to generate a dynamic portable network graphic, so as to obtain the dynamic picture of the 3D model, and the dynamic picture generation parameters include: the picture height, the picture width, the number of static pictures and the time interval between two static pictures, and the time interval between two static pictures is equal to the dynamic picture duration divided by the number of static pictures.

[0028] According to yet another aspect of the embodiments of the present invention, an electronic device is provided.

[0029] An electronic device comprises: one or more processors; a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the dynamic picture generation method provided in an embodiment of the present invention.

[0030] According to yet another aspect of an embodiment of the present invention, a computer readable medium is provided.

[0031] A computer-readable medium stores a computer program, which, when executed by a processor, implements a dynamic picture generation method provided in an embodiment of the present invention.

[0032] One embodiment of the above invention has the following advantages or beneficial effects: the 3D model is rotated according to the static picture interception parameters, and multiple static pictures of the 3D model are intercepted during the rotation process. The static picture interception parameters include the model rotation angle, wherein a static picture is intercepted for each rotation of the 3D model by the model rotation angle; after each static picture of the 3D model is intercepted, each intercepted static picture is sampled according to a preset sampling algorithm to obtain a corresponding sampled static picture; the sampled static pictures corresponding to each static picture are combined to obtain a dynamic picture of the 3D model. The 3D model can be converted into a dynamic picture in apng format, which reduces the volume of the dynamic picture, has high conversion efficiency, and is easy to operate.

[0033] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0035] Figure 1 is a schematic diagram of the main steps of a method for generating a dynamic picture according to an embodiment of the present invention;

[0036] Figure 2is one of the flowcharts of a method for generating a dynamic picture according to an embodiment of the present invention;

[0037] Figure 3 is a second flow chart of a method for generating a dynamic picture according to an embodiment of the present invention;

[0038] Figure 4 is a schematic diagram of a rendering process according to an embodiment of the present invention;

[0039] Figure 5 is a schematic diagram of main modules of a dynamic picture generating device according to an embodiment of the present invention;

[0040] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0041] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0042] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0043] Figure 1 1 is a schematic diagram of main steps of a method for generating a dynamic picture according to an embodiment of the present invention.

[0044] like Figure 1 As shown, a dynamic picture generation method according to an embodiment of the present invention mainly includes the following steps S101 to S103.

[0045] Step S101: Rotate the 3D model according to static image capture parameters, and capture multiple static images of the 3D model during the rotation process. The static image capture parameters include a model rotation angle, wherein a static image is captured each time the 3D model rotates by the model rotation angle.

[0046] The 3D model used for rotation is a pre-generated or stored 3D model, and the embodiment of the present invention is used to generate a dynamic image in a specific format (such as apng format) for the 3D model.

[0047] The rotation process will rotate the 3D model multiple times. The model rotation angle is the angle of each rotation of the 3D model. After the model rotation angle is set, it will remain unchanged during the rotation process of the 3D model. After each rotation is completed, a picture of the 3D model is captured, that is, a static picture.

[0048] The static image capture parameters may also include the number of static images, the pixel width and pixel height of the static images.

[0049] Before rotating the 3D model according to the static image interception parameters, the following steps may be included: obtaining configuration parameters, including the configured dynamic image frame number, image height, image width, and pixel density; subtracting 1 from the dynamic image frame number to obtain the number of static images; calculating the difference between the number of static images and 1, and dividing the difference by the preset total model rotation angle to calculate the angle between the two static images as the model rotation angle; multiplying the image height and image width by the pixel density to obtain the pixel height and pixel width of the static image. The preset total model rotation angle is, for example, the angle corresponding to one circle (2π).

[0050] Configuration parameters may also include dynamic image duration, that is, the time required for the dynamic image to be displayed.

[0051] When the number of captured static images reaches the number of static images, or the angle of rotation of the 3D model reaches the preset total rotation angle of the model, the rotation process is stopped.

[0052] Every time the 3D model is rotated by a rotation angle, a static image is captured, which may include: every time the 3D model is rotated by the rotation angle, a canvas is created based on the pixel width and pixel height, the 3D model is drawn into the canvas, so that the canvas includes pixel information of the static image of the 3D model, and the pixel information is obtained from the canvas to form a typed array file (arraybuffer) corresponding to the static image.

[0053] Step S102: after capturing each static image of the 3D model, sampling is performed on each captured static image according to a preset sampling algorithm to obtain a corresponding sampled static image.

[0054] The sampled static image is a sampling result obtained by sampling the static image.

[0055] Sampling each captured static image according to a preset sampling algorithm to obtain a corresponding sampled static image may include: sampling a typed array file according to a diagonal weight sampling method to obtain a sampled typed array file, wherein the sampled typed array file is a typed array file of the corresponding sampled static image. The static image and the sampled static image may be files in arraybuffer (typed array file) format.

[0056] According to the diagonal weight sampling method, the typed array file of the static image is sampled to obtain the sampled typed array file, which may include: according to a preset rule, all the pixels in the typed array file are divided into one or more pixel groups, referred to as sampling pixel groups; for each sampling pixel group, a pixel is selected as the sampling pixel of the sampling pixel group, the sum of the weights of all the pixels in the sampling pixel group is calculated, that is, the sum of the first weights, and the proportion of the weights of each pixel other than the sampling pixel in the sum of the first weights is calculated respectively, the weights of all the pixels are deleted, and the proportions corresponding to each pixel other than the sampling pixel and the sum of the first weights are saved in the information of the sampling pixel; according to the information of each sampling pixel, the sampled typed array file is obtained. The proportion corresponding to a pixel refers to the proportion of the weight of the pixel in the sum of the first weights. Among them, the selection of the sampling pixel can select the pixel at the diagonal position as the sampling pixel, or select the sampling pixel according to the distribution of the pixels in each sampling pixel group.

[0057] The sampled typed array file may also include information of check pixels.

[0058] According to the diagonal weight sampling method, the typed array file of the static image is sampled to obtain the sampled typed array file, which may also include: selecting the pixel points to be verified as the pixel points to be verified, that is, the predetermined pixel points to be verified, according to the predetermined pixel points to be verified, determining one or more pixel groups from the typed array file, called the verification pixel group, the pixel points to be verified are the sampling pixel points in the sampling pixel group or the pixel points other than the sampling pixel points, and the verification pixel group includes the pixel points to be verified; for each verification pixel group, selecting a pixel point as the verification pixel point of the verification pixel group, calculating the sum of the weights of all the pixels in the verification pixel group, that is, the sum of the second weights, and respectively calculating the proportion of the weights of each pixel point other than the verification pixel point to the sum of the second weights, deleting the weight information of all the pixels, and saving the proportions corresponding to each pixel point other than the verification pixel point and the sum of the second weights to the information of the verification pixel point. Among them, the selection of the verification pixel point can select the pixel points to be verified in the diagonal position as the verification pixel point, or select the verification pixel point according to the distribution of the pixel points to be verified in each verification pixel group.

[0059] Step S103: The sampled static images corresponding to the static images are combined to obtain a dynamic image of the 3D model.

[0060] Combining the sampled static images corresponding to the static images to obtain the dynamic image of the 3D model may include: transcoding the sampled static images from arraybuffer format to png format to obtain the sampled static images of the set format; performing restoration calculation on the sampled static images of the set format through the color palette to generate the static images of the set format; and obtaining the dynamic image of the 3D model based on the static images of the set format. The sampled static images of the set format and the static images of the set format may be files in png format, which is a lossless compressed bitmap graphic format.

[0061] The sampled static image of the set format is restored and calculated by the color palette to generate the static image of the set format, which may specifically include: for each sampled pixel group, the color value corresponding to the sum of the first weights is obtained by the color palette, the proportion corresponding to each pixel point other than the sampled pixel point is multiplied by the color value corresponding to the sum of the first weights to obtain the color value corresponding to each pixel point other than the sampled pixel point, the color value corresponding to all pixels in the sampled pixel group other than the sampled pixel point is subtracted from the color value corresponding to the sum of the first weights to obtain the color value of the sampled pixel point; based on the color value corresponding to each pixel point other than the sampled pixel point in each sampled pixel group and the color value of the sampled pixel point, the sampled static image of the set format is restored to generate the static image of the set format. Among them, the color value corresponding to the sum of the weights can be directly obtained through the color palette in the libpng library.

[0062] Based on the color values ​​corresponding to each pixel point other than the sampling pixel point in each sampling pixel group and the color values ​​of the sampling pixel point, restoring the sampled static image of the set format, before generating the static image of the set format, it can include: for each verification pixel group of the pixel points to be verified, obtaining the verification color value corresponding to the sum of the second weights through the color palette, multiplying the proportion corresponding to each pixel point other than the verification pixel point by the verification color value corresponding to the sum of the second weights, to obtain the verification color value corresponding to each pixel point other than the verification pixel point, and subtracting the verification color value corresponding to all the pixel points other than the verification pixel point in the verification pixel group from the verification color value corresponding to the sum of the second weights , obtain the verification color value of the verification pixel; for each pixel to be verified, perform a weighted average of the color value of the pixel to be verified and the verification color value of the pixel to be verified, so as to update the color value of the pixel to be verified according to the obtained weighted average value, wherein, since the verification pixel group includes the pixel to be verified, that is, the pixel to be verified is a pixel in the verification pixel group, the verification color value of the pixel to be verified can be the verification color value corresponding to the pixel other than the verification pixel (corresponding to the case where the pixel to be verified and the verification pixel are not the same pixel) or the verification color value of the verification pixel (corresponding to the case where the pixel to be verified and the verification pixel are the same pixel). The specific calculation formula for weighted average of the color value of the pixel to be verified and the verification color value of the pixel to be verified is:

[0063] M=C1*W1 / (W1+W2)+C2*W2 / (W1+W2)

[0064] Among them, M is the weighted average, C1 is the color value obtained by sampling the pixel group, C2 is the color value obtained by verifying the pixel group (i.e., the verification color value), W1 is the weight coefficient of the color value obtained by sampling the pixel group, and W2 is the weight coefficient of the color value obtained by verifying the pixel group.

[0065] The method of obtaining a dynamic image of a 3D model based on a combination of static images of a set format may include: according to dynamic image generation parameters, generating a dynamic portable network graphic (apng) by combining static images of a set format corresponding to each static image through a libpng library, and obtaining a dynamic image of a 3D model, wherein the dynamic image generation parameters include: image height, image width, number of static images, and time interval between two static images, and the time interval between two static images is equal to the duration of the dynamic image divided by the number of static images. Among them, libpng is a set of open source program libraries that support operations such as creation, reading and writing of png graphic files, and apng (Animated Portable Network Graphics) is a dynamic portable network graphic, which is a file format inherited from portable network graphics (png).

[0066] Figure 2 This is one of the flowcharts of a method for generating a dynamic picture according to an embodiment of the present invention.

[0067] like Figure 2 As shown, input the 3D model and configuration parameters, and calculate the static image capture parameters and dynamic image generation parameters according to the configuration parameters. Determine whether the 3D model rotates one circle. If not, rotate the 3D model according to the static image capture parameters and draw it on the canvas, so as to obtain a static image in arraybuffer (i.e., typed array file) format. Sample and compress the static image in arraybuffer format to obtain a sampled static image in arraybuffer format. Transcode the sampled static image in arraybuffer format, and the transcoded result is called a sampled static image in png format, and push the sampled static image in png format into the png image queue, determine whether the 3D model rotates one circle, if not, continue to rotate the 3D model, and continue to generate sampled static images in png format until the model rotates one circle, and obtain a png image queue with a length equal to the number of static images. Based on the color palette (also known as the palette) in the libpng library, restore the sampled static images in png format in the png image queue to obtain a static image in png format. The libpng library is used to combine static images in png format to obtain dynamic images of 3D models in apng format.

[0068] In one embodiment, the configuration parameters include the dynamic picture frame rate, picture height, picture width, pixel density, and dynamic picture duration. The dynamic picture frame rate (rate), picture height (height), picture width (width), and dynamic picture duration (duration) are input by the user, and the pixel density (pixelRatio) is a physical parameter that can be obtained by reading the pixel density of the display device. The calculation formula for the number of static pictures (amount) is:

[0069] amount = rate - 1

[0070] Taking 2π as the total model rotation angle, the calculation formula for the model rotation angle (degree) between two static images is:

[0071] degree=2π / (amount-1)

[0072] The calculation formula for the time interval (delay) between two static images is:

[0073] delay = duration / amount

[0074] The calculation formula for the pixel width (pixelWidth) of a static image is:

[0075] pixelWidth=width*pixelRatio

[0076] The calculation formula for the pixel height (pixelHeight) of a static image is:

[0077] pixelHeight=height*pixelRatio

[0078] The static image capture parameters are determined by the model rotation angle, the pixel width of the static image, and the pixel height of the static image. The dynamic image generation parameters are determined by the image height, image width, the number of static images, and the time interval between two static images.

[0079] In one embodiment, the typed array file of the static image is sampled according to the diagonal weight sampling method to obtain a sampled typed array file, and the sampled typed array file is the typed array file of the static image after sampling. Specifically, according to the preset rules, all the pixels in the typed array file are divided into one or more sampling pixel groups; for each sampling pixel group, a pixel is selected as the sampling pixel of the sampling pixel group, and the sum of the weights of all the pixels in the sampling pixel group is calculated, that is, the sum of the first weight is calculated, and the proportion of the weight of each pixel except the sampling pixel to the sum of the first weight is calculated respectively, and the weights of all the pixels are deleted, and the proportions corresponding to each pixel except the sampling pixel and the sum of the first weight are saved in the information of the sampling pixel; according to the information of each sampling pixel, the sampled typed array file is obtained.

[0080] Table 1 Example of diagonal weight sampling method

[0081] a b c d e f g h i j k l m n o p

[0082] For example, a static image in an arraybuffer format includes 16 pixels, namely: pixel a, pixel b, pixel c, pixel d, pixel e, pixel f, pixel g, pixel h, pixel i, pixel j, pixel k, pixel l, pixel m, pixel n, pixel o, pixel p, arranged in a 4×4 manner, as shown in Table 1. Each pixel contains its own weight information, and the static image in the arraybuffer format is sampled according to the diagonal weight sampling method, specifically: the 16 pixels are divided into 4 2×2 sampling pixel groups, that is, pixel a, pixel b, pixel e, pixel f are a sampling pixel group, pixel c, pixel d, pixel g, pixel h are a sampling pixel group, pixel i, pixel j, pixel m, pixel n are a sampling pixel group, pixel k, pixel l, pixel o, pixel p are a sampling pixel group. For a sampling pixel group including pixel point a, pixel point b, pixel point e, and pixel point f, pixel point f at a diagonal position is taken as a sampling pixel point, the sum of the weights of pixel point a, pixel point b, pixel point e, and pixel point f, as well as the proportion of pixel point a in the sum of the weights, the proportion of pixel point b in the sum of the weights, and the proportion of pixel point e in the sum of the weights are calculated, and the information of the weights of each of pixel point a, pixel point b, pixel point e, and pixel point f is deleted, and the calculated sum of the weights, the proportion of pixel point a in the sum of the weights, the proportion of pixel point b in the sum of the weights, and the proportion of pixel point e in the sum of the weights are stored in the information of pixel point f (i.e., the sampling pixel point), that is, the proportions corresponding to each pixel point except the sampling pixel point f and the sum of the weights of pixel point a, pixel point b, pixel point e, and pixel point f are saved in the information of the sampling pixel point f. The same method is used to process the remaining sampled pixel groups. After all sampled pixel groups are processed, a sampled static image in arraybuffer format is obtained based on the information of each pixel point.

[0083] In one embodiment, one or more verification pixel groups are determined from a typed array file according to predetermined pixels to be verified, and the pixels to be verified are pixels in a sampling pixel group. Specifically, the pixels to be verified may be sampling pixels in a sampling pixel group, or may be pixels other than sampling pixels in a sampling pixel group. The verification pixel group includes the pixels to be verified; for each verification pixel group, a pixel is selected as the verification pixel of the verification pixel group, the sum of the weights of all pixels in the verification pixel group is calculated, and the proportion of the weight of each pixel other than the verification pixel to the sum of the weights of all pixels in the verification pixel group is calculated, and the weight information of all pixels is deleted, and the proportion corresponding to each pixel other than the verification pixel and the sum of the weights are saved in the information of the verification pixel. Specifically, according to the requirements, the pixels to be checked are selected as the pixels to be checked. As shown in Table 1, pixel b, pixel c, pixel d, pixel f, pixel g, pixel h, pixel j, pixel k, pixel l, pixel n, pixel o, and pixel p can be selected as the pixels to be checked, and the 12 pixels to be checked are divided into two 2×3 check pixel groups, for example, pixel b, pixel c, pixel d, pixel f, pixel g, and pixel h are one check pixel group, and pixel j, pixel k, pixel l, pixel n, pixel o, and pixel p are another check pixel group. For a verification pixel group including pixel b, pixel c, pixel d, pixel f, pixel g, and pixel h, pixel g can be selected as a verification pixel, the sum of the weights of pixel b, pixel c, pixel d, pixel f, pixel g, and pixel h, as well as the proportion of pixel b in the sum of weights, the proportion of pixel c in the sum of weights, the proportion of pixel d in the sum of weights, the proportion of pixel f in the sum of weights, and the proportion of pixel h in the sum of weights are calculated, and information on the weights of each of pixel b, pixel c, pixel d, pixel f, pixel g, and pixel h is deleted, and the calculated sum of weights, the proportion of pixel b in the sum of weights, the proportion of pixel c in the sum of weights, the proportion of pixel d in the sum of weights, the proportion of pixel f in the sum of weights, and the proportion of pixel h in the sum of weights are stored in the information of pixel g (i.e., the verification pixel). The same method is used to process the remaining verification pixel groups. In one embodiment, after all verification pixel groups are processed, the information of each pixel to be verified is saved in a sampled static image in arraybuffer format. The above-mentioned division of the verification pixel groups can also be based on the diagonal rule, that is, the verification pixel groups are determined from the pixel points at the diagonal positions of the pixel points.

[0084] In one embodiment, the calculation formula of the weight sum(X,Y) of each pixel point can be:

[0085]

[0086] Where x and y represent the horizontal and vertical coordinates of the pixel, respectively, and image represents the color information of the pixel. The calculation formula of the area of ​​each pixel sqsum(X,Y) can be:

[0087]

[0088] The formula for calculating the weight of a rectangle containing one or more pixels, titled(X,Y), can be:

[0089]

[0090] Known x 3 ≤x≤x 1 And y 3 ≤y≤y 1 The weight of the rectangle, x 3 ≤x≤x 2 And y 3 ≤y≤y 2 The weight of the rectangle, x 3 ≤x≤x 1 And y 3 ≤y≤y 2 The weight of the rectangle, x 3 ≤x≤x 2 And y 3 ≤y≤y 1 The weight of the rectangle, then x 1 ≤x≤x 2 And y 1 ≤y≤y 2 The calculation formula for the weight of the rectangle can be:

[0091]

[0092] Among them, x 3 <x 1 <x 2 .

[0093] In one embodiment, a sampled static image of a set format is restored and calculated using a color palette to generate a static image of a set format. Specifically, for each sampled pixel group, a color value corresponding to the sum of weights of all pixels in the sampled pixel group (i.e., the sum of first weights) is obtained using the color palette, and the proportions corresponding to each pixel other than the sampled pixel are multiplied by the color value corresponding to the sum of the first weights to obtain the color value corresponding to each pixel other than the sampled pixel, and the color value corresponding to all pixels in the sampled pixel group other than the sampled pixel is subtracted from the color value corresponding to the sum of the first weights to obtain the color value of the sampled pixel; based on the color values ​​corresponding to each pixel other than the sampled pixel in each sampled pixel group and the color values ​​of the sampled pixel, the sampled static image of the set format is restored to generate a static image of the set format. For example, in a static sampling picture in png format, taking Table 1 as an example, for a sampling pixel group including pixel a, pixel b, pixel e, and pixel f, after sampling, the information of pixel f (i.e., the sampling pixel) includes the sum of the weights of pixel a, pixel b, pixel e, and pixel f, as well as the proportion of pixel a in the sum of the weights, the proportion of pixel b in the sum of the weights, and the proportion of pixel e in the sum of the weights. When performing restoration calculation, the color value corresponding to the sum of weights is obtained through the palette in the libpng library, and the color value corresponding to the sum of weights is multiplied by the proportion of pixel a in the sum of weights to obtain the color value of pixel a, and the color value corresponding to the sum of weights is multiplied by the proportion of pixel b in the sum of weights to obtain the color value of pixel b, and the color value corresponding to the sum of weights is multiplied by the proportion of pixel e in the sum of weights to obtain the color value of pixel e, and the color value of pixel a, pixel b, and pixel e are subtracted from the color value corresponding to the sum of weights to obtain the color value of pixel f. The same method is used to perform restoration calculation for the remaining sampled pixel groups. After the restoration calculation of all sampled pixel groups is completed, a static image in png format is obtained according to the color value of each pixel.

[0094] In one embodiment, for the pixel to be verified, the color value of the verification pixel is updated through the verification information. Specifically, for each verification pixel group of the pixel to be verified, the verification color value corresponding to the sum of the weights of all the pixels in the verification pixel group (i.e., the sum of the second weights) is obtained through the color palette, and the weights corresponding to each pixel except the verification pixel are multiplied by the verification color value corresponding to the sum of the second weights to obtain the verification color value corresponding to each pixel except the verification pixel, and the verification color value corresponding to all the pixels in the verification pixel group except the verification pixel is subtracted from the verification color value corresponding to the sum of the second weights to obtain the verification color value of the verification pixel; for each pixel to be verified, the color value of the pixel to be verified and the verification color value of the pixel to be verified are weighted averaged to update the color value of the pixel to be verified according to the obtained weighted average value. In a static sampling image in png format, taking Table 1 as an example, for pixel b, a color value can be obtained in the sampling pixel group including pixel a, pixel b, pixel e, and pixel f, and a color value (i.e., verification color value) can be obtained in the verification pixel group including pixel b, pixel c, pixel d, pixel f, pixel g, and pixel h. The two color values ​​are weighted averaged to update the color value of pixel b.

[0095] In one embodiment, according to the dynamic image generation parameters, the static images of the set format corresponding to each static image are combined through the libpng library to generate a dynamic portable network graphic to obtain a dynamic image. Specifically, according to the standard of the libpng library, each png format static image is input into the libpng library, and is configured according to the image height, image width, number of static images and the time interval between two static images to generate a png format dynamic image.

[0096] Figure 3 This is a second flow chart of a method for generating a dynamic image according to an embodiment of the present invention.

[0097] like Figure 3As shown, input the model and configuration parameters, input the configuration parameters and calculate the static image capture parameters and dynamic image generation parameters. Create a scene and create a camera, add lights to the scene, parse the 3D model and add it to the scene, add a renderer and a manipulator. Create a canvas, rotate the model through the manipulator, intercept the canvas to obtain a static image in arraybuffer format, save the canvas, including saving the static image in arraybuffer format, process the static image in arraybuffer format, and obtain a sampled static image in png format. Determine whether the number of generated pngs (that is, the number of sampled static images in png format) is less than the input number (that is, the number of static images in the static image capture parameter). If not, continue to rotate the model through the manipulator to generate sampled static images in png format until the number of sampled static images in png format reaches the number of static images in the static image capture parameter. Generate a dynamic image in apng format based on each sampled static image in png format.

[0098] Figure 4 It is a schematic diagram of a rendering process according to an embodiment of the present invention.

[0099] like Figure 4 As shown, after rotating the 3D model, create a canvas according to the pixel height and pixel width of the static image, determine whether the current canvas and model support webGL2, if so, obtain the webGL2 context, if not, obtain the webGL1 context. Set the viewport size, create and bind the buffer, upload data to the GPU, create a matrix, create a vertex shader and a fragment shader, create a program and bind the program to the shader, draw the image source, and obtain a static image in arraybuffer format. Among them, webGL (Web Graphics Library) is a 3D drawing protocol, webGL1 and webGL2 are two versions of webGL respectively. The rendering process is the same as the conventional image rendering process, and the embodiment of the present invention will not be described in detail.

[0100] In one embodiment, the configuration parameters also include the interception x-axis offset and the interception y-axis offset input by the user. By default, the coordinates of the upper left corner of the canvas are the coordinate origin, and the offset is the distance from the upper left corner of the canvas. According to the interception x-axis offset and the interception y-axis offset, part of the canvas pixels can be intercepted. If the offsets are all 0, the entire canvas pixels are intercepted.

[0101] Figure 5 4 is a schematic diagram of main modules of a dynamic picture generating device according to an embodiment of the present invention.

[0102] like Figure 5 As shown, a dynamic picture generating device 500 according to an embodiment of the present invention mainly includes: a static picture capturing module 501 , a sampling module 502 , and a dynamic picture generating module 503 .

[0103] The static image capture module 501 is used to rotate the 3D model according to the static image capture parameters, and capture multiple static images of the 3D model during the rotation process. The static image capture parameters include the model rotation angle, and a static image is captured every time the 3D model rotates by the model rotation angle.

[0104] The sampling module 502 is used to sample each static image of the 3D model according to a preset sampling algorithm after the static image is captured, so as to obtain a corresponding sampled static image.

[0105] The dynamic image generation module 503 is used to obtain a dynamic image of the 3D model by combining the sampled static images corresponding to the static images.

[0106] In one embodiment, the static image capture parameters may further include the number of static images, the pixel width and pixel height of the static images.

[0107] In one embodiment, a parameter calculation module may also be included, which is used to: obtain configuration parameters, the configuration parameters include the configured number of dynamic image frames, image height, image width, and pixel density; subtract 1 from the number of dynamic image frames to obtain the number of static images; calculate the difference between the number of static images and 1, and divide the difference by the preset total model rotation angle to calculate the angle between the two static images as the model rotation angle; multiply the image height and image width by the pixel density respectively to obtain the pixel height and pixel width of the static image.

[0108] In one embodiment, the rotation process may be stopped when the number of captured static images reaches the number of static images, or when the angle of rotation of the 3D model reaches a preset total rotation angle of the model.

[0109] In one embodiment, the static image capture module 501 is specifically used for: creating a canvas based on the pixel width and pixel height every time the 3D model is rotated by an angle, drawing the 3D model into the canvas, and obtaining pixel information from the canvas to form a typed array file corresponding to the static image; the sampling module 502 is specifically used for: sampling the typed array file according to the diagonal weight sampling method to obtain a sampled typed array file, and the sampled typed array file is the typed array file of the static image after sampling.

[0110] In one embodiment, the sampling module 502 is specifically used to: divide all pixel points in the typed array file into one or more sampling pixel groups according to a preset rule; for each sampling pixel group, select a pixel point as the sampling pixel point of the sampling pixel group, calculate the sum of the first weights of all pixel points in the sampling pixel group, and respectively calculate the proportion of the weight of each pixel point other than the sampling pixel point to the sum of the first weights, delete the weights of all pixel points, and save the proportion corresponding to each pixel point other than the sampling pixel point and the sum of the first weights to the information of the sampling pixel point; and obtain the sampled typed array file according to the information of each sampling pixel point.

[0111] In one embodiment, the dynamic image generation module 503 is specifically used for: transcoding the sampled static image to obtain a sampled static image of a set format; performing restoration calculation on the sampled static image of a set format through a color palette to generate a static image of a set format; and obtaining a dynamic image of a 3D model based on a combination of static images of a set format.

[0112] In one embodiment, the dynamic image generation module 503 is specifically used to: for each sampling pixel group, obtain the color value corresponding to the sum of the first weights through the color palette, multiply the proportions corresponding to each pixel point other than the sampling pixel point by the color value corresponding to the sum of the first weights, to obtain the color value corresponding to each pixel point other than the sampling pixel point, subtract the color value corresponding to all the pixels in the sampling pixel group other than the sampling pixel point from the color value corresponding to the sum of the first weights, to obtain the color value of the sampling pixel point; based on the color values ​​corresponding to each pixel point other than the sampling pixel point in each sampling pixel group and the color values ​​of the sampling pixel points, restore the sampled static image of the set format to generate a static image of the set format.

[0113] In one embodiment, the sampled typed array file may further include information of verification pixels; the sampling module 502 is specifically used to: determine one or more verification pixel groups from the typed array file according to predetermined pixels to be verified, the pixels to be verified are sampling pixels in the sampling pixel group or pixels other than the sampling pixels, and the verification pixel group includes the pixels to be verified; for each verification pixel group, select a pixel as the verification pixel of the verification pixel group, calculate the sum of the second weights of all pixels in the verification pixel group, and calculate the proportion of the weight of each pixel other than the verification pixel to the sum of the second weights, delete the weight information of all pixels, and save the proportion corresponding to each pixel other than the verification pixel and the sum of the second weights to the information of the verification pixel.

[0114] In one embodiment, the sampling module 502 is specifically used for: for each verification pixel group of the pixel points to be verified, obtaining the verification color value corresponding to the sum of the second weights through the color palette, multiplying the proportions corresponding to each pixel point except the verification pixel point by the verification color value corresponding to the sum of the second weights, obtaining the verification color value corresponding to each pixel point except the verification pixel point, subtracting the verification color value corresponding to all the pixels except the verification pixel point in the verification pixel group from the verification color value corresponding to the sum of the second weights, obtaining the verification color value of the verification pixel point; for each pixel point to be verified, weightedly averaging the color value of the pixel point to be verified and the verification color value of the pixel point to be verified, so as to update the color value of the pixel point to be verified according to the obtained weighted average value, wherein the verification color value of the pixel point to be verified is the verification color value corresponding to the pixel point except the verification pixel point or the verification color value of the verification pixel point.

[0115] In one embodiment, the configuration parameters may also include the duration of the dynamic image; the dynamic image generation module 503 is specifically used to: according to the dynamic image generation parameters, combine the static images of the set format corresponding to each static image through the libpng library to generate a dynamic portable network graphic, so as to obtain a dynamic image of the 3D model, and the dynamic image generation parameters include: image height, image width, number of static images and time interval between two static images, and the time interval between two static images is equal to the duration of the dynamic image divided by the number of static images.

[0116] In addition, the specific implementation content of the dynamic picture generation device in the embodiment of the present invention has been described in detail in the above dynamic picture generation method, so the repeated content will not be described again here.

[0117] Figure 6 An exemplary system architecture 600 is shown to which the dynamic picture generation method or dynamic picture generation device according to the embodiment of the present invention can be applied.

[0118] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0119] Users can use terminal devices 601, 602, and 603 to interact with server 605 through network 604 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 601, 602, and 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).

[0120] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0121] The server 605 may be a server that provides various services, such as a background management server (only an example) that provides support for websites browsed by users using the terminal devices 601, 602, and 603. The background management server may analyze and process the received data such as the image generation request, and feed back the processing results (such as animated images - only an example) to the terminal device.

[0122] It should be noted that the dynamic image generation method provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the dynamic image generation device is generally arranged in the server 605 .

[0123] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0124] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 7 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0125] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0126] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.

[0127] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.

[0128] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-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 of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer 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 of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0129] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0130] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be provided in a processor, for example, may be described as: a processor including a static image capture module, a sampling module, and a dynamic image generation module. The names of these modules do not constitute limitations on the modules themselves in certain circumstances. For example, the sampling module may also be described as "a module for sampling each static image of a 3D model according to a preset sampling algorithm to obtain a corresponding sampled static image after the image is captured".

[0131] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device includes: rotating the 3D model according to the static picture capture parameters, and capturing multiple static pictures of the 3D model during the rotation process. The static picture capture parameters include the model rotation angle, wherein a static picture is captured for each rotation of the 3D model by the model rotation angle; after capturing each static picture of the 3D model, sampling each captured static picture according to a preset sampling algorithm to obtain a corresponding sampled static picture; and combining the sampled static pictures corresponding to each static picture to obtain a dynamic picture of the 3D model.

[0132] According to the technical solution of the embodiment of the present invention, the 3D model is rotated according to the static picture interception parameters, and multiple static pictures of the 3D model are intercepted during the rotation process. The static picture interception parameters include the model rotation angle, wherein a static picture is intercepted for each rotation of the 3D model by the model rotation angle; after each static picture of the 3D model is intercepted, each intercepted static picture is sampled according to a preset sampling algorithm to obtain a corresponding sampled static picture; and a dynamic picture of the 3D model is obtained by combining the sampled static pictures corresponding to each static picture. The 3D model can be converted into a dynamic picture in apng format, which reduces the volume of the dynamic picture, has high conversion efficiency, and is easy to operate.

[0133] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for generating a dynamic picture, characterized in that: include: Rotating the 3D model according to static image capture parameters, and capturing multiple static images of the 3D model during the rotation process, wherein the static image capture parameters include a model rotation angle, a pixel width, and a pixel height of the static image; Each time the 3D model is rotated by the model rotation angle, a static picture is captured, including: each time the 3D model is rotated by the model rotation angle, a canvas is created based on the pixel width and the pixel height, the 3D model is drawn into the canvas, and pixel information is obtained from the canvas to form a typed array file corresponding to the static picture; After each static picture of the 3D model is intercepted, each of the intercepted static pictures is sampled according to a preset sampling algorithm to obtain a corresponding sampled static picture, including: sampling the typed array file according to a diagonal weight sampling method to obtain a sampled typed array file, wherein the sampled typed array file is a typed array file corresponding to the sampled static picture; The dynamic image of the 3D model is obtained by combining the sampled static images corresponding to the static images.

2. The method according to claim 1, characterized in that The static image capture parameters also include the number of static images; Before rotating the 3D model according to the static image capture parameters, the method includes: Obtain configuration parameters, including the number of frames of the configured dynamic picture, picture height, picture width, and pixel density; Subtract 1 from the number of frames of the dynamic image to obtain the number of static images; Calculate the difference between the number of static images and 1, and divide the difference by the preset total model rotation angle to calculate the angle between the two static images as the model rotation angle; The image height and the image width are respectively multiplied by the pixel density to obtain the pixel height and pixel width of the static image.

3. The method according to claim 2, characterized in that When the number of the captured static images reaches the number of static images, or the angle of rotation of the 3D model reaches the preset total rotation angle of the model, the rotation process is stopped.

4. The method according to claim 1, characterized in that The step of sampling the typed array file according to the diagonal weight sampling method to obtain the sampled typed array file comprises: According to a preset rule, all pixels in the typed array file are divided into one or more sampling pixel groups; For each sampling pixel group, select a pixel point as the sampling pixel point of the sampling pixel group, calculate the sum of the first weights of all the pixels in the sampling pixel group, and respectively calculate the proportion of the weight of each pixel point other than the sampling pixel point to the sum of the first weights, delete the weights of all the pixels, and save the proportion corresponding to each pixel point other than the sampling pixel point and the sum of the first weights in the information of the sampling pixel point; The sampled typed array file is obtained according to the information of each sampled pixel point.

5. The method according to claim 4, characterized in that The dynamic image of the 3D model is obtained by combining the sampled static images corresponding to the static images, including: Transcoding the sampled static image to obtain a sampled static image in a set format; Performing restoration calculation on the sampled static image of the set format through the color palette to generate a static image of the set format; The dynamic image of the 3D model is obtained based on the combination of static images in the set format.

6. The method according to claim 5, characterized in that The restoring calculation of the sampled static image of the set format by using the color palette to generate the static image of the set format includes: For each sampling pixel group, a color value corresponding to the sum of the first weights is obtained by using a color palette, the proportions corresponding to each pixel point other than the sampling pixel point are multiplied by the color value corresponding to the sum of the first weights to obtain a color value corresponding to each pixel point other than the sampling pixel point, and the color value corresponding to all pixels in the sampling pixel group other than the sampling pixel point is subtracted from the color value corresponding to the sum of the first weights to obtain a color value of the sampling pixel point; Based on the color values ​​corresponding to each pixel point other than the sampling pixel point in each sampling pixel group and the color value of the sampling pixel point, the sampled static image of the set format is restored to generate the static image of the set format.

7. The method according to claim 6, characterized in that The sampled typed array file also includes information of verification pixels; The method of sampling the typed array file according to the diagonal weight sampling method to obtain the sampled typed array file further includes: According to predetermined pixels to be verified, one or more verification pixel groups are determined from the typed array file, wherein the pixels to be verified are the sampling pixels in the sampling pixel group or pixels other than the sampling pixels, and the verification pixel group includes the pixels to be verified; For each verification pixel group, select a pixel point as the verification pixel point of the verification pixel group, calculate the sum of the second weights of all pixels in the verification pixel group, and calculate the proportion of the weight of each pixel point except the verification pixel point to the sum of the second weights, delete the weight information of all pixels, and save the proportion corresponding to each pixel point except the verification pixel point and the sum of the second weights to the information of the verification pixel point.

8. The method according to claim 7, characterized in that The method further comprises: restoring the sampled static image of the set format based on the color values ​​corresponding to each pixel point other than the sampled pixel point in each sampled pixel group and the color value of the sampled pixel point to generate the static image of the set format, comprising: For each verification pixel group of the pixel to be verified, obtain a verification color value corresponding to the sum of the second weights through a color palette, multiply the proportions corresponding to each pixel except the verification pixel by the verification color value corresponding to the sum of the second weights, respectively, to obtain a verification color value corresponding to each pixel except the verification pixel, and subtract the verification color values ​​corresponding to all pixels except the verification pixel in the verification pixel group from the verification color value corresponding to the sum of the second weights to obtain a verification color value of the verification pixel; For each pixel to be verified, a weighted average is performed on the color value of the pixel to be verified and the verification color value of the pixel to be verified, so as to update the color value of the pixel to be verified according to the obtained weighted average value, wherein the verification color value of the pixel to be verified is the verification color value corresponding to the pixel other than the verification pixel or the verification color value of the verification pixel.

9. The method according to claim 5, characterized in that The configuration parameters also include dynamic picture duration; The step of obtaining the dynamic image of the 3D model by combining the static images in the set format includes: According to the dynamic picture generation parameters, the static pictures of the set format corresponding to each static picture are combined through the libpng library to generate a dynamic portable network graphic to obtain the dynamic picture of the 3D model. The dynamic picture generation parameters include: the picture height, the picture width, the number of static pictures and the time interval between two static pictures. The time interval between two static pictures is equal to the duration of the dynamic picture divided by the number of static pictures.

10. A dynamic picture generating device, characterized in that: include: A static picture capture module, used to rotate the 3D model according to static picture capture parameters, and capture multiple static pictures of the 3D model during the rotation process, wherein the static picture capture parameters include a model rotation angle, a pixel width and a pixel height of the static picture, wherein a static picture is captured each time the 3D model rotates by the model rotation angle; A sampling module, for sampling each static image of the 3D model according to a preset sampling algorithm after the static image is captured, to obtain a corresponding sampled static image; A dynamic picture generation module, used for combining the sampled static pictures corresponding to the static pictures to obtain the dynamic picture of the 3D model; The static picture capture module is further used for: creating a canvas based on the pixel width and the pixel height every time the 3D model rotates by the model rotation angle, drawing the 3D model into the canvas, and acquiring pixel information from the canvas to form a typed array file corresponding to the static picture; The sampling module is also used to: sample the typed array file according to the diagonal weight sampling method to obtain a sampled typed array file, and the sampled typed array file is a typed array file corresponding to the sampled static picture.

11. The device according to claim 10, characterized in that The static image capture parameters also include the number of static images; Also included are parameter calculation modules for: Obtain configuration parameters, including the number of frames of the configured dynamic picture, picture height, picture width, and pixel density; Subtract 1 from the number of frames of the dynamic image to obtain the number of static images; Calculate the difference between the number of static images and 1, and divide the difference by the preset total model rotation angle to calculate the angle between the two static images as the model rotation angle; The image height and the image width are respectively multiplied by the pixel density to obtain the pixel height and pixel width of the static image.

12. The device according to claim 11, characterized in that When the number of the captured static images reaches the number of static images, or the angle of rotation of the 3D model reaches the preset total rotation angle of the model, the rotation process is stopped.

13. The device according to claim 10, characterized in that The sampling module is also used for: According to a preset rule, all pixels in the typed array file are divided into one or more sampling pixel groups; For each sampling pixel group, select a pixel point as the sampling pixel point of the sampling pixel group, calculate the sum of the first weights of all the pixels in the sampling pixel group, and respectively calculate the proportion of the weight of each pixel point other than the sampling pixel point to the sum of the first weights, delete the weights of all the pixels, and save the proportion corresponding to each pixel point other than the sampling pixel point and the sum of the first weights in the information of the sampling pixel point; The sampled typed array file is obtained according to the information of each sampled pixel point.

14. The device according to claim 13, characterized in that The dynamic picture generation module is also used for: Transcoding the sampled static image to obtain a sampled static image in a set format; Performing restoration calculation on the sampled static image of the set format through the color palette to generate a static image of the set format; The dynamic image of the 3D model is obtained based on the combination of static images in the set format.

15. The device according to claim 14, characterized in that The dynamic picture generation module is also used for: For each sampling pixel group, a color value corresponding to the sum of the first weights is obtained by using a color palette, the proportions corresponding to each pixel point other than the sampling pixel point are multiplied by the color value corresponding to the sum of the first weights to obtain a color value corresponding to each pixel point other than the sampling pixel point, and the color value corresponding to all pixels in the sampling pixel group other than the sampling pixel point is subtracted from the color value corresponding to the sum of the first weights to obtain a color value of the sampling pixel point; Based on the color values ​​corresponding to each pixel point other than the sampling pixel point in each sampling pixel group and the color value of the sampling pixel point, the sampled static image of the set format is restored to generate the static image of the set format.

16. The device according to claim 15, characterized in that The sampled typed array file also includes information of verification pixels; The sampling module is also used for: According to predetermined pixels to be verified, one or more verification pixel groups are determined from the typed array file, wherein the pixels to be verified are the sampling pixels in the sampling pixel group or pixels other than the sampling pixels, and the verification pixel group includes the pixels to be verified; For each verification pixel group, select a pixel point as the verification pixel point of the verification pixel group, calculate the sum of the second weights of all pixels in the verification pixel group, and calculate the proportion of the weight of each pixel point except the verification pixel point to the sum of the second weights, delete the weight information of all pixels, and save the proportion corresponding to each pixel point except the verification pixel point and the sum of the second weights to the information of the verification pixel point.

17. The device according to claim 16, characterized in that The sampling module is also used for: For each verification pixel group of the pixel to be verified, obtain a verification color value corresponding to the sum of the second weights through a color palette, multiply the proportions corresponding to each pixel except the verification pixel by the verification color value corresponding to the sum of the second weights, respectively, to obtain a verification color value corresponding to each pixel except the verification pixel, and subtract the verification color values ​​corresponding to all pixels except the verification pixel in the verification pixel group from the verification color value corresponding to the sum of the second weights to obtain a verification color value of the verification pixel; For each pixel to be verified, a weighted average is performed on the color value of the pixel to be verified and the verification color value of the pixel to be verified, so as to update the color value of the pixel to be verified according to the obtained weighted average value, wherein the verification color value of the pixel to be verified is the verification color value corresponding to the pixel other than the verification pixel or the verification color value of the verification pixel.

18. The device according to claim 14, characterized in that The configuration parameters also include dynamic picture duration; The dynamic picture generation module is also used for: According to the dynamic picture generation parameters, the static pictures of the set format corresponding to each static picture are combined through the libpng library to generate a dynamic portable network graphic to obtain the dynamic picture of the 3D model. The dynamic picture generation parameters include: the picture height, the picture width, the number of static pictures and the time interval between two static pictures. The time interval between two static pictures is equal to the duration of the dynamic picture divided by the number of static pictures.

19. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 9.

20. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Method and device for generating dynamic image

    CN113450434A