Video interpolation frame generation method, storage medium and terminal device based on optical flow
Through the video frame generation method based on optical flow, the optical flow diagram is used to generate the frame image, which solves the smoothness problem of low frame rate videos when played on high frame rate devices and improves the frame rate and playback effect of the video.
Patent Information
- Application Number
- CN202010750809.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-30
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2040-07-30
AI Technical Summary
Existing technology is difficult to effectively solve the problems of image stuttering and ghosting when playing high frame rate videos, especially the lack of smoothness when playing low frame rate videos on high frame rate devices.
Using a video frame insertion method based on optical flow, by acquiring image frames and optical flow maps, forward and backward optical flow maps are generated, and the interpolation frame image is determined by combining the predicted frame insertion moment and the target optical flow map to improve the video frame rate and Image quality.
It improves the frame rate and playback effect of the original video, reduces screen freezes, and improves the smoothness of the video.
Smart Images

Figure CN114071223B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video processing technology, and in particular to a method for generating video interpolation frames based on optical flow, a storage medium and a terminal device. Background Art
[0002] With the maturity of smart display devices (such as mobile phones, TVs, etc.) and the demand of users for smooth images, the upper limit of video frame rate continues to increase. For example, mobile phone screens use 90hz and TV screens use 120hz. However, previously shot videos are often limited by the level of equipment, and the frame rate is generally lower than 30hz, which causes problems such as screen freezes and ghosting when playing previously shot videos, which brings inconvenience to users. Summary of the invention
[0003] The technical problem to be solved by the present application is to provide a method for generating video interpolation frames based on optical flow, a storage medium and a terminal device in view of the deficiencies in the prior art.
[0004] In order to solve the above technical problems, a first aspect of an embodiment of the present application provides a method for generating a video interpolation frame based on optical flow, the method comprising:
[0005] Acquire a first image frame and a second image frame;
[0006] Determine a forward optical flow map and a backward optical flow map according to the first image frame and the second image frame;
[0007] Based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map, interpolated images corresponding to the first image frame and the second image frame are determined.
[0008] In the method for generating video interpolation frames based on optical flow, the first image frame and the second image frame are continuous image frames in the original video.
[0009] The method for generating video interpolation frames based on optical flow, wherein the step of determining a forward optical flow map and a backward optical flow map according to the first image frame and the second image frame specifically comprises:
[0010] Inputting the first image frame and the second image frame into a preset optical flow generation module in sequence, and generating the forward optical flow map through the optical flow generation module;
[0011] The second image frame and the first image frame are sequentially input into the optical flow generation module, and the backward optical flow map is generated by the optical flow generation module.
[0012] The method for generating video interpolation frames based on optical flow, wherein the step of determining interpolation images corresponding to the first image frame and the second image frame based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map specifically includes:
[0013] Determine a first prediction frame corresponding to the first image frame and a second prediction frame corresponding to the second image frame based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map;
[0014] Based on the first prediction frame and the second prediction frame, interpolation images corresponding to the first image frame and the second image frame are determined.
[0015] The method for generating video interpolation frames based on optical flow, wherein determining a first predicted frame corresponding to the first image frame and a second predicted frame corresponding to the second image frame based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map specifically includes:
[0016] Based on a preset predicted interpolation moment and a target optical flow map, determining a predicted optical flow map corresponding to the predicted interpolation moment, wherein when the target optical flow image is a forward optical flow map, the predicted optical flow map is a predicted forward optical flow map, and when the target optical flow image is a backward optical flow map, the predicted optical flow map is a predicted backward optical flow map;
[0017] Based on the predicted optical flow map and the target image frame, a target predicted frame is determined; wherein, when the target optical flow image is a forward optical flow map, the target image frame is a first image frame, and the target predicted frame is a first predicted frame; when the target optical flow image is a backward optical flow map, the target image frame is a second image frame, and the target predicted frame is a second predicted frame.
[0018] The method for generating video interpolation frames based on optical flow, wherein the step of determining a target prediction frame based on the predicted optical flow map and the target image frame is as follows:
[0019] An affine transformation is performed on the target image frame based on the predicted optical flow map to determine a target predicted frame.
[0020] The method for generating video interpolation frames based on optical flow, wherein the step of performing affine transformation on the target image frame based on the predicted optical flow map to determine the target predicted frame specifically includes:
[0021] Acquire a target area corresponding to the target image frame, wherein the target area is a partial image area of the target image frame;
[0022] An affine transformation is performed on a candidate region in the target image frame based on the predicted optical flow map to determine a target predicted frame, wherein the candidate region is a remaining image region in the target image frame except the target region.
[0023] The method for generating video interpolation frames based on optical flow, wherein after determining the interpolation images corresponding to the first image frame and the second image frame based on the first image frame, the forward optical flow map, the second image frame and the backward optical flow map, the method comprises:
[0024] Acquire a first feature map corresponding to the first image frame and a second feature map corresponding to the second image frame;
[0025] Based on the predicted forward optical flow map and the predicted backward optical flow map, the first feature map, the second feature map, the first predicted frame, and the second predicted frame, the interpolated frame image is corrected to obtain a corrected interpolated frame image;
[0026] The corrected interpolation frame image is used as the interpolation frame image corresponding to the first image frame and the second image frame.
[0027] The method for generating video interpolation frames based on optical flow, wherein the step of correcting the interpolation frame image based on the predicted forward optical flow map and the predicted backward optical flow map, the first feature map, the second feature map, the first predicted frame, and the second predicted frame to obtain the corrected interpolation frame image specifically includes:
[0028] Determine a first mask image corresponding to the first image frame, wherein the first mask image is used to reflect the target area carried by the first image frame;
[0029] Determining a second mask image corresponding to the second image frame, wherein the second mask image is used to reflect the target area carried by the second image frame;
[0030] Determine a residual image corresponding to the interpolated image based on the predicted forward optical flow map, the predicted backward optical flow map, the first image frame, the second image frame, the first predicted frame, the second predicted frame, the first mask map, and the second mask map;
[0031] A modified interpolation frame image is determined based on the residual image and the interpolation frame image.
[0032] The method for generating video interpolation frames based on optical flow, wherein after acquiring the first image frame and the second image frame, the method comprises:
[0033] Acquire a first feature map corresponding to the first image frame, and use the first feature map as the first image frame;
[0034] Obtain a second feature map corresponding to the second image frame, and use the second feature map as the second image frame.
[0035] The method for generating video interpolation based on optical flow, wherein the preset interpolation moment includes a plurality of predicted interpolation moments, and each of the plurality of predicted interpolation moments is between a playback moment corresponding to the first image frame and a playback moment corresponding to the second image frame; and determining the interpolation images corresponding to the first image frame and the second image frame based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map specifically includes:
[0036] For each predicted interpolation moment, based on the predicted interpolation moment and the target optical flow map, determining a predicted optical flow map corresponding to the interpolation moment;
[0037] Based on the predicted optical flow map and the target image frame, a target predicted frame is determined to obtain a target predicted frame corresponding to the predicted interpolation frame moment, wherein when the target optical flow image is a forward optical flow map, the target image frame is a first image frame, and the target predicted frame is a first predicted frame; when the target optical flow image is a backward optical flow map, the target image frame is a second image frame, and the target predicted frame is a second predicted frame;
[0038] Based on the first predicted frame and the second predicted frame corresponding to the predicted interpolation frame moment, interpolation frame images corresponding to the first image frame and the second image frame are determined to obtain a plurality of interpolation frame images.
[0039] The method for generating video interpolation frames based on optical flow, wherein the method further comprises:
[0040] For each interpolated image frame, the interpolated image is inserted between the first image frame and the second image frame according to its corresponding interpolation time to obtain an interpolated video, wherein the frame rate of the interpolated video is higher than the frame rate of the original video.
[0041] A second aspect of an embodiment of the present application provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps in any of the above-described methods for generating optical flow-based video interpolation.
[0042] A second aspect of an embodiment of the present application provides a terminal device, comprising: a processor, a memory, and a communication bus; the memory stores a computer-readable program that can be executed by the processor;
[0043] The communication bus realizes the connection and communication between the processor and the memory;
[0044] When the processor executes the computer-readable program, the processor implements the steps in any of the above-mentioned methods for generating video interpolation frames based on optical flow.
[0045] Beneficial effects: Compared with the prior art, the present application provides a method for generating video interpolation based on optical flow, a storage medium and a terminal device, the method comprising acquiring a first image frame and a second image frame; determining a forward optical flow map and a backward optical flow map according to the first image frame and the second image frame; and determining interpolation images corresponding to the first image frame and the second image frame based on the first image frame, the forward optical flow map, the second image frame and the backward optical flow map. The present method determines the interpolation image based on the two predicted interpolation images by using two predicted interpolation images at the same interpolation position of the forward optical flow map and the backward optical flow map. On the one hand, this can improve the video frame rate of the original video by interpolating the original video, thereby improving the playback effect of the original video. On the other hand, determining the interpolation image by using two predicted interpolation images can improve the image effect of the interpolation image, thereby further improving the playback effect of the original video. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] 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 only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without inventive work.
[0047] Figure 1 A flowchart of a method for generating video interpolation frames based on optical flow provided in this application.
[0048] Figure 2 A schematic diagram of the interpolation process corresponding to several predicted interpolation moments in the optical flow-based video interpolation generation method provided in the present application.
[0049] Figure 3 This is an example of the first image frame in the method for generating video interpolation based on optical flow provided in the present application.
[0050] Figure 4 This is an example of a forward optical flow map in the method for generating video interpolation based on optical flow provided in the present application.
[0051] Figure 5 This is an example of the second image frame in the method for generating video interpolation based on optical flow provided in the present application.
[0052] Figure 6 This is an example of a backward optical flow map in the method for generating video interpolation based on optical flow provided in this application.
[0053] Figure 7This is an example of a feature extraction module in the optical flow-based video interpolation generation method provided in this application.
[0054] Figure 8 This is another example of a forward optical flow map in the method for generating optical flow-based video interpolation provided in the present application.
[0055] Fig. 9 This is an example of an interpolated frame image in the method for generating video interpolation based on optical flow provided in this application.
[0056] Fig.10 Schematic diagram of the optical flow-based video interpolation model provided for this application.
[0057] Fig.11 This is an example diagram of an optical flow generation module in the optical flow-based video interpolation generation method provided in the present application.
[0058] Fig.12 This is an example diagram of a correction module in the optical flow-based video interpolation generation method provided in this application.
[0059] Fig.13 This is a schematic diagram of the structure of the terminal device provided in this application. DETAILED DESCRIPTION
[0060] The present application provides a method for generating video interpolation frames based on optical flow, a storage medium, and a terminal device. In order to make the purpose, technical solution, and effect of the present application clearer and more specific, the present application is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described here are only used to explain the present application and are not used to limit the present application.
[0061] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.
[0062] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with those in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.
[0063] In a specific implementation, the terminal device described in the embodiments of the present application includes, but is not limited to, other portable devices such as mobile phones with touch-sensitive surfaces (e.g., touch display screens and / or touch pads), laptop computers, or tablet computers. It should also be understood that in some embodiments, the device is not a portable communication device, but a desktop computer with a touch-sensitive surface (e.g., touch display screens and / or touch pads).
[0064] In the following discussion, a terminal device including a display and a touch-sensitive surface is described. However, it should be understood that the terminal device may also include one or more other physical user interface devices such as a physical keyboard, a mouse and / or a joystick.
[0065] The terminal device supports various applications, such as one or more of the following: drawing applications, presentation applications, word processing applications, video conferencing applications, disk burning applications, spreadsheet applications, game applications, telephone applications, video conferencing applications, email applications, instant messaging applications, exercise support applications, photo management applications, data camera applications, digital video camera applications, web browsing applications, digital music player applications and / or digital video playback applications, etc.
[0066] Various applications that can be executed on the terminal device can use at least one common physical user interface device such as a touch-sensitive surface. The first or multiple functions of the touch-sensitive surface and the corresponding information displayed on the terminal can be adjusted and / or changed between applications and / or within the corresponding application. In this way, the common physical framework of the terminal (e.g., the touch-sensitive surface) can support various applications with user interfaces that are intuitive and transparent to the user.
[0067] It should be understood that the sequence numbers and sizes of the steps in this embodiment do not mean the order of execution. The execution order of each process is determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.
[0068] The inventor has found through research that the upper limit of the video frame rate of smart display devices is constantly increasing. For example, mobile phone screens use 90hz and TV screens use 120hz. However, previously shot videos are often limited by the level of equipment, and the frame rate is generally lower than 30hz, which causes problems such as screen freezes and ghosting when playing previously shot videos, causing inconvenience to users. Therefore, in order to avoid problems such as screen freezes and ghosting when shooting videos, low frame rate videos are converted into high frame rate videos.
[0069] At present, the method commonly used to convert low frame rate videos into high frame rate videos is the video interpolation method, among which video interpolation mainly includes copy frames, average frames and predicted frames. The advantages of the first two video interpolation methods are that the methods are simple and the processing speed is fast, but the generated video quality is poor; while the predicted frame mainly predicts the intermediate frame based on the motion conditions of the previous frame and the next frame, and the generated video quality is good. Therefore, when hardware conditions such as computing power are sufficient, the industry mostly uses the predicted frame method for video interpolation.
[0070] At present, the main methods of video interpolation based on predicted frames are NVIDIA's superslomo method and Shanghai Jiao Tong University's DAIN method. Among them, superslomo is an optical flow prediction and intermediate frame generation method based on UNet. Its advantages are simple network structure and small amount of calculation, but the generated predicted frame is blurry and has obvious ghosting phenomenon; the DAIN method is an interpolation network composed of multiple sub-networks such as the PWCNet optical flow estimation network. It uses depth information to effectively correct erroneous motion estimation information. The optical flow correction efficiency of this method is low and it takes a long time.
[0071] Based on this, an embodiment of the present application improves a method for generating video interpolation based on optical flow, the method obtaining a first image frame and a second image frame; determining a forward optical flow map and a backward optical flow map according to the first image frame and the second image frame; determining a predicted frame set based on the first image frame, the forward optical flow map, the second image frame and the backward optical flow map; and determining interpolation images corresponding to the first image frame and the second image frame based on the predicted frame set. This method determines an interpolation image based on two predicted interpolation images at the same interpolation position of the forward optical flow map and the backward optical flow map, which can improve the video frame rate of the original video by interpolating the original video, thereby improving the playback effect of the original video. On the other hand, determining the interpolation image through two predicted interpolation images can improve the image effect of the interpolation image, thereby further improving the playback effect of the original video.
[0072] The application content is further explained below through the description of embodiments in conjunction with the accompanying drawings.
[0073] This implementation provides a method for generating video interpolation frames based on optical flow, such as Figure 1 As shown, the method includes:
[0074] S10: Acquire a first image frame and a second image frame.
[0075] Specifically, the first image frame and the second image frame are both image frames in the original video, wherein the original video is the video to be interpolated, and the original video may be a video captured by a terminal device that runs the optical flow-based video interpolation (e.g., a smart phone, etc.), or a video shot by other external devices (e.g., a camera, etc.) and stored in the terminal device, or a video sent to the terminal device via the cloud. In this embodiment, the video may be a video shot by an imaging system (e.g., a camera), wherein the imaging system may be configured by the terminal device itself or by other devices. In an implementation of this embodiment, the original video may be a live video with a low frame rate, or a short video with a low frame rate, or other videos with a low frame rate, etc., wherein the frame rate (Framerate) is a measure for measuring the number of displayed frames.
[0076] In one implementation of the present embodiment, the first image frame and the second image frame are continuous image frames in the original video, and continuous image frames refer to that the first image frame and the second image frame are continuous image frames in the playback order, wherein the first image frame is located before the second image frame in the playback order, or the first image frame is located after the second image frame. For example, when the first image frame is located before the second image frame, the terminal device (for example, a smart TV, etc.) that plays the video plays the second image frame after playing the first image frame. In addition, for the convenience of the following description, the first image frame is located before the second image frame as an example, that is, in the subsequent description, the first image frame is located before the second image frame.
[0077] Further, the similarity between the shooting scene corresponding to the first image frame and the shooting scene corresponding to the second image frame satisfies a preset condition, wherein the similarity satisfies the preset condition that the similarity between the image content carried by the first image frame and the image content carried by the second image frame satisfies the preset condition, and the position information of the reference image content of the first image frame is different from the position information of the target image content in the second image frame, wherein the reference image content and the target image content are the same. For example, the image content of the first image frame includes a puppy, and the image content of the second image frame also includes the puppy, and the position of the image area of the puppy in the first image frame is a rectangular area with (10,50), (50,50), (50,10) and (10,10) as vertices, and the position of the image area of the puppy in the first image frame is a rectangular area with (20,60), (60,60), (60,20) and (20,20) as vertices. In addition, the preset condition is a preset threshold, and the similarity satisfies the preset condition means that the similarity reaches the preset threshold, for example, 90%.
[0078] S20. Determine a forward optical flow map and a backward optical flow map according to the first image frame and the second image frame.
[0079] Specifically, the forward optical flow map is an optical flow map from the first image frame to the second image frame, which is used to reflect the motion information from the first image frame to the second image frame; the backward optical flow map is an optical flow map from the second image frame to the first image frame, which is used to reflect the motion information from the second image frame to the first image frame. Figure 4 The optical flow diagram shown is as follows Figure 3 The first image frame shown and Figure 5 The forward optical flow map corresponding to the second image frame is as follows: Figure 6 The optical flow diagram shown is as follows Figure 3 The first image frame shown and Figure 5 The backward optical flow map corresponding to the second image frame. In one implementation of the present embodiment, the image size of the first optical flow map is the same as the image size of the second optical flow map, and the image size of the first optical flow map is smaller than the image size of the first image frame / the second image frame, so that the acquisition speed of the interpolated image can be improved by saving the computational effort in the process of determining the interpolated image based on the optical flow map. For example, if the image size of the first image frame is 1280*720, then the image size of the optical flow map can be 1 / 4 of the first image frame, that is, the image size of the optical flow map is 320*180. Of course, the image size of the second image frame is the same as the image size of the first image frame, so that the image size of the second optical flow map is also smaller than the image size of the second image frame.
[0080] The optical flow map is used to reflect the speed of pattern motion in the image, and the pattern motion refers to the brightness pattern motion of the corresponding pixel points of the object on the image when the object moves. The optical flow map contains the information of the object motion (for example, the x, y displacement of the pixel corresponding to the object during the movement of the picture), and the target motion information of the object can be determined based on the optical flow. It can be understood that the optical flow map includes two channels, one of the two channels is used to reflect the horizontal movement of the pixel; the other channel of the two channels is used to reflect the vertical movement of the pixel; that is, the optical flow map includes a horizontal movement optical flow channel and a vertical movement optical flow channel.
[0081] Based on this, the pixel value of each pixel point in the forward optical flow map represents the pixel movement amount of the corresponding first reference pixel point in the first image frame to the first target pixel point in the second image frame, and when the pixel movement amount is superimposed on the first reference pixel point, the first reference pixel point coincides with the first target pixel point. The pixel value of each pixel point in the backward optical flow map represents the pixel movement amount of the corresponding second reference pixel point in the second image frame to the second target pixel point in the first image frame, and when the pixel movement amount is superimposed on the second reference pixel point, the second reference pixel point coincides with the second target pixel point.
[0082] Further, the optical flow map can be calculated by a traditional method (e.g., Lucas-Kanade optical flow method, etc.), or can be determined by a deep learning network. In one implementation of this embodiment, the optical flow map is determined based on a deep learning network (e.g., a convolutional neural network, etc.). Accordingly, determining the forward optical flow map and the backward optical flow map according to the first image frame and the second image frame specifically includes:
[0083] Inputting the first image frame and the second image frame into a preset optical flow generation module in sequence, and generating the forward optical flow map through the optical flow generation module;
[0084] The second image frame and the first image frame are sequentially input into the optical flow generation module, and the backward optical flow map is generated by the optical flow generation module.
[0085] Specifically, the optical flow generation module is a trained deep learning model, the input of the optical flow generation module is two image frames, and the output is an optical flow map corresponding to the two image frames, wherein the two image frames are input into the optical flow generation module in sequence, and the optical flow map is the optical flow from the image frame input first to the image frame input later of the two image frames.
[0086] Therefore, when determining the forward optical flow map, the first image frame and the second image frame are sequentially input into the optical flow generation module, so that the optical flow generation module outputs the forward optical flow map from the first image frame to the second image frame; when determining the backward optical flow map, the second image frame and the first image frame are sequentially input into the optical flow generation module, so that the optical flow generation module outputs the backward optical flow map from the second image frame to the first image frame. Therefore, during the training process, the training samples corresponding to the optical flow generation model include two training images, which are respectively recorded as the first training image and the second training image. When the training samples are input into the preset network model corresponding to the optical flow generation model, the first training image and the second training image need to first input the first training image into the preset network model, and then input the second training image into the preset network model, and the preset network model outputs the optical flow map from the first training image to the second training image.
[0087] In one implementation of this embodiment, Fig.11 As shown, the optical flow generation module can adopt the optical flow estimation subnetwork in IRR_PWCNet, and the optical flow estimation subnetwork uses the same set of model parameters for the forward optical flow map and the backward optical flow map. It can be understood that when the forward optical flow map corresponding to the first image frame and the backward optical flow map corresponding to the second image frame, the optical flow estimation subnetwork shares the same set of model parameters, and only needs to exchange the input order of the first image frame and the second image frame, so that the image features of the first image frame and the image features of the second image frame can be reused, which can reduce the model parameters of the optical flow generation module and reduce the memory consumption of the optical flow generation module.
[0088] Further, in an implementation of the embodiment, after acquiring the first image frame and the second image frame, the method includes:
[0089] Acquire a first feature map corresponding to the first image frame, and use the first feature map as the first image frame;
[0090] Obtain a second feature map corresponding to the second image frame, and use the second feature map as the second image frame.
[0091] Specifically, both the first feature map and the second feature map can be determined by a feature extraction module, wherein the feature extraction module is trained and used to extract feature maps of image frames. The input item of the feature extraction module is an image frame, and the input item is a feature map corresponding to the image frame. It can be understood that obtaining the first feature map corresponding to the first image frame can be inputting the first image frame into the feature extraction module, and outputting the first feature map corresponding to the first image frame through the feature extraction module, and obtaining the second feature map corresponding to the second image frame can be inputting the second image frame into the feature extraction module, and outputting the second feature map corresponding to the second image frame through the feature extraction module. Among them, the image scale of the first feature map is the same as the image size of the first image frame, and the image size of the second feature map is the same as the image size of the second image frame, so that the first feature map carries the image content information of the first image frame; and the second feature map carries the image content information of the second image frame. In one implementation of this embodiment, the feature extraction module can be as follows Figure 7 In the VGG16 network shown, the first feature map corresponding to the first image frame and the second feature map corresponding to the second image frame are both feature maps extracted by the first feature map unit in the VGG16 network. When the image scales of the first image frame and the second image frame are both 224*224*3, the image scales of the first feature map and the second feature map are both 224*224*64.
[0092] Furthermore, after acquiring the first feature map and the second feature map, the first feature map is used as the first image frame and the second feature map is used as the second image frame. It can be known that the forward optical flow map is determined based on the first feature map and the second feature map, and the backward optical flow map is determined based on the second feature map and the first feature map. Therefore, in practical applications, the feature extraction module can be connected to the optical flow generation module, and after acquiring the first image frame and the second image frame, the first image frame and the second image frame are input into the feature map extraction module, and the first feature map and the second feature map are input into the feature extraction module, and then the first feature map and the second feature map are sequentially input into the optical flow generation module to obtain the forward image frame, and the second feature map and the first feature map are sequentially input into the optical flow generation module to obtain the backward image frame. In this way, the optical flow generation module does not need to perform feature extraction, and can directly use the feature map extracted by the feature extraction module. At the same time, in the subsequent correction step, the first feature map can be directly used as the first image frame, and the second feature map can be directly used as the second image frame. The first feature map and the second feature map extracted by the feature extraction module can be directly used, thereby realizing the reuse of feature maps in the optical flow map extraction process and the subsequent correction process, reducing the time consumed in feature extraction, and improving the speed of determining the interpolated image, thereby improving the video interpolation speed.
[0093] S30. Determine interpolated images corresponding to the first image frame and the second image frame based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map.
[0094] Specifically, the interpolated image is an image frame inserted between a first image frame and a second image frame, so as to increase the frame rate of the original video by inserting the interpolated image, wherein the image scale of the interpolated image is the same as the image scale of the first image frame. In one implementation, the interpolated image is generated based on two predicted images, which are respectively recorded as the first predicted image and the second predicted image, wherein the image scale of the first predicted frame is the same as the image scale of the second predicted frame. After obtaining the first predicted frame and the second predicted frame, the first predicted frame and the second predicted frame are fused to obtain the interpolated image, for example, Figure 3 The first image frame and Figure 5 The interpolated frame image corresponding to the second image frame is as follows: Fig. 9 shown.
[0095] Furthermore, the two predicted images corresponding to the interpolated frame image include one determined based on the first image frame and the forward optical flow map and one determined based on the second image frame and the backward optical flow map. Here, the one determined based on the first image frame and the forward optical flow map is recorded as the first predicted image, and the one determined based on the second image frame and the backward optical flow map is recorded as the second predicted frame, wherein the first predicted frame and the second predicted frame are two predicted frames corresponding to the same predicted interpolated frame moment. It can be understood that for a predicted interpolated frame moment, the first predicted frame corresponding to the interpolated frame moment is determined based on the first image frame and the forward optical flow map, and the second predicted frame corresponding to the interpolated frame moment is determined based on the second image frame and the backward optical flow map.
[0096] In an implementation of this embodiment, determining the interpolated image corresponding to the first image frame and the second image frame based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map specifically includes:
[0097] Determine a first prediction frame corresponding to the first image frame and a second prediction frame corresponding to the second image frame based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map;
[0098] Based on the first prediction frame and the second prediction frame, interpolation images corresponding to the first image frame and the second image frame are determined.
[0099] Specifically, after obtaining the first predicted frame and the second predicted frame, the first predicted frame and the second predicted frame can be fused to obtain an interpolated image, wherein the fusion process of the first predicted frame and the second predicted frame can be: for each pixel point in the first predicted frame, determine the target pixel point corresponding to the pixel point, wherein the target pixel point is in the second predicted frame, and the pixel position of the target pixel point in the second predicted frame corresponds to the pixel position of the pixel point in the first predicted frame; determine the average value of the pixel value of the pixel point and the pixel value of the target pixel point, and use the average value as the pixel value of the pixel point to update the pixel value of the pixel point; when the pixel values of all pixels in the first predicted frame are updated, use the updated first predicted frame as the interpolated image corresponding to the first image frame and the second image frame. For example, for pixel a with pixel position (100, 100) in the first prediction frame, pixel b with pixel position (100, 100) is selected in the second prediction frame, the pixel value of pixel a is 50 and the pixel value of pixel b is 60, and the average value of the pixel value of pixel a and the pixel value of pixel B is (50+60) / 2=55, then the pixel value of pixel a is updated to 55.
[0100] Further, in an implementation of this embodiment, determining a first predicted frame corresponding to the first image frame and a second predicted frame corresponding to the second image frame based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map specifically includes:
[0101] S31, based on a preset predicted frame insertion time and a target optical flow map, determining a predicted optical flow map corresponding to the predicted frame insertion time, wherein the predicted frame insertion time is between a playback time corresponding to the first image frame and a playback time corresponding to the second image frame;
[0102] S32. Determine a target prediction frame based on the predicted optical flow map and the target image frame, wherein when the target optical flow image is a forward optical flow map, the target image frame is a first image frame, and the target prediction frame is a first prediction frame; when the target optical flow image is a backward optical flow map, the target image frame is a second image frame, and the target prediction frame is a second prediction frame.
[0103] Specifically, in step S31, the preset predicted interpolation moment is the playback moment corresponding to the target predicted frame, wherein the predicted interpolation moment is between the first playback moment of the first image frame and the second playback moment of the second image frame, and the predicted interpolation moment can be any moment between the first playback moment and the second playback moment. The predicted interpolation time may be randomly selected from the first playback time and the second playback time. For example, the first playback time corresponding to the first image frame is the 150th second, and the second playback time corresponding to the second image frame is the 151st second, then the predicted interpolation time may be the 150.2th second, etc.; or, it may be determined according to the interpolation data configured for the first image frame and the second image frame, and the number of interpolation frames divides the time period between the first playback time and the second playback time into the number of interpolation frames+1 sub-time period, and the predicted interpolation time is the equal division point. For example, the first playback time corresponding to the first image frame is the 150th second, and the second playback time corresponding to the second image frame is the 151st second, the number of interpolation frames of the first image frame and the second image frame is 1, and the 1-second time period between the first playback time of the 150th second and the second playback time of the 151st second is equally divided into two time periods, and the predicted interpolation time is the equal division point, so that the predicted interpolation time is 150.5 seconds.
[0104] In addition, for each predicted interpolation moment, the predicted interpolation moment corresponds to two predicted optical flow maps, wherein one predicted optical flow map is a predicted forward optical flow map, and the other is a candidate predicted optical flow map. The predicted forward optical flow map is determined based on the forward optical flow map and the predicted interpolation moment, and the predicted backward optical flow map is determined based on the backward optical flow map and the predicted interpolation moment.
[0105] Furthermore, the predicted optical flow map is used to reflect the motion information from the image frame A corresponding to the target optical flow map to the interpolated image corresponding to the predicted optical flow map, and the target optical flow map is used to reflect the motion information from the previous image frame corresponding to the target optical flow map to the next image frame corresponding to the target optical flow map, and the image scene in the image frame moves at a uniform speed. Thus, the ratio of the pixel value of each pixel point in the predicted optical flow map to the pixel value of the corresponding pixel point in the target optical flow map is equal to the target ratio, and the target ratio is the ratio of the first time period to the second time period, the first time period is the time interval between the playback time of the image frame A corresponding to the predicted optical flow map and the playback time of the predicted frame; the second time period is the time interval between the playback time of the image frame A corresponding to the target optical flow map and the playback time of the image frame B. Wherein, when the target optical flow map is a forward optical flow map, the image frame A is the first image frame, and the image frame B is the second image frame, and when the target optical flow map is a backward optical flow map, the image frame A is the second image frame, and the image frame B is the first image frame.
[0106] Based on this, in one implementation, based on the predicted interpolation moment and the target optical flow map, the predicted optical flow map corresponding to the interpolation moment is determined specifically as follows: a first time interval between two image frames corresponding to the target optical flow map and a second time interval between the predicted interpolation moment and the playback time of the previous image frame in the target optical flow map are obtained; for each pixel in the predicted optical flow map, a pixel value of a reference pixel corresponding to the pixel is obtained, and the pixel position of the reference pixel in the target optical flow map corresponds to the pixel position of the pixel in the predicted optical flow map; the pixel value of the pixel is determined according to the first time interval, the second time interval and the pixel value of the reference pixel, wherein the pixel value of the pixel = the pixel value of the object pixel * the second time interval / the first time interval.
[0107] For example: the target optical flow map is a forward optical flow map, the playback time of the first image frame is 150 seconds, the playback time of the second image frame is 151 seconds, the predicted interpolation time is 150.5 seconds, the pixel value of the pixel point at the pixel position (100,100) in the target optical flow map is (10,20), and the pixel value of the pixel point at the pixel position (100,100) in the predicted optical flow map is (a, b), then a / 10=(150.5-150) / (151-150)=0.5 / 1,=1 / 2, it can be seen that a=10*0.5 / 1=5, and similarly it can be concluded that b=10.
[0108] Further, in step S32, after obtaining the predicted optical flow map, the target image frame can be affine-mapped to the interpolation time corresponding to the predicted optical flow map based on the predicted optical flow map to obtain the target predicted frame. Accordingly, determining the target predicted frame based on the predicted optical flow map and the target image frame specifically includes:
[0109] An affine transformation is performed on the target image frame based on the predicted optical flow map to determine a target predicted frame.
[0110] Specifically, the affine transformation is a warp operation for spatially moving the image frame, wherein the warp operation spatially moves each pixel in the image according to the optical flow (i.e., the pixels in the image are moved according to the x, y displacement in the optical flow). It can be understood that the target prediction frame is obtained by performing a warp operation on the target image frame based on the predicted optical flow map, wherein, when the predicted optical flow map is determined based on the forward optical flow map, a warp operation is performed on the first image frame based on the predicted optical flow map to obtain the target prediction frame; when the predicted optical flow map is determined based on the backward optical flow map, a warp operation is performed on the second image frame based on the predicted optical flow map to obtain the target prediction frame. Thus, for each predicted interpolation moment, two target prediction frames corresponding to the predicted interpolation moment can be determined, namely, the first prediction frame and the second prediction frame, and the first prediction frame and the second prediction frame constitute a prediction frame set corresponding to the interpolation moment.
[0111] Further, in an implementation of this embodiment, performing an affine transformation on the target image frame based on the predicted optical flow map to determine a target predicted frame specifically includes:
[0112] Acquire a target area corresponding to the target image frame, wherein the target area is a partial image area of the target image frame;
[0113] An affine transformation is performed on a candidate region in the target image frame based on the predicted optical flow map to determine a target predicted frame, wherein the candidate region is a remaining image region in the target image frame except the target region.
[0114] Specifically, the target area is a partial image area in the target image frame, which is used to reflect the image area of the target image frame that needs to be protected, for example, Figure 8 As shown, the target area is Figure 8 The candidate region is the remaining image region in the target image frame except the target region, and is used to reflect the region of the target image frame that needs to be affine transformed, for example, Figure 8 As shown, the candidate region is Figure 8 The image area is composed of the remaining areas except the area occupied by the text. When the target image frame is affine transformed based on the predicted optical flow map, the image content in the target area remains unchanged, and only the candidate area is affine transformed, so that the image content corresponding to the target area in the target prediction frame obtained by the affine transformation is the same as the image content corresponding to the target area in the target image frame, which can avoid content errors in the target area due to optical flow estimation errors.
[0115] Further, the target area can be determined according to the image content. For example, the image content corresponding to the target area can be logo text such as a station logo and subtitles. Accordingly, the target area can be determined by a trained positioning module, and the positioning module is used to locate the area where the logo text is located in the image to obtain the target area. Accordingly, obtaining the target area corresponding to the target image frame is specifically: inputting the target image frame into the positioning module, and determining the target prediction frame corresponding to the target image frame through the positioning module. Among them, the target area is formed by a target area mask, and when the target image frame is affinely transformed based on the predicted optical flow map to determine the target prediction frame, a reference optical flow map can be determined based on the target area mask and the preset optical flow map, and the target image frame is affinely transformed based on the target optical flow map to determine the target prediction frame, wherein the pixel points in the image area corresponding to the target area in the reference optical flow map are all preset pixel values, for example, 0, etc.
[0116] Therefore, in one implementation of the present embodiment, the positioning module can be connected to the feature extraction module and connected in parallel with the optical flow model; the first feature map and the second feature map obtained by the feature extraction module are respectively input into the optical flow generation module and the positioning module, and the forward optical flow map and the backward optical flow map are generated by the optical flow generation module, and the forward target area mask and the backward target area mask are determined based on the positioning module, wherein the forward target area mask is determined based on the first feature map, and the backward target area mask is determined based on the second feature map.
[0117] Furthermore, in an implementation of this embodiment, after acquiring the interpolated frame image, the interpolated frame image may be corrected to improve the image quality of the interpolated frame image. Accordingly, after determining the interpolated frame images corresponding to the first image frame and the second image frame based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map, the method includes:
[0118] Based on the predicted forward optical flow map and the predicted backward optical flow map, the first feature map, the second feature map, the first predicted frame, and the second predicted frame, the interpolated frame image is corrected to obtain a corrected interpolated frame image;
[0119] The corrected interpolation frame image is used as the interpolation frame image corresponding to the first image frame and the second image frame.
[0120] Specifically, the corrected interpolated image is a picture obtained by correcting the interpolated image by using the predicted forward optical flow map, the predicted backward optical flow map, the first image frame, the second image frame, the first predicted frame, and the second predicted frame, wherein the corrected interpolated image is an output item of the trained image correction model. In an implementation of this embodiment, Fig.12 As shown, the image correction model can adopt residual blocks in the ResNet network, etc. In one implementation of this embodiment, the first image frame can be the first feature map extracted by the above-mentioned feature extraction module, and the second image frame can be the second feature map extracted by the above-mentioned feature extraction module. It can be understood that the first feature map is the same as the first feature map used to determine the forward optical flow map corresponding to the first image frame, and the second feature map is the same as the first feature map used to determine the forward optical flow map corresponding to the first image frame. It will not be repeated here, and the specific process of determining the first feature map and the second feature map can be referred to.
[0121] In one implementation, the correcting the interpolated frame image based on the predicted forward optical flow map and the predicted backward optical flow map corresponding to the predicted interpolated frame moment, the first feature map, the second feature map, the first predicted frame, and the second predicted frame to obtain the corrected interpolated frame image specifically includes:
[0122] Determine a first mask image corresponding to the first image frame, wherein the first mask image is used to reflect the target area carried by the first image frame;
[0123] Determining a second mask image corresponding to the second image frame, wherein the second mask image is used to reflect the target area carried by the second image frame;
[0124] Determine a residual map corresponding to the interpolated image based on the predicted forward optical flow map and the predicted backward optical flow map, the first feature map, the second feature map, the first predicted frame, the second predicted frame, the first mask map, and the second mask map;
[0125] A modified interpolation frame image is determined based on the residual image and the interpolation frame image.
[0126] Specifically, after obtaining the first feature map and the second feature map, an affine transformation can be performed on the first feature map based on the forward predicted optical flow map corresponding to the first feature map to obtain a first predicted feature map corresponding to the first feature map, and correspondingly, an affine transformation can be performed on the second feature map based on the backward predicted optical flow map corresponding to the second feature map to obtain a second predicted feature map corresponding to the second feature map. However, after adopting the first predicted feature map as the first feature map and the second predicted feature map as the second feature map, the interpolated image is corrected based on the predicted forward optical flow map and the predicted backward optical flow map corresponding to the predicted interpolation moment, the first feature map, the second feature map, the first predicted frame, the second predicted frame, the first mask map and the second mask map to obtain a corrected interpolated image. In this way, the first feature map and the second feature map corresponding to the interpolation moment can be used to guide the fusion network, which can enhance the edge details of the interpolated image. In addition, the redundant information of the first prediction frame, the second prediction frame, the forward prediction optical flow, and the backward prediction optical flow can be used to enhance the picture details of the interpolated image, and the precision errors existing in some warp affine transformations can be corrected by adding the first mask map and the second mask map, thereby improving the image quality of the corrected interpolated image. In one implementation of this embodiment, the first mask map and the second mask map can both be determined by the above-mentioned positioning module, wherein the first mask map is used to reflect the target area carried by the first image frame, and the second mask map is used to reflect the target area carried by the second image frame, and the target area corresponding to the first mask map is the same as the target area in the affine transformation of the first image frame, and the target area corresponding to the second mask map is the same as the target area in the radial transformation of the second image frame. For example, the target area in the first image frame is the image area corresponding to the logo text, then the first mask image includes a first image area and a second image area, wherein the first image area is the image area corresponding to the logo text, and the second image area is other areas in the first image frame except the image area corresponding to the logo text, the pixel value of the pixel point in the first image area can be a first pixel value, and the pixel value of the pixel point in the second image area can be a second pixel value, for example, the first pixel value is 1, and the second pixel value is 1.
[0127] In addition, in practical applications, the image size of the first mask image is the same as the image size of the second mask image, and the image size of the first mask image is smaller than the image size of the first image frame, and the image size of the second mask image is smaller than the image size of the second image frame. For example, the image size of the first image frame is 224*224, and the image size of the first mask image is 28*28. In this way, by using the first mask image with a smaller image size than the first image frame and the second mask image with a smaller image size than the second image frame, when correcting the interpolated image, the computational effort can be reduced and the acquisition speed of the interpolated image can be increased.
[0128] In one implementation of this embodiment, Figure 2 As shown, the preset interpolation moment includes a plurality of predicted interpolation moments, and each of the plurality of predicted interpolation moments is between a playback moment corresponding to the first image frame and a playback moment corresponding to the second image frame; and determining the interpolation images corresponding to the first image frame and the second image frame based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map specifically includes:
[0129] For each predicted interpolation moment, based on the predicted interpolation moment and the target optical flow map, determining a predicted optical flow map corresponding to the interpolation moment;
[0130] Based on the predicted optical flow map and the target image frame, a target predicted frame is determined to obtain a target predicted frame corresponding to the predicted interpolation frame moment, wherein when the target optical flow image is a forward optical flow map, the target image frame is a first image frame, and the target predicted frame is a first predicted frame; when the target optical flow image is a backward optical flow map, the target image frame is a second image frame, and the target predicted frame is a second predicted frame;
[0131] Based on the first predicted frame and the second predicted frame corresponding to the predicted interpolation frame moment, interpolation frame images corresponding to the first image frame and the second image frame are determined to obtain a plurality of interpolation frame images.
[0132] Specifically, when there are several predicted interpolation moments, for each predicted interpolation moment, the steps in the above embodiment are used to determine the predicted optical flow map corresponding to the predicted interpolation moment, so as to obtain the predicted optical flow map determined at each predicted interpolation moment, and the target predicted frame can be determined based on the target image frame and the predicted optical flow map, so that the predicted frame set corresponding to each predicted interpolation moment can be obtained. Among them, the process of determining the predicted optical flow map and the process of determining the predicted frame based on the predicted optical flow map and the target image frame can be parameterized as step S31 and step S32, which will not be described in detail here.
[0133] In addition, when there are several predicted frame sets, for each predicted frame set, the interpolated frame images corresponding to the first image frame and the second image frame can be determined by the predicted frame set to obtain several interpolated frame images, wherein the several interpolated frame images correspond one-to-one to the several predicted interpolated frame moments, and each interpolated frame image is used to insert the corresponding interpolated frame moment. Based on this, after obtaining the interpolated frame images, the method further includes: for each interpolated frame image, inserting the interpolated frame image between the first image frame and the second image frame according to its corresponding interpolated frame moment to obtain the interpolated video, wherein the frame rate of the interpolated video is higher than the frame rate of the original video. In this way, the frame rate of the original video can be increased, thereby avoiding problems such as freezes in the original video, and further improving the playback effect of the original video.
[0134] In summary, this embodiment provides a method for generating video interpolation based on optical flow, the method comprising acquiring a first image frame and a second image frame; determining a forward optical flow map and a backward optical flow map according to the first image frame and the second image frame; determining a predicted frame set based on the first image frame, the forward optical flow map, the second image frame and the backward optical flow map; and determining interpolation images corresponding to the first image frame and the second image frame based on the predicted frame set. This method determines the interpolation image based on the two predicted interpolation images through two predicted interpolation images at the same interpolation position of the forward optical flow map and the backward optical flow map. On the one hand, this can improve the video frame rate of the original video by interpolating the original video, thereby improving the playback effect of the original video. On the other hand, determining the interpolation image through two predicted interpolation images can improve the image effect of the interpolation image, thereby further improving the playback effect of the original video.
[0135] Based on the above-mentioned method for generating video interpolation frames based on optical flow, this embodiment can also provide a video interpolation model based on optical flow, such as Fig.10 As shown, the optical flow video interpolation model includes a feature extraction module, an optical flow generation module, a positioning module, a prediction generation module and a correction module, the feature map extraction module is respectively connected to the optical flow generation module, the positioning module and the prediction generation module, the optical flow module and the positioning module are connected to the prediction generation module, and the prediction generation module is connected to the correction module; the feature extraction module is used to extract the first feature map corresponding to the first image frame and the second feature map corresponding to the second image frame, and input the first feature map and the second feature map into the optical flow generation module, the positioning module and the prediction generation module respectively; the optical flow generation module is used to generate a forward optical flow map according to the first feature map and the second feature map, and A backward optical flow map is generated according to the second feature map and the first feature map, and the forward optical flow map and the backward optical flow map are input into the prediction generation module; the positioning module is used to generate a first target area mask corresponding to the first feature map according to the first feature map, and to generate a second target area mask corresponding to the second feature map according to the second feature map, and the first target area mask and the second target area mask are input into the prediction generation module; the prediction generation module is used to generate an interpolation image according to the first feature map, the second feature map, the first target area mask, the second target area mask, the forward optical flow map and the backward optical flow map, and the interpolation image is input into the correction module; the correction module is used to correct the interpolation image to obtain a corrected interpolation image. Among them, the working process of the feature extraction module can refer to the description of step S10, the working process of the optical flow generation module can refer to the description of step S20, and the working process of the positioning module, the prediction generation module and the warning correction module can refer to the description of steps S30 and S40, which will not be repeated here.
[0136] Based on the above-mentioned method for generating video interpolation based on optical flow, this embodiment provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps in the method for generating video interpolation based on optical flow as described in the above-mentioned embodiment.
[0137] Based on the above optical flow-based video interpolation frame generation method, the present application also provides a terminal device, such as Fig.13 As shown, it includes at least one processor (processor) 20; display screen 21; and memory (memory) 22, and may also include a communications interface (Communications Interface) 23 and a bus 24. Among them, the processor 20, the display screen 21, the memory 22 and the communication interface 23 can communicate with each other through the bus 24. The display screen 21 is configured to display a preset user guide interface in the initial setting mode. The communication interface 23 can transmit information. The processor 20 can call the logic instructions in the memory 22 to execute the method in the above embodiment.
[0138] In addition, the logic instructions in the memory 22 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0139] The memory 22 is a computer-readable storage medium that can be configured to store software programs, computer executable programs, such as program instructions or modules corresponding to the methods in the embodiments of the present disclosure. The processor 20 executes functional applications and data processing by running the software programs, instructions or modules stored in the memory 22, that is, implementing the methods in the above embodiments.
[0140] The memory 22 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 22 may include a high-speed random access memory and may also include a non-volatile memory. For example, a variety of media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, may also be a transient storage medium.
[0141] In addition, the specific process of loading and executing the multiple instruction processors in the above-mentioned storage medium and the terminal device has been described in detail in the above-mentioned method, and will not be described one by one here.
[0142] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for generating video interpolation frames based on optical flow, characterized in that: The method comprises: Obtain a first image frame and a second image frame in the original video; Determine a forward optical flow map and a backward optical flow map according to the first image frame and the second image frame; Determine interpolated images corresponding to the first image frame and the second image frame based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map; The determining, based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map, of the interpolated image corresponding to the first image frame and the second image frame specifically includes: Based on the first image frame, the forward optical flow map, the second image frame and the backward optical flow map, a first predicted frame corresponding to the first image frame and a second predicted frame corresponding to the second image frame are determined, wherein the process of determining the first predicted frame and the second predicted frame is as follows: based on a preset predicted interpolation frame moment and a target optical flow map, a predicted optical flow map corresponding to the predicted interpolation frame moment is determined, wherein when the target optical flow image is a forward optical flow map, the predicted optical flow map is a predicted forward optical flow map, and when the target optical flow image is a backward optical flow map, the predicted optical flow map is a predicted backward optical flow map; based on the predicted optical flow map and the target image frame, a target predicted frame is determined; wherein when the target optical flow image is a forward optical flow map, the target image frame is the first image frame, and the target predicted frame is the first predicted frame; when the target optical flow image is a backward optical flow map, the target image frame is the second image frame, and the target predicted frame is the second predicted frame; Determining interpolated images corresponding to the first image frame and the second image frame based on the first predicted frame and the second predicted frame; Acquire a first feature map corresponding to the first image frame and a second feature map corresponding to the second image frame; Determine a first mask image corresponding to the first image frame, wherein the first mask image is used to reflect the target area carried by the first image frame; Determining a second mask image corresponding to the second image frame, wherein the second mask image is used to reflect the target area carried by the second image frame; Determine a residual image corresponding to the interpolated image based on the predicted forward optical flow map, the predicted backward optical flow map, the first image frame, the second image frame, the first predicted frame, the second predicted frame, the first mask map, and the second mask map; Determine a corrected interpolation frame image based on the residual image and the interpolation frame image; The corrected interpolation frame image is used as the interpolation frame image corresponding to the first image frame and the second image frame.
2. The method for generating video interpolation frames based on optical flow according to claim 1, characterized in that: The first image frame and the second image frame are consecutive image frames in the original video.
3. The method for generating video interpolation frames based on optical flow according to claim 1, characterized in that: The determining of the forward optical flow map and the backward optical flow map according to the first image frame and the second image frame specifically includes: Inputting the first image frame and the second image frame into a preset optical flow generation module in sequence, and generating the forward optical flow map through the optical flow generation module; The second image frame and the first image frame are sequentially input into the optical flow generation module, and the backward optical flow map is generated by the optical flow generation module.
4. The method for generating video interpolation frames based on optical flow according to claim 1, characterized in that: The step of determining the target prediction frame based on the predicted optical flow map and the target image frame is specifically as follows: An affine transformation is performed on the target image frame based on the predicted optical flow map to determine a target predicted frame.
5. The method for generating video interpolation frames based on optical flow according to claim 4, characterized in that: The performing affine transformation on the target image frame based on the predicted optical flow map to determine the target predicted frame specifically includes: Acquire a target area corresponding to the target image frame, wherein the target area is a partial image area of the target image frame; An affine transformation is performed on a candidate region in the target image frame based on the predicted optical flow map to determine a target predicted frame, wherein the candidate region is a remaining image region in the target image frame except the target region.
6. The method for generating video interpolation frames based on optical flow according to any one of claims 1 to 5, characterized in that: After acquiring the first image frame and the second image frame, the method includes: Acquire a first feature map corresponding to the first image frame, and use the first feature map as the first image frame; Obtain a second feature map corresponding to the second image frame, and use the second feature map as the second image frame.
7. The method for generating video interpolation frames based on optical flow according to any one of claims 1 to 5, characterized in that: The predicted interpolation frame moment includes a plurality of predicted interpolation frame moments, each of which is between a playback moment corresponding to the first image frame and a playback moment corresponding to the second image frame; and determining the interpolation frame images corresponding to the first image frame and the second image frame based on the first image frame, the forward optical flow map, the second image frame, and the backward optical flow map specifically includes: For each predicted interpolation moment, based on the predicted interpolation moment and the target optical flow map, determining a predicted optical flow map corresponding to the interpolation moment; Based on the predicted optical flow map and the target image frame, a target predicted frame is determined to obtain a target predicted frame corresponding to the predicted interpolation frame moment, wherein when the target optical flow image is a forward optical flow map, the target image frame is a first image frame, and the target predicted frame is a first predicted frame; when the target optical flow image is a backward optical flow map, the target image frame is a second image frame, and the target predicted frame is a second predicted frame; Based on the first predicted frame and the second predicted frame corresponding to the predicted interpolation frame moment, interpolation frame images corresponding to the first image frame and the second image frame are determined to obtain a plurality of interpolation frame images.
8. The method for generating video interpolation frames based on optical flow according to claim 7, characterized in that: The method further comprises: For each interpolated image frame, the interpolated image is inserted between the first image frame and the second image frame according to its corresponding interpolation time to obtain an interpolated video, wherein the frame rate of the interpolated video is higher than the frame rate of the original video.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps in the method for generating video interpolation based on optical flow as described in any one of claims 1 to 8.
10. A terminal device, characterized in that: include: Processor, memory and communication bus; The memory stores a computer-readable program executable by the processor; The communication bus realizes the connection and communication between the processor and the memory; When the processor executes the computer-readable program, the steps in the method for generating video interpolation based on optical flow as described in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
A method and apparatus for generating an interpolated frame image of a video
CN109922231A
Method and device for training optical flow network and processing image
CN110310299A
Video frame insertion method, computer storage medium and server
CN110392282A
Method and device for improving frame insertion effect
CN111277780A
Optical flow frame insertion method and device
CN111277863A
