Video inpainting method, related apparatus, device and storage medium

Determining the video repair method through optical flow clustering, combining the optical flow method and the neural network method, solves the problem in the existing technology that the optical flow is susceptible to interference and the neural network is easy to cause blur, and improves the effect and stability of video repair.

WO2023193521A9PCT designated stage expired Publication Date: 2024-09-12TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/075576
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2022-04-06
Filing Date
2023-02-13
Publication Date
2024-09-12

AI Technical Summary

Technical Problem

Among the existing video repair technologies, although the method based on optical flow has high definition, it is susceptible to interference and prone to distortion and false filling, while the method based on neural network is stable but prone to blurred filling.

Method used

By obtaining the video sample sequence and optical flow data, optical flow clustering processing is performed to determine the optical flow quality score, and an appropriate video repair method is selected based on the optical flow quality, and the optical flow method or neural network method is selected for repair.

Benefits of technology

It is possible to use the optical flow method to obtain high-definition filling content when the optical flow quality is good, and to use the neural network method to obtain a high-stability filling effect when the optical flow quality is poor, improving the overall quality of video repair. Effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023075576_12092024_PF_FP_ABST
    Figure CN2023075576_12092024_PF_FP_ABST
Patent Text Reader

Abstract

The present application discloses a video inpainting method based on artificial intelligence, with application scenarios at least comprising different types of terminal, such as a mobile phone, a computer, and a vehicle-mounted terminal. The present application comprises: acquiring a video sample sequence; acquiring a target mask sample sequence according to the video sample sequence; acquiring an optical flow data sequence according to the video sample sequence; on the basis of each piece of optical flow data in the optical flow data sequence, performing clustering processing on pixel points comprised by a target mask region in each target mask frame, to obtain an optical flow clustering result for each target mask frame; determining an optical flow quality score according to the optical flow clustering result of each target mask frame; and performing inpainting processing on a video to be inpainted using a video inpainting mode matching the optical flow quality score. The present application also provides a related apparatus. According to the present application, the optical flow quality is used as a basis for selecting a video inpainting mode, enabling different video inpainting modes to complement each other, thereby helping to obtain a video picture having a better inpainting effect.
Need to check novelty before this filing date? Find Prior Art

Description

A video repair method, related device, equipment and storage medium

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on April 6, 2022, with application number 2022103555942 and application name “A method, related devices, equipment and storage medium for video repair”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of data processing technology, and in particular to video restoration technology. Background Art

[0003] Video inpainting is a task used to fill in missing areas in video frames with reasonable content. It mainly uses information from unobstructed areas in the video to repair obscured areas. For example, it can repair damaged videos, remove unwanted objects, reposition videos, and repair underexposed images.

[0004] Currently, there are two main types of video restoration techniques. One uses optical flow propagation and image inpainting, which first propagates available pixels to the corresponding area through optical flow, and then uses image inpainting to fill in isolated pixel blocks. The other uses an end-to-end neural network approach, using a generative model to fill in occluded areas.

[0005] However, these video restoration techniques have at least the following issues: While optical flow-based infilling provides high-definition content, it relies heavily on optical flow, which is susceptible to interference and can be estimated inaccurately, making it prone to distortion and inaccurate infilling. End-to-end neural network approaches consider semantic information and generally avoid distortion and serious errors. However, complex backgrounds can easily lead to blurred infill content.

[0006] Summary of the Invention

[0007] The embodiments of the present application provide a method, related apparatus, device, and storage medium for video restoration. The present application uses optical flow quality as the basis for selecting a video restoration method, allowing different video restoration methods to complement each other's strengths and weaknesses, thereby facilitating the acquisition of better restored video images.

[0008] In view of this, the present application provides, on one hand, a method for video restoration, which is performed by a computer device and includes:

[0009] Obtain a video sample sequence corresponding to the video to be repaired, wherein the video sample sequence includes K video frame pairs, each video frame pair includes two adjacent video frames, and K is an integer greater than or equal to 1;

[0010] Obtaining a target mask sample sequence according to the video sample sequence, wherein the target mask sample sequence includes K target mask frames, each target mask frame includes a target mask region obtained by expanding an original mask region, and there is a one-to-one correspondence between the K target mask frames and the K video frame pairs;

[0011] Obtain an optical flow data sequence according to the video sample sequence, wherein the optical flow data sequence includes K optical flow data, and there is a one-to-one correspondence between the K optical flow data and the K video frame pairs;

[0012] Based on each optical flow data in the optical flow data sequence, clustering processing is performed on the pixel points included in the target mask area in each target mask frame to obtain an optical flow clustering result of each target mask frame;

[0013] Determine the optical flow quality score based on the optical flow clustering results of each target mask frame;

[0014] The video to be repaired is repaired using a video repair method that matches the optical flow quality score.

[0015] Another aspect of the present application provides a video restoration device, comprising:

[0016] An acquisition module, configured to acquire a video sample sequence for a video to be repaired, wherein the video sample sequence includes K video frame pairs, each video frame pair includes two adjacent video frames, and K is an integer greater than or equal to 1;

[0017] The acquisition module is further configured to acquire a target mask sample sequence according to the video sample sequence, wherein the target mask sample sequence includes K target mask frames, each target mask frame includes a target mask area obtained by expanding an original mask area, and there is a one-to-one correspondence between the K target mask frames and the K video frame pairs;

[0018] The acquisition module is further configured to acquire an optical flow data sequence according to the video sample sequence, wherein the optical flow data sequence includes K optical flow data, and there is a one-to-one correspondence between the K optical flow data and the K video frame pairs;

[0019] a processing module, configured to perform clustering processing on the pixel points included in the target mask area in each target mask frame based on each optical flow data in the optical flow data sequence, to obtain an optical flow clustering result for each target mask frame;

[0020] A determination module, configured to determine an optical flow quality score based on the optical flow clustering result of each target mask frame;

[0021] The restoration module is used to restore the video to be restored by using a video restoration method that matches the optical flow quality score.

[0022] On the other hand, the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned methods when executing the computer program.

[0023] Another aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the above-mentioned methods when the computer program is executed by a processor.

[0024] Another aspect of the present application provides a computer program product, including a computer program, which implements the above-mentioned methods when executed by a processor.

[0025] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:

[0026] In an embodiment of the present application, a method for video restoration is provided. First, a video sample sequence corresponding to the video to be restored is obtained. Then, a target mask sample sequence can be obtained based on the video sample sequence, wherein each target mask frame includes a target mask area obtained by expanding the original mask area. Furthermore, an optical flow data sequence is obtained based on the video sample sequence. Then, based on the individual optical flow data in the optical flow data sequence, the pixels included in the target mask area in each target mask frame are clustered to obtain an optical flow clustering result for each target mask frame. Based on this, an optical flow quality score can be determined based on the optical flow clustering result of each target mask frame, and a video restoration method that matches the optical flow quality score is used to restore the video to be restored. In this way, the optical flow clustering result of the masked area is used to predict the optical flow quality. When the optical flow quality is good, the optical flow method can be used as a video restoration method to obtain fill content with high clarity and credibility. When the optical flow quality is poor, a generative model can be used as a video restoration method to obtain a fill effect with high stability. It can be seen that this application uses optical flow quality as the basis for selecting a video restoration method, so that different video restoration methods can complement each other, thereby facilitating obtaining a video image with a better restoration effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] FIG1 is a schematic diagram of the architecture of a video restoration system according to an embodiment of the present application;

[0028] FIG2 is an effect diagram of video frame filling based on the optical flow method in an embodiment of the present application;

[0029] FIG3 is an effect diagram of video frame filling based on the model method in an embodiment of the present application;

[0030] FIG4 is a flow chart of a video restoration method according to an embodiment of the present application;

[0031] FIG5 is a schematic diagram of generating a target mask frame in an embodiment of the present application;

[0032] FIG6 is another schematic diagram of generating a target mask frame according to an embodiment of the present application;

[0033] FIG7 is another schematic diagram of generating a target mask frame in an embodiment of the present application;

[0034] FIG8 is another schematic diagram of generating a target mask frame in an embodiment of the present application;

[0035] FIG9 is a schematic diagram of determining a two-dimensional optical flow value based on forward optical flow in an embodiment of the present application;

[0036] FIG10 is a schematic diagram of determining a two-dimensional optical flow value based on backward optical flow in an embodiment of the present application;

[0037] FIG11 is a schematic diagram showing an effect of removing a mark based on a video repair application in an embodiment of the present application;

[0038] FIG12 is a schematic diagram showing the effect of removing subtitles based on a video repair application in an embodiment of the present application;

[0039] FIG13 is a schematic diagram showing an effect of removing an object based on a video restoration application in an embodiment of the present application;

[0040] FIG14 is a schematic diagram showing a comparison of the effects of video frame restoration based on the optical flow method and the model method in an embodiment of the present application;

[0041] FIG15 is a schematic diagram of a video restoration device according to an embodiment of the present application;

[0042] FIG16 is a schematic structural diagram of a terminal in an embodiment of the present application;

[0043] FIG17 is a schematic structural diagram of a server in an embodiment of the present application. DETAILED DESCRIPTION

[0044] With the advent of the multimedia and artificial intelligence (AI) era, video has gradually become the mainstream way of information exchange. The massive amount of video has posed more challenges to video quality management. At present, videos may have defects due to certain reasons. For example, there are mosaic patterns in the video screen, which will affect the user's viewing experience. For example, during the video formation process, there may be station logos or advertising patterns. Based on this, the present application proposes a video repair method, which aims to remove unnecessary objects in the video or restore damaged images.

[0045] The video restoration method specifically involves AI-based computer vision (CV) and machine learning (ML). Specifically, CV technology is used to identify repairable objects (e.g., station logos, subtitles, etc.) in the video. A neural network trained using ML is then used to restore the video.

[0046] In order to improve the effect of video image restoration, the present application proposes a video restoration method, which is applied to the video restoration system shown in Figure 1. As shown in the figure, the video restoration system includes a server and a terminal, and a client is deployed on the terminal, wherein the client can be run on the terminal in the form of a browser, or can be run on the terminal in the form of an independent application (APP), etc. The specific presentation form of the client is not limited here. The server involved in this application can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud services. The terminal can be a mobile phone, a computer, an intelligent voice interaction device, a smart home appliance, a car terminal, an aircraft, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application does not impose any restrictions on this. There is no limit on the number of servers and terminals. The solution provided in this application can be completed independently by the terminal, independently by the server, or by the terminal and server in cooperation, and this application does not impose any specific restrictions on this.

[0047] The following describes the workflows for two video restoration scenarios using the architecture shown in Figure 1.

[0048] For example, in one scenario, a user can upload a video to a server via a terminal, and the server can directly invoke the video restoration function. Specifically, the server first determines the selected video restoration algorithm (i.e., optical flow or modeling), and based on this, uses the corresponding video restoration algorithm to restore the video. Finally, the restored video is stored in a database. When the terminal requests the server to play a video, the server retrieves the corresponding video from the database and feeds it back to the terminal.

[0049] For example, in another scenario, a user can upload a video to a server via a terminal, and the server stores the uploaded video in a database. When a video needs to be repaired, the corresponding video can be selected from the database and then the video repair function is called. That is, the selected video repair algorithm (i.e., optical flow method or model method) is first determined. Based on this, the corresponding video repair algorithm is used to repair the video. Finally, the repaired video is stored in the database.

[0050] There are some differences in the effects of video restoration using optical flow and model methods. The following diagrams will explain these differences.

[0051] 1. Fill the mask area based on the optical flow method;

[0052] For ease of introduction, please refer to Figure 2, which is an effect diagram of video frame filling based on the optical flow method in an embodiment of the present application. As shown in Figure 2 (a), a mask object is detected in the video frame. After filling using the optical flow method, a video frame as shown in Figure 2 (b) is obtained. It can be seen that in the case of object occlusion and complex background movement, the filling effect achieved by the optical flow method will be greatly affected, and the erroneous pixels caused by the optical flow estimation error will gradually expand as it propagates, resulting in incorrect filling content.

[0053] 2. Fill the mask area based on the model method;

[0054] For ease of introduction, please refer to Figure 3, which shows an example of the effects of implementing video frame filling based on the model method in an embodiment of the present application. As shown in Figure 3 (a), a masked object is detected in the video frame. After filling using the model method, the video frame shown in Figure 3 (b) is obtained. As can be seen, the filled portion is relatively blurry, and due to limitations in video memory and other factors, it is difficult to process high-resolution input. However, the overall effect is relatively stable, and it is not prone to obvious errors with strong contrast.

[0055] In combination with the above introduction, due to the limitations of the restoration quality of the optical flow method and the model method, this application proposes a video restoration method that can pre-determine which video restoration method to select for image restoration, and then use a more appropriate video restoration method to restore the video image, thereby achieving a more robust filling effect. The following will introduce the video restoration method in this application. Please refer to Figure 4. In the embodiment of this application, the video restoration method can be executed by a computer device, which can be a terminal or a server. The embodiment of this application includes:

[0056] 110. Obtain a video sample sequence corresponding to the video to be repaired, where the video sample sequence includes K video frame pairs, each video frame pair includes two adjacent video frames, and K is an integer greater than or equal to 1.

[0057] In one or more embodiments, a computer device may obtain a video to be repaired, and then extract K video frame pairs from the video to be repaired to form a video sample sequence, where each video frame pair includes two adjacent video frames, and each video frame has a corresponding video frame number. For example, if normalization is not performed, the video sample sequence can be represented as x s , x s ={(x1,x2),(x 11 ,x 12),…}. ; Wherein, the video sample sequence includes K video frame pairs, that is, the first video frame pair is represented as (x1, x2), the second video frame pair is represented as (x 11 ,x 12 ), and so on. For example, if normalization has been performed, the video sample sequence is represented as x sr , x sr ={(x r1 ,x r2 ),(x r11 ,x r12 ),…}; wherein the video sample sequence includes K video frame pairs, that is, the first video frame pair is represented as (x r1 ,x r2 ), the second video frame pair is represented as (x r11 ,x r12 ), and so on.

[0058] 120. Obtain a target mask sample sequence according to the video sample sequence, wherein the target mask sample sequence includes K target mask frames, each target mask frame includes a target mask area obtained by expanding an original mask area, and there is a one-to-one correspondence between the K target mask frames and the K video frame pairs.

[0059] In one or more embodiments, after obtaining a video sample sequence, a computer device may obtain at least one corresponding original mask frame for each video frame pair. For each original mask frame, the corresponding original mask region is marked, and then the original mask region is expanded by a certain number of pixels to obtain a target mask region. A target mask frame is then obtained based on the target mask region. Thus, a target mask sample sequence comprising K target mask frames is obtained.

[0060] 130. Obtain an optical flow data sequence according to the video sample sequence, wherein the optical flow data sequence includes K optical flow data, and there is a one-to-one correspondence between the K optical flow data and the K video frame pairs.

[0061] In one or more embodiments, a computer device may generate corresponding optical flow data based on K video frame pairs in a video sample sequence, thereby obtaining an optical flow data sequence including K optical flow data. The optical flow data may be represented as a two-channel optical flow matrix. One optical flow matrix is ​​used to record the horizontal offset of all pixels in the video frame pair, and the other optical flow matrix is ​​used to record the vertical offset of all pixels in the video frame pair.

[0062] It should be noted that, in actual applications, the computer device may execute step 120 first and then step 130, or may execute step 130 first and then step 120, or may execute steps 120 and 130 at the same time. The embodiment of the present application does not impose any limitation on the execution order of steps 120 and 130.

[0063] 140. Based on each optical flow data in the optical flow data sequence, cluster the pixels included in the target mask area in each target mask frame to obtain an optical flow clustering result for each target mask frame.

[0064] In one or more embodiments, the optical flow data sequence is aligned with the target mask sample sequence, i.e., the optical flow data in the optical flow data sequence corresponds to the target mask frame in the target mask sample sequence. Based on this, for each target mask frame, the corresponding optical flow data is used to assign a corresponding two-dimensional optical flow value to each pixel within the target mask region. Then, based on the two-dimensional optical flow values ​​of each pixel, a clustering algorithm is used to cluster these pixels, thereby obtaining an optical flow clustering result for each target mask frame.

[0065] It is understandable that the present application may use a density-based spatial clustering of applications with noise (DBSCAN), or a mean shift clustering method (meanshift), or other clustering methods to cluster pixels, which is not limited here.

[0066] 150. Determine an optical flow quality score based on the optical flow clustering result of each target mask frame.

[0067] In one or more embodiments, the computer device may combine the optical flow clustering results of each target mask frame to comprehensively determine the quality of the optical flow, thereby generating a corresponding optical flow quality score. For example, the optical flow quality score in this application is a first score or a second score. A first score indicates good optical flow quality, for example, the first score may be "1." A second score indicates poor optical flow quality, for example, the second score may be "0."

[0068] It is understandable that in actual applications, other values ​​may be set for the first score and the second score respectively. This is only an illustration and should not be understood as a limitation to the present application.

[0069] 160. A video restoration method that matches the optical flow quality score is used to restore the video to be restored.

[0070] In one or more embodiments, the computer device may select a corresponding video restoration method based on the optical flow quality score. Specifically, if the optical flow quality score is a first value, the video to be restored is restored using an optical flow method. If the optical flow quality score is a second value, the video to be restored is restored using a neural network.

[0071] Specifically, the process of using optical flow to inpaint a video involves estimating optical flow using adjacent frames, then filling the original masked area in each frame with optical flow. This process propagates the pixel gradients of the unmasked area to the original masked area. Poisson reconstruction is then performed on the pixel gradients to generate red, green, and blue (RGB) pixels. Finally, image inpainting is performed on areas that cannot be filled with optical flow.

[0072] The process of calling a neural network to repair the video to be repaired is to receive the frame sequence information as input, and output the repaired video frame after processing by the neural network. It can be understood that the neural network mostly adopts an encoder-decoder structure. The neural network used in this application can be a fine-grained visual categorization (FGVC) network, or a spatial-temporal transformer network (STTN), or a decoupled spatial-temporal attention network (DSTT), etc., which are not limited here.

[0073] The embodiment of the present application provides a method for video restoration. Through the above method, the optical flow clustering result of the masked area is used to predict the optical flow quality. When the optical flow quality is good, the optical flow method can be used as a video restoration method to obtain filling content with higher clarity and credibility. When the optical flow quality is poor, a generative model can be used as a video restoration method to obtain a filling effect with higher stability. It can be seen that the present application uses optical flow quality as the basis for selecting a video restoration method, so as to achieve the purpose of making different video restoration methods complement each other, thereby facilitating the acquisition of video images with better restoration effects.

[0074] Optionally, based on the embodiment corresponding to FIG. 4 above, in another optional embodiment provided by the embodiment of the present application, obtaining a video sample sequence corresponding to the video to be repaired may specifically include:

[0075] Obtaining a video sequence from the video to be repaired, wherein the video sequence includes T original video frames, each original video frame displays a target object, and T is an integer greater than 1;

[0076] Extracting K to-be-processed video frame pairs from a video sequence, wherein each to-be-processed video frame pair includes two adjacent original video frames;

[0077] Normalize the size of each original video frame in the K video frame pairs to be processed to obtain K video frame pairs, and use the K video frame pairs as video sample sequences.

[0078] In one or more embodiments, a method for generating a video sample sequence is introduced. As can be seen from the above embodiments, the video sample sequence is derived from the video to be repaired, and the video to be repaired is represented by x={x t}(t=1,2,…,T), it can be seen that the video to be repaired includes T original video frames, that is, x t Represents the tth original video frame.

[0079] Specifically, adjacent original video frames can be extracted at a certain interval. For example, a group of adjacent original video frames are extracted every 10 frames, and the extracted sequence can be expressed as x s , x s ={(x1,x2),(x 11 ,x 12 ),…}, where the sequence includes K pairs of video frames to be processed, that is, the first pair of video frames to be processed is represented as (x1, x2), the second pair of video frames to be processed is represented as (x 11 ,x 12 ), and so on. Based on this, each original video frame in the video frame pair to be processed is size-normalized to obtain the corresponding video frame. Adjacent video frames constitute a video frame pair, and K video frame pairs constitute a video sample sequence, where the video sample sequence can be expressed as x sr , x sr ={(x r1 ,x r2 ),(x r11 ,x r12 ),…}.

[0080] It should be noted that the video frame after size normalization has a fixed size, for example, 512×288.

[0081] Secondly, embodiments of the present application provide a method for generating a video sample sequence. This method, on the one hand, extracts a number of to-be-processed video frames from a video sequence for subsequent processing, thereby reducing the amount of data to be processed and conserving data processing resources. On the other hand, size normalization is performed on the original video frames, which not only aligns the statistics of each video frame but also reduces the size of the video frames, thereby improving processing efficiency.

[0082] Optionally, based on the embodiment corresponding to FIG. 4 , in another optional embodiment provided by the embodiment of the present application, obtaining a target mask sample sequence according to a video sample sequence may specifically include:

[0083] For each video frame pair in the video sample sequence, obtaining an original mask frame corresponding to the video frame pair based on any one of the video frames in the video frame pair, wherein the original mask frame includes an original mask area obtained after masking the target object in any one of the video frames;

[0084] For each video frame pair in the video sample sequence, the original mask region in the original mask frame corresponding to the video frame pair is expanded to obtain a target mask frame corresponding to the video frame pair;

[0085] The target mask frames corresponding to each of the K video frame pairs are used as the target mask sample sequence.

[0086] In one or more embodiments, a method for generating a target mask frame based on a single video frame is described. As can be seen from the aforementioned embodiments, if a target object is displayed in the video to be restored, a masking process is performed on the target object to obtain a corresponding original mask region. The original mask region is then expanded by a certain number of pixels to obtain a target mask region.

[0087] It should be noted that the target object can be a logo, a subtitle, an object, etc. It is understood that methods for identifying the target object include but are not limited to manual labeling and model recognition, for example, using a fully convolution network (FCN) to identify the target object.

[0088] For example, one processing method is that the video to be repaired is x={x t}(t=1,2,…,T). Mask processing is performed on each original video frame in the video to be repaired, thereby obtaining m={m t}(t=1,2,…,T). Assume that a group of adjacent original video frames are extracted every 10 frames, then the extracted video sample sequence is represented as x s ={(x1,x2),(x 11 ,x 12 ),…}, thus, the corresponding mask frame sequence is expressed as m s ={(m1,m2),(m 11 ,m 12 ),…}, where (m1,m2) corresponds to (x1,x2), (m 11 ,m 12 ) corresponds to (x 11 ,x 12 ), and so on. If the forward optical flow is used, then based on ms Extract the previous video frame of each video frame pair and get m sF ={m1,m 11 ,…}, then m sF Normalized, the original mask frame sequence is represented as m sr ={m r1 ,m r11 ,…}; where m r1 Corresponding to (x1,x2), m r11 Corresponding to (x 11 ,x 12 ), and so on. If backward optical flow is used, then based on m s Extract the next video frame of each video frame pair and get m sB ={m2,m 12 ,…}, then m sB Normalized, the original mask frame sequence is represented as m sr ={m r2 ,m r12 ,…}, where m r2 Corresponding to (x1,x2), m r12 Corresponding to (x 11 ,x 12 ), and so on. The original mask frame sequence includes K original mask frames.

[0089] For example, one processing method is that the video to be repaired is x={x t}(t=1,2,…,T). Assume that a set of adjacent original video frames is extracted every 10 frames, then the extracted sequence is represented as x s ={(x1,x2),(x 11 ,x 12 ),…}. For x s Each original video frame in is normalized and the video sample sequence is expressed as x sr ={(x r1 ,x r2 ),(x r11 ,x r12 ),…}. If the forward optical flow is used, then based on x sr Extract the previous video frame of each video frame pair and get x srF ={x r1 ,x r11 ,…}, then for x srF Perform mask processing, and the original mask frame sequence obtained is represented as m sr ={m r1 ,m r11 ,…}; where m r1 Corresponding to (x r1,x r2 ), m r11 Corresponding to (x r11 ,x r12 ), and so on. If backward optical flow is used, then based on x sr Extract the next video frame of each video frame pair and get x srB ={x r2 ,x r12 ,…}, then for x srB Perform mask processing, and the original mask frame sequence obtained is represented as m sr ={m r2 ,m r12 ,…}, where m r2 Corresponding to (x r1 ,x r2 ), m r12 Corresponding to (x r11 ,x r12 ), and so on. The original mask frame sequence includes K original mask frames.

[0090] Specifically, for ease of understanding, please refer to Figure 5, which is a schematic diagram of generating a target mask frame in an embodiment of the present application. Taking the original mask frame shown in Figure 5 (a) as an example, the 15 pixels marked as "1" constitute the original mask area. Assume that the original mask area is expanded by 2 pixels to obtain the target mask area (i.e., the gray area composed of pixels marked as "1"). Based on this, the target mask frame shown in Figure 5 (b) is obtained.

[0091] Similarly, each original mask frame is processed until the target mask sample sequence is obtained. The target mask sample sequence can be expressed as {m dst}(t=1,2,…,K). Among them, m dst represents the t-th target mask frame.

[0092] Secondly, the present embodiment provides a method for generating a target mask frame based on a single video frame. In this way, considering that the original mask regions of the two frames before and after the video frame pair are not much different, the region expansion process can be performed on only one of the original mask frames, thereby reducing the complexity of the operation.

[0093] Optionally, based on the embodiment corresponding to FIG. 4 above, another optional embodiment provided by the embodiment of the present application includes, for each video frame pair in the video sample sequence, expanding the original mask area in the original mask frame corresponding to the video frame pair to obtain a target mask frame corresponding to the video frame pair, which may specifically include:

[0094] For each video frame pair in the video sample sequence, expanding an original mask region in an original mask frame corresponding to the video frame pair according to a first number of pixels to obtain a first mask region corresponding to the video frame pair;

[0095] For each video frame pair in the video sample sequence, dilate an original mask region in an original mask frame corresponding to the video frame pair according to a second number of pixels to obtain a second mask region corresponding to the video frame pair, wherein the second number of pixels is greater than the first number of pixels;

[0096] For each video frame pair in the video sample sequence, an exclusive OR operation is performed on the first mask area and the second mask area corresponding to the video frame pair to obtain a target mask frame corresponding to the video frame pair.

[0097] In one or more embodiments, a method for expanding an original mask region is described. As can be seen from the aforementioned embodiments, for each original mask frame in the original mask frame sequence, the original mask region can be expanded to obtain a target mask region. This results in a target mask frame containing the target mask region.

[0098] Specifically, for ease of understanding, please refer to Figure 6, which is another schematic diagram of generating a target mask frame in an embodiment of the present application. Taking the original mask frame shown in Figure 6 (a) as an example, wherein 15 pixels marked as "1" constitute the original mask area. Assuming that the original mask area is expanded according to a first number of pixels (for example, 2 pixels), a first mask area (i.e., a gray area composed of pixels marked as "1") is obtained, that is, a mask frame as shown in Figure 6 (b) is obtained. Assuming that the original mask area is expanded according to a second number of pixels (for example, 4 pixels), a second mask area (i.e., a gray area composed of pixels marked as "1") is obtained, that is, a mask frame as shown in Figure 6 (c) is obtained. Furthermore, an exclusive OR operation is performed on the first mask area and the second mask area to obtain a target mask frame as shown in Figure 6 (d), wherein the target mask frame includes the target mask area (i.e., a gray area composed of pixels marked as "1").

[0099] Similarly, each original mask frame is processed until the target mask sample sequence is obtained. The target mask sample sequence can be expressed as {m dst =m da ^m db}(t=1,2,…,K). Among them, m dst represents the tth target mask frame, m da represents the mask frame including the first mask area, a represents the number of first pixels, m db represents the mask frame including the second mask area, b represents the second number of pixels, and “^” represents the exclusive OR operator.

[0100] In practical applications, the number of the first pixels may be 7, and the number of the second pixels may be 9. Thus, the target mask sample sequence can be expressed as {m dst =m d7 ^m d9}(t=1, 2, ..., K) It should be noted that the first number of pixels and the second number of pixels can be adjusted according to circumstances and are not limited here.

[0101] Thirdly, the embodiments of the present application provide a method for expanding the original mask area. With this method, the optical flow within the original mask area is derived from the surrounding optical flow. If the surrounding optical flow is chaotic, the optical flow within the original mask area cannot be well filled. Considering that pixels close to the original mask area may contain some noise, the target mask area obtained by deviating from the original mask area has less noise, which helps improve the judgment effect of optical flow quality.

[0102] Optionally, based on the embodiment corresponding to FIG. 4 , in another optional embodiment provided by the embodiment of the present application, obtaining a target mask sample sequence according to a video sample sequence may specifically include:

[0103] For each video frame pair in the video sample sequence, obtaining a first original mask frame corresponding to the video frame pair based on a previous video frame in the video frame pair, and obtaining a second original mask frame corresponding to the video frame pair based on a subsequent video frame in the video frame pair, wherein the first original mask frame and the second original mask frame respectively include original mask regions obtained after masking the target object in the previous video frame and the subsequent video frame;

[0104] For each video frame pair in the video sample sequence, performing union processing on the first original mask frame and the second original mask frame corresponding to the video frame pair to obtain the original mask frame corresponding to the video frame pair;

[0105] For each video frame pair in the video sample sequence, the original mask region in the original mask frame corresponding to the video frame pair is expanded to obtain a target mask frame corresponding to the video frame pair;

[0106] The target mask frames corresponding to each of the K video frame pairs are used as the target mask sample sequence.

[0107] In one or more embodiments, a method for generating a target mask frame based on multiple video frames is described. As can be seen from the aforementioned embodiments, if a target object is displayed in the video to be restored, a masking process is performed on the target object to obtain a corresponding original mask region. The original mask region is then expanded by a certain number of pixels to obtain a target mask region.

[0108] It should be noted that the target object may be a logo, a subtitle, an object, etc. It is understood that the method of identifying the target object includes but is not limited to manual labeling and model recognition, for example, using FCN to identify the target object.

[0109] For example, one processing method is that the video to be repaired is x={x t}(t=1,2,…,T). Mask processing can be performed on each original video frame in the video to be repaired, thereby obtaining m={m t}(t=1,2,…,T). Assume that a group of adjacent original video frames are extracted every 10 frames, then the extracted video sample sequence is represented as x s ={(x1,x2),(x 11 ,x 12 ),…}, thus, the corresponding mask frame sequence is expressed as m s ={(m1,m2),(m 11 ,m 12 ),…}. Then for m s Normalized, the original mask frame sequence is represented as m sr ={(m r1 ,m r2 ),(m r11 ,m r12 ),…}. The original mask frame sequence includes K first original mask frames (ie, {m r1 ,m r11 ,…}) and K second original mask frames (ie, m sr ={m r2 ,m r12 ,…}); In the first original mask frame, m r1 Corresponding to (x1,x2), m r11 Corresponding to (x 11 ,x 12 ), and so on; in the second original mask frame, m r2 Corresponding to (x1,x2), m r12 Corresponding to (x 11 ,x 12 ), and so on.

[0110] For example, one processing method is that the video to be repaired is x={x t}(t=1,2,…,T). Assume that a set of adjacent original video frames is extracted every 10 frames, then the extracted sequence is represented as x s ={(x1,x2),(x 11 ,x 12 ),…}. For x sEach original video frame in is normalized and the video sample sequence is expressed as x sr ={(x r1 ,x r2 ),(x r11 ,x r12 ),…}. Then for x sr Perform mask processing, and the original mask frame sequence obtained is represented as m sr ={(m r1 ,m r2 ),(m r11 ,m r12 ),…}. The original mask frame sequence includes K first original mask frames (ie, {m r1 ,m r11 ,…}) and K second original mask frames (ie, m sr ={m r2 ,m r12 ,…}); In the first original mask frame, m r1 Corresponding to (x r1 ,x r2 ), m r11 Corresponding to (x r11 ,x r12 ), and so on; in the second original mask frame, m r2 Corresponding to (x r1 ,x r2 ), m r12 Corresponding to (x r11 ,x r12 ), and so on.

[0111] Specifically, for ease of understanding, please refer to Figure 7, which is another schematic diagram of generating a target mask frame in an embodiment of the present application. Figure 7 (a) shows the first original mask frame, wherein the 13 pixels marked as "1" constitute the original mask area of ​​the first original mask frame. Figure 7 (b) shows the second original mask frame, wherein the 13 pixels marked as "1" constitute the original mask area of ​​the second original mask frame. After the first original mask frame and the second original mask frame are combined, the original mask frame shown in Figure 7 (c) is obtained, wherein the 15 pixels marked as "1" constitute the original mask area of ​​the original mask frame. Assume that the original mask area is expanded according to the number of 2 pixels to obtain the target mask area (i.e., the gray area composed of pixels marked as "1"). Based on this, the target mask frame shown in Figure 7 (d) is obtained.

[0112] Similarly, each original mask frame is processed until the target mask sample sequence is obtained. The target mask sample sequence can be expressed as {m dst}(t=1,2,…,K). Among them, m dst represents the t-th target mask frame.

[0113] Secondly, embodiments of the present application provide a method for generating a target mask frame based on multiple video frames. This method takes into account the potential differences between the original mask regions of the preceding and following video frames in a video frame pair. Therefore, the original mask regions of the preceding and following frames are first unioned to obtain a more accurate original mask region. This improves the processing performance of the video frames.

[0114] Optionally, based on the embodiment corresponding to FIG. 4 above, another optional embodiment provided by the embodiment of the present application includes, for each video frame pair in the video sample sequence, expanding the original mask area in the original mask frame corresponding to the video pair to obtain a target mask frame corresponding to the video pair, which may specifically include:

[0115] For each video frame pair in the video sample sequence, expanding an original mask region in an original mask frame corresponding to the video pair according to a first number of pixels to obtain a first mask region corresponding to the video pair;

[0116] For each video frame pair in the video sample sequence, dilate an original mask region in an original mask frame corresponding to the video pair according to a second number of pixels to obtain a second mask region corresponding to the video pair, wherein the second number of pixels is greater than the first number of pixels;

[0117] For each video frame pair in the video sample sequence, an exclusive OR operation is performed on the first mask area and the second mask area corresponding to the video pair to obtain a target mask frame corresponding to the video pair.

[0118] In one or more embodiments, a method for expanding an original mask region is described. As can be seen from the aforementioned embodiments, for each original mask frame in the original mask frame sequence, the original mask region therein can be expanded to obtain a target mask region. This results in a target mask frame containing the target mask region.

[0119] Specifically, for ease of understanding, please refer to Figure 8, which is another schematic diagram of generating a target mask frame in an embodiment of the present application. Figure 8 (a) shows the first original mask frame, wherein the 13 pixels marked as "1" constitute the original mask area of ​​the first original mask frame. Figure 8 (b) shows the second original mask frame, wherein the 13 pixels marked as "1" constitute the original mask area of ​​the second original mask frame. After the first original mask frame and the second original mask frame are combined, the original mask frame shown in Figure 8 (c) is obtained, wherein the 15 pixels marked as "1" constitute the original mask area of ​​the original mask frame. Assuming that the original mask area is expanded according to the first number of pixels (for example, 2 pixels), the first mask area (i.e., the gray area composed of pixels marked as "1") is obtained, that is, the mask frame shown in Figure 8 (d) is obtained. Assume that the original mask area is expanded according to a second number of pixels (for example, 4 pixels), resulting in a second mask area (i.e., a gray area consisting of pixels marked as "1"), thus obtaining the mask frame shown in Figure 8(e). Based on this, an XOR operation is performed on the first mask area and the second mask area to obtain the target mask frame shown in Figure 8(f), where the target mask frame includes the target mask area (i.e., a gray area consisting of pixels marked as "1").

[0120] Similarly, each original mask frame is processed until the target mask sample sequence is obtained. The target mask sample sequence can be expressed as {m dst =m da ^m db}(t=1,2,…,K). Among them, m dst represents the tth target mask frame, m da represents the mask frame including the first mask area, a represents the number of first pixels, m db represents the mask frame including the second mask area, b represents the second number of pixels, and “^” represents the exclusive OR operator.

[0121] In practical applications, the number of the first pixels may be 7, and the number of the second pixels may be 9. Thus, the target mask sample sequence can be expressed as {m dst =m d7 ^m d9}(t=1, 2, ..., K) It should be noted that the first number of pixels and the second number of pixels can be adjusted according to circumstances and are not limited here.

[0122] Thirdly, the embodiments of the present application provide a method for expanding the original mask area. With this method, the optical flow within the original mask area is derived from the surrounding optical flow. If the surrounding optical flow is chaotic, the optical flow within the original mask area cannot be well filled. Considering that pixels close to the original mask area may contain some noise, the target mask area obtained by deviating from the original mask area has less noise, which helps improve the judgment effect of optical flow quality.

[0123] Optionally, based on the embodiment corresponding to FIG. 4 , in another optional embodiment provided by the embodiment of the present application, obtaining an optical flow data sequence according to a video sample sequence may specifically include:

[0124] For each video frame pair in the video sample sequence, determine the optical flow data corresponding to the video pair based on the horizontal offset and vertical offset of each pixel point in the latter video frame relative to each pixel point in the previous video frame in the video pair;

[0125] The optical flow data corresponding to each of the K video pairs is used as an optical flow data sequence;

[0126] or,

[0127] Obtaining an optical flow data sequence based on a video sample sequence may specifically include:

[0128] For each video frame pair in the video sample sequence, determine the optical flow data corresponding to the video pair based on the horizontal offset and vertical offset of each pixel point in the previous video frame relative to each pixel point in the next video frame in the video pair;

[0129] The optical flow data corresponding to each of the K video pairs is used as an optical flow data sequence.

[0130] In one or more embodiments, two methods for determining optical flow data based on video frame pairs are introduced. As can be seen from the above embodiments, the video sample sequence includes K video frame pairs, each video frame pair includes two video frames. If the video frames have been size-normalized, the video sample sequence can be represented as x sr ={(x r1 ,x r2 ),(x r11 ,x r12 ),…}. Assuming the size of the video frame is 512×288, the optical flow data Fl t It can represent an optical flow matrix with 2 channels and a size of 512×288. The optical flow data sequence is represented as {Fl t}(t=1,…,K). Thus, the two-dimensional optical flow value (w′,h′) corresponding to each pixel can be determined by combining the optical flow data, where w ′represents the horizontal offset of the pixel, and h′ represents the vertical offset of the pixel.

[0131] The following will take a pixel as an example and illustrate how to determine optical flow data.

[0132] 1. Determine optical flow data based on forward optical flow;

[0133] Specifically, if forward optical flow is used, it is necessary to determine the optical flow data corresponding to the video frame pair based on the horizontal offset and vertical offset of each pixel point in the subsequent video frame relative to each pixel point in the previous video frame. For ease of understanding, please refer to Figure 9, which is a schematic diagram of determining the two-dimensional optical flow value based on the forward optical flow in an embodiment of the present application. In the previous video frame, the pixel coordinates are (3,4). In the next video frame, the pixel coordinates are (4,5). The horizontal offset of the pixel point from the previous video frame to the next video frame is 1 (i.e., 4-3), and the vertical offset is 1 (i.e., 5-4). It can be seen that the two-dimensional optical flow value of the pixel point is (1,1).

[0134] 2. Determine the optical flow data based on the backward optical flow;

[0135] Specifically, if backward optical flow is used, it is necessary to determine the optical flow data corresponding to the video frame pair based on the horizontal offset and vertical offset of each pixel point in the previous video frame relative to each pixel point in the next video frame in the video frame pair. For ease of understanding, please refer to Figure 10. Figure 10 is a schematic diagram of determining the two-dimensional optical flow value based on backward optical flow in an embodiment of the present application. In the previous video frame, the pixel coordinates are (1,3). In the next video frame, the pixel coordinates are (4,5). The horizontal offset of the pixel point from the next video frame to the previous video frame is -4 (i.e., 1-4), and the vertical offset is -2 (i.e., 3-5). It can be seen that the two-dimensional optical flow value of the pixel point is (-4, -2).

[0136] Secondly, the embodiments of the present application provide two methods for determining optical flow data based on video frame pairs. Through the above methods, optical flow data can be generated based on forward optical flow or backward optical flow, thereby improving the flexibility of the solution.

[0137] Optionally, based on the embodiment corresponding to FIG. 4 above, in another optional embodiment provided by the embodiment of the present application, based on each optical flow data in the optical flow data sequence, clustering processing is performed on the pixels included in the target mask area in each target mask frame to obtain an optical flow clustering result for each target mask frame, which may specifically include:

[0138] For each target mask frame, determine the two-dimensional optical flow values ​​of X pixels in the target mask area of ​​the target mask frame based on the optical flow data corresponding to the target mask frame in the optical flow data sequence, where the optical flow data corresponding to the target mask frame and the target mask frame correspond to the same video frame pair, and X is an integer greater than 1;

[0139] For each target mask frame, clustering is performed on the X pixels in the target mask area according to their two-dimensional optical flow values ​​to obtain an optical flow clustering result of the target mask frame.

[0140] In one or more embodiments, a method for clustering pixels within a target mask region is described. As can be seen from the aforementioned embodiments, the target mask sample sequence includes K target mask frames, and optical flow clustering is required for the pixels within the target mask region in each target mask frame. It is understood that in actual situations, the number of pixels included in the target mask region may be large. Therefore, the pixels within the target mask region may be randomly sampled in advance to obtain X pixels. Here, X is an integer greater than 1, for example, X can be set to 15,000.

[0141] Specifically, the target mask sample sequence is {m dst}(t=1,2,…,K), the optical flow data sequence is {Fl t}(t=1,…,K). Based on this, we can calculate Among them, "*" represents element-wise multiplication, thereby retaining the target mask frame The two-dimensional optical flow value corresponding to the pixel marked as "1" in the image is set, and the rest are set to 0. Therefore, the DBSCAN algorithm can be used to map the target mask frame. The X pixels within the image are clustered based on the two-dimensional optical flow value of each pixel to obtain the optical flow clustering result of the target mask frame.

[0142] It should be noted that the optical flow clustering results of each target mask frame include the category labels corresponding to each pixel after clustering. Among them, the pixels with category label "0" are noise pixels and need to be removed. After removal, the total number of categories corresponding to the target mask frame is obtained. Taking the tth target mask frame as an example, the total number of categories corresponding to it can be expressed as C t , that is, with C t Clusters. Clusters may include N ct pixels.

[0143] Secondly, the embodiments of the present application provide a method for clustering pixels within a target mask area. Using this method, the DBSCAN algorithm can be used to cluster pixels. This allows for adaptive clustering without pre-setting the number of categories. Furthermore, the DBSCAN algorithm is able to better identify outliers and can discover clusters of any shape.

[0144] Optionally, based on the embodiment corresponding to FIG. 4 above, in another optional embodiment provided by the embodiment of the present application, determining the optical flow quality score according to the optical flow clustering result of each target mask frame may specifically include:

[0145] According to the optical flow clustering results of each target mask frame, the total number of categories of each target mask frame is determined;

[0146] Count the target mask frames whose total number of categories is less than or equal to the category number threshold;

[0147] According to the ratio between the number of target mask frames and the K value, the single category ratio is determined;

[0148] If the single ratio of the category is greater than the ratio threshold, the optical flow quality score is determined to be the first score;

[0149] If the single category ratio is less than or equal to the ratio threshold, the optical flow quality score is determined to be a second score.

[0150] In one or more embodiments, a method for determining an optical flow quality score based on a clean rate (CR) is provided. As can be seen from the aforementioned embodiments, the optical flow clustering results for each target mask frame include the class labels corresponding to each pixel after clustering. By eliminating pixels with a class label of "0," the total number of classes corresponding to the target mask frame can be obtained.

[0151] Specifically, for the optical flow clustering results For example, the single category proportion can be calculated as follows:

[0152] Among them, CR represents the single ratio of the category. t represents the frame number of the target mask frame, K represents the total number of target mask frames. c represents the category label, C t Indicates the total number of categories in the t-th target mask frame. i represents the pixel number, N ct Indicates the number of pixels of the t-th target mask frame corresponding to the c-th category label. Indicates an indicative function that returns 1 if the input is 1, otherwise it returns 0.

[0153] Based on this, the proportion of frames in which the total number of categories is less than or equal to the category number threshold (for example, 1) in the K target mask frames can be counted, that is, the category single ratio can be obtained.

[0154] Combined with the single ratio of each category, the criteria for determining the quality of optical flow can be defined as:

[0155] Where Q represents the optical flow quality score. CR represents the single category ratio. threshold Represents a ratio threshold. For example, the ratio threshold can be set to 0.8, or other reasonable values, which are not limited here.

[0156] Secondly, the present embodiment provides a method for determining optical flow quality scores based on the category-specific ratio. This method takes into account that a larger category-specific ratio indicates a smaller total number of categories and more stable video optical flow. Therefore, using the category-specific ratio to filter out videos with disturbed optical flow serves as the basis for determining optical flow quality, thereby improving the feasibility and operability of the solution.

[0157] Optionally, based on the embodiment corresponding to FIG. 4 above, in another optional embodiment provided by the embodiment of the present application, determining the optical flow quality score according to the optical flow clustering result of each target mask frame may specifically include:

[0158] For the optical flow clustering result of each target mask frame, a moving average of each cluster is determined according to the two-dimensional optical flow value of each pixel point in each cluster, wherein the optical flow clustering result is used to characterize one or more clusters;

[0159] For each target mask frame, the moving average value of the target mask frame is determined based on the moving average value of each cluster cluster according to the optical flow clustering result of each target mask frame.

[0160] Accumulate the moving average of each target mask frame to obtain the total moving distance;

[0161] If the total moving distance is greater than or equal to the distance threshold, determining the optical flow quality score to be the first score;

[0162] If the total moving distance is less than the distance threshold, the optical flow quality score is determined to be a second score.

[0163] In one or more embodiments, a method for determining an optical flow quality score based on the total distance traveled is described. As can be seen from the aforementioned embodiments, the optical flow clustering results for each target mask frame include the class labels corresponding to each clustered pixel. By eliminating pixels with a class label of "0," the total number of classes corresponding to the target mask frame can be obtained.

[0164] Specifically, for the optical flow clustering results For K target mask frames, the total moving distance accumulated can be calculated as follows:

[0165] Where D represents the total distance moved. t represents the moving average of the t-th target mask frame. t represents the frame number of the target mask frame, and K represents the total number of target mask frames.

[0166] The moving average of the target mask frame can be calculated as follows:

[0167] Among them, D t Denotes the moving average of the t-th target mask frame. D tc represents the moving average of the cth cluster in the tth target mask frame. c represents the category label, C t Represents the total number of categories in the t-th target mask frame.

[0168] The moving average of the clusters can be calculated as follows:

[0169] in, represents the moving average of the cth cluster in the tth target mask frame. Represents the two-dimensional optical flow value of the i-th pixel in the c-th cluster in the t-th target mask frame. i represents the pixel number, N ct represents the number of pixels in the t-th target mask frame corresponding to the c-th category label. ||.|| represents the Euclidean distance.

[0170] Based on this, the total moving distance of K target mask frames can be counted. Combined with the total moving distance, the judgment standard of optical flow quality can be defined as:

[0171] Where Q represents the optical flow quality score. D represents the total distance moved. threshold Represents the distance threshold. For example, the distance threshold can be set to 4, or other reasonable values, which are not limited here.

[0172] Secondly, this embodiment of the present application provides a method for determining optical flow quality scores based on total movement distance. This method takes into account that a larger total movement distance indicates more pronounced frame motion, which facilitates optical flow estimation. Therefore, the total movement distance is used to filter out relatively static video and serve as the basis for determining optical flow quality, thereby improving the feasibility and operability of the solution.

[0173] Optionally, based on the embodiment corresponding to FIG. 4 above, in another optional embodiment provided by the embodiment of the present application, determining the optical flow quality score according to the optical flow clustering result of each target mask frame may specifically include:

[0174] According to the optical flow clustering results of each target mask frame, the total number of categories of each target mask frame is determined;

[0175] Count the target mask frames whose total number of categories is less than or equal to the category number threshold;

[0176] According to the ratio between the number of target mask frames and the K value, the single category ratio is determined;

[0177] For the optical flow clustering result of each target mask frame, a moving average of each cluster is determined according to the two-dimensional optical flow value of each pixel point in each cluster, wherein the optical flow clustering result is used to characterize one or more clusters;

[0178] For each target mask frame, the moving average value of the target mask frame is determined based on the moving average value of each cluster cluster based on the optical flow clustering result.

[0179] Accumulate the moving average of each target mask frame to obtain the total moving distance;

[0180] If the single ratio of the category is greater than the ratio threshold, and the total moving distance is greater than or equal to the distance threshold, then the optical flow quality score is determined to be the first score;

[0181] If the single category ratio is less than or equal to the ratio threshold, and the total movement distance is less than the distance threshold, the optical flow quality score is determined to be the second score.

[0182] In one or more embodiments, a method for jointly determining an optical flow quality score based on a single category ratio and a total movement distance is introduced. As can be seen from the aforementioned embodiments, on the one hand, the proportion of frames in which the total number of categories is less than or equal to a category number threshold (e.g., 1) in the K target mask frames can be counted, that is, the single category ratio can be obtained. On the other hand, the total movement distance of the K target mask frames can be counted. It is understood that the method for determining the single category ratio and the total movement distance can be referred to the aforementioned embodiments and will not be repeated here.

[0183] Specifically, combining the single ratio of categories and the total distance moved, the criterion for determining the optical flow quality can be defined as:

[0184] Where Q represents the optical flow quality score. D represents the total distance moved. threshold Indicates the distance threshold. For example, the distance threshold can be set to 4, or other reasonable values, which are not limited here. CR indicates the single ratio of the category.threshold Represents a ratio threshold. For example, the ratio threshold can be set to 0.8, or other reasonable values, which are not limited here.

[0185] Secondly, the present embodiment provides a method for determining the optical flow quality score based on both the single category ratio and the total distance traveled. This method, on the one hand, uses the single category ratio to filter out videos with disturbed optical flow, while on the other hand, uses the total distance traveled to filter out relatively static videos. Therefore, the combination of these two methods can more comprehensively and accurately reflect the optical flow quality, thereby improving the reliability of the optical flow quality score.

[0186] Optionally, based on the embodiment corresponding to FIG. 4 above, another optional embodiment provided by the embodiment of the present application adopts a video restoration method that matches the optical flow quality score to restore the video to be restored, which may specifically include:

[0187] If the optical flow quality score is the first score, the optical flow method is used to repair the video to be repaired.

[0188] If the optical flow quality score is the second score, the neural network is called to perform repair processing on the video to be repaired.

[0189] In one or more embodiments, a method for video restoration based on an optical flow quality score is described. As can be seen from the aforementioned embodiments, the optical flow quality score can be a first score or a second score. The following description uses the first score of "1" and the second score of "0" as an example.

[0190] Specifically, you can select the video repair method in the following ways:

[0191] Where F1(x,m) represents the video restoration process using the optical flow method. F2(x,m) represents the video restoration process using the neural network. Q represents the optical flow quality score.

[0192] It should be noted that the goal of this application is to solve the video sequence y={y t}(t=0,1,2,…,T). The video sequence differs from the video to be repaired only in the original mask area, and the video sequence is natural and consistent in time and space. Since naturalness and consistency are difficult to define formally, when training the neural network, it is hoped that the completed video sequence is consistent with the real video sequence y gt Close. Among them, y gt Represents the true value of the video sequence without the original mask area. Based on this, by constructing the algorithm F, the solution of the video sequence y can be defined as y = F(x,m).

[0193] Secondly, the present invention provides a method for video inpainting based on optical flow quality scores. Using this approach, before video inpainting, if the optical flow quality is judged to be good, clear and reliable inpainting content can be directly obtained using the optical flow method. If the optical flow is unreliable, a model method is used to inpaint the content, thereby avoiding incorrect inpainting caused by inaccurate optical flow estimation and achieving a more stable inpainting effect overall.

[0194] Optionally, based on the embodiment corresponding to FIG. 4 above, another optional embodiment provided in the embodiment of the present application may further include:

[0195] Displaying the video to be repaired and a list of repair objects, wherein the list of repair objects includes at least one repairable object;

[0196] In response to a selection operation for a target object, performing a step of acquiring a video sample sequence for a video to be repaired, wherein the target object is at least one repairable object;

[0197] After the video to be repaired is repaired using a video repair method that matches the optical flow quality score, the following steps may also be performed:

[0198] In response to a play operation on the repaired video, the repaired video is played.

[0199] In one or more embodiments, a method for intelligently repairing videos is introduced. As can be seen from the aforementioned embodiments, the present application can be applied to various video repair tasks, such as removing logos, removing subtitles, removing objects, etc. If a user wants to use a video from a certain platform, but the video contains the logo of the platform, which affects the viewing experience, then a video repair application can be used to remove the logo. Similarly, users can erase subtitles from some videos, or remove certain moving objects from videos. The following will introduce each of them with reference to the diagrams.

[0200] For example, please refer to Figure 11, which is a schematic diagram of the effect of removing the logo based on the video repair application in an embodiment of the present application. As shown in the figure, the video to be repaired and the list of repair objects are displayed on the interface provided by the video repair application, wherein the list of repair objects displays at least one repairable object (for example, a logo, subtitles, a ship, clouds, etc.). Assume that the user selects the "one-key removal" control corresponding to the "logo", thereby triggering a selection operation for the target object (i.e., the logo). Then, in response to the selection operation, the video repair function is called. Based on this, a suitable video repair method is used to repair the video, thereby obtaining a repaired video, and the logo does not exist in the repaired video. When the user triggers the play operation for the repaired video, the repaired video can be played.

[0201] For example, please refer to Figure 12, which is a schematic diagram of the effect of removing subtitles based on a video repair application in an embodiment of the present application. As shown in the figure, the video to be repaired and the list of repair objects are displayed on the interface provided by the video repair application, wherein the list of repair objects displays at least one repairable object (for example, a logo, subtitles, a ship, clouds, etc.). Assume that the user selects the "one-key removal" control corresponding to "subtitles", thereby triggering a selection operation for the target object (i.e., subtitles). Then, in response to the selection operation, the video repair function is called. Based on this, a suitable video repair method is used to repair the video, thereby obtaining a repaired video, and there are no subtitles in the repaired video. When the user triggers a play instruction for the repaired video, the repaired video can be played.

[0202] For example, please refer to Figure 13, which is a schematic diagram of the effect of removing objects based on a video repair application in an embodiment of the present application. As shown in the figure, the video to be repaired and the list of repair objects are displayed on the interface provided by the video repair application, wherein the list of repair objects displays at least one repairable object (for example, a logo, subtitles, a ship, clouds, etc.). Suppose the user selects the "one-click removal" control corresponding to "ship", thereby triggering a selection operation for the target object (i.e., ship). Then, in response to this selection operation, the video repair function is called. Based on this, a suitable video repair method is used to repair the video, thereby obtaining a repaired video, and the object "ship" does not exist in the repaired video. When the user triggers the play instruction for the repaired video, the repaired video can be played.

[0203] It should be noted that the interface elements, interface layout and interface text shown in Figures 11, 12 and 13 are only for reference only and should not be understood as limitations on this application.

[0204] Secondly, the embodiments of this application provide a method for intelligent video restoration. Through this method, users can use the video restoration application to select one or more objects in the video for restoration, achieving the purpose of intelligent restoration. This not only improves the practicality of the solution, but also improves the efficiency of video restoration.

[0205] It can be seen that the present application can accurately and efficiently judge the quality of the optical flow in the video clip, and then select the optical flow method or the model method based on this before calling the video repair method, that is, use the better video repair method for repair, so that the repair effect is better than the effect of using either method alone. The following will introduce the effect of video frame repair based on the optical flow method and the model method with reference to examples. Please refer to Figure 14, which is a schematic diagram comparing the effects of video frame repair based on the optical flow method and the model method in an embodiment of the present application. As shown in the figure, in one example, Figure 14 (a) shows the effect of filling based on the optical flow method, and Figure 14 (b) shows the effect of filling based on the model method. Among them, the original mask area is located in the lower left corner of the video frame (that is, the area circled by the rectangular frame). In the example, the lens movement is smooth and the optical flow estimation is good. Therefore, the present application chooses to use the optical flow method for filling. In another example, Figure 14 (c) shows the effect of filling based on the optical flow method, and Figure 14 (d) shows the effect of filling based on the model method. Among them, the original mask area is located in the lower left corner of the video frame (i.e., the area circled by the rectangular box). For example, since the optical flow is affected by the person's watch, this application chooses to use the model method for filling.

[0206] The video restoration device in the present application is described in detail below. Please refer to FIG15 , which is a schematic diagram of an embodiment of the video restoration device in the present application. The video restoration device 20 includes:

[0207] An acquisition module 210 is configured to acquire a video sample sequence corresponding to the video to be repaired, wherein the video sample sequence includes K video frame pairs, each video frame pair includes two adjacent video frames, and K is an integer greater than or equal to 1;

[0208] The acquisition module 210 is further configured to acquire a target mask sample sequence based on the video sample sequence, wherein the target mask sample sequence includes K target mask frames, each target mask frame includes a target mask region obtained by expanding an original mask region, and there is a one-to-one correspondence between the K target mask frames and the K video frame pairs;

[0209] The acquisition module 210 is further configured to acquire an optical flow data sequence according to the video sample sequence, wherein the optical flow data sequence includes K optical flow data, and there is a one-to-one correspondence between the K optical flow data and the K video frame pairs;

[0210] The processing module 220 is configured to perform clustering processing on the pixel points included in the target mask area in each target mask frame based on each optical flow data in the optical flow data sequence to obtain an optical flow clustering result for each target mask frame;

[0211] a determination module 230 for determining an optical flow quality score based on the optical flow clustering result of each target mask frame;

[0212] The restoration module 240 is configured to perform restoration processing on the video to be restored by adopting a video restoration method that matches the optical flow quality score.

[0213] Optionally, based on the embodiment corresponding to FIG. 15 , in another embodiment of the video restoration device 20 provided in the embodiment of the present application,

[0214] The acquisition module 210 is specifically configured to acquire a video sequence from the video to be repaired, wherein the video sequence includes T original video frames, each original video frame displays a target object, and T is an integer greater than 1;

[0215] Extracting K to-be-processed video frame pairs from a video sequence, wherein each to-be-processed video frame pair includes two adjacent original video frames;

[0216] Normalize the size of each original video frame in the K video frame pairs to be processed to obtain K video frame pairs, and use the K video frame pairs as video sample sequences.

[0217] Optionally, based on the embodiment corresponding to FIG. 15 , in another embodiment of the video restoration device 20 provided in the embodiment of the present application,

[0218] The acquisition module 210 is specifically configured to acquire, for each video frame pair in the video sample sequence, an original mask frame corresponding to the video frame pair based on any one of the video frames in the video frame pair, wherein the original mask frame includes an original mask region obtained by performing mask processing on the target object in the any one of the video frames;

[0219] For each video frame pair in the video sample sequence, the original mask region in the original mask frame corresponding to the video frame pair is expanded to obtain a target mask frame corresponding to the video frame pair;

[0220] The target mask frames corresponding to each of the K video frame pairs are used as the target mask sample sequence.

[0221] Optionally, based on the embodiment corresponding to FIG. 15 , in another embodiment of the video restoration device 20 provided in the embodiment of the present application,

[0222] The acquisition module 210 is specifically configured to expand, for each video frame pair in the video sample sequence, an original mask region in an original mask frame corresponding to the video frame pair according to a first number of pixels, to obtain a first mask region corresponding to the video frame pair;

[0223] For each video frame pair in the video sample sequence, dilate an original mask region in an original mask frame corresponding to the video frame pair according to a second number of pixels to obtain a second mask region corresponding to the video frame pair, wherein the second number of pixels is greater than the first number of pixels;

[0224] For each video frame pair in the video sample sequence, an exclusive OR operation is performed on the first mask area and the second mask area corresponding to the video frame pair to obtain a target mask frame corresponding to the video frame pair.

[0225] Optionally, based on the embodiment corresponding to FIG. 15 , in another embodiment of the video restoration device 20 provided in the embodiment of the present application,

[0226] The acquisition module 210 is specifically configured to, for each video frame pair in the video sample sequence, acquire a first original mask frame corresponding to the video frame pair based on a preceding video frame in the video frame pair, and acquire a second original mask frame corresponding to the video frame pair based on a succeeding video frame in the video frame pair, wherein the first original mask frame and the second original mask frame respectively include original mask regions obtained by masking the target object in the preceding video frame and the succeeding video frame;

[0227] For each video frame pair in the video sample sequence, performing union processing on the first original mask frame and the second original mask frame corresponding to the video frame pair to obtain the original mask frame corresponding to the video frame pair;

[0228] For each video frame pair in the video sample sequence, the original mask region in the original mask frame corresponding to the video frame pair is expanded to obtain a target mask frame corresponding to the video frame pair;

[0229] The target mask frames corresponding to each of the K video frame pairs are used as the target mask sample sequence.

[0230] Optionally, based on the embodiment corresponding to FIG. 15 , in another embodiment of the video restoration device 20 provided in the embodiment of the present application,

[0231] The acquisition module 210 is specifically configured to expand, for each video frame pair in the video sample sequence, an original mask region in an original mask frame corresponding to the video frame pair according to a first number of pixels, to obtain a first mask region corresponding to the video frame pair;

[0232] For each video frame pair in the video sample sequence, dilate an original mask region in an original mask frame corresponding to the video frame pair according to a second number of pixels to obtain a second mask region corresponding to the video frame pair, wherein the second number of pixels is greater than the first number of pixels;

[0233] For each video frame pair in the video sample sequence, an exclusive OR operation is performed on the first mask area and the second mask area corresponding to the video frame pair to obtain a target mask frame corresponding to the video frame pair.

[0234] Optionally, based on the embodiment corresponding to FIG. 15 , in another embodiment of the video restoration device 20 provided in the embodiment of the present application,

[0235] The acquisition module 210 is specifically configured to determine, for each video frame pair in the video sample sequence, optical flow data corresponding to the video frame pair based on the horizontal and vertical offsets of each pixel point in the subsequent video frame relative to each pixel point in the previous video frame in the video frame pair;

[0236] The optical flow data corresponding to each of the K video frame pairs is used as an optical flow data sequence;

[0237] or,

[0238] The acquisition module 210 is specifically configured to determine, for each video frame pair in the video sample sequence, optical flow data corresponding to the video frame pair based on the horizontal and vertical offsets of each pixel point in the previous video frame relative to each pixel point in the next video frame in the video frame pair;

[0239] The optical flow data corresponding to each of the K video frame pairs is used as an optical flow data sequence.

[0240] Optionally, based on the embodiment corresponding to FIG. 15 , in another embodiment of the video restoration device 20 provided in the embodiment of the present application,

[0241] The processing module 220 is specifically configured to determine, for each target mask frame, two-dimensional optical flow values ​​of X pixels in a target mask area in the target mask frame based on the optical flow data corresponding to the target mask frame in the optical flow data sequence, where the optical flow data corresponding to the target mask frame and the target mask frame correspond to the same video frame pair, and X is an integer greater than 1.

[0242] For each target mask frame, clustering is performed on the X pixels in the target mask area according to their two-dimensional optical flow values ​​to obtain an optical flow clustering result of the target mask frame.

[0243] Optionally, based on the embodiment corresponding to FIG. 15 , in another embodiment of the video restoration device 20 provided in the embodiment of the present application,

[0244] A determination module 230 is specifically configured to determine the total number of categories of each target mask frame based on the optical flow clustering result of each target mask frame;

[0245] Count the target mask frames whose total number of categories is less than or equal to the category number threshold;

[0246] According to the ratio between the number of target mask frames and the K value, the single category ratio is determined;

[0247] If the single ratio of the category is greater than the ratio threshold, the optical flow quality score is determined to be the first score;

[0248] If the single category ratio is less than or equal to the ratio threshold, the optical flow quality score is determined to be a second score.

[0249] Optionally, based on the embodiment corresponding to FIG. 15 , in another embodiment of the video restoration device 20 provided in the embodiment of the present application,

[0250] A determination module 230 is specifically configured to determine, for each target mask frame, an optical flow clustering result, and a moving average of each cluster based on the two-dimensional optical flow values ​​of each pixel in each cluster, wherein the optical flow clustering result is used to represent one or more clusters;

[0251] For each target mask frame, the moving average value of the target mask frame is determined based on the moving average value of each cluster cluster according to the optical flow clustering result of each target mask frame.

[0252] Accumulate the moving average of each target mask frame to obtain the total moving distance;

[0253] If the total moving distance is greater than or equal to the distance threshold, determining the optical flow quality score to be the first score;

[0254] If the total moving distance is less than the distance threshold, the optical flow quality score is determined to be a second score.

[0255] Optionally, based on the embodiment corresponding to FIG. 15 , in another embodiment of the video restoration device 20 provided in the embodiment of the present application,

[0256] A determination module 230 is specifically configured to determine the total number of categories of each target mask frame based on the optical flow clustering result of each target mask frame;

[0257] Count the target mask frames whose total number of categories is less than or equal to the category number threshold;

[0258] According to the ratio between the number of target mask frames and the K value, the single category ratio is determined;

[0259] For the optical flow clustering result of each target mask frame, a moving average of each cluster is determined according to the two-dimensional optical flow value of each pixel point in each cluster, wherein the optical flow clustering result is used to characterize one or more clusters;

[0260] For each target mask frame, the moving average value of the target mask frame is determined based on the moving average value of each cluster cluster based on the optical flow clustering result.

[0261] Accumulate the moving average of each target mask frame to obtain the total moving distance;

[0262] If the single ratio of the category is greater than the ratio threshold, and the total moving distance is greater than or equal to the distance threshold, then the optical flow quality score is determined to be the first score;

[0263] If the single category ratio is less than or equal to the ratio threshold, or the total movement distance is less than the distance threshold, the optical flow quality score is determined to be the second score.

[0264] Optionally, based on the embodiment corresponding to FIG. 15 , in another embodiment of the video restoration device 20 provided in the embodiment of the present application,

[0265] The restoration module 240 is specifically configured to restore the video to be restored by using the optical flow method if the optical flow quality score is the first score.

[0266] If the optical flow quality score is the second score, the neural network is called to perform repair processing on the video to be repaired.

[0267] Optionally, based on the embodiment corresponding to FIG. 15 , in another embodiment of the video restoration device 20 provided in the embodiment of the present application, the video restoration device 20 further includes a display module 250 ;

[0268] A display module 250 is configured to display the video to be repaired and a list of repair objects, wherein the list of repair objects includes at least one repairable object;

[0269] The acquisition module 210 is further configured to, in response to a selection operation for a target object, execute a step of acquiring a video sample sequence for the video to be repaired, wherein the target object is at least one repairable object;

[0270] The display module 250 is further configured to use a video restoration method that matches the optical flow quality score to restore the video to be restored, and then respond to a play operation on the restored video to play the restored video.

[0271] The present application also provides a terminal, as shown in FIG16. For ease of explanation, only the parts related to the present application are shown. For specific technical details not disclosed, please refer to the method part of the present application embodiment. In the present application embodiment, the terminal is a mobile phone as an example for explanation:

[0272] FIG16 is a block diagram showing a partial structure of a mobile phone related to a terminal provided in an embodiment of the present application. Referring to FIG16 , the mobile phone includes: a radio frequency (RF) circuit 310, a memory 320, an input unit 330 (including a touch panel 331 and other input devices 332), a display unit 340 (including a display panel 341), a sensor 350, an audio circuit 360 (connected to a speaker 361 and a microphone 362), a wireless fidelity (WiFi) module 370, a processor 380, and a power supply 390. It will be understood by those skilled in the art that the mobile phone structure shown in FIG16 does not constitute a limitation on the mobile phone, and may include more or fewer components than shown, or combine certain components, or arrange the components differently.

[0273] The memory 320 can be used to store software programs and modules. The processor 380 executes the various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 320. The memory 320 can mainly include a program storage area and a data storage area. The program storage area can store an operating system and at least one application required for a function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created based on the use of the mobile phone (such as audio data, a phone book, etc.). In addition, the memory 320 can include a high-speed random access memory and a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device.

[0274] The processor 380 is the control center of the phone, connecting all parts of the phone using various interfaces and circuits. It executes software programs and / or modules stored in the memory 320 and accesses data stored in the memory 320 to perform various phone functions and process data. Optionally, the processor 380 may include one or more processing units. Alternatively, the processor 380 may integrate an application processor and a modem processor. The application processor primarily handles the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into the processor 380.

[0275] The steps executed by the terminal in the above embodiment may be based on the terminal structure shown in FIG16 .

[0276] Figure 17 is a schematic diagram of a server structure provided in an embodiment of the present application. The server 400 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPUs) 422 (for example, one or more processors) and a memory 432, and one or more storage media 430 (for example, one or more massive storage devices) for storing application programs 442 or data 444. Among them, the memory 432 and the storage medium 430 can be temporary storage or permanent storage. The program stored in the storage medium 430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 422 can be configured to communicate with the storage medium 430 to execute a series of instruction operations in the storage medium 430 on the server 400.

[0277] The server 400 may also include one or more power supplies 426, one or more wired or wireless network interfaces 450, one or more input and output interfaces 458, and / or one or more operating systems 441, such as Windows Server 2003 or Windows Server 2003R. TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM etc.

[0278] The steps executed by the server in the above embodiment can be based on the server structure shown in FIG17 .

[0279] A computer device is also provided in an embodiment of the present application, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the methods described in the above embodiments are implemented.

[0280] A computer-readable storage medium is also provided in an embodiment of the present application, on which a computer program is stored. When the computer program is executed by a processor, the steps of the methods described in the above embodiments are implemented.

[0281] A computer program product is also provided in an embodiment of the present application, including a computer program. When the computer program is executed by a processor, the steps of the methods described in the above embodiments are implemented.

[0282] It is understandable that in the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0283] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above 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 video restoration, performed by a computer device, comprising: Obtain a video sample sequence corresponding to the video to be repaired, wherein the video sample sequence includes K video frame pairs, each video frame pair includes two adjacent video frames, and K is an integer greater than or equal to 1; Acquire a target mask sample sequence according to the video sample sequence, wherein the target mask sample sequence includes K target mask frames, each target mask frame includes a target mask area obtained by expanding an original mask area, and there is a one-to-one correspondence between the K target mask frames and the K video frame pairs; Acquire an optical flow data sequence according to the video sample sequence, wherein the optical flow data sequence includes K optical flow data, and there is a one-to-one correspondence between the K optical flow data and the K video frame pairs; Based on each optical flow data in the optical flow data sequence, clustering is performed on the pixel points included in the target mask area in each target mask frame to obtain an optical flow clustering result of each target mask frame; Determining an optical flow quality score according to the optical flow clustering result of each target mask frame; The video to be repaired is repaired using a video repair method that matches the optical flow quality score.

2. According to the method of claim 1, the step of obtaining a video sample sequence corresponding to the video to be repaired comprises: Acquire a video sequence from the video to be repaired, wherein the video sequence includes T original video frames, each original video frame displays a target object, and T is an integer greater than 1; Extracting K pairs of video frames to be processed from the video sequence, wherein each pair of video frames to be processed includes two adjacent original video frames; The size of each original video frame in the K to-be-processed video frame pairs is normalized to obtain the K video frame pairs, and the K video frame pairs are used as the video sample sequence.

3. The method according to claim 1, wherein obtaining a target mask sample sequence according to the video sample sequence comprises: For each video frame pair in the video sample sequence, according to any one of the video frame pairs, an original mask frame corresponding to the video frame pair is obtained, wherein the original mask frame includes an original mask area obtained after masking the target object in any one of the video frames; For each video frame pair in the video sample sequence, expanding an original mask region in an original mask frame corresponding to the video frame pair to obtain a target mask frame corresponding to the video frame pair; The target mask frames corresponding to the K video frame pairs are used as the target mask sample sequences.

4. The method according to claim 3, wherein for each video frame pair in the video sample sequence, expanding the original mask area in the original mask frame corresponding to the video frame pair to obtain the target mask frame corresponding to the video frame pair comprises: For each video frame pair in the video sample sequence, expanding an original mask region in an original mask frame corresponding to the video frame pair according to a first number of pixels to obtain a first mask region corresponding to the video frame pair; For each video frame pair in the video sample sequence, expanding an original mask region in an original mask frame corresponding to the video frame pair according to a second number of pixels to obtain a second mask region corresponding to the video frame pair, wherein the second number of pixels is greater than the first number of pixels; For each video frame pair in the video sample sequence, an XOR operation is performed on the first mask area and the second mask area corresponding to the video frame pair to obtain a target mask frame corresponding to the video frame pair.

5. The method according to claim 1, wherein obtaining a target mask sample sequence according to the video sample sequence comprises: For each video frame pair in the video sample sequence, a first original mask frame corresponding to the video frame pair is obtained according to a previous video frame in the video frame pair, and a second original mask frame corresponding to the video frame pair is obtained according to a subsequent video frame in the video frame pair, wherein the first original mask frame and the second original mask frame respectively include original mask regions obtained after masking the target objects in the previous video frame and the subsequent video frame; For each video frame pair in the video sample sequence, performing union processing on a first original mask frame and a second original mask frame corresponding to the video frame pair to obtain an original mask frame corresponding to the video frame pair; For each video frame pair in the video sample sequence, expanding an original mask region in an original mask frame corresponding to the video frame pair to obtain a target mask frame corresponding to the video frame pair; The target mask frames corresponding to the K video frame pairs are used as the target mask sample sequences.

6. The method according to claim 5, wherein for each video frame pair in the video sample sequence, expanding the original mask area in the original mask frame corresponding to the video frame pair to obtain the target mask frame corresponding to the video frame pair comprises: For each video frame pair in the video sample sequence, expanding an original mask region in an original mask frame corresponding to the video frame pair according to a first number of pixels to obtain a first mask region corresponding to the video frame pair; For each video frame pair in the video sample sequence, expanding an original mask region in an original mask frame corresponding to the video frame pair according to a second number of pixels to obtain a second mask region corresponding to the video frame pair, wherein the second number of pixels is greater than the first number of pixels; For each video frame pair in the video sample sequence, an XOR operation is performed on the first mask area and the second mask area corresponding to the video frame pair to obtain a target mask frame corresponding to the video frame pair.

7. The method according to claim 1, wherein obtaining an optical flow data sequence according to the video sample sequence comprises: For each video frame pair in the video sample sequence, determining optical flow data corresponding to the video frame pair according to a horizontal offset and a vertical offset of each pixel point in a subsequent video frame of the video frame pair relative to each pixel point in a previous video frame; Taking the optical flow data corresponding to each of the K video frame pairs as the optical flow data sequence; or, The step of acquiring an optical flow data sequence according to the video sample sequence comprises: For each video frame pair in the video sample sequence, determining optical flow data corresponding to the video frame pair according to a horizontal offset and a vertical offset of each pixel point in a previous video frame relative to each pixel point in a subsequent video frame in the video frame pair; The optical flow data corresponding to each of the K video frame pairs is used as the optical flow data sequence.

8. The method according to claim 1, wherein the clustering process is performed on the pixel points included in the target mask area in each target mask frame based on each optical flow data in the optical flow data sequence to obtain the optical flow clustering result of each target mask frame, comprising: For each target mask frame, determining the two-dimensional optical flow values ​​of X pixels in the target mask area in the target mask frame according to the optical flow data corresponding to the target mask frame in the optical flow data sequence, wherein the optical flow data corresponding to the target mask frame corresponds to the same video frame pair as the target mask frame, and X is an integer greater than 1; For each target mask frame, clustering processing is performed on the X pixels according to the two-dimensional optical flow values ​​of the X pixels in the target mask area to obtain an optical flow clustering result of the target mask frame.

9. The method according to claim 1, wherein determining the optical flow quality score according to the optical flow clustering result of each target mask frame comprises: Determining the total number of categories of each target mask frame according to the optical flow clustering result of each target mask frame; Counting the number of target mask frames whose total number of categories is less than or equal to the category number threshold; Determining a single category ratio according to a ratio between the target mask frame number and the K value; If the single ratio of the category is greater than the ratio threshold, determining the optical flow quality score to be a first score; If the single category ratio is less than or equal to the ratio threshold, the optical flow quality score is determined to be a second score.

10. The method according to claim 1, wherein determining the optical flow quality score according to the optical flow clustering result of each target mask frame comprises: For the optical flow clustering result of each target mask frame, determine the moving average of each cluster according to the two-dimensional optical flow value of each pixel in each cluster, wherein the optical flow clustering result is used to characterize one or more clusters; For the optical flow clustering result of each target mask frame, determine the moving average value of the target mask frame according to the moving average value of each cluster cluster; Accumulating the moving average of each target mask frame to obtain a total moving distance; If the total moving distance is greater than or equal to the distance threshold, determining the optical flow quality score to be a first score; If the total moving distance is less than the distance threshold, the optical flow quality score is determined to be a second score.

11. The method according to claim 1, wherein determining the optical flow quality score according to the optical flow clustering result of each target mask frame comprises: Determining the total number of categories of each target mask frame according to the optical flow clustering result of each target mask frame; Counting the number of target mask frames whose total number of categories is less than or equal to the category number threshold; Determining a single category ratio according to a ratio between the target mask frame number and the K value; For the optical flow clustering result of each target mask frame, determine the moving average of each cluster according to the two-dimensional optical flow value of each pixel in each cluster, wherein the optical flow clustering result is used to characterize one or more clusters; For the optical flow clustering result of each target mask frame, determine the moving average value of the target mask frame according to the moving average value of each cluster cluster; Accumulating the moving average of each target mask frame to obtain a total moving distance; If the single ratio of the category is greater than the ratio threshold, and the total moving distance is greater than or equal to the distance threshold, determining the optical flow quality score to be a first score; If the single category ratio is less than or equal to the ratio threshold, or the total moving distance is less than the distance threshold, the optical flow quality score is determined to be a second score.

12. The method according to any one of claims 9 to 11, wherein the step of using a video restoration method that matches the optical flow quality score to restore the video to be restored comprises: If the optical flow quality score is the first score, the optical flow method is used to repair the video to be repaired. If the optical flow quality score is the second score, a neural network is called to perform restoration processing on the video to be restored.

13. The method according to claim 1, further comprising: Displaying the video to be repaired and a list of repair objects, wherein the list of repair objects includes at least one repairable object; In response to a selection operation for a target object, executing the step of acquiring a video sample sequence for the video to be repaired, wherein the target object belongs to the at least one repairable object; After the video to be repaired is repaired using a video repair method that matches the optical flow quality score, the method further includes: In response to a play operation on the repaired video, the repaired video is played.

14. A video repair device, comprising: An acquisition module, used to acquire a video sample sequence corresponding to the video to be repaired, wherein the video sample sequence includes K video frame pairs, each video frame pair includes two adjacent video frames, and K is an integer greater than or equal to 1; The acquisition module is further used to acquire a target mask sample sequence according to the video sample sequence, wherein the target mask sample sequence includes K target mask frames, each target mask frame includes a target mask area obtained by expanding an original mask area, and there is a one-to-one correspondence between the K target mask frames and the K video frame pairs; The acquisition module is further used to acquire an optical flow data sequence according to the video sample sequence, wherein the optical flow data sequence includes K optical flow data, and there is a one-to-one correspondence between the K optical flow data and the K video frame pairs; A processing module, configured to perform clustering processing on the pixel points included in the target mask area in each target mask frame based on each optical flow data in the optical flow data sequence, so as to obtain an optical flow clustering result of each target mask frame; A determination module, configured to determine an optical flow quality score according to an optical flow clustering result of each target mask frame; The restoration module is used to use a video restoration method that matches the optical flow quality score to restore the video to be restored.

15. A computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method according to any one of claims 1 to 13 when executing the computer program.

16. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method according to any one of claims 1 to 13.

17. A computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 13.