Video processing method and apparatus, and device, storage medium and program product
Through frame extraction processing and optical flow propagation technology, the problem of low repair efficiency of unknown areas in the video is solved, and efficient video processing is achieved, which is suitable for large-scale commercial deployment.
Patent Information
- Application Number
- PCT/CN2023/082430
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2022-05-19
- Filing Date
- 2023-03-20
- Publication Date
- 2024-09-12
AI Technical Summary
After the existing technology removes watermarks, subtitles or moving objects in videos, the repair efficiency of unknown areas is low, making it difficult to carry out large-scale commercial deployment.
Through the frame extraction processing method, the sample frame sequence and the mask sequence are first subjected to optical flow propagation and image repair processing to obtain the repaired sample frame sequence, and then the repaired sample frame sequence and the remaining frame sequence are merged to generate a repaired video , avoiding multiple rounds of processing for each frame of image and reducing the amount of calculation.
It improves the efficiency of video processing, reduces the amount of calculation, avoids the problem of insufficient memory caused by large videos, and ensures the quality and effect of video processing.
Smart Images

Figure CN2023082430_12092024_PF_FP_ABST
Abstract
Description
Video processing method, device, equipment, storage medium and program product
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on May 19, 2022, with application number 202210545680.X and application name “Video processing method, device, equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present disclosure relates to the field of computer technology, and in particular to video processing. Background Art
[0003] With the advancement of computer technology, the demand for video processing is also increasing. For example, people may need to remove watermarks, subtitles, or moving objects from a video. However, watermarks, subtitles, or moving objects can obscure the video content. Therefore, after the removal operation is completed, unknown areas will be generated in the video. Therefore, it is necessary to fill and repair these unknown areas in the video. However, the existing video repair solutions are inefficient, making them difficult to deploy on a large scale commercially.
[0004] Summary of the Invention
[0005] The embodiments of the present disclosure provide a video processing method, apparatus, device, storage medium, and program product, which can be used to improve the efficiency of video processing.
[0006] An embodiment of the present disclosure provides a video processing method, which includes: obtaining a first target frame sequence and a first target mask sequence of a video to be processed; performing frame extraction processing on the first target frame sequence and the first target mask sequence respectively to obtain a first sampling frame sequence and a first residual frame sequence thereof, and a first sampling mask sequence and a first residual mask sequence thereof; performing optical flow propagation and image restoration processing on the first sampling frame sequence and the first sampling mask sequence to obtain a first restored sampling frame sequence; performing optical flow propagation and image restoration processing on the first restored sampling frame sequence, the first residual frame sequence, and the first residual mask sequence to obtain a first restored residual frame sequence; and merging the first restored sampling frame sequence and the first restored residual frame sequence to obtain a restored video of the video to be processed.
[0007] An embodiment of the present disclosure provides a video processing device, which includes: an acquisition module, used to acquire a first target frame sequence and a first target mask sequence of a video to be processed; a frame extraction module, used to perform frame extraction processing on the first target frame sequence and the first target mask sequence respectively to obtain a first sampling frame sequence and its first residual frame sequence, and a first sampling mask sequence and its first residual mask sequence; the acquisition module is also used to perform optical flow propagation and image restoration processing on the first sampling frame sequence and the first sampling mask sequence to obtain a first restored sampling frame sequence; the acquisition module is also used to perform optical flow propagation and image restoration processing on the first restored sampling frame sequence, the first residual frame sequence and the first residual mask sequence to obtain a first restored residual frame sequence; the acquisition module is also used to merge the first restored sampling frame sequence and the first restored residual frame sequence to obtain a restored video of the video to be processed.
[0008] An embodiment of the present disclosure provides a computer device, including a processor, a memory, and an input / output interface; the processor is connected to the memory and the input / output interface, respectively, wherein the input / output interface is used to receive and output data, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device including the processor executes the video processing method in any embodiment of the present disclosure.
[0009] An embodiment of the present disclosure provides a computer-readable storage medium storing a computer program. The computer program is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the video processing method in any embodiment of the present disclosure.
[0010] The present disclosure provides a computer program product, including a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the video processing method provided in any of the various optional embodiments of the present disclosure.
[0011] The technical solution provided by the embodiments of the present disclosure can first process the first sampling frame sequence and the first sampling mask sequence through a frame extraction method to obtain a first repaired sampling frame sequence. The first remaining frame sequence is then processed using the first repaired sampling frame sequence and the first remaining mask sequence to obtain a repaired video of the video to be processed. Therefore, the present disclosure can process the remaining frame sequence using the first repaired sampling frame sequence through frame extraction, avoiding multiple rounds of processing for each frame, reducing the computational complexity, and thus improving the efficiency of video processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] FIG1 is a schematic diagram of an implementation environment provided by an embodiment of the present disclosure;
[0013] FIG2 is a flow chart of a video processing method provided by an embodiment of the present disclosure;
[0014] FIG3 is a schematic diagram of a cropping area provided by an embodiment of the present disclosure;
[0015] FIG4 is a schematic diagram of performing optical flow propagation processing on a frame of image according to an embodiment of the present disclosure;
[0016] FIG5 is a framework diagram of an optical flow estimation module provided by an embodiment of the present disclosure;
[0017] FIG6 is a schematic diagram of a process of optical flow estimation and optical flow filling provided by an embodiment of the present disclosure;
[0018] FIG7 is a schematic diagram of a process for obtaining a first repaired remaining frame sequence according to an embodiment of the present disclosure;
[0019] FIG8 is a schematic diagram of a video processing process provided by an embodiment of the present disclosure;
[0020] FIG9 is a flowchart of another video processing method provided by an embodiment of the present disclosure;
[0021] FIG10 is a schematic diagram of a video processing effect of removing a watermark provided by an embodiment of the present disclosure;
[0022] FIG11 is a schematic diagram of a video processing effect of removing subtitles provided by an embodiment of the present disclosure;
[0023] FIG12 is a schematic diagram of a video processing effect of removing moving objects provided by an embodiment of the present disclosure;
[0024] FIG13 is a schematic diagram of a video processing device provided by an embodiment of the present disclosure;
[0025] FIG14 is a schematic structural diagram of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0026] The following will be combined with the accompanying drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the embodiments described are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present disclosure.
[0027] In addition, the accompanying drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. Identical reference numerals in the figures denote identical or similar parts, and thus repetitive descriptions thereof will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities that do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0028] The embodiment of the present disclosure provides a video processing method, as shown in FIG1 , which is a schematic diagram of an implementation environment provided by the embodiment of the present disclosure. The implementation environment may include: a terminal 11 and a server 12 .
[0029] Terminal 11 may send the video to be processed to server 12. Server 12 may receive the video to be processed and process it using the method provided in the embodiments of the present disclosure to obtain a repaired video of the video to be processed. Server 12 may then send the repaired video obtained after processing to terminal 11. Terminal 11 may receive the repaired video. Alternatively, terminal 11 may process the video to be processed using the method provided in the embodiments of the present disclosure to obtain a repaired video. Terminal 11 may also store the repaired video.
[0030] Exemplarily, the terminal 11 and the server 12 can be connected via a network, which can be a wireless network or a wired network. The wireless network or wired network uses standard communication technologies and / or protocols. The network is typically the Internet, but can also be any network, including but not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a private network or any combination of a virtual private network. In some embodiments, technologies and / or formats including Hypertext Markup Language (HTML) and Extensible Markup Language (XML) are used to represent data exchanged over the network. In addition, conventional encryption technologies such as Secure Sockets Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), and Internet Protocol Security (IPsec) can be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies can also be used to replace or supplement the above-mentioned data communication technologies.
[0031] Exemplarily, the terminal 11 can be various electronic devices, including but not limited to mobile phones, computers, laptops, desktop computers, wearable devices, intelligent voice interaction devices, vehicle-mounted terminals, smart home appliances, aircraft, augmented reality devices, virtual reality devices, etc.
[0032] For example, the server 12 may be a server that provides various services, such as a background management server that provides support for devices operated by the user using the terminal 11. The background management server may analyze and process the received data and feed back the processing results to the terminal.
[0033] Optionally, the server 12 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to these. The terminal and the server can be directly or indirectly connected via wired or wireless communication, which is not limited in this application.
[0034] Those skilled in the art will appreciate that the number of terminals 11 and servers 12 in FIG1 is merely illustrative, and any number of terminals 11 and servers 12 may be provided based on actual needs, which is not limited in the present disclosure.
[0035] This exemplary implementation is described in detail below with reference to the accompanying drawings and examples.
[0036] First, a video processing method is provided in an embodiment of the present disclosure. The method can be executed by any computer device with computing and processing capabilities. The following takes the application of the method to a terminal as an example.
[0037] FIG2 shows a flow chart of a video processing method in an embodiment of the present disclosure. As shown in FIG2 , the video processing method provided in an embodiment of the present disclosure may include the following S201 to S205 .
[0038] S201: Acquire a first target frame sequence and a first target mask sequence of a video to be processed.
[0039] The embodiment of the present disclosure does not limit the type and acquisition source of the video to be processed. For example, the video to be processed may be a user's photographic work or a video on a certain video platform.
[0040] In some embodiments, the first target frame sequence of the video to be processed may include a continuous multi-frame image in the video to be processed and / or a frame sequence obtained after processing (for example, cropping and / or scaling) the continuous multi-frame image in the video to be processed. The first target frame sequence contains at least one frame of image that needs to be processed (for example, repair, or remove subtitles, watermarks or certain specific objects or people, etc.). The at least one frame of image that needs to be processed can be determined according to the actual application scenario. For example, for the video repair scenario, the image that needs to be processed refers to the image with a missing area in the video to be processed, and the missing area is repaired by the method provided in the embodiment of the present disclosure. For another example, for the scenario of removing subtitles in the video, the image that needs to be processed refers to the image with subtitles in the video to be processed, and the subtitle area is removed by the method provided in the embodiment of the present disclosure, and the area after the subtitles are removed is filled and repaired.
[0041] In some embodiments, the first target mask sequence of the video to be processed may correspond to the first target frame sequence, and the first target mask sequence is used to indicate the area to be processed in the image to be processed in the first target frame sequence, so that the first target mask sequence can be represented as a coordinate matrix set, which includes multiple coordinate matrices, and each target mask can be represented by a corresponding coordinate matrix. For example, for a scene where subtitles are removed, the area to be processed refers to the area where the subtitles to be removed are located. For another example, for a scene where watermarks need to be removed, the area to be processed refers to the area where the watermarks to be removed are located. The above-mentioned area to be processed can also be referred to as a mask area. The embodiment of the present disclosure does not limit the method for obtaining the first target mask sequence. Exemplarily, the first target mask sequence can be obtained based on an algorithm. For example, for a scene where watermarks and / or subtitles are removed, the watermarks can be detected based on an algorithm to obtain the first target mask sequence. Alternatively, the first target mask sequence can also be obtained based on a manual annotation method.
[0042] For example, the first target frame sequence can be expressed as x={x t}, (t=0,1,2,…,T), where T can be an integer greater than or equal to zero, x t is the t+1th frame image in the first target frame sequence x. Corresponding to the first target frame sequence, the first target mask sequence can be expressed as m={m t}, (t=0,1,2,…,T). Among them, m in the first target mask sequence m t is the t+1th mask, the m t It can be expressed as a binary matrix. For example, for the area to be processed in the first target frame sequence, m tThe value of can be 1. For the area in the first target frame sequence that does not need to be processed, m t The value of can be 0, but the present disclosure is not limited thereto. For example, for the scene shown in FIG12, if the person riding a bicycle in FIG12 needs to be removed, the m of the area corresponding to the person riding a bicycle can be set to t The value of m in other areas is 1. t The value of can be 0.
[0043] In some embodiments, multiple frames of images in the video to be processed that contain at least one frame of image that needs to be processed are recorded as a first frame sequence. The first frame sequence can be directly used as a first target frame sequence. The mask sequence corresponding to the first frame sequence is recorded as a first mask sequence. When the first frame sequence is directly used as the first target frame sequence, the first mask sequence can be directly used as a first target mask sequence.
[0044] In other embodiments, in order to reduce the workload of processing the video to be processed and further improve the video processing speed, the above-mentioned first frame sequence and first mask sequence can be processed first to obtain the first target frame sequence and first target mask sequence of the video to be processed.
[0045] Exemplarily, processing the first frame sequence and the first mask sequence to obtain the first target frame sequence and the first target mask sequence of the video to be processed may include the following two methods.
[0046] Method 1, obtaining a first target frame sequence and a first target mask sequence of a video to be processed, may include: obtaining a first frame sequence of the video to be processed and a corresponding first mask sequence thereof; if a proportion of a mask area in the first mask sequence is less than a proportion threshold, determining a target mask according to the first mask sequence, and a mask area of the target mask covers a mask area of the first mask sequence; and cropping the first frame sequence and the first mask sequence respectively according to the target mask to obtain a first target frame sequence and a first target mask sequence.
[0047] For example, all masks in the first mask sequence can be obtained. When the proportion of any mask area in all masks to the corresponding frame image in the first frame sequence is less than a proportion threshold, since the area to be filled (i.e., the corresponding mask area) is only related to its surrounding information, if the coverage area of the mask area in the frame image in the first frame sequence is small, there is no need to process the entire first frame sequence and the first mask sequence. Therefore, the first frame sequence and the first mask sequence can be cropped. The embodiment of the present disclosure does not limit the size of the proportion threshold, and the size of the proportion threshold can be limited based on experience or application scenarios.
[0048] In another exemplary embodiment, a target mask M can be first determined. When the target mask M covers all masks in the first mask sequence, and the mask area in the target mask M accounts for less than a threshold percentage of the area of the frame images in the first frame sequence, it is determined that the mask area in the first mask sequence accounts for less than the threshold percentage. In other words, if the mask area in the target mask is determined to be small, it can be determined that the mask areas of all frame images in the first mask sequence are also small. Therefore, the first frame sequence and the first mask sequence can be cropped to obtain a first target frame sequence and a first target mask sequence.
[0049] In some embodiments, the target mask may be a mask that covers all masks in the first mask sequence. In particular, when all masks in the first mask sequence are identical, the target mask may be any mask in the first mask sequence.
[0050] For example, in the application scenario of removing watermarks and / or subtitles, since the areas corresponding to the watermarks and subtitles in each frame of image are the same, when the first mask sequence is m={m t}, (t=0,1,2,…,T), for different t1 and t2 (t1 and t2 are positive integers greater than or equal to zero and less than or equal to T, and t1 and t2 are different), the corresponding m t1 With m t2 can be equal, then the target mask M can be equal to any m in the first mask sequence t Afterwards, the first frame sequence and the first mask sequence may be cropped based on the size of the mask area of the target mask to obtain a first target frame sequence and a first target mask sequence.
[0051] In an exemplary embodiment, the first frame sequence and the first mask sequence are respectively cropped according to the target mask to obtain the first target frame sequence and the first target mask sequence, which may include: obtaining the number of outwardly extended pixels of the mask area of the target mask according to the length and width of the mask area of the target mask; obtaining the cropping boundary of the mask area of the target mask according to the length, width and the number of outwardly extended pixels of the mask area of the target mask; obtaining a cropping area including the mask area of the target mask according to the cropping boundary of the mask area of the target mask and the length and width of the mask area of the target mask; and cropping the first frame sequence and the first mask sequence according to the cropping area to obtain the first target frame sequence and the first target mask sequence.
[0052] In some embodiments, after determining the target mask M, the length and width of the mask area of the target mask M can be determined based on the coverage of the mask area in the target mask M. Exemplarily, the coverage of the mask area in M can be expressed as [x1, y1, x2, y2], where (x1, y1) can be the coordinate value of the upper left corner of the coverage of the mask area in M, and (x2, y2) can be the coordinate value of the lower right corner of the coverage of the mask area. Therefore, the length of the mask area of the target mask can be calculated by the following formula (1) (in formula (1), the length is expressed as h, and h is a real number greater than 0), and the width of the mask area of the target mask can be calculated by the following formula (2) (in formula (2), the width is expressed as w, and w is a real number greater than 0). h=x2-x1 (1) w=y2-y1 (2)
[0053] After obtaining the length h and width w of the target mask's mask area, the number of outward extended pixels minBound of the target mask's mask area can be calculated using the following formula (3): pix Exemplarily, the outward expansion pixel number is the value of the number of pixels that the mask area of the target mask needs to expand outward, for example, the outward expansion pixel number may be 1152 or 2048.
[0054] Among them, minBound pix is the number of outward expansion pixels of the mask area of the target mask. a is the minimum outward expansion pixel number set based on the resolution of the video to be processed, b is the slope of the outward expansion pixel number for the resolution of the video to be processed, and c can be the length or width pixel number of the video to be processed with a larger amount of data. For example, a, b, and c are all real numbers greater than 0. The embodiment of the present disclosure does not limit the values of a, b, and c in formula (3). The values of a, b, and c can all be set according to experience or application scenarios. For example, a can be 128, b can be 64, and c can be 1024, or a can be 196, b can be 48, and c can be 960. edge is used to indicate the maximum value of the length and width of the mask area of the target mask. The value of edge can be calculated by the following formula (4). edge=max(h, w) (4)
[0055] Afterwards, the outward expansion range of the mask area of the target mask in the x-axis direction and the y-axis direction can be obtained by the outward expansion pixel number of the mask area of the target mask. For example, the value of the outward expansion range can be estimated based on the amplitude of the video motion. Two aspects can be considered in the estimation process. One is that the outward expansion area needs to cover a certain range to include the pixels and context information required in the optical flow propagation process. At the same time, while ensuring that the optical flow propagation is not affected, the outward expansion range can be as small as possible to reduce the processing time. The outward expansion range of the mask area of the target mask in the x-axis direction and the y-axis direction is used as the clipping boundary of the mask area of the target mask. For example, the outward expansion range of the mask area of the target mask in the x-axis direction can be calculated by the following formula (5), and the outward expansion range of the mask area of the target mask in the y-axis direction can be calculated by the following formula (6).
[0056] like
[0057] like
[0058] Among them, minBound h The minBound is the outer expansion range of the target mask area in the x-axis direction. w is the outer expansion range of the target mask's mask area in the y-axis direction. r is the ratio of the side length of the target mask's mask area to the corresponding side length of the cropping area. h with minBound w That is, the clipping boundaries of the mask area of the target mask in the x-axis direction and the y-axis direction.
[0059] For example, the crop area can be calculated by the following formulas (7)-(10). crop1 =clip(x1-minBound w ,0,w) (7) y crop1 =clip(y1-minBound h ,0,h) (8) x crop2 =clip(x²+minBound w ,0,w) (9) y crop2 =clip(y2+minBound h ,0,h) (10)
[0060] Among them, (x crop1 ,y crop1 ) is the coordinate value of the upper left corner of the cropping area. (x crop2,y crop2 ) is the coordinate value of the lower right corner of the clipping area. The clip function is used to limit the value input to the corresponding range. For example, x crop1 For example, the input value in the clip function is x1-minBound w , so (x1-minBound w ) should be between 0 and w, so when (x1-minBound w ) is between 0 and w, then (x1-minBound w ) as the value of x crop1 When (x1-minBound w ) is greater than w, then the value of w is used as x crop1 When (x1-minBound w ) is less than 0, then let x crop1 =0.
[0061] For example, FIG3 shows a schematic diagram of a cropping area. As shown in FIG3 , the target mask corresponds to the person riding a bicycle. Therefore, the mask area of the target mask M can be shown as the dotted line in FIG3 , where (x1, y1) is the coordinate value of the upper left corner of the coverage range of the mask area, and (x2, y2) is the coordinate value of the lower right corner of the coverage range of the mask area. Therefore, the length h of the mask area of the target mask M and the width w of the mask area of the target mask M can be calculated. Then, the outer expansion range minBound of the mask area of the target mask M in the x-axis direction can be calculated h , and the minBound of the expansion range in the y-axis direction w The resulting clipping boundary can be shown as the dotted line in Figure 3. Then, the clipping area can be calculated using the above formulas (7)-(10). For the situation shown in Figure 3, the obtained (x crop1 ,y crop1 ) and (x crop2 ,y crop2 ) are the coordinate values of the upper left corner and the lower right corner of the area framed by the cropping boundary.
[0062] The purpose of calculating the outward expansion range of the mask area of the target mask in the x-axis direction and the y-axis direction is to retain a sufficient number of pixels in the non-mask area after cropping. The pixels in the non-mask area can be used for optical flow filling and pixel propagation processing inside the mask area, and also affect the image restoration process.
[0063] Through the above calculation process, a cropping region can be obtained. Then, the first frame sequence and the first mask sequence can be cropped according to the cropping region, and only the portion within the cropping region is retained for each of the first frame sequence and the first mask sequence, thereby obtaining a first target frame sequence and a first target mask sequence.
[0064] The above-mentioned cropping process of the first frame sequence and the first mask sequence can effectively reduce the number of processed pixels for scenarios where the proportion of the mask area in the first mask sequence is less than the proportion threshold, thereby reducing the workload of processing the video to be processed without affecting the effect of video processing, thereby further improving the video processing speed.
[0065] In the scenario where the proportion of the mask area in the first mask sequence is greater than or equal to the proportion threshold, the cropping area calculated according to the above formulas (7)-(10) is large, and the effect of the cropping process will be correspondingly reduced. In the case where the determined target mask M is too large, the effect of the cropping process is too small, which is equivalent to not cropping the first frame sequence and the first mask sequence. In this case, the first frame sequence and its corresponding first mask sequence can be scaled using the following method 2 to reduce the workload of processing the video to be processed without affecting the effect of video processing, thereby further improving the effect of video processing speed.
[0066] Method 2, obtaining the first target frame sequence and the first target mask sequence of the video to be processed, may include: obtaining the first frame sequence of the video to be processed and its corresponding first mask sequence; if the proportion of the mask area in the first mask sequence is greater than or equal to the proportion threshold, then scaling the first frame sequence and the first mask sequence respectively to obtain the first target frame sequence and the first target mask sequence.
[0067] For example, all masks in the first mask sequence can be obtained. When the proportion of any mask area in all masks to the corresponding frame image in the first frame sequence is greater than or equal to a proportion threshold, it is determined that the proportion of the mask area in the first mask sequence is greater than or equal to the proportion threshold. Alternatively, a target mask M can be first determined, and the target mask M is set to cover all masks in the first mask sequence. When the proportion of the area of the mask area in the target mask M in the frame image in the first frame sequence is greater than or equal to the proportion threshold, it is determined that the proportion of the mask area in the first mask sequence is greater than or equal to the proportion threshold.
[0068] Exemplarily, the embodiment of the present disclosure does not limit the scaling ratio of the scaling processing of the first frame sequence and the first mask sequence. The scaling ratio can be limited based on experience or application scenarios. For example, the scaling ratio can be one-half or one-third of the side length of the original frame image and the mask. The scaling ratio will not cause a significant impact on the filling effect, and at the same time greatly reduces the number of processed pixels. In addition, for scenarios where the proportion of the mask area in the first mask sequence is less than the proportion threshold, but the distribution of the mask area is relatively dispersed, the method provided in the second method can also be used to obtain the first target frame sequence and the first target mask sequence. For example, when the mask is scattered in different areas of the image, such as when the mask is located in the upper right corner and the lower left corner of the image, in this case, the coverage area of the target mask M is too large, and the effect of cropping the first frame sequence and the first mask sequence is small.
[0069] Exemplarily, for a video to be processed with a smaller amount of data, the complete frame sequence and the complete mask sequence of the video to be processed can be directly used as the above-mentioned first frame sequence and its corresponding first mask sequence. However, for a video to be processed with a larger amount of data, the memory may not be loaded, and thus the video to be processed cannot be processed. In this case, obtaining the first target frame sequence and the first target mask sequence of the video to be processed may include: obtaining the complete frame sequence and the corresponding complete mask sequence of the video to be processed; performing shot segmentation processing on the complete frame sequence and the complete mask sequence respectively to obtain a single-shot frame sequence and a corresponding single-shot mask sequence; if the single-shot frame sequence and the corresponding single-shot mask sequence exceed the duration threshold, then performing segmentation processing on the single-shot frame sequence and the corresponding single-shot mask sequence to obtain a segmented frame sequence and a corresponding segmented mask sequence, the segmented frame sequence including the first frame sequence, and the segmented mask sequence including the first mask sequence; obtaining the first target frame sequence and the first target mask sequence according to the first frame sequence and its corresponding first mask sequence.
[0070] For example, if a complete frame sequence and a complete mask sequence are both composed of three shots. Then, the complete frame sequence and the complete mask sequence are subjected to shot segmentation processing, and three single-shot frame sequences and three corresponding single-shot mask sequences can be obtained. If any single-shot frame sequence and the corresponding single-shot mask sequence of the three single-shot frame sequences and the three corresponding single-shot mask sequences exceed the duration threshold, the single-shot frame sequence and the corresponding single-shot mask sequence exceeding the duration threshold can be segmented. The embodiment of the present disclosure does not limit the duration threshold. For example, the duration threshold can be 1 second or 2 seconds. The embodiment of the present disclosure also does not limit the number of segments for segmentation processing. For example, every 5 adjacent frames can be divided into a segment, or every 8 adjacent frames can be divided into a segment. After segmentation processing, multiple segmented frame sequences and multiple corresponding segmented mask sequences can be obtained.
[0071] The method for performing shot segmentation and segmentation processing on a video to be processed provided by the embodiment of the present disclosure can avoid the problem that a large video to be processed cannot be loaded into the memory, thereby preventing the video to be processed from being processed.
[0072] S202 : Perform frame extraction processing on the first target frame sequence and the first target mask sequence respectively to obtain a first sampling frame sequence and a first remaining frame sequence thereof, and a first sampling mask sequence and a first remaining mask sequence thereof.
[0073] The disclosed embodiments do not limit the frame extraction method. For example, one frame may be extracted from the first target frame sequence every three or four frames to obtain a first sampling frame sequence, with the unextracted frames forming the first remaining frame sequence. Similarly, one frame may be extracted from the first target mask sequence every three or four frames to obtain a first sampling mask sequence, with the unextracted frames forming the first remaining mask sequence.
[0074] S203 , performing optical flow propagation and image restoration processing on the first sampling frame sequence and the first sampling mask sequence to obtain a first restored sampling frame sequence.
[0075] In some embodiments, the first sampling mask sequence is used to indicate regions in the first sampling frame sequence that require processing. In these regions, due to, for example, removal of watermarks or moving objects, unknown regions may be generated in the image of the first sampling frame sequence. Therefore, the unknown regions in the first sampling frame sequence need to be filled to repair the first sampling frame sequence.
[0076] In an exemplary embodiment, optical flow propagation and image restoration processing are performed on the first sampling frame sequence and the first sampling mask sequence to obtain a first restored sampling frame sequence, including: performing optical flow propagation processing on the first sampling frame sequence and the first sampling mask sequence to obtain a first updated sampling gradient frame sequence and a first updated sampling mask sequence; performing Poisson reconstruction processing on the first updated sampling gradient frame sequence and the first updated sampling mask sequence to obtain a first updated sampling frame sequence; and performing frame-by-frame image restoration processing on the first updated sampling frame sequence to obtain a first restored sampling frame sequence.
[0077] In a possible embodiment, the first updated sampling gradient frame sequence is a frame sequence obtained by filling the unknown area in the first sampling frame sequence. The first updated sampling mask sequence is a mask sequence corresponding to the first updated sampling gradient frame sequence. Exemplarily, the optical flow propagation processing of a frame image can be performed through the previous frame image and the next frame image of the frame image. As shown in Figure 4, forward propagation can be performed through the previous frame image of the frame image, that is, Figure 4 (a), to fill the unknown area in the frame image, and obtain Figure 4 (b1). And backward propagation can be performed through the next frame image of the frame image, that is, Figure 4 (c), to fill the unknown area in the frame image, and obtain Figure 4 (b2).
[0078] For regions of the first updated sampling gradient frame sequence that have been filled compared to the first sampling frame sequence, the first sampling mask sequence needs to be updated accordingly to obtain a first updated sampling mask sequence. For example, the values of the first sampling mask sequence corresponding to the filled regions can be changed from 1 to 0 to obtain the first updated sampling mask sequence.
[0079] In an exemplary embodiment, after obtaining the first updated sampling gradient frame sequence and the first updated sampling mask sequence, the first updated sampling gradient frame sequence and the first updated sampling mask sequence can be subjected to Poisson reconstruction processing to obtain the first updated sampling frame sequence. The Poisson reconstruction processing is used to reconstruct the first updated sampling gradient frame sequence and the first updated sampling mask sequence of the gradient pixel pattern into the first updated sampling frame sequence of the RGB (Red, Green, Blue, three primary colors) pixel pattern. Exemplarily, each frame of the image is represented by a two-dimensional discrete function, and the two-dimensional discrete function is differentiated, so that the derivative value can be used to describe the pixel point at the corresponding position. This pixel description method can be called a gradient pixel pattern. For example, the gradient pixel G of point (i, j) can be described according to the following formula (11). G=dx(i, j)+dy(i, j) (11)
[0080] Here, dx represents the operation of differentiating the independent variable, and dy represents the operation of differentiating the function value.
[0081] Alternatively, pixels can be described using RGB values, which is called an RGB pixel mode. For example, the RGB values corresponding to a pixel may be (50, 80, 10), where the red value for the pixel is 50, the green value is 80, and the blue value is 10.
[0082] For example, an octree can be constructed based on the first updated sampling gradient frame sequence and the first updated sampling mask sequence, and a spatial function can be set for each node of the octree. The linear sum of all spatial functions can represent a vector field. The Poisson equation can then be solved for this vector field. The solution to the Poisson equation can be found using Laplace matrix iteration. The first updated sampling frame sequence can be obtained based on the solution to the Poisson equation.
[0083] In some embodiments, there may be unknown pixels in the first update sampling frame sequence that cannot be filled by the optical flow propagation process. The area composed of these unknown pixels that cannot be filled can be called an isolated area, which is included in the above-mentioned unknown area.
[0084] For example, the isolated region in the first updated sampling frame sequence can be subjected to frame-by-frame image restoration processing to obtain a first restored sampling frame sequence. For example, the isolated region can be subjected to image restoration using a pre-trained neural network model. The disclosed embodiments do not limit the type of the neural network model. For example, DeepFillv2 (a neural network model based on gated convolution) or CR-Fill (Contexutal Reconstruction-Fill) can be used.
[0085] In an exemplary embodiment, performing optical flow propagation processing on the first sampling frame sequence and the first sampling mask sequence to obtain a first updated sampling gradient frame sequence and a first updated sampling mask sequence may include: performing optical flow estimation processing on the first sampling frame sequence to obtain a first sampling optical flow sequence; performing gradient pixel conversion processing on the first sampling frame sequence to obtain a first sampling gradient frame sequence; performing optical flow filling processing on the mask area in the first sampling optical flow sequence to obtain a first filled sampling optical flow sequence; and performing optical flow propagation processing on the first sampling gradient frame sequence and the first sampling mask sequence based on the first filled sampling optical flow sequence to obtain a first updated sampling gradient frame sequence and a first updated sampling mask sequence.
[0086] Exemplarily, in the method for optical flow estimation processing, any two adjacent images in the first sampling frame sequence can be input, and the pixels in the two adjacent images can be matched through optical flow estimation processing. Then, the first sampling optical flow sequence can be output, and the first sampling optical flow sequence contains a forward optical flow map and a backward optical flow map corresponding to any frame image. The forward optical flow map is the optical flow map between the frame image and the previous frame image of the frame image, and the backward optical flow map is the optical flow map between the frame image and the next frame image of the frame image. Both the forward optical flow map and the backward optical flow map can indicate the offset of the image in the horizontal and vertical directions.
[0087] In an exemplary embodiment, a gradient pixel conversion process may be performed on the first sampling frame sequence, thereby converting the first sampling frame sequence in an RGB pixel mode into a first sampling gradient frame sequence in a corresponding gradient pixel mode. Then, an optical flow filling process is performed on the first sampling optical flow sequence and the first sampling mask sequence to obtain a first filled sampling optical flow sequence.
[0088] Exemplarily, the optical flow filling process is used to fill the mask area in the optical flow map. During the optical flow filling process, the Laplace equation can be solved for the corresponding mask area in the optical flow map to make the filled optical flow smoothly connect with the edge optical flow.
[0089] In an exemplary embodiment, during the optical flow filling process, optical flow filling can be performed on a frame image based on a forward optical flow map between the frame image and the previous frame image, as well as a backward optical flow map between the frame image and the next frame image, to obtain a first filled sampled optical flow sequence. Then, based on the matching relationships in the first filled sampled optical flow sequence, optical flow propagation can be performed on the first sampled gradient frame sequence and the first sampled mask sequence to obtain a first updated sampled gradient frame sequence and a first updated sampled mask sequence.
[0090] The disclosed embodiments do not limit the method used for optical flow estimation. In one possible implementation, a CNN (Convolutional Neural Network) can be used for optical flow estimation. For example, a CNN-based optical flow estimation module diagram can be shown in FIG5 . The CNN-based optical flow estimation module is a lightweight optical flow estimation network module.
[0091] In Figure 5, the two adjacent frames of images must first pass through the convolution layer to perform two convolution operations, and then perform two pooling operations to extract the pyramid features. Afterwards, the cost volume (Cost Volume) construction module can be used to obtain the first cost volume corresponding to the pyramid feature, and then the convolution of the pyramid features extracted from the previous frame image and the first cost volume are input into the regression optical flow (regressing optical flow) module to obtain the predicted optical flow map (Predicted Flow) corresponding to the previous frame image. For example, the above-mentioned cost volume can be used to describe the degree of matching between corresponding pixels in the two frames of images. The regression optical flow module can be used to estimate the optical flow of corresponding feature points in the two frames of images through a regression model, thereby obtaining the corresponding predicted optical flow map.
[0092] Afterwards, the predicted optical flow map corresponding to the previous frame image can be upsampled to obtain an upsampled result. The upsampled structure and the result of the next frame image after a single pooling are input into the warping processing module to obtain a warping result. Exemplarily, the warping process can be used to transform changes such as changes in lens position or changes in objects in the image, so that corresponding pixels in the two frames of image can be aligned. The warping process can narrow the processing range corresponding to the optical flow estimation process to reduce the computational complexity of the optical flow estimation module. Then, the warping result and the result of the previous frame image after a single pooling can be input into the cost volume construction module to obtain a second cost volume. The convolution of the result of the next frame image after a single pooling and the second cost volume are input into the regression optical flow module to obtain the predicted optical flow map corresponding to the next frame image. Accordingly, upsampling and other operations can be performed based on the predicted optical flow map corresponding to the next frame image to obtain the predicted optical flow map corresponding to the next frame image.
[0093] The disclosed embodiment can perform optical flow estimation using the optical flow estimation module in FIG5 . The optical flow estimation speed can reach 91 FPS (Frames Per Second), which is 27 times that of the RAFT network. Therefore, the disclosed embodiment can increase the speed of optical flow estimation and achieve effective optical flow estimation results. This can improve the efficiency of video processing by the video processing method and ensure the quality of video processing.
[0094] In an exemplary embodiment, a schematic diagram of the optical flow estimation and optical flow filling process can be shown in Figure 6. In Figure 6, Figure 6(a) is a schematic diagram of an image in a first sampling frame sequence. As shown in Figure 6, the image includes a mask region. Optical flow estimation is performed on the image to obtain a predicted optical flow map as shown in Figure 6(b), which is included in the first sampling optical flow sequence. Subsequently, optical flow filling is performed on the predicted optical flow map to obtain a filled optical flow map as shown in Figure 6(c), which is included in the first filled sampling optical flow sequence.
[0095] S204 , performing optical flow propagation and image restoration processing on the first restored sampling frame sequence, the first remaining frame sequence, and the first remaining mask sequence to obtain a first restored remaining frame sequence.
[0096] In an exemplary embodiment, performing optical flow propagation and image restoration processing on the first repaired sampling frame sequence, the first remaining frame sequence, and the first remaining mask sequence to obtain the first repaired remaining frame sequence may include: performing gradient pixel conversion processing on the first remaining frame sequence to obtain a first remaining gradient frame sequence; obtaining a first remaining optical flow sequence based on the first remaining frame sequence and the first sampling frame sequence; performing optical flow filling processing on the mask area in the first remaining optical flow sequence to obtain a first filled remaining optical flow sequence; performing optical flow propagation and image restoration on the first remaining gradient frame sequence, the first filled remaining optical flow sequence, the first repaired sampling frame sequence, and the first remaining mask sequence to obtain the first repaired remaining frame sequence.
[0097] In some embodiments, the method of performing gradient pixel conversion on the first residual frame sequence to obtain the first residual gradient frame sequence may be the same as the method of performing gradient pixel conversion on the first sampling frame sequence described above, which will not be described in detail here.
[0098] In an exemplary embodiment, obtaining a first residual optical flow sequence based on a first residual frame sequence and a first sampling frame sequence may include: determining a target residual frame in the first residual frame sequence; determining a target forward frame and a target backward frame of the target residual frame from the first sampling frame sequence; obtaining a forward optical flow map between the target forward frame and the target residual frame, and a backward optical flow map between the target backward frame and the target residual frame; and determining the first residual optical flow sequence based on the forward optical flow map and the backward optical flow map.
[0099] The embodiment of the present disclosure does not limit the target residual frame, and the target residual frame can be any frame in the first residual frame sequence. The target forward frame of the target residual frame is the frame that precedes the target residual frame and is closest to the target residual frame in the first sampling frame sequence; the target backward frame of the target residual frame is the frame that follows the target residual frame and is closest to the target residual frame in the first sampling frame sequence.
[0100] Exemplarily, assuming that the first sampling frame sequence can be {X_0, X_4, X_8, ...}, and the first remaining frame sequence can be {X_1, X_2, X_3, X_5, X_6, X_7, X_9, ...}, when the target remaining frame is X_1, the target forward frame of the target remaining frame is X_0, and the target backward frame is X_4. After determining the target forward frame and the target backward frame of the target remaining frame, the forward optical flow map between the target forward frame and the target remaining frame, and the backward optical flow map between the target backward frame and the target remaining frame can be obtained by the optical flow estimation processing method. Afterwards, the first remaining optical flow sequence can be determined based on the forward optical flow maps and the backward optical flow maps of multiple target remaining frames. Exemplarily, the optical flow estimation processing method can be the same as the above-mentioned method for performing optical flow estimation processing on the first sampling frame sequence, and will not be repeated here.
[0101] In some embodiments, the method for performing optical flow filling processing on the mask area in the first residual optical flow sequence can be the same as the method for performing optical flow filling processing on the first sampled optical flow sequence described above, and this will not be described in detail here. Then, the first residual gradient frame sequence can be subjected to optical flow propagation and image restoration processing using the first filled residual optical flow sequence and the first restored sampled frame sequence to obtain a first restored residual frame sequence. Exemplarily, the method for performing optical flow propagation and image restoration processing on the first residual gradient frame sequence can be the same as the method for performing optical flow propagation and image restoration processing on the first sampled frame sequence and the first sampled mask sequence described above, and this will not be described in detail here.
[0102] Optionally, while performing optical flow propagation processing on the first residual gradient frame sequence, the first residual mask sequence may also be updated to obtain a first updated residual mask sequence. This updating of the first residual mask sequence may be performed in the same manner as the updating of the first sampling mask sequence described above, and will not be further described herein.
[0103] In an exemplary embodiment, a schematic diagram of a process for obtaining a first repaired remaining frame sequence can be shown in FIG7 . A frame extraction process can be performed on the first target frame sequence. In FIG7 , assuming that the first target frame sequence includes 13 frames, from frame X_0 to frame X_12, the frame extraction process is performed on the first target frame sequence to obtain a first sampled frame sequence including frame X_0, frame X_4, frame X_8, and frame X_12. Then, optical flow propagation and image restoration can be performed on the first sampled frame sequence to obtain a first repaired sampled frame sequence. Since the target forward frame for frame X_1 is frame X_0 and the target backward frame is frame X_4, the filled optical flow map corresponding to frame X_1 can be obtained by using frames X_0 and X_4. Similarly, the filled optical flow maps corresponding to frames X_2 and X_3 can be obtained by using frames X_0 and X_4. According to the above steps, the filled optical flow maps corresponding to frames X_5, X_6, and X_7 can be obtained in sequence through frames X_4 and X_8; and the filled optical flow maps corresponding to frames X_9, X_10, and X_11 can be obtained in sequence through frames X_8 and X_12. No further details will be given here.
[0104] S205 , merging the first repaired sampling frame sequence and the first repaired remaining frame sequence to obtain a repaired video of the video to be processed.
[0105] In some embodiments, each frame of the first restored sample frame sequence may be inserted into the first restored remaining frame sequence in frame order to obtain a complete restored frame sequence, which may correspond to the restored video of the video to be processed.
[0106] In an exemplary embodiment, before processing the first sampling frame sequence and the first remaining frame sequence to obtain the first repaired sampling frame sequence and the first repaired remaining frame sequence, the video to be processed may be subjected to shot cutting processing and / or segmentation processing. At this time, the segmented frame sequence may further include a second frame sequence, and the segmented mask sequence may further include a second mask sequence. In this case, merging the first repaired sampling frame sequence and the first repaired remaining frame sequence to obtain a repaired video of the video to be processed may include: inserting the tail frames of the first repaired sampling frame sequence and the first repaired remaining frame sequence into the second frame sequence and the second mask sequence, respectively, as the first frames of the second frame sequence and the second mask sequence; processing the second frame sequence and the second mask sequence to obtain the second repaired sampling frame sequence and the second repaired remaining frame sequence; merging the first repaired sampling frame sequence and the first repaired remaining frame sequence, and the second repaired sampling frame sequence and the second repaired remaining frame sequence to obtain the repaired video.
[0107] For example, a schematic diagram of a video processing process can be shown in Figure 8. In Figure 8, each consecutive four frames can be divided into a segment. Thus, a 12-frame video to be processed can be divided into three segments, as shown in Figure 8: frames x_0 to x_3, frames x_4 to x_7, and frames x_8 to x_11. Subsequently, the segmented frame sequence and segmented mask sequence corresponding to each segment can be repaired according to the order in which the frames are arranged. Therefore, the segmented frame sequence and segmented mask sequence corresponding to frames x_0 to x_3 can be processed first to obtain the repaired video corresponding to frames x_0 to x_3, namely, the repaired {X_0, X_1, X_2, X_3} shown in Figure 8. The last frame of this repaired video, frame x_3, can then be inserted into the beginning of the segmented frame sequence and segmented mask sequence corresponding to frames x_4 to x_7. Afterwards, the segmented frame sequence and segmented mask sequence corresponding to frames x_3 to x_7 can be repaired to obtain the repaired video corresponding to frames x_4 to x_7, namely the repaired {X_3, X_4, X_5, X_6, X_7} shown in Figure 8. The same method is used to process the segmented frame sequence and segmented mask sequence corresponding to frames x_8 to x_11. Through this tail frame insertion method, when processing the segmented frame sequence and segmented mask sequence, information from the previous repaired video can be obtained. In the disclosed embodiment, after the video to be processed is shot-split and / or segment-segmented, the video repair process is sequentially performed on each segmented frame sequence and its corresponding segmented mask sequence. At the same time, the last frame of each repaired segmented frame sequence is inserted as the first frame into the next segmented frame sequence for repairing the next segmented frame sequence. This method can prevent the loss of information between segments caused by simple segmentation, thereby achieving better video processing results.
[0108] It should be noted that the above description of dividing each continuous 4 frames into one segment and dividing a 12-frame video into 3 segments is only an example and is not used to limit the above-mentioned tail frame insertion method.
[0109] The method provided by the embodiment of the present disclosure, on the one hand, can first process the first sampling frame sequence and the first sampling mask sequence by the frame extraction method to obtain the first repaired sampling frame sequence. Then, the first remaining frame sequence is processed by the first repaired sampling frame sequence and the first remaining mask sequence to obtain the repaired video of the video to be processed. Therefore, the present disclosure can process the remaining frame sequence by the first repaired sampling frame sequence through the frame extraction process, avoid multiple rounds of processing for each frame image, reduce the amount of calculation, and thus improve the efficiency of video processing. On the other hand, it can also effectively avoid the problem of insufficient memory caused by large video by shot cutting and / or video segmentation processing. In addition, by inserting the last frame of each repaired segmented frame sequence as the first frame into the next segmented frame sequence for repairing the next segmented frame sequence, this method can prevent the loss of information between segments caused by simple cutting, so as to obtain a better video processing effect.
[0110] As shown in FIG9 , FIG9 shows a flow chart of a video processing method provided by an embodiment of the present disclosure. For example, the first target frame sequence can be represented as X={X t}, (t=0,1,2,…,T), the first target mask sequence can be expressed as M={M t}, (t=0,1,2,…,T). The purpose of this scheme is to obtain the processed video sequence y={y t}, (t = 0, 1, 2, ..., T), the processed video sequence y is different from X only in the mask area, making y natural and consistent in time and space. Since naturalness and consistency are difficult to define in a formal way, this solution makes the processed video sequence y and y gt Close, where y gt Used to represent the true value of the video sequence without the mask.
[0111] First, a complete frame sequence and a complete mask sequence of the video to be restored can be obtained. These can then be shot-cut and / or segmented to obtain a first frame sequence X_1 and a first mask sequence M_1. Subsequently, the first frame sequence X_1 and the first mask sequence M_1 can be cropped or scaled using the Data Preprocessing Module (DPM) to obtain a first target frame sequence X and a first target mask sequence M.
[0112] Then, the first target frame sequence X can be processed by frame extraction to obtain the first sampling frame sequence X_sampled and the first remaining frame sequence X_remain. For example, if one frame is extracted every four frames of the first target frame sequence, then X_sampled = {X_0, X_4, X_8, ...}. If the last frame of the first target frame sequence X is not selected, the last frame is added to the first sampling frame sequence X_sampled. The first target mask sequence M is also processed by frame extraction to obtain the first sampling mask sequence M_sampled and the first remaining mask sequence X_remain. X_sampled and M_sampled can then be input into the FPM (Flow Propagation Module) and IIM (Image Inpainting Module) to output the completed restoration subset. Different from the multi-round propagation scheme, here, we only use the FPM module for one round of filling. For the unfilled isolated areas, we use IIM to fill them frame by frame.
[0113] In FIG9 , gradient pixel conversion processing can be performed on the first sampling frame sequence X_sampled to obtain a first sampling gradient frame sequence X_sgrad, and the first sampling frame sequence X_sampled is input into a lightweight FEM (Flow Estimation Module) for optical flow estimation processing to obtain a first sampled optical flow sequence F_sampled. The first sampled optical flow sequence F_sampled is input into an FCM (Flow Completion Module) for optical flow completion processing to obtain a first filled sampled optical flow sequence F_scomp.
[0114] Then, the first filled sampled optical flow sequence F_scomp, the first sampled gradient frame sequence X_sgrad, and the first sampled mask sequence M_sampled can be input into the FPM module for optical flow propagation processing to obtain the first updated sampled gradient frame sequence X_sgrad_fill and the first updated sampled mask sequence M_sfill. For example, the FPM and frame extraction processing here can be included in the SPM (Sampled Propagation Module).
[0115] The first updated sampled gradient frame sequence X_sgrad_fill and the first updated sampled mask sequence M_sfill are then input into a Poisson Reconstruction Module (PRM) for Poisson reconstruction, yielding a first updated sampled frame sequence X_sfill_fpm. The first updated sampled frame sequence is then subjected to frame-by-frame image restoration through an IIM, yielding a first restored sampled frame sequence X_sfill.
[0116] Similarly, gradient pixel conversion can be performed on the first remaining frame sequence X_remain to obtain a first remaining gradient frame sequence X_rgrad. The first remaining frame sequence X_remain and the first sampled frame sequence X_sampled are input into a lightweight FEM for optical flow filling to obtain a first remaining optical flow sequence. Optical flow filling is performed on the masked area in the first remaining optical flow sequence to obtain a first filled remaining optical flow sequence F_rcomp.
[0117] Then, the first residual gradient frame sequence X_rgrad, the first filled residual optical flow sequence F_rcomp, the first repaired sample frame sequence X_sfill, and the first residual mask sequence X_remain can be input into the FPM and PRM for optical flow filling and Poisson reconstruction, thereby obtaining a first updated residual frame sequence X_rgrad_fill. The first updated residual frame sequence X_rgrad_fill is then subjected to frame-by-frame image restoration through the IIM to obtain a first repaired residual frame sequence X_rfill. Optionally, for each unselected frame X_remain, the closest forward frame X_prev and backward frame X_next in X_sampled are found. For example, in the aforementioned case where one frame is sampled every four frames of the first target frame sequence, assuming that X_remain is frame X_1, then the closest forward frame X_prev is frame X_0, and the closest backward frame X_next is frame X_4.
[0118] Optical flow propagation is performed between X_remain and the forward frame X_prev and the backward frame X_next. Pixels in corresponding regions are filled using optical flow. If pixels in the same position are already filled, the pixels are averaged. Unfilled regions are filled using a separate IIM module. Finally, the first repaired remaining frame sequence is merged with the first repaired sample frame sequence to obtain the repaired video of the video being processed.
[0119] In the disclosed embodiment, the amount of calculation performed by the FPM module is relatively large. In order to reduce the time consumption of the optical flow propagation module, this solution first extracts frames from the frame sequence before optical flow propagation. After the extracted frames are filled, we use optical flow to propagate the contents of the forward frame and the backward frame to the remaining frames at one time. Therefore, this solution only performs one round of optical flow propagation processing, which reduces the amount of calculation of the FPM module and reduces the time consumption. Afterwards, the IIM module can be used to perform frame-by-frame image restoration processing on the isolated areas so that each frame is completely filled. Avoiding the use of multiple rounds of optical flow filling to process the isolated areas here can reduce the amount of calculation of the FPM module. Therefore, this solution can accelerate the video processing algorithm to achieve commercially available processing efficiency.
[0120] The video processing method provided in Figure 9 can avoid multiple rounds of optical flow propagation, accelerating the deployment of video processing algorithms. As shown in Table 1, for a 188-frame shot, the video preprocessing process using DPM in this solution, namely the process of cropping or scaling the video, takes approximately 267.8 seconds, while the multi-round optical flow propagation solution takes approximately 267.8 seconds, a time reduction of approximately 67.4%. The video optical flow estimation process using FEM in this solution takes approximately 217.4 seconds, a time reduction of approximately 73.5% compared to the multi-round optical flow propagation solution. The video frame extraction and optical flow propagation process using SPM in this solution takes approximately 88.2 seconds. Since frame extraction is performed before optical flow propagation, the time reduction compared to the multi-round optical flow propagation solution is approximately 89.3%.
[0121] Table 1
[0122] Exemplarily, a schematic diagram of a video processing effect for removing a watermark may be shown in Figure 10. In Figure 10(a), there is an elliptical watermark in the lower left corner of the video to be processed. The elliptical watermark can be removed by the method provided by the embodiment of the present disclosure, and the effect after removal can be shown in Figure 10(b). Exemplarily, a schematic diagram of a video processing effect for removing subtitles may be shown in Figure 11. In Figure 11(a), there is a line of subtitles at the bottom of the video to be processed. The line of subtitles can be removed by the method provided by the embodiment of the present disclosure, and the effect after removal can be shown in Figure 11(b). Exemplarily, a schematic diagram of a video processing effect for removing a moving object may be shown in Figure 12. In Figure 12(a), there is a person riding a bicycle in the video to be processed. The person riding a bicycle can be removed by the method provided by the embodiment of the present disclosure, and the effect after removal can be shown in Figure 12(b).
[0123] FIG13 is a schematic diagram of a video processing device provided by an embodiment of the present disclosure. As shown in FIG13 , the video processing device provided by an embodiment of the present disclosure may include an acquisition module 1301 and a frame extraction module 1302 .
[0124] An acquisition module 1301 is configured to acquire a first target frame sequence and a first target mask sequence of a video to be processed;
[0125] The frame extraction module 1302 is configured to perform frame extraction processing on the first target frame sequence and the first target mask sequence respectively to obtain a first sampling frame sequence and a first residual frame sequence thereof, and a first sampling mask sequence and a first residual mask sequence thereof;
[0126] The acquisition module 1301 is further configured to perform optical flow propagation and image restoration processing on the first sampling frame sequence and the first sampling mask sequence to obtain a first restored sampling frame sequence;
[0127] The acquisition module 1301 is further configured to perform optical flow propagation and image restoration processing on the first restored sampling frame sequence, the first remaining frame sequence, and the first remaining mask sequence to obtain a first restored remaining frame sequence;
[0128] The acquisition module 1301 is further configured to merge the first repaired sampling frame sequence and the first repaired remaining frame sequence to obtain a repaired video of the video to be processed.
[0129] In an exemplary embodiment, the acquisition module 1301 is used to perform gradient pixel conversion processing on the first residual frame sequence to obtain a first residual gradient frame sequence; obtain a first residual optical flow sequence based on the first residual frame sequence and the first sampling frame sequence; perform optical flow filling processing on the mask area in the first residual optical flow sequence to obtain a first filled residual optical flow sequence; perform optical flow propagation and image restoration processing on the first residual gradient frame sequence, the first filled residual optical flow sequence, the first repaired sampling frame sequence, and the first residual mask sequence to obtain a first repaired residual frame sequence.
[0130] In an exemplary embodiment, an acquisition module 1301 is used to determine a target residual frame in a first residual frame sequence; determine a target forward frame and a target backward frame of the target residual frame from a first sampling frame sequence; obtain a forward optical flow map between the target forward frame and the target residual frame, and a backward optical flow map between the target backward frame and the target residual frame; and determine a first residual optical flow sequence based on the forward optical flow map and the backward optical flow map.
[0131] In an exemplary embodiment, the acquisition module 1301 is used to perform optical flow propagation processing on the first sampling frame sequence and the first sampling mask sequence to obtain a first updated sampling gradient frame sequence and a first updated sampling mask sequence; perform Poisson reconstruction processing on the first updated sampling gradient frame sequence and the first updated sampling mask sequence to obtain a first updated sampling frame sequence; and perform frame-by-frame image restoration processing on the first updated sampling frame sequence to obtain a first restored sampling frame sequence.
[0132] In an exemplary embodiment, the acquisition module 1301 is configured to perform optical flow estimation on the first sampling frame sequence to obtain a first sampling optical flow sequence; perform gradient pixel conversion on the first sampling frame sequence to obtain a first sampling gradient frame sequence; perform optical flow filling on the mask area in the first sampling optical flow sequence to obtain a first filled sampling optical flow sequence; and perform optical flow propagation on the first sampling gradient frame sequence and the first sampling mask sequence based on the first filled sampling optical flow sequence to obtain a first updated sampling gradient frame sequence and a first updated sampling mask sequence.
[0133] In an exemplary embodiment, the acquisition module 1301 is used to obtain a first frame sequence of a video to be processed and its corresponding first mask sequence; if the proportion of the mask area in the first mask sequence is less than a proportion threshold, a target mask is determined according to the first mask sequence, and the mask area of the target mask covers the mask area of the first mask sequence; the first frame sequence and the first mask sequence are cropped respectively according to the target mask to obtain a first target frame sequence and a first target mask sequence.
[0134] In an exemplary embodiment, the acquisition module 1301 is used to obtain the number of outwardly extended pixels of the mask area of the target mask based on the length and width of the mask area of the target mask; obtain the cropping boundary of the mask area of the target mask based on the length, width and outwardly extended pixels of the mask area of the target mask; obtain a cropping area including the mask area of the target mask based on the cropping boundary of the mask area of the target mask and the length and width of the mask area of the target mask; and perform cropping processing on the first frame sequence and the first mask sequence respectively according to the cropping area to obtain a first target frame sequence and a first target mask sequence.
[0135] In an exemplary embodiment, the acquisition module 1301 is used to obtain a first frame sequence of a video to be processed and its corresponding first mask sequence; if the proportion of the mask area in the first mask sequence is greater than or equal to a proportion threshold, the first frame sequence and the first mask sequence are scaled respectively to obtain a first target frame sequence and a first target mask sequence.
[0136] In an exemplary embodiment, the acquisition module 1301 is used to obtain a complete frame sequence and a corresponding complete mask sequence of a video to be processed; perform shot segmentation processing on the complete frame sequence and the complete mask sequence respectively to obtain a single-shot frame sequence and a corresponding single-shot mask sequence; if the single-shot frame sequence and the corresponding single-shot mask sequence exceed a duration threshold, segment the single-shot frame sequence and the corresponding single-shot mask sequence to obtain a segmented frame sequence and a corresponding segmented mask sequence, the segmented frame sequence includes a first frame sequence, and the segmented mask sequence includes a first mask sequence; obtain a first target frame sequence and a first target mask sequence based on the first frame sequence and its corresponding first mask sequence.
[0137] In an exemplary embodiment, the segmented frame sequence also includes a second frame sequence, and the segmented mask sequence also includes a second mask sequence; the acquisition module 1301 is used to insert the tail frames of the first repaired sampling frame sequence and the first repaired remaining frame sequence into the second frame sequence and the second mask sequence, respectively, as the first frames of the second frame sequence and the second mask sequence; the second frame sequence and the second mask sequence are processed to obtain a second repaired sampling frame sequence and a second repaired remaining frame sequence; and the first repaired sampling frame sequence and the first repaired remaining frame sequence, and the second repaired sampling frame sequence and the second repaired remaining frame sequence are used to obtain a repaired video.
[0138] The apparatus provided in the embodiments of the present disclosure can first process the first sampling frame sequence and the first sampling mask sequence using a frame extraction method to obtain a first repaired sampling frame sequence. The first remaining frame sequence is then processed using the first repaired sampling frame sequence and the first remaining mask sequence to obtain a repaired video of the video to be processed. Therefore, the present disclosure can process the remaining frame sequence using the first repaired sampling frame sequence through frame extraction, avoiding multiple rounds of processing for each frame, reducing the computational effort, and thus improving video processing efficiency.
[0139] Referring to Figure 14, Figure 14 is a schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure. As shown in Figure 14, the computer device in an embodiment of the present disclosure may include: one or more processors 1401, a memory 1402, and an input / output interface 1403. The processor 1401, the memory 1402, and the input / output interface 1403 are connected via a bus 1404. The memory 1402 is used to store a computer program, which includes program instructions. The input / output interface 1403 is used to receive and output data, such as for data exchange between a host machine and a computer device, or for data exchange between various virtual machines in a host machine; the processor 1401 is used to execute the program instructions stored in the memory 1402.
[0140] Among them, the processor 1401 can perform the following operations: obtain the first target frame sequence and the first target mask sequence of the video to be processed; perform frame extraction processing on the first target frame sequence and the first target mask sequence respectively to obtain the first sampling frame sequence and its first residual frame sequence, and the first sampling mask sequence and its first residual mask sequence; obtain the first repaired sampling frame sequence based on the first sampling frame sequence and the first sampling mask sequence; obtain the first repaired residual frame sequence based on the first repaired sampling frame sequence, the first residual frame sequence and the first residual mask sequence; obtain the repaired video of the video to be processed based on the first repaired sampling frame sequence and the first repaired residual frame sequence.
[0141] In some feasible implementations, the processor 1401 may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, etc.
[0142] The memory 1402 may include a read-only memory and a random access memory, and provides instructions and data to the processor 1401 and the input / output interface 1403. A portion of the memory 1402 may also include a non-volatile random access memory. For example, the memory 1402 may also store device type information.
[0143] In a specific implementation, the computer device can execute the video processing implementation method provided in each step of any of the above method embodiments through its built-in functional modules. For details, please refer to the implementation method provided in each step in the figure shown in the above method embodiment, which will not be repeated here.
[0144] The embodiments of the present disclosure provide a computer device including a processor, an input / output interface, and a memory. The processor obtains a computer program in the memory to execute the steps of the method shown in any of the above embodiments.
[0145] The embodiments of the present disclosure also provide a computer-readable storage medium, which stores a computer program, and the computer program is suitable for being loaded by the processor and executing the training method of the acoustic model provided in each step of any of the above embodiments. For details, please refer to the implementation method provided in each step of any of the above embodiments, which will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in the present disclosure, please refer to the description of the method embodiment of the present disclosure. As an example, the computer program can be deployed to be executed on one computer device, or on multiple computer devices located at one location, or on multiple computer devices distributed at multiple locations and interconnected by a communication network.
[0146] The computer-readable storage medium may be the video processing device provided in any of the aforementioned embodiments or the internal storage unit of the computer device, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Furthermore, the computer-readable storage medium may also include both the internal storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0147] The present disclosure also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method provided in any of the optional embodiments described above.
[0148] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present disclosure are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or device that includes a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules that are not listed, or may optionally include other steps and units inherent to these processes, methods, apparatuses, products, or devices.
[0149] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in this description according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.
[0150] The methods and related devices provided by the embodiments of the present disclosure are described with reference to the method flow charts and / or structural diagrams provided by the embodiments of the present disclosure. Specifically, each process and / or box in the method flow charts and / or structural diagrams, as well as the combination of processes and / or boxes in the flow charts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable application display device to produce a machine, so that the instructions executed by the processor of the computer or other programmable application display device produce a device for implementing the functions specified in one or more processes in the flow chart and / or one or more boxes in the structural diagram. These computer program instructions can also be stored in a computer-readable memory that can guide the computer or other programmable application display device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in one or more processes in the flow chart and / or one or more boxes in the structural diagram. These computer program instructions can also be loaded onto a computer or other programmable application display device, so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the structural diagram.
[0151] The above disclosure is merely a preferred embodiment of the present disclosure and certainly cannot be used to limit the scope of the present disclosure. Therefore, equivalent changes made according to the claims of the present disclosure are still within the scope of the present disclosure.
Claims
1. A video processing method, the method being executed by a computer device, the method comprising: Acquire a first target frame sequence and a first target mask sequence of a video to be processed; Performing frame extraction processing on the first target frame sequence and the first target mask sequence respectively to obtain a first sampling frame sequence and a first remaining frame sequence thereof, and a first sampling mask sequence and a first remaining mask sequence thereof; Performing optical flow propagation and image restoration processing on the first sampling frame sequence and the first sampling mask sequence to obtain a first restored sampling frame sequence; Performing optical flow propagation and image restoration processing on the first restored sampling frame sequence, the first remaining frame sequence, and the first remaining mask sequence to obtain a first restored remaining frame sequence; The first repaired sampling frame sequence and the first repaired remaining frame sequence are merged to obtain a repaired video of the video to be processed.
2. The method according to claim 1, wherein the performing optical flow propagation and image restoration processing on the first restored sampling frame sequence, the first remaining frame sequence, and the first remaining mask sequence to obtain the first restored remaining frame sequence comprises: Performing gradient pixel conversion processing on the first residual frame sequence to obtain a first residual gradient frame sequence; Obtaining a first residual optical flow sequence according to the first residual frame sequence and the first sampling frame sequence; Performing optical flow filling processing on the mask area in the first residual optical flow sequence to obtain a first filled residual optical flow sequence; Optical flow propagation and image restoration are performed on the first remaining gradient frame sequence, the first filled remaining optical flow sequence, the first restored sampling frame sequence, and the first remaining mask sequence to obtain the first restored remaining frame sequence.
3. The method according to claim 2, wherein obtaining a first residual optical flow sequence according to the first residual frame sequence and the first sampling frame sequence comprises: determining a target remaining frame in the first remaining frame sequence; Determining a target forward frame and a target backward frame of the target residual frame from the first sampling frame sequence; Obtaining a forward optical flow map between the target forward frame and the target residual frame, and a backward optical flow map between the target backward frame and the target residual frame; The first residual optical flow sequence is determined according to the forward optical flow map and the backward optical flow map.
4. The method according to any one of claims 1 to 3, wherein the performing optical flow propagation and image restoration processing on the first sampling frame sequence and the first sampling mask sequence to obtain a first restored sampling frame sequence comprises: Performing optical flow propagation processing on the first sampling frame sequence and the first sampling mask sequence to obtain a first updated sampling gradient frame sequence and a first updated sampling mask sequence; Performing Poisson reconstruction processing on the first updated sampling gradient frame sequence and the first updated sampling mask sequence to obtain a first updated sampling frame sequence; Performing frame-by-frame image restoration processing on the first updated sampling frame sequence to obtain the first restored sampling frame sequence.
5. The method according to claim 4, wherein the performing optical flow propagation processing on the first sampling frame sequence and the first sampling mask sequence to obtain a first updated sampling gradient frame sequence and a first updated sampling mask sequence comprises: Performing optical flow estimation processing on the first sampling frame sequence to obtain a first sampling optical flow sequence; Performing gradient pixel conversion processing on the first sampling frame sequence to obtain a first sampling gradient frame sequence; Performing optical flow filling processing on the mask area in the first sampled optical flow sequence to obtain a first filled sampled optical flow sequence; Optical flow propagation processing is performed on the first sampled gradient frame sequence and the first sampled mask sequence according to the first filled sampled optical flow sequence to obtain the first updated sampled gradient frame sequence and the first updated sampled mask sequence.
6. The method according to any one of claims 1 to 3, wherein obtaining a first target frame sequence and a first target mask sequence of a video to be processed comprises: Acquire a first frame sequence of the video to be processed and a first mask sequence corresponding thereto; If the proportion of the mask area in the first mask sequence is less than the proportion threshold, determining a target mask according to the first mask sequence, the mask area of the target mask covering the mask area of the first mask sequence; The first frame sequence and the first mask sequence are respectively cropped according to the target mask to obtain the first target frame sequence and the first target mask sequence.
7. The method according to claim 6, wherein the first frame sequence and the first mask sequence are respectively cropped according to the target mask to obtain the first target frame sequence and the first target mask sequence, comprising: According to the length and width of the mask area of the target mask, obtaining the number of outwardly extended pixels of the mask area of the target mask; Obtaining a clipping boundary of the mask area of the target mask according to the length and width of the mask area of the target mask and the number of outwardly extended pixels; Obtaining a cropping region including the mask region of the target mask according to a cropping boundary of the mask region of the target mask and a length and a width of the mask region of the target mask; According to the cropping area, the first frame sequence and the first mask sequence are cropped respectively to obtain the first target frame sequence and the first target mask sequence.
8. The method according to any one of claims 1 to 3, wherein obtaining a first target frame sequence and a first target mask sequence of a video to be processed comprises: Acquire a first frame sequence of the video to be processed and a first mask sequence corresponding thereto; If the proportion of the mask area in the first mask sequence is greater than or equal to a proportion threshold, scaling processing is performed on the first frame sequence and the first mask sequence respectively to obtain the first target frame sequence and the first target mask sequence.
9. The method according to any one of claims 1 to 3, wherein obtaining a first target frame sequence and a first target mask sequence of a video to be processed comprises: Obtaining a complete frame sequence of the video to be processed and a corresponding complete mask sequence; Performing shot segmentation processing on the complete frame sequence and the complete mask sequence respectively to obtain a single-shot frame sequence and a corresponding single-shot mask sequence; If the single-shot frame sequence and the corresponding single-shot mask sequence exceed the duration threshold, segmenting the single-shot frame sequence and the corresponding single-shot mask sequence to obtain a segmented frame sequence and a corresponding segmented mask sequence, wherein the segmented frame sequence includes a first frame sequence, and the segmented mask sequence includes a first mask sequence; The first target frame sequence and the first target mask sequence are obtained according to the first frame sequence and the first mask sequence corresponding thereto.
10. The method of claim 9, wherein the segmented frame sequence further comprises a second frame sequence, and the segmented mask sequence further comprises a second mask sequence; in, The merging process of the first repaired sampling frame sequence and the first repaired remaining frame sequence to obtain the repaired video of the video to be processed includes: Inserting the tail frames of the first repaired sampling frame sequence and the first repaired remaining frame sequence into the second frame sequence and the second mask sequence respectively as the first frames of the second frame sequence and the second mask sequence; Processing the second frame sequence and the second mask sequence to obtain a second repaired sampling frame sequence and a second repaired remaining frame sequence; The first repaired sampling frame sequence and the first repaired remaining frame sequence, the second repaired sampling frame sequence and the second repaired remaining frame sequence are merged to obtain the repaired video.
11. A video processing device, comprising: An acquisition module, used to acquire a first target frame sequence and a first target mask sequence of a video to be processed; A frame extraction module, used for performing frame extraction processing on the first target frame sequence and the first target mask sequence respectively, to obtain a first sampling frame sequence and a first remaining frame sequence thereof, and a first sampling mask sequence and a first remaining mask sequence thereof; The acquisition module is further used to perform optical flow propagation and image restoration processing on the first sampling frame sequence and the first sampling mask sequence to obtain a first restored sampling frame sequence; The acquisition module is further used to perform optical flow propagation and image restoration processing on the first restored sampling frame sequence, the first remaining frame sequence and the first remaining mask sequence to obtain a first restored remaining frame sequence; The acquisition module is further used to merge the first repaired sampling frame sequence and the first repaired remaining frame sequence to obtain the repaired video of the video to be processed.
12. A computer device comprising a processor, a memory, and an input and output interface; The processor is connected to the memory and the input / output interface respectively, wherein: The input and output interface is used to receive data and output data, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the video processing method according to any one of claims 1 to 10.
13. A computer-readable storage medium storing a computer program, wherein the computer program is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the video processing method according to any one of claims 1 to 10.
14. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the video processing method according to any one of claims 1 to 10 is implemented.
