Video generation method, device, electronic device and storage medium
By calculating the longitudinal texture coordinate offset of the image to generate a distorted video transition effect, the problem of blunt video transition effects in the existing technology is solved, and the visual beauty and user experience are improved.
Patent Information
- Application Number
- CN202211710296.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-12-29
AI Technical Summary
The existing video transition animation effect is stiff, lacks visual beauty, and cannot satisfy the user's visual experience.
By obtaining the longitudinal texture coordinates of the image to be processed, calculating and offsetting its transverse texture coordinates, multiple target distorted images are generated, thereby creating a distorted video transition effect and enhancing the visual beauty of the video transition effects.
It improves the visual beauty of video transition effects, enhances the user's visual experience, and reduces the stiffness of transition animations.
Smart Images

Figure CN117745888B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a video generation method, device, electronic device and storage medium. Background Art
[0002] With the development of the Internet, short videos are becoming more and more popular. More and more users are starting to make and share short videos on social platforms. When making videos, various special effects are added to increase the aesthetics. For example, special effects are added to the entry and exit transition animations of the video. However, the current entry and exit transition animations are generally regular motion changes. For example, the image required for the transition is only entered horizontally, exited horizontally, etc. The final effect is that the image is only entered or exited horizontally in a regular shape (such as a rectangle, a square, etc.). This method makes the transition animation finally presented by the video relatively stiff and lacks visual beauty, and thus cannot satisfy the user's visual experience. Therefore, how to enhance the visual beauty of video transition special effects and improve the user's visual experience is a problem that needs to be solved urgently. Summary of the invention
[0003] The embodiments of the present application provide a video generation method, device, electronic device and storage medium, which enhance the visual beauty of video transition effects and improve the user's visual experience.
[0004] In a first aspect, an embodiment of the present application provides a video generation method, the method comprising:
[0005] Get the image to be processed;
[0006] Determine a first offset corresponding to a transverse texture coordinate of each pixel point in the image to be processed based on the longitudinal texture coordinate of each pixel point in the image to be processed;
[0007] Get multiple second offsets;
[0008] Based on the first offset and the plurality of second offsets corresponding to the horizontal texture coordinates of each pixel point, the horizontal texture coordinates of each pixel point are offset respectively to obtain a plurality of target distorted images, wherein the plurality of target distorted images correspond to the plurality of second offsets one by one, and each second offset is used to control the position of the target distorted image corresponding to the second offset in the target distorted video;
[0009] Generate a target warped video based on multiple target warped images.
[0010] In a second aspect, an embodiment of the present application provides a video generating device, the device comprising: an acquiring unit and a processing unit;
[0011] An acquisition unit, used for acquiring an image to be processed;
[0012] A processing unit, configured to determine a first offset corresponding to a transverse texture coordinate of each pixel point in the image to be processed based on a longitudinal texture coordinate of each pixel point in the image to be processed;
[0013] The acquisition unit is further used to acquire a plurality of second offsets;
[0014] The processing unit is further used to offset the horizontal texture coordinates of each pixel point based on the first offset and multiple second offsets corresponding to the horizontal texture coordinates of each pixel point, so as to obtain multiple target distorted images, wherein the multiple target distorted images correspond to the multiple second offsets one by one, and each second offset is used to control the position of the target distorted image corresponding to the second offset in the target distorted video;
[0015] The processing unit is further used to generate a target distorted video based on a plurality of target distorted images.
[0016] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, the processor being connected to the memory, the memory being used to store a computer program, and the processor being used to execute the computer program stored in the memory, so that the electronic device executes the method of the first aspect.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program enables a computer to execute the method of the first aspect.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and is computer-operable to cause the computer to execute the method of the first aspect.
[0019] Implementing the embodiments of the present application has the following beneficial effects:
[0020] By obtaining an image to be processed; then based on the longitudinal texture coordinates of each pixel in the image to be processed, determining the first offset corresponding to the transverse texture coordinates of each pixel in the image to be processed; obtaining multiple second offsets; then based on the first offset and multiple second offsets corresponding to the transverse texture coordinates of each pixel, offset the transverse texture coordinates of each pixel respectively, to obtain multiple target distorted images, wherein the multiple target distorted images correspond to the multiple second offsets one by one, and each second offset is used to control the position of the target distorted image corresponding to the second offset in the target distorted video; based on the multiple target distorted images, generate a target distorted video. By offsetting the transverse texture coordinates of each pixel in the image to be processed respectively based on the first offset and multiple second offsets corresponding to the transverse texture coordinates of each pixel, multiple target distorted images are obtained, and then a target distorted video is generated based on the multiple target distorted images, wherein the target distorted video can be understood as a distorted transition animation special effect, which increases the visual beauty of the video transition special effect and improves the user's visual experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0022] Figure 1 A schematic diagram of a flow chart of a video generation method provided in an embodiment of the present application;
[0023] Figure 2 A schematic diagram of performing center scaling on an image to be processed to obtain a sixth image provided by an embodiment of the present application;
[0024] Figure 3 A schematic diagram of another method of performing center scaling on an image to be processed to obtain a sixth image provided by an embodiment of the present application;
[0025] Figure 4 A schematic diagram of obtaining a target distorted image a based on an image to be processed provided in an embodiment of the present application;
[0026] Figure 5 A schematic diagram of a target distorted image b provided in an embodiment of the present application;
[0027] Figure 6 A schematic diagram of determining a target pixel point whose texture coordinates exceed a texture coordinate range in a target distorted image b provided by an embodiment of the present application;
[0028] Figure 7A schematic diagram of obtaining a second image c according to a target distorted image c provided in an embodiment of the present application;
[0029] Figure 8 A schematic diagram of obtaining a third image d according to a target distorted image d and a rough edge texture image provided by an embodiment of the present application;
[0030] Fig. 9 A schematic diagram of obtaining a fifth image e according to a target distorted image e and a noisy dark corner image provided in an embodiment of the present application;
[0031] Fig.10 A block diagram of the functional units of a video generation device provided in an embodiment of the present application;
[0032] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0034] The terms "first", "second", "third" and "fourth" etc. in the specification, claims and drawings of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0035] Reference to "embodiments" herein means that a particular feature, result, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0036] See also Figure 1 , Figure 1 A schematic flow chart of a video generation method provided in an embodiment of the present application, the method includes but is not limited to steps 101-105:
[0037] 101: Obtain the image to be processed.
[0038] It should be noted that the image to be processed can be a frame image in a video or a single frame image; and the image to be processed can be a single frame image obtained from other devices or a frame image in a video, or it can be a single frame image locally stored in a video generating device or a frame image in a video.
[0039] In an optional embodiment, the image to be processed can be scaled in the center, specifically: the texture coordinates of each pixel in the image to be processed are translated in a first direction; then the scaling factor is determined based on the scale of the image to be processed; then the second texture coordinates of each pixel in the image to be processed are determined based on the scaling factor and the texture coordinates of each pixel in the image to be processed after the texture coordinates are translated in the first direction; then the second texture coordinates of each pixel in the image to be processed are translated in a second direction to obtain a sixth image, wherein the first direction and the second direction are relative directions; finally, the sixth image is re-determined as the image to be processed. For example, see Figure 2 , Figure 2 A schematic diagram of a sixth image obtained by centering and scaling an image to be processed provided in an embodiment of the present application, wherein the texture coordinate system of the image to be processed is constructed as follows: Figure 2 As shown, the texture coordinates of five pixels are A(0,0), B(0,1), C(1,1), D(1,0), and E(0.5,0.5). Then, the texture coordinates of each pixel in the image to be processed are subtracted by 0.5, that is, the horizontal texture coordinates of each pixel are translated to the left by 0.5, and the vertical texture coordinates of each pixel are translated downward by 0.5, so as to obtain the image a to be processed. In other words, A1(0,0), B1(0,1), C1(1,1), D1(1,0), and E1(0.5,0.5) of the image to be processed correspond to A(0,0), B(0,1), C(1,1), D(1,0), and E(0.5,0.5) of the image to be processed, respectively. In other words, the texture pixels corresponding to the multiple pixels A, B, C, D, and E in the image to be processed are respectively mapped to the corresponding pixels in the image to be processed in the image a to be processed.
[0040] Then, assuming that the scaling factor of the image to be processed is 1.2, the texture coordinates of each pixel in the image to be processed a are multiplied by 1.2 to obtain the image to be processed b. It should be noted that when the texture coordinates of each pixel in the image to be processed a are multiplied by 1.2, it can be understood that A1(0,0), B1(0,1), C1(1,1), and D1(1,0) in the image to be processed a are changed to A1'(0,0), B1'(0,1.2), C1'(1.2,1.2), and D1'(1.2,0) in the texture coordinate system of the image to be processed b, respectively. The image to be processed b is The rectangular area enclosed by A2(0,0), B2(0,1), C2(1,1), and D2(1,0) means that the image b to be processed is reduced compared to the image a to be processed which is enclosed by A1'(0,0), B1'(0,1.2), C1'(1.2,1.2), and D1'(1.2,0), and A2(0,0), B2(0,1), C2(1,1), and D2(1,0) in the image b to be processed correspond to A1'(0,0), B1'(0,1.2), C1'(1.2,1.2), and D1'(1.2,0), respectively. Then add 0.5 to the texture coordinates of each pixel in the image b to be processed, that is, translate the horizontal texture coordinates of each pixel in the image b to be processed to the right by 0.5, and translate the vertical texture coordinates of each pixel upward by 0.5, to obtain the sixth image, that is, the rectangle surrounded by A3, B3, C3, and D3, and then the sixth image can be re-determined as the image to be processed. For easier understanding, refer to Figure 3 , Figure 3 Another schematic diagram of performing center scaling on an image to be processed to obtain a sixth image provided by an embodiment of the present application is as follows: Figure 3 As shown, the image to be processed is scaled in the center to obtain Figure 3 The sixth image in the image can then be re-determined as the image to be processed.
[0041] 102: Determine a first offset corresponding to a transverse texture coordinate of each pixel point in the image to be processed based on the longitudinal texture coordinate of each pixel point in the image to be processed.
[0042] In an optional embodiment, step 102 may be specifically as follows: according to the target curve function and the longitudinal texture coordinates of each pixel point, a first offset corresponding to the transverse texture coordinates of each pixel point is obtained. Exemplarily, the target curve function may be a sine function, a cosine function, a tangent function, etc. When the target curve function is a sine function, a first coefficient and a second coefficient are obtained, wherein the first coefficient and the second coefficient are both used to control the phase shift and period of the sine function, and then the sine function is used to process the first coefficient, the second coefficient and the longitudinal texture coordinates of each pixel point to determine the first offset corresponding to the transverse texture coordinates of each pixel point, wherein the first offset of the i-th pixel point may be obtained by formula (1):
[0043] K i =αsin[π / a*(1-b*y i )+0.5π](1)
[0044] Among them, K i Indicates the first offset of the i-th pixel, a is the first coefficient, b is the second coefficient, y i represents the vertical texture coordinate of the i-th pixel, and α is a constant. Therefore, from formula (1), we can know that the period controlled by the first coefficient and the second coefficient is The phase shift controlled by the first coefficient and the second coefficient is
[0045] 103: Get multiple second offsets.
[0046] Among them, multiple second offsets can be preset and set by the user according to actual needs.
[0047] 104: Based on the first offset and multiple second offsets corresponding to the horizontal texture coordinates of each pixel point, offset the horizontal texture coordinates of each pixel point to obtain multiple target distorted images.
[0048] Among them, multiple target distorted images correspond one-to-one to multiple second offsets, and each second offset is used to control the position of the target distorted image corresponding to the second offset in the target distorted video, or it can be understood that when the target distorted video is an entry transition video or an exit transition video, each second offset is used to control the position of the target distorted image corresponding to the second offset in the entry transition video or the exit transition video.
[0049] In an optional embodiment, step 104 may specifically be: first, based on the first offset and the plurality of second offsets corresponding to the horizontal texture coordinate of each pixel, a plurality of first horizontal texture coordinates of each pixel are obtained, wherein the plurality of first horizontal texture coordinates and the plurality of second offsets correspond one to one. For example, the nth first horizontal texture coordinate of the ith pixel may be: V in =(x i +P i -K i ), where V in Indicates the nth first horizontal texture coordinate of the ith pixel, x i represents the horizontal texture coordinate of the i-th pixel, K i Indicates the first offset of the i-th pixel, P i It represents the second offset corresponding to the i-th pixel point. Therefore, for the i-th pixel point, by obtaining multiple second offsets, multiple first horizontal texture coordinates corresponding to the i-th pixel point can be obtained. It should be noted that since the first offset of each pixel point changes according to the motion law of the target curve function (such as a sine function), the multiple first horizontal texture coordinates corresponding to each pixel point also change according to the motion law of the target curve function (such as a sine function), such as presenting a curve change law in the form of a sine function, so as to obtain multiple target distorted images, which increases the visual beauty.
[0050] Then, each first transverse texture coordinate of each pixel and the longitudinal texture coordinate of the pixel in the image to be processed are determined as the first texture coordinate of the pixel, and a plurality of first texture coordinates can be obtained for each pixel. For example, for the i-th pixel, the n-th first texture coordinate of the i-th pixel (i.e., U in V in ) can be (V in ,y i ), where V in Indicates the nth first horizontal texture coordinate of the i-th pixel, y i Represents the longitudinal texture coordinate of the i-th pixel. Finally, the texture pixel corresponding to the texture coordinate of each pixel in the image to be processed is determined as the texture pixel corresponding to each first texture coordinate of the pixel, and a plurality of target warped images are obtained. It should be understood that the plurality of target warped images are continuous in the position of the target warped video, that is, the target warped video can be obtained by splicing and fusing the plurality of target warped images.
[0051] For ease of understanding, based on Figure 3 The sixth image (i.e. the image to be processed) shown is shown in FIG. Figure 4 , Figure 4A schematic diagram of obtaining a target distorted image a based on an image to be processed is provided in an embodiment of the present application, such as Figure 4 As shown, the image to be processed is in the case of center scaling, that is, a rectangular image including the "female figure" surrounded by A4, B4, C4, and D4, and the texture coordinate system is constructed as shown in Figure 4 As shown, based on the first offset and the second offset a corresponding to the horizontal texture coordinates of each pixel in the image to be processed, the first horizontal texture coordinate a of each pixel is obtained, and then the first horizontal texture coordinate a of each pixel and the vertical texture coordinate of the pixel in the image to be processed are determined as the first texture coordinate a of the pixel, and the texture pixel corresponding to the texture coordinate of each pixel in the image to be processed is determined as the texture pixel corresponding to the first texture coordinate a of the pixel, and the target distorted image a is obtained. At this time, A4', C4', and D4' of the target distorted image a correspond to A4, C4, and D4 respectively; wherein the second offset is to control the position of the target distorted image a in the target distorted video, as Figure 4 As shown, the ratio of the target distorted video is 4:3, and the position of the target distorted image a in this 4:3 target distorted video is as follows Figure 4 As shown, Figure 4 The distortion direction of the target distorted image a shown can be understood as horizontal leftward distortion. Therefore, when the distortion directions of the multiple target distorted images generated by the multiple second offset controls are all horizontal leftward distortion, the target distorted video generated based on the multiple target distorted images can be understood as the transition video. Figure 5 , Figure 5 A schematic diagram of a target distorted image b provided in an embodiment of the present application should be explained. The principle of how to generate the target distorted image b can be referred to Figure 4 The example of how to obtain the target distorted image a based on the image to be processed is shown, which will not be repeated; Figure 5 From the target distorted image b shown, it can be known that the distortion direction of the target distorted image b can be understood as horizontal distortion to the right. When the distortion directions of the multiple target distorted images generated by the multiple second offset controls are all horizontal distortion to the right, the target distorted video generated based on the multiple target distorted images can be understood as an exit transition video.
[0052] In an optional embodiment, before generating a target warped video based on multiple target warped images, target pixels whose texture coordinates exceed the texture coordinate range in each target warped image may be determined; then the color value of the target pixel in each target warped image is set to the target color to obtain multiple first images; and finally, the multiple first images are determined as multiple target warped images. Figure 5 The target warped image b is shown, see Figure 6 , Figure 6A schematic diagram of determining a target pixel point whose texture coordinates exceed a texture coordinate range in a target distorted image b provided by an embodiment of the present application is shown in FIG. Figure 6 As shown in the figure, C5(1,1) and D5(0,1) are both pixels within the texture coordinate range. Since the texture coordinate range of the image is 0-1, that is, the horizontal texture coordinate of each pixel is greater than or equal to 0 and less than or equal to 1, and the vertical texture coordinate of each pixel is greater than or equal to 0 and less than or equal to 1, the target pixel whose texture coordinate exceeds the texture coordinate range in the target distorted image b is Figure 6 It should be noted that when the color value of the target pixel in each target distorted image is set to the target color, such as black, it can be understood as performing boundary processing on the target distorted image, which can avoid the pixel value of the target pixel beyond the texture coordinate range from interfering with the target distorted image, thereby increasing the visual beauty of the target distorted video.
[0053] In an optional embodiment, before generating a target distorted video based on a plurality of target distorted images, a plurality of brightness coefficients may be determined, wherein the plurality of brightness coefficients correspond one to one to the plurality of target distorted images; then, for the target distorted image A, according to the first texture pixel corresponding to the first texture coordinate of each pixel point in the target distorted image A and the brightness coefficient corresponding to the target distorted image A, the second texture pixel corresponding to the first texture coordinate of each pixel point in the target distorted image A is determined, for example, the second texture pixel corresponding to the first texture coordinate of each pixel point in the target distorted image A may be the product of the first texture pixel corresponding to the first texture coordinate of the pixel point and the brightness coefficient corresponding to the target distorted image A, wherein the target distorted image A is any one of the plurality of target distorted images; then, the first texture coordinate of each pixel point in each target distorted image is calculated. The second texture pixel corresponding to the target mark and the first texture pixel corresponding to the first texture coordinate of the pixel point are mixed to obtain multiple second images; it should be noted that the brightness coefficient is used to control the brightness of the target distorted image. For example, when the target distorted video is generated by multiple target distorted images that are horizontally twisted to the left and then enter the transition video, the brightness of each target distorted image is adjusted by the brightness coefficient, and then the texture pixels of the corresponding pixel points in the target distorted image with adjusted brightness and the target distorted image without adjusted brightness are mixed to obtain a second image. The second image will show an exposure effect. Of course, the sizes of the multiple brightness coefficients corresponding to the multiple target distorted images will be reduced in sequence according to the positions of the multiple target distorted images in the target distorted video, so that the target distorted video generated based on the multiple second images shows an overexposure effect that gradually decreases, thereby increasing the visual beauty. Finally, the multiple second images are determined as multiple target distorted images. For example, refer to Figure 7 , Figure 7A schematic diagram of obtaining a second image c according to a target distorted image c is provided in an embodiment of the present application. First, a brightness coefficient c corresponding to the target distorted image c is determined. Then, a first texture pixel corresponding to a first texture coordinate of each pixel point in the target distorted image c is multiplied by the brightness coefficient c to obtain a second texture pixel corresponding to the first texture coordinate of each pixel point in the target distorted image c. Then, the second texture pixel corresponding to the first texture coordinate of each pixel point in the target distorted image c is mixed with the first texture pixel corresponding to the first texture coordinate of the pixel point to obtain the second image c. Compared with the target distorted image c, the second image c presents an effect of brightness enhancement, i.e., overexposure, thereby enhancing the visual beauty.
[0054] In an optional embodiment, before generating a target warped video based on multiple target warped images, a rough edge texture image may be obtained; then, the texture pixel corresponding to the texture coordinate of each pixel point in the rough edge texture image is mixed with the texture pixel corresponding to the texture coordinate of the pixel point in each target warped image to obtain multiple third images; finally, the multiple third images are determined as multiple target warped images. For example, see Figure 8 , Figure 8 A schematic diagram of obtaining a third image d according to a target distorted image d and a rough edge texture image provided in an embodiment of the present application is shown in FIG. Figure 8 The burr texture image shown includes four burr textures, and then the texture pixels corresponding to the texture coordinates of each pixel point in each burr texture in the burr texture image and the texture pixels corresponding to the texture coordinates of the pixel point in the target distorted image are mixed to obtain a third image d, wherein the effect presented in the white rectangular box in the third image d is the result of mixing the texture pixels corresponding to the texture coordinates of each pixel point in each burr texture in the burr texture image and the texture pixels corresponding to the texture coordinates of the pixel point in the target distorted image. It can also be commonly understood as the effect of a texture with burr texture on the edges and an uneven texture, which can enhance the visual beauty.
[0055] In an optional embodiment, before generating a target distorted video based on multiple target distorted images, a pure color image may be obtained, such as a pure color luminous image; then the texture pixels corresponding to the texture coordinates of each pixel point in the pure color image and the texture pixels corresponding to the texture coordinates of the pixel point in each target distorted image are mixed to obtain multiple fourth images; finally, the multiple fourth images are determined as multiple target distorted images. It should be noted that after the texture pixels corresponding to the texture coordinates of each pixel point in the pure color image (such as the pure color luminous image) and the texture pixels corresponding to the texture coordinates of the pixel point in the target distorted image are mixed, the light perception of the target distorted image can be enhanced, and the exposure effect of the target distorted image can be strengthened, so that the target distorted image can present the effect of film projection, thereby increasing the visual beauty.
[0056] In an optional embodiment, before generating a target distorted video based on multiple target distorted images, a noisy dark corner image can also be obtained; then the texture pixels corresponding to the texture coordinates of each pixel point in the noisy dark corner image and the texture pixels corresponding to the texture coordinates of the pixel point in each target distorted image are mixed to obtain multiple fifth images; Gaussian blur is performed on each fifth image, and the multiple fifth images after Gaussian blur are determined as multiple target distorted images. For example, see Fig. 9 , Fig. 9 A schematic diagram of obtaining a fifth image e based on a target distorted image e and a noise vignetting image is provided in an embodiment of the present application. The texture pixels of each pixel in the noise vignetting image and the texture pixels corresponding to the pixel in the target distorted image e are mixed to obtain the fifth image e. It can be seen from the fifth image e that the fifth image e presents a vignetting effect with a noise graininess, thereby enhancing the visual beauty.
[0057] 105: Generate a target warped video based on multiple target warped images.
[0058] Exemplarily, if the distortion direction of each target distorted image in a plurality of target distorted images is the above-mentioned horizontal leftward distortion, then the target distorted video generated based on the plurality of target distorted images can be understood as an entry transition video; if the distortion direction of each target distorted image in a plurality of target distorted images is the above-mentioned horizontal rightward distortion, then the target distorted video generated based on the plurality of target distorted images can be understood as an exit transition video.
[0059] It can be seen that in the embodiment of the present application, by obtaining an image to be processed; then using a target curve function such as a sine function to process the longitudinal texture coordinates, the first coefficient and the second coefficient of each pixel point in the image to be processed, determining the first offset corresponding to the transverse texture coordinates of each pixel point in the image to be processed; obtaining multiple second offsets; then based on the first offset and the multiple second offsets corresponding to the transverse texture coordinates of each pixel point, the transverse texture coordinates of each pixel point are offset respectively to obtain multiple target distorted images, wherein the multiple target distorted images correspond to the multiple second offsets one by one, and each second offset is used to control the position of the target distorted image corresponding to the second offset in the target distorted video; based on the multiple target distorted images, a target distorted video is generated. It should be noted that the distortion change law of each target distorted image is similar to the change law of the target curve function. For example, when the target distorted video is an entry transition, the target distorted image is the above-mentioned horizontal leftward distortion, which reduces the stiffness of the entry transition video generated based on the multiple target distorted images with horizontal leftward distortion, enhances the visual beauty of the video transition special effects, and improves the user's visual experience.
[0060] See also Fig.10 , Fig.10 This is a block diagram of the functional units of a video generation device provided in an embodiment of the present application. The video generation device 1000 includes: an acquisition unit 1001 and a processing unit 1002;
[0061] An acquisition unit 1001 is used to acquire an image to be processed;
[0062] The processing unit 1002 is used to determine a first offset corresponding to a horizontal texture coordinate of each pixel point in the image to be processed based on the vertical texture coordinate of each pixel point in the image to be processed;
[0063] An acquisition unit 1001 is used to acquire a plurality of second offsets;
[0064] The processing unit 1002 is used to offset the horizontal texture coordinates of each pixel point based on the first offset and multiple second offsets corresponding to the horizontal texture coordinates of each pixel point to obtain multiple target warped images, wherein the multiple target warped images correspond to the multiple second offsets one by one, and each second offset is used to control the position of the target warped image corresponding to the second offset in the target warped video;
[0065] The processing unit 1002 is configured to generate a target distorted video based on a plurality of target distorted images.
[0066] In one embodiment of the present application, in determining the first offset corresponding to the horizontal texture coordinate of each pixel point in the image to be processed based on the vertical texture coordinate of each pixel point in the image to be processed, the processing unit 1002 is specifically configured to:
[0067] According to the target curve function and the longitudinal texture coordinate of each pixel point, a first offset corresponding to the transverse texture coordinate of each pixel point is obtained.
[0068] In one embodiment of the present application, the target curve function includes a sine function. In terms of obtaining a first offset corresponding to a transverse texture coordinate of each pixel point according to the target curve function and the longitudinal texture coordinate of each pixel point, the processing unit 1002 is specifically configured to:
[0069] Obtaining a first coefficient and a second coefficient, wherein the first coefficient and the second coefficient are both used to control a phase shift and a period of a sine function;
[0070] The first coefficient, the second coefficient and the longitudinal texture coordinate of each pixel are processed by using a sine function to determine a first offset corresponding to the transverse texture coordinate of each pixel.
[0071] In one embodiment of the present application, in terms of offsetting the transverse texture coordinates of each pixel point based on the first offset and the plurality of second offsets corresponding to the transverse texture coordinates of each pixel point to obtain a plurality of target distorted images, the processing unit 1002 is specifically configured to:
[0072] Based on the first offset and the multiple second offsets corresponding to the horizontal texture coordinates of each pixel point, a plurality of first horizontal texture coordinates of each pixel point are obtained, wherein the multiple first horizontal texture coordinates and the multiple second offsets correspond to each other in a one-to-one manner;
[0073] Determine each first transverse texture coordinate of each pixel and the longitudinal texture coordinate of the pixel in the image to be processed as the first texture coordinate of the pixel;
[0074] The texture pixel corresponding to the texture coordinate of each pixel point in the image to be processed is determined as the texture pixel corresponding to each first texture coordinate of the pixel point, so as to obtain a plurality of target distorted images.
[0075] In one embodiment of the present application, before generating a target distorted video based on multiple target distorted images, the processing unit 1002 is specifically configured to:
[0076] Determine the target pixel points whose texture coordinates exceed the texture coordinate range in each target distorted image;
[0077] The color value of the target pixel in each target distorted image is set to the target color to obtain a plurality of first images;
[0078] A plurality of first images are determined as a plurality of target warped images.
[0079] In one embodiment of the present application, before generating a target distorted video based on multiple target distorted images, the processing unit 1002 is specifically configured to:
[0080] Determine a plurality of brightness coefficients, wherein the plurality of brightness coefficients correspond to the plurality of target distorted images one by one;
[0081] For a target distorted image A, according to a first texture pixel corresponding to a first texture coordinate of each pixel point in the target distorted image A and a brightness coefficient corresponding to the target distorted image A, a second texture pixel corresponding to the first texture coordinate of each pixel point in the target distorted image A is determined, wherein the target distorted image A is any one of the multiple target distorted images;
[0082] Mixing the second texture pixel corresponding to the first texture coordinate of each pixel point in each target distorted image with the first texture pixel corresponding to the first texture coordinate of the pixel point to obtain a plurality of second images;
[0083] A plurality of second images are determined as a plurality of target warped images.
[0084] In one embodiment of the present application, before generating a target distorted video based on multiple target distorted images, the processing unit 1002 is specifically configured to:
[0085] Get the rough edge texture image;
[0086] Mixing the texture pixel corresponding to the texture coordinate of each pixel point in the rough edge texture image with the texture pixel corresponding to the texture coordinate of the pixel point in each target distorted image to obtain a plurality of third images;
[0087] A plurality of third images are determined as a plurality of target warped images.
[0088] In one embodiment of the present application, before generating a target distorted video based on multiple target distorted images, the processing unit 1002 is specifically configured to:
[0089] Get a solid color image;
[0090] Mixing the texture pixel corresponding to the texture coordinate of each pixel point in the pure color image with the texture pixel corresponding to the texture coordinate of the pixel point in each target distorted image to obtain a plurality of fourth images;
[0091] A plurality of fourth images are determined as a plurality of target warped images.
[0092] In one embodiment of the present application, before generating a target distorted video based on multiple target distorted images, the processing unit 1002 is specifically configured to:
[0093] Get noisy dark corner image;
[0094] Mixing the texture pixel corresponding to the texture coordinate of each pixel point in the noisy dark corner image with the texture pixel corresponding to the texture coordinate of the pixel point in each target distorted image to obtain a plurality of fifth images;
[0095] Gaussian blur is performed on each fifth image, and multiple fifth images after Gaussian blur are determined as multiple target distorted images.
[0096] In one embodiment of the present application, before determining the first offset corresponding to the horizontal texture coordinate of each pixel point in the image to be processed based on the vertical texture coordinate of each pixel point in the image to be processed, the processing unit 1002 is specifically configured to:
[0097] Translating the texture coordinates of each pixel in the image to be processed in a first direction;
[0098] Determining a scaling factor based on the scale of the image to be processed;
[0099] Determine a second texture coordinate of each pixel in the image to be processed based on the scaling factor and the texture coordinate of each pixel in the image to be processed after the texture coordinate is translated in the first direction;
[0100] Performing a second direction translation on the second texture coordinates of each pixel point of the image to be processed to obtain a sixth image, wherein the first direction and the second direction are relative directions;
[0101] The sixth image is re-determined as the image to be processed.
[0102] See also Fig.11 , Fig.11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.11 As shown, the electronic device 1100 includes a transceiver 1101, a processor 1102 and a memory 1103. They are connected via a bus 1104. The memory 1103 is used to store computer programs and data, and can transmit the data stored in the memory 1103 to the processor 1102.
[0103] The processor 1102 is used to read the computer program in the memory 1103 and perform the following operations:
[0104] Controlling the transceiver 1101 to obtain an image to be processed;
[0105] Determine a first offset corresponding to a transverse texture coordinate of each pixel point in the image to be processed based on the longitudinal texture coordinate of each pixel point in the image to be processed;
[0106] Controlling the transceiver 1101 to obtain a plurality of second offsets;
[0107] Based on the first offset and the plurality of second offsets corresponding to the horizontal texture coordinates of each pixel point, the horizontal texture coordinates of each pixel point are offset respectively to obtain a plurality of target distorted images, wherein the plurality of target distorted images correspond to the plurality of second offsets one by one, and each second offset is used to control the position of the target distorted image corresponding to the second offset in the target distorted video;
[0108] Generate a target warped video based on multiple target warped images.
[0109] In one embodiment of the present application, in terms of determining a first offset corresponding to a horizontal texture coordinate of each pixel point in the image to be processed based on the vertical texture coordinate of each pixel point in the image to be processed, the processor 1102 is specifically configured to perform the following steps:
[0110] According to the target curve function and the longitudinal texture coordinate of each pixel point, a first offset corresponding to the transverse texture coordinate of each pixel point is obtained.
[0111] In one embodiment of the present application, the target curve function includes a sine function. In terms of obtaining a first offset corresponding to a horizontal texture coordinate of each pixel point according to the target curve function and the vertical texture coordinate of each pixel point, the processor 1102 is specifically configured to perform the following steps:
[0112] Obtaining a first coefficient and a second coefficient, wherein the first coefficient and the second coefficient are both used to control a phase shift and a period of a sine function;
[0113] The first coefficient, the second coefficient and the longitudinal texture coordinate of each pixel are processed by using a sine function to determine a first offset corresponding to the transverse texture coordinate of each pixel.
[0114] In one embodiment of the present application, in terms of offsetting the transverse texture coordinates of each pixel point based on the first offset and the plurality of second offsets corresponding to the transverse texture coordinates of each pixel point to obtain a plurality of target distorted images, the processor 1102 is specifically configured to perform the following steps:
[0115] Based on the first offset and the multiple second offsets corresponding to the horizontal texture coordinates of each pixel point, a plurality of first horizontal texture coordinates of each pixel point are obtained, wherein the multiple first horizontal texture coordinates and the multiple second offsets correspond to each other in a one-to-one manner;
[0116] Determine each first transverse texture coordinate of each pixel and the longitudinal texture coordinate of the pixel in the image to be processed as the first texture coordinate of the pixel;
[0117] The texture pixel corresponding to the texture coordinate of each pixel point in the image to be processed is determined as the texture pixel corresponding to each first texture coordinate of the pixel point, so as to obtain a plurality of target distorted images.
[0118] In one embodiment of the present application, before generating a target distorted video based on multiple target distorted images, the processor 1102 is specifically configured to perform the following steps:
[0119] Determine the target pixel points whose texture coordinates exceed the texture coordinate range in each target distorted image;
[0120] The color value of the target pixel in each target distorted image is set to the target color to obtain a plurality of first images;
[0121] A plurality of first images are determined as a plurality of target warped images.
[0122] In one embodiment of the present application, before generating a target distorted video based on multiple target distorted images, the processor 1102 is specifically configured to perform the following steps:
[0123] Determine a plurality of brightness coefficients, wherein the plurality of brightness coefficients correspond to the plurality of target distorted images one by one;
[0124] For a target distorted image A, according to a first texture pixel corresponding to a first texture coordinate of each pixel point in the target distorted image A and a brightness coefficient corresponding to the target distorted image A, a second texture pixel corresponding to the first texture coordinate of each pixel point in the target distorted image A is determined, wherein the target distorted image A is any one of the multiple target distorted images;
[0125] Mixing the second texture pixel corresponding to the first texture coordinate of each pixel point in each target distorted image with the first texture pixel corresponding to the first texture coordinate of the pixel point to obtain a plurality of second images;
[0126] A plurality of second images are determined as a plurality of target warped images.
[0127] In one embodiment of the present application, before generating a target distorted video based on multiple target distorted images, the processor 1102 is specifically configured to perform the following steps:
[0128] Get the rough edge texture image;
[0129] Mixing the texture pixel corresponding to the texture coordinate of each pixel point in the rough edge texture image with the texture pixel corresponding to the texture coordinate of the pixel point in each target distorted image to obtain a plurality of third images;
[0130] A plurality of third images are determined as a plurality of target warped images.
[0131] In one embodiment of the present application, before generating a target distorted video based on multiple target distorted images, the processor 1102 is specifically configured to perform the following steps:
[0132] Get a solid color image;
[0133] Mixing the texture pixel corresponding to the texture coordinate of each pixel point in the pure color image with the texture pixel corresponding to the texture coordinate of the pixel point in each target distorted image to obtain a plurality of fourth images;
[0134] A plurality of fourth images are determined as a plurality of target warped images.
[0135] In one embodiment of the present application, before generating a target distorted video based on multiple target distorted images, the processor 1102 is specifically configured to perform the following steps:
[0136] Get noisy dark corner image;
[0137] Mixing the texture pixel corresponding to the texture coordinate of each pixel point in the noisy dark corner image with the texture pixel corresponding to the texture coordinate of the pixel point in each target distorted image to obtain a plurality of fifth images;
[0138] Gaussian blur is performed on each fifth image, and multiple fifth images after Gaussian blur are determined as multiple target distorted images.
[0139] In one embodiment of the present application, before determining the first offset corresponding to the horizontal texture coordinate of each pixel point in the image to be processed based on the vertical texture coordinate of each pixel point in the image to be processed, the processor 1102 is specifically configured to perform the following steps:
[0140] Translating the texture coordinates of each pixel in the image to be processed in a first direction;
[0141] Determining a scaling factor based on the scale of the image to be processed;
[0142] Determine a second texture coordinate of each pixel in the image to be processed based on the scaling factor and the texture coordinate of each pixel in the image to be processed after the texture coordinate is translated in the first direction;
[0143] Performing a second direction translation on the second texture coordinates of each pixel point of the image to be processed to obtain a sixth image, wherein the first direction and the second direction are relative directions;
[0144] The sixth image is re-determined as the image to be processed.
[0145] Specifically, the transceiver 1101 may be Fig.10 The acquisition unit 1001 of the video generation device 1000 of the embodiment, the processor 1102 may be Fig.10 The processing unit 1002 of the video generating device 1000 of the embodiment.
[0146] It should be understood that the electronic devices in this application may include smart phones (such as Android phones, iOS phones, Windows Phone phones, etc.), tablet computers, PDAs, laptops, mobile Internet devices MID (Mobile Internet Devices, referred to as: MID) or wearable devices, etc. The above electronic devices are only examples, not exhaustive, and include but are not limited to the above electronic devices. In practical applications, the above electronic devices may also include: smart vehicle terminals, computer equipment, etc.
[0147] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. The computer program is executed by a processor to implement part or all of the steps of any one of the video generation methods recorded in the above method embodiments.
[0148] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps of any one of the video generation methods recorded in the above method embodiments.
[0149] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0150] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0151] In the several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0152] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0153] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of a software program module.
[0154] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of each embodiment method of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0155] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.
[0156] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A video generation method, characterized in that: The method comprises: Get the image to be processed; Determine a first offset corresponding to a transverse texture coordinate of each pixel point in the image to be processed based on the longitudinal texture coordinate of each pixel point in the image to be processed; Get multiple second offsets; Based on the first offset corresponding to the horizontal texture coordinate of each pixel point and the multiple second offsets, the horizontal texture coordinate of each pixel point is offset to obtain multiple target warped images, wherein the multiple target warped images correspond to the multiple second offsets one by one, and each second offset is used to control the position of the target warped image corresponding to the second offset in the target warped video; Determine a plurality of brightness coefficients; for a target warped image A, determine a second texture pixel corresponding to the first texture coordinate of each pixel point in the target warped image A according to a first texture pixel corresponding to the first texture coordinate of each pixel point in the target warped image A and a brightness coefficient corresponding to the target warped image A, wherein the target warped image A is any one of the plurality of target warped images; mix the second texture pixel corresponding to the first texture coordinate of each pixel point in each target warped image with the first texture pixel corresponding to the first texture coordinate of the pixel point to obtain a plurality of second images; determining the plurality of second images as a plurality of target distorted images; Based on the multiple target warped images, the target warped video is generated.
2. The method according to claim 1, characterized in that The step of determining the first offset corresponding to the horizontal texture coordinate of each pixel point in the image to be processed based on the vertical texture coordinate of each pixel point in the image to be processed includes: According to the target curve function and the longitudinal texture coordinate of each pixel point, a first offset corresponding to the transverse texture coordinate of each pixel point is obtained.
3. The method according to claim 2, characterized in that The target curve function includes a sine function, and obtaining a first offset corresponding to a horizontal texture coordinate of each pixel point according to the target curve function and the vertical texture coordinate of each pixel point includes: Obtaining a first coefficient and a second coefficient, wherein the first coefficient and the second coefficient are both used to control a phase shift and a period of a sine function; The first coefficient, the second coefficient and the longitudinal texture coordinate of each pixel are processed by using a sine function to determine a first offset corresponding to the transverse texture coordinate of each pixel.
4. The method according to any one of claims 1 to 3, characterized in that: The step of offsetting the transverse texture coordinates of each pixel point based on the first offset corresponding to the transverse texture coordinates of each pixel point and the plurality of second offsets to obtain a plurality of target distorted images includes: Based on the first offset corresponding to the transverse texture coordinate of each pixel point and the plurality of second offsets, a plurality of first transverse texture coordinates of each pixel point is obtained, wherein the plurality of first transverse texture coordinates and the plurality of second offsets correspond to each other in a one-to-one manner; Determine each first transverse texture coordinate of each pixel and the longitudinal texture coordinate of the pixel in the image to be processed as the first texture coordinate of the pixel; The texture pixel corresponding to the texture coordinate of each pixel point in the image to be processed is determined as the texture pixel corresponding to each first texture coordinate of the pixel point, so as to obtain the multiple target distorted images.
5. The method according to claim 1, characterized in that Before generating the target distorted video based on the multiple target distorted images, the method further includes: Determine the target pixel points whose texture coordinates exceed the texture coordinate range in each target distorted image; The color value of the target pixel in each target distorted image is set to the target color to obtain a plurality of first images; The plurality of first images are determined as the plurality of target warped images.
6. The method according to claim 1, characterized in that Before generating the target distorted video based on the multiple target distorted images, the method further includes: Get the rough edge texture image; Mixing the texture pixel corresponding to the texture coordinate of each pixel point in the rough edge texture image with the texture pixel corresponding to the texture coordinate of the pixel point in each target distorted image to obtain a plurality of third images; The plurality of third images are determined as the plurality of target warped images.
7. The method according to claim 1, characterized in that Before generating the target distorted video based on the multiple target distorted images, the method further includes: Get a solid color image; Mixing the texture pixel corresponding to the texture coordinate of each pixel point in the pure color image with the texture pixel corresponding to the texture coordinate of the pixel point in each target distorted image to obtain a plurality of fourth images; The plurality of fourth images are determined as the plurality of target warped images.
8. The method according to claim 1, characterized in that Before generating the target distorted video based on the multiple target distorted images, the method further includes: Get noisy dark corner image; Mixing the texture pixels corresponding to the texture coordinates of each pixel point in the noisy dark corner image with the texture pixels corresponding to the texture coordinates of the pixel point in each target distorted image to obtain a plurality of fifth images; Gaussian blur is performed on each fifth image, and the plurality of fifth images after Gaussian blur are determined as the plurality of target distorted images.
9. The method according to claim 1, characterized in that: Before determining the first offset corresponding to the horizontal texture coordinate of each pixel point in the image to be processed based on the vertical texture coordinate of each pixel point in the image to be processed, the method further includes: Translating the texture coordinates of each pixel in the image to be processed in a first direction; Determining a scaling factor based on the scale of the image to be processed; Determine a second texture coordinate of each pixel in the image to be processed based on the scaling factor and the texture coordinate of each pixel in the image to be processed after the texture coordinate is translated in the first direction; Performing a second-direction translation on the second texture coordinates of each pixel point of the image to be processed to obtain a sixth image, wherein the first direction and the second direction are relative directions; The sixth image is re-determined as the image to be processed.
10. A video generating device, characterized in that: The device comprises: an acquisition unit and a processing unit; The acquisition unit is used to acquire the image to be processed; The processing unit is used to determine a first offset corresponding to a horizontal texture coordinate of each pixel point in the image to be processed based on the vertical texture coordinate of each pixel point in the image to be processed; The acquisition unit is further used to acquire a plurality of second offsets; The processing unit is further used to offset the horizontal texture coordinates of each pixel point based on the first offset corresponding to the horizontal texture coordinates of each pixel point and the multiple second offsets, so as to obtain multiple target distorted images, wherein the multiple target distorted images correspond to the multiple second offsets one by one, and each second offset is used to control the position of the target distorted image corresponding to the second offset in the target distorted video; Determine a plurality of brightness coefficients; for a target warped image A, determine a second texture pixel corresponding to the first texture coordinate of each pixel point in the target warped image A according to a first texture pixel corresponding to the first texture coordinate of each pixel point in the target warped image A and a brightness coefficient corresponding to the target warped image A, wherein the target warped image A is any one of the plurality of target warped images; mix the second texture pixel corresponding to the first texture coordinate of each pixel point in each target warped image with the first texture pixel corresponding to the first texture coordinate of the pixel point to obtain a plurality of second images; determining the plurality of second images as a plurality of target distorted images; The processing unit is further configured to generate the target distorted video based on the multiple target distorted images.
11. An electronic device, characterized in that: include: A processor and a memory, wherein the processor is connected to the memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the method as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 9.
