Video processing method, device, electronic device and storage medium

Calculate the sampling offset through the optical flow map and offset information of the video frame, blur the video, and fuse the post-frame and the original frame, which solves the problem that the existing technology cannot reflect the dynamics of sports videos and realizes the dynamics of the video. A combination of enhancement and clarity.

CN117593211BActive Publication Date: 2024-09-24SHUXING TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311734397.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-15
Publication Date
2024-09-24
Estimated Expiration
2043-12-15

AI Technical Summary

Technical Problem

Existing video blur processing technology cannot effectively reflect the dynamics of sports videos with a strong sense of speed, and cannot enhance the dynamic visual experience of videos while maintaining picture clarity.

Method used

By obtaining the optical flow map and offset information of the video frame, the sampling offset required for the motion blur effect is calculated, the video frame is sampled, and the blurred frame and the original frame are fused to ensure that the main object is clear and the background area has motion. Blur effect to enhance the motion of the video.

Benefits of technology

It achieves enhanced video dynamics while maintaining video clarity, improves the dynamic visual experience, and solves the problem that video blur processing cannot reflect motion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117593211B
    Figure CN117593211B
Patent Text Reader

Abstract

The present application provides a video processing method, device, electronic device and storage medium, which obtains the optical flow map of the target video frame in the video to be processed, and the offset information corresponding to the optical flow map of each video frame in the video to be processed; determines the sampling offset required for the target video frame to have a motion blur effect according to the optical flow map of the target video frame and the offset information corresponding to the video to be processed; samples the target video frame according to the sampling offset to obtain a blurred target video frame; fuses the blurred target video frame with the target video frame to obtain a target special effect video frame with a clear main object and a motion blur effect in the background area. The target video frame is blurred and the sense of motion is enhanced at the same time, and the blur processing is performed based on the pixel dimension at the same time, so as to ensure the accuracy of the blur processing and the precision of the dynamic effect enhancement, and enhance the dynamic visual experience of the video.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of video image processing, and in particular to a video processing method, device, electronic device and storage medium. Background Art

[0002] With the development of video processing, the types of video processing are gradually diversified. Among them, video blur is generally achieved by blurring the video screen. In related technologies, the video screen is generally blurred as a whole, which is unable to perform motion enhancement for sports videos with a strong sense of speed (skateboard, skiing, surfing, football, cycling, etc.), and is unable to reflect the dynamic sense of such videos for users. Summary of the invention

[0003] The present application provides a video processing method, device, electronic device and storage medium, aiming to solve the technical problem in the related art that video blur processing cannot reflect the dynamic effect of the video picture.

[0004] In a first aspect, the present application provides a video processing method, comprising:

[0005] Obtaining an optical flow map of a target video frame in a to-be-processed video, and offset information corresponding to the optical flow map of each video frame in the to-be-processed video;

[0006] Determining, according to the optical flow graph of the target video frame and the offset information corresponding to the video to be processed, a sampling offset required for the target video frame to have a motion blur effect;

[0007] Sampling the target video frame according to the sampling offset to obtain a blurred target video frame;

[0008] The blurred target video frame and the target video frame are fused to obtain a target special effect video frame in which the main object is clear and the background area has a motion blur effect.

[0009] In a possible implementation of the present application, the fusion of the blurred target video frame and the target video frame to obtain a target special effect video frame with a clear main object and a background area having a motion blur effect includes:

[0010] Identify a foreground area of ​​a main object in the target video frame, and generate a first mask image corresponding to the foreground area;

[0011] Performing dilation processing on the first mask image to obtain a second mask image;

[0012] The target video frame and the blurred target video frame are fused according to the second mask image to obtain a target special effect video frame with a clear main object and a background area having a motion blur effect.

[0013] In a possible implementation of the present application, the step of obtaining an optical flow map of a target video frame in a video to be processed includes:

[0014] Acquire a target pixel in the target video frame and a reference pixel corresponding to the target pixel in a reference video frame in the video to be processed;

[0015] Determining the offset direction of the target pixel according to a directional gradient histogram of a target area corresponding to the target pixel in the target video frame;

[0016] Obtaining an offset strength of the target pixel according to a pixel brightness difference between the target pixel and the reference pixel;

[0017] An optical flow map is generated according to the shift intensity and the shift direction of each of the target pixels in the target video frame.

[0018] In a possible implementation of the present application, the step of obtaining the offset information corresponding to the optical flow map of each video frame in the video to be processed includes:

[0019] Obtaining the maximum offset vector of each optical flow map corresponding to the video to be processed;

[0020] The obtained offset vectors are set as the offset information of the optical flow map of the target video frame.

[0021] In a possible implementation of the present application, determining the sampling offset required for the target video frame to have a motion blur effect according to the optical flow map of the target video frame and the offset information corresponding to the video to be processed includes:

[0022] Calculating an offset strength difference between a maximum offset strength and a minimum offset strength in the offset information;

[0023] The offset intensities and offset directions in the optical flow map are adjusted according to the offset intensity difference and the maximum offset intensity to obtain a sampling offset of the target video frame.

[0024] In a possible implementation of the present application, adjusting each offset strength and each offset direction in the optical flow map according to the offset strength difference and the maximum offset strength to obtain the sampling offset of the target video frame includes:

[0025] Performing texture mapping on the pixel coordinates of the optical flow map to obtain optical flow texture information corresponding to each of the optical flow maps;

[0026] Sampling the optical flow map according to the optical flow texture information by a graphics processor to obtain an offset direction and an offset strength corresponding to each pixel in the optical flow map;

[0027] The product of the offset intensity difference, the offset direction and the offset intensity is calculated, and the product and the maximum offset intensity are fused to obtain a sampling offset.

[0028] In a possible implementation of the present application, sampling the target video frame according to the sampling offset to obtain a blurred target video frame includes:

[0029] Sorting the offset intensities in the optical flow map;

[0030] Calculating an offset intensity average of a preset number of target offset intensities in the sorted offset intensity sequence, and correcting the sampling offset according to the offset intensity average;

[0031] Determining the number of iterations according to the offset intensity difference between the maximum offset intensity and the minimum offset intensity in the optical flow map;

[0032] Sampling the target video frame according to the corrected sampling offset to obtain a blurred first video frame;

[0033] The first video frame is sampled according to the sampling offset until the number of sampling times reaches the number of iterations, thereby obtaining a blurred target video frame.

[0034] In a second aspect, the present solution further provides a video processing device, the video processing device comprising:

[0035] An acquisition module is used to acquire an optical flow map of a target video frame in a video to be processed, and offset information corresponding to the optical flow map of each video frame in the video to be processed;

[0036] An offset determination module, used to determine a sampling offset required for the target video frame to have a motion blur effect according to the optical flow map of the target video frame and the offset information corresponding to the video to be processed;

[0037] A blur processing module samples the target video frame according to the sampling offset to obtain a blurred target video frame;

[0038] A fusion module is used to fuse the blurred target video frame with the target video frame to obtain a target special effect video frame with a clear main object and a background area having a motion blur effect.

[0039] In a third aspect, the present application provides an electronic device, the electronic device comprising:

[0040] One or more processors, wherein the processors include a central processing unit and / or a graphics processing unit;

[0041] Memory; and

[0042] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the steps in any one of the video processing methods.

[0043] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is loaded by a processor to execute the steps in any one of the video processing methods described above.

[0044] The present application provides a video processing method, device, electronic device and storage medium, which obtain an optical flow map of a target video frame in a video to be processed, and offset information corresponding to the optical flow map of each video frame in the video to be processed; determine a sampling offset required for the target video frame to have a motion blur effect according to the optical flow map of the target video frame and the offset information corresponding to the video to be processed; sample the target video frame according to the sampling offset to obtain a blurred target video frame; and fuse the blurred target video frame with the target video frame to obtain a target special effect video frame with a clear main object and a motion blur effect in the background area. In this scheme, the optical flow of the target video frame corresponding to the reference video frame is analyzed by combining the target video frame to be processed and the change information of each pixel before the reference video frame, and the sampling offset is determined by combining the optical flow and the offset corresponding to the optical flow, that is, the sampling offset containing the optical flow characteristics of the target video frame and the corresponding offset characteristics is obtained, and sampling blur is further performed according to the sampling offset to obtain the target video frame, that is, the optical flow information and the offset information of the target video frame are combined with the blurred sampling process, so that the video frame after blurred sampling contains the motion information of the target video frame, which solves the problem that the video blur processing cannot reflect the dynamic sense of the video picture, and realizes the dynamic enhancement while blurring the target video frame. At the same time, the blur processing is performed based on the pixel dimension to ensure the accuracy of the blur processing and the precision of the dynamic effect enhancement, thereby enhancing the dynamic visual experience effect of the video. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0046] Figure 1 is a scene schematic diagram of the video processing method provided in an embodiment of the present application;

[0047] Figure 2is a schematic diagram of an embodiment of a video processing method provided in an embodiment of the present application;

[0048] Figure 3 A schematic diagram of a flow chart of one implementation scheme for blurring a target video frame in a video processing method provided in an embodiment of the present application;

[0049] Figure 4 A schematic diagram of a flow chart of one implementation scheme for generating an optical flow map in a video processing method provided in an embodiment of the present application;

[0050] Figure 5 A schematic diagram of a flow chart of one implementation scheme for determining a sampling offset in a video processing method provided in an embodiment of the present application;

[0051] Figure 6 A schematic diagram of a flow chart of one implementation scheme for determining a sampling offset in a video processing method provided in an embodiment of the present application;

[0052] Figure 7 A reference schematic diagram of a blurred target video frame provided in the video processing method provided in an embodiment of the present application;

[0053] Figure 8 is a schematic diagram of the structure of an embodiment of a video processing device provided in an embodiment of the present application;

[0054] Fig. 9 It is a schematic diagram of the structure of an embodiment of an electronic device provided in the embodiments of the present application. DETAILED DESCRIPTION

[0055] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0056] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, which are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first" and "second" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.

[0057] In the embodiment of the present application, "and / or" describes the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / ", unless otherwise specified, generally indicates that the associated objects before and after are in an "or" relationship.

[0058] In this application, the word "exemplary" is used to mean "serving as an example, illustration, or illustration." Any embodiment described in this application as "exemplary" is not necessarily to be construed as being preferred or advantageous over other embodiments. The following description is given to enable any person skilled in the art to implement and use the invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the invention can be implemented without using these specific details. In other instances, well-known structures and processes are not elaborated in detail to avoid obscuring the description of the invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in this application.

[0059] The embodiments of the present application provide a video processing method, apparatus, device, and computer-readable storage medium, which are described in detail below.

[0060] The video processing method in the embodiment of the present invention is applied to a video processing device, and the video processing device is arranged in an electronic device. The electronic device is provided with one or more processors, a memory, and one or more applications. It can be understood that the processor may include a central processing unit and / or a graphics processor, wherein one or more applications are stored in the memory and configured to be executed by the processor to implement the video processing method; the electronic device can be a terminal, for example, a mobile phone or a tablet computer, and the electronic device can also be a server, or a service cluster consisting of multiple servers.

[0061] like Figure 1 As shown, Figure 1 This is a scenario diagram of the video processing method in an embodiment of the present application. The video processing scenario in the embodiment of the present invention includes an electronic device 100 (a video processing device is integrated in the electronic device 100), and a computer-readable storage medium corresponding to the video processing runs in the electronic device 100 to execute the steps of video processing.

[0062] Understandably, Figure 1 The electronic devices in the scenario of the video processing method shown, or the devices included in the electronic devices, do not constitute limitations on the embodiments of the present invention, that is, the number of devices and types of devices included in the scenario of the video processing method, or the number of devices and types of devices included in each device, do not affect the overall implementation of the technical solution in the embodiments of the present invention, and can all be regarded as equivalent replacements or derivatives of the technical solution claimed to be protected in the embodiments of the present invention.

[0063] The electronic device 100 in the embodiment of the present invention is mainly used to: obtain an optical flow map of a target video frame in a video to be processed, and offset information corresponding to the optical flow map of each video frame in the video to be processed; determine a sampling offset required for the target video frame to have a motion blur effect according to the optical flow map of the target video frame and the offset information corresponding to the video to be processed; sample the target video frame according to the sampling offset to obtain a blurred target video frame; and fuse the blurred target video frame with the target video frame to obtain a target special effect video frame in which the main object is clear and the background area has a motion blur effect.

[0064] In the embodiment of the present invention, the electronic device 100 may be an independent electronic device, or an electronic device network or electronic device cluster composed of electronic devices. For example, the electronic device 100 described in the embodiment of the present invention includes but is not limited to a computer, a network host, a single network electronic device, a set of multiple network electronic devices, or a cloud electronic device composed of multiple electronic devices. The cloud electronic device is composed of a large number of computers or network electronic devices based on cloud computing.

[0065] Those skilled in the art will understand that Figure 1 The application environment shown in the figure is only one application scenario of the present application solution and does not constitute a limitation on the application scenario of the present application solution. Other application environments may also include Figure 1 More or fewer electronic devices shown in, or electronic device network connection relationships, such as Figure 1 Only one electronic device is shown. It can be understood that the scenario of the video processing method can also include one or more other electronic devices, which are not limited here. The electronic device 100 can also include a memory for storing data, for example, storing image information obtained by shooting.

[0066] In addition, in the scenario of the video processing method of the present application, the electronic device 100 may be provided with a display device, or the electronic device 100 may not be provided with a display device and may be communicated with an external display device 200, and the display device 200 is used to output the result of the execution of the video processing method in the electronic device. The electronic device 100 may access a background database 300 (the background database may be in the local memory of the electronic device, or the background database may also be set in the cloud), and the background database 300 may store information related to video processing, for example, an initial image in the background database 300, or pre-set filtering parameters.

[0067] It should be noted that Figure 1 The scene diagram of the video processing method shown is only an example. The scene of the video processing method described in the embodiment of the present invention is to more clearly illustrate the technical solution of the embodiment of the present invention, and does not constitute a limitation on the technical solution provided by the embodiment of the present invention.

[0068] Based on the scenario of the above video processing method, an embodiment of the video processing method is proposed.

[0069] like Figure 2 FIG. 2 is a flow chart of an embodiment of a video processing method in an embodiment of the present application. The video processing method includes steps S201-S204:

[0070] S201, obtaining an optical flow map of a target video frame in a to-be-processed video, and offset information corresponding to the optical flow map of each video frame in the to-be-processed video.

[0071] Among them, the target video frame, that is, any video frame in the video to be blurred, it can be understood that a video to be processed can be decoded to obtain a video frame sequence, a video frame sequence includes multiple video frames corresponding to the video, and the target video frame is any one of the video frame sequence.

[0072] Among them, the optical flow map, that is, an image used to characterize the optical flow of the target video frame corresponding to the reference video frame, that is, the optical flow map is a form of visual expression of the optical flow of the target video frame corresponding to the reference video frame. The optical flow map can be visualized as an optical flow map by encoding the calculated optical flow corresponding to the target video frame. It can be understood that the optical flow includes an offset intensity and an offset direction, which characterizes the offset intensity of the user in a certain direction. Exemplarily, the offset intensity can be instantaneous speed, brightness difference, etc. The optical flow map can be in the form of JPG, PNG and other formats, which are not specifically limited in this application.

[0073] Among them, the offset information, that is, the offset strength corresponding to the optical flow map, specifically, the offset information can be at least one offset strength in the optical flow map corresponding to the target video frame, such as the maximum offset strength, or the maximum offset strength and the minimum offset strength, or the mean offset strength, etc.; in another implementation scheme, the offset information can also be at least one offset strength in the optical flow map corresponding to each video frame in the video frame sequence corresponding to the target video frame, which is not specifically limited in this application.

[0074] Specifically, in one embodiment of the present application, the video processing method is applied to an electronic device, which may be a mobile phone or a computer, etc. A display device is provided on the electronic device for providing a user with an operation page for video or image processing, and the operation page has a database access port. When the user clicks on the data access port in the operation page, the user's image / video database is accessed and the images and video materials in the image / video database are displayed on the premise of obtaining the user's data access rights, the user's operation information based on the displayed image / video material is received to determine the video to be processed, and the video file of the video is obtained, a video frame sequence is obtained by reading the target video file and then decoding it frame by frame, and each video frame in the video frame is set as a target video frame to be processed, and a corresponding reference video is determined, and then each target video frame is further blurred, and a blurred video is generated according to the blurred target video frame.

[0075] S202: Determine a sampling offset required for the target video frame to have a motion blur effect according to the optical flow graph of the target video frame and the offset information corresponding to the video to be processed.

[0076] Among them, the sampling offset, that is, the coordinate offset of the texture sampling coordinates when blurring the target video frame, it can be understood that, in the implementation scheme of the present application, the blurring of the target video frame is achieved by resampling the target video frame, and this scheme combines the optical flow and the offset to determine the offset degree of the sampling coordinates in the blurring, that is, the optical flow information is integrated to perform sampling blurring to achieve motion enhanced blurring effect.

[0077] Exemplarily, in one of the embodiments of the present application, after determining the optical flow map, the electronic device extracts the maximum offset intensity in the optical flow map corresponding to all video frames (including the target video frame) in the video frame sequence corresponding to the target video frame as the offset information corresponding to each optical flow map. It can be understood that the offset information represents the overall offset intensity information of the video.

[0078] Specifically, the specific implementation scheme for determining the sampling offset according to the optical flow map and the offset information corresponding to the optical flow map is not specifically limited in this application, but is exemplary:

[0079] In one embodiment of the present application, the offset information corresponding to the optical flow information includes an offset strength. Then, for each pixel in the optical flow map, the optical flow corresponding to the pixel can be extracted, and a preset mapping table corresponding to the optical flow and the offset can be searched to obtain the optical flow corresponding to the pixel and the sampling offset corresponding to the offset strength.

[0080] In another embodiment of the present application, the offset information corresponding to the optical flow information includes multiple offset strengths. The offset strength is filtered out from the offset information according to a preset offset strength filtering rule. Further, the sampling offset is determined according to the filtered offset strength and the optical flow corresponding to each pixel in the optical flow map. It can be understood that the offset strength filtering rule can be to find the maximum value and / or the minimum value, or to find the mean, or to calculate the variance value, standard deviation value, etc., which is not specifically limited in the present application.

[0081] S203: Sample the target video frame according to the sampling offset to obtain a blurred target video frame.

[0082] Specifically, in one implementation scheme of the present application, after obtaining the sampling offset, the target sampling coordinates are determined by the texture sampling coordinates corresponding to the target video frame and the sampling coordinate offset, and the target video frame is further texture sampled according to the sampling table, and a blurred target video frame is obtained after sampling; the blurred target video frame presents a blurred effect after motion enhancement.

[0083] In one of the implementation schemes of the present application, the target video frame is blurred by visualizing the optical flow as an optical flow map, and image processing is performed on the optical flow map and the target video frame through a graphics processing unit (GPU). Since the execution efficiency is higher in the GPU, the efficiency can be greatly improved, and the optical flow information can be analyzed at the pixel level to blur the target video frame while enhancing the sense of motion. At the same time, the blurring is performed based on the pixel dimension to ensure the accuracy of the blurring and the precision of the dynamic effect enhancement, thereby enhancing the dynamic visual experience of the video.

[0084] Exemplarily, after determining the sampling offset, the original sampling UV (texture mapping coordinates) corresponding to the target video frame is adjusted according to the sampling offset, and the target video frame is sampled according to the adjusted UV to obtain a blurred target video frame.

[0085] S204: Fusing the blurred target video frame with the target video frame to obtain a target special effect video frame in which the main object is clear and the background area has a motion blur effect.

[0086] Further, it can be understood that the main object in the blurred target video frame is blurred. At this time, the blurred target video frame and the target video frame before blurring are fused to blur the area other than the main object in the blurred target video frame. Exemplarily, the main object in the target video frame before blurring can be identified, and the image area corresponding to the main object can be extracted, and the image area corresponding to the main object can be fused into the blurred target video frame to obtain a target special effects video frame in which the main object is clear and the background area has a motion blur effect.

[0087] Further, based on the above implementation scheme, see Figure 3 , Figure 3 A schematic flow chart of one implementation scheme for determining a target special effect video frame in a video processing method provided in an embodiment of the present application, specifically comprising steps S301-S303:

[0088] S301, identifying a foreground area of ​​a main object in the target video frame, and generating a first mask image corresponding to the foreground area.

[0089] The main object, that is, the object that is not blurred in the video blur processing, can be, for example, a person, an animal, or the like.

[0090] Exemplarily, in some application scenarios of the present application, the target video is the user's skating video, that is, the main object is a portrait, and the portrait recognition can be performed on the target video frame by using a portrait recognition method to identify the portrait area in the target video frame. Furthermore, the portrait area corresponding to the target video frame is marked, that is, the area of ​​the target video frame except the mark is the background area. For example, the ID of the portrait area is set to 0; so that when the target image frame is subsequently processed, the background area and the area corresponding to the target object are determined to generate a first mask map; the mask corresponding to the main object is obtained according to the ID. This method is equivalent to controlling at the algorithm layer, recording the "main object" of the first frame in the video frame sequence and tracking the main object all the time, and outputting the mask of the main object.

[0091] In some other embodiments of the present application, the generation of the first mask map can also be achieved by the size of the mask area. For example, each object in the target image frame is identified, and a mask map mask of each object is generated; and the main object is determined according to the size of each mask, specifically:

[0092] a. Identify the objects containing the moving device in the target image frame, and return a mask containing the moving device according to a preset mask algorithm;

[0093] b. Get the contour points of the mask. Use opencv (OpenCV stands for Open Source Computer Vision Library, a cross-platform computer vision library), input the parameters related to the mask, and use the findContours interface (users search for image contours) to get the contour points of the mask, denseContours (indicating that the contour is dense).

[0094] c. The previous step will get the contour points of all masks and store them in multiple arrays. The size of the mask can be obtained through the array length (the array length is equivalent to the perimeter of the mask). This step is compared. The mask with the longest array length is determined as the "main object". Only the mask of the main object (the first mask image) is retained, and other masks are used as background blur. The "main object" mask is passed to the shader for the later generation of the blurred target video frame.

[0095] It is understandable that the above methods of identifying the subject object and generating the first mask map are both possible, each with its own advantages and disadvantages. The ID tag detection mask of each frame can ensure that the person and his sports equipment that account for the largest proportion of the frame are obtained, but the disadvantage is that it depends on the shooting angle of the video, and there may be a situation where the subject object of the person switches. Another method can ensure that the subject object person is always the same person, but if the person moves out of the picture, there is no subject object protection at the moment; you can choose according to actual needs.

[0096] S302: Perform dilation processing on the first mask image to obtain a second mask image.

[0097] It is understandable that in some implementation scenarios of the present application, the amount of picture information may be large. After obtaining the first mask image mask, that is, the mask obtained is the mask of the main object (the part that is not blurred), it is usually limited by precision issues. The mask shape cannot be 100% aligned with the actual display range of the main object. Therefore, in order to ensure the accuracy of the blurring processing, the first mask image mask is further expanded.

[0098] Specifically, in one implementation scheme of the present application, the first mask map mask is expanded by an image processor GPU; by filtering the input mask and calculating the mask value, the mask value is compared with the preset mask value. When the mask value is greater than the preset mask value, the point is determined to be the area where the mask is located, that is, the pixel points are further divided into mask areas to achieve mask expansion and obtain a second mask map.

[0099] Exemplarily, according to the size relationship between the preset mask value and the mask value of each pixel in the first mask image, the foreground area is expanded to obtain the second mask image. The mask expansion specifically includes the steps of:

[0100] a. Determine the step size: adjust the variable value of the step size / the width (height) of the image, wherein the width of the image, i.e., the width of the target image frame, and the variable value, i.e., the preset general value;

[0101] b. determining the surrounding pixels of any pixel in the first mask image according to the step size, and sampling the alpha values ​​of the surrounding pixels to obtain the alpha value of the pixel and the surrounding pixels corresponding to the pixel;

[0102] c. Then filter the sampling result to obtain the filtered alpha value; the filtering is achieved by converting the input value to the [0,1] interval through a linear transformation, that is, subtracting the background threshold from the input value, and then dividing it by the difference between the foreground threshold and the background threshold, and the final result is restricted to the [0,1] interval.

[0103] The filtering is implemented based on the clamp() function. The function of the clamp() function is to clamp a value between an upper limit and a lower limit. When the value exceeds the range of the minimum and maximum values, a value between the minimum and maximum values ​​is selected for use. For the function, see:

[0104] clamp((v-BG_THRESHOLD) / (FG_THRESHOLD-BG_THRESHOLD),0.0,1.0);

[0105] Among them, v is the alpha value of the sampled pixel, the BG_THRESHOLD is the alpha value of each pixel in the background area, and FG_THRESHOLD is the alpha value of each pixel in the mask area.

[0106] d. Compare the filtered alpha values ​​of the surrounding pixels and calculate two mask values ​​mask1 and tmask. Mask1 is the difference between the maximum filtered alpha value of the surrounding pixels and the filtered alpha value of the current pixel, while tMask is the difference between the filtered alpha value of the current pixel and the minimum filtered alpha value.

[0107] e. According to the result of the previous step, determine the expanded mask area.

[0108] S303: Fusing the target video frame and the blurred target video frame according to the second mask image to obtain a target special effect video frame in which the main object is clear and the background area has a motion blur effect.

[0109] Furthermore, the second mask image is fused with the blurred target video frame to generate a blurred target video frame, so that the background area other than the main object in the target video frame is only in a motion-enhanced blurred state, that is, the main object is clear and the background environment is dynamically blurred.

[0110] Further, based on the above implementation scheme, see Figure 4 , Figure 4 A schematic flow chart of one implementation scheme for obtaining an optical flow map in a video processing method provided in an embodiment of the present application, specifically including steps S401-S404:

[0111] S401, obtaining a target pixel in the target video frame and a reference pixel corresponding to the target pixel in a reference video frame in the video to be processed.

[0112] It can be further understood that the reference video frame is also at least one corresponding to the target video in the video frame sequence. Exemplarily, the reference video frame is the next video frame corresponding to the target video frame in the video frame sequence, or the reference video frame is the second video frame corresponding to the target video frame in the video frame sequence, or the reference video frame is the previous video frame corresponding to the target video frame in the video frame sequence. This application does not make any specific limitation.

[0113] Exemplarily, in one embodiment of the present application, when the target video frame is the first video frame in the video frame sequence, the reference video frame is the subsequent video frame of the target video frame in the video frame sequence, that is, the reference video frame is the second video frame in the video frame sequence; when the target video frame is the second video frame in the video frame sequence, the reference video frame is the third video frame in the video frame sequence…, and so on. When the target video frame is the last video frame in the video frame sequence, the reference video frame may be the derivative second video frame in the video frame sequence.

[0114] The target pixel, that is, any pixel in the target video frame, may include one or more target pixels.

[0115] The reference pixel is a pixel in the reference video frame that is identical to the target pixel.

[0116] Exemplarily, in one of the embodiments of the present application, the technical solution of the present application obtains the target pixel and the reference pixel by performing a similarity matching search on the target pixel and the descriptor in the target video frame and the descriptor of each pixel in the reference video frame.

[0117] S402: Determine the offset direction of the target pixel according to a directional gradient histogram of a target area corresponding to the target pixel in the target video frame.

[0118] Among them, the Histogram of Oriented Gradient (HOG) feature is a feature descriptor used for object detection in computer vision and image processing. It constructs features by calculating and counting the gradient directional histogram of the local area of ​​the image.

[0119] Specifically, in another embodiment of the present application, the implementation method of determining the target pixel and the reference pixel specifically includes:

[0120] a. For the target video frame and the reference video frame, Gaussian pyramids are constructed respectively. By applying a series of Gaussian blurs, the image is downsampled at multiple levels to obtain pyramid layers at different scales and spatial positions for the target video frame and the reference video frame respectively.

[0121] b. Detect key points: Find stable key points by comparing the difference between a pixel and its surrounding neighborhood at different scales and spatial positions.

[0122] c. Calculate the direction of the key point: In the image area around the key point, calculate the gradient direction histogram and select the main direction as the direction of the key point, that is, determine the offset direction of the target pixel.

[0123] d. Describe key points: Convert the pixels around the key points into feature vectors with scale and rotation changes.

[0124] 3) Corresponding point matching: By comparing the feature vectors between two adjacent frames, we can find the pixel pairs with corresponding relationships, that is, find the reference pixels and the target pixels.

[0125] S403: Obtain an offset strength of the target pixel according to a pixel brightness difference between the target pixel and the reference pixel.

[0126] Among them, after determining the target pixel and the reference pixel, the pixel brightness difference between the target pixel and the reference pixel can be calculated, and the pixel brightness difference can be set as the offset strength of the target pixel. It can be understood that the target pixel can be each pixel in the target video frame, that is, using the corresponding pixel point pairs, the displacement vector of each pixel in the target video frame can be calculated, that is, the optical flow vector, which can also be referred to as optical flow. The optical flow includes an offset strength and an offset direction, which represents the motion information between the two frames.

[0127] S404: Generate an optical flow map according to the shift intensity and the shift direction of each of the target pixels in the target video frame.

[0128] Further, after obtaining the optical flow of each pixel in the target video frame, the optical flow is visualized to generate an optical flow map. Exemplarily, in one embodiment of the present application, the optical flow map is visualized, that is, the optical flow vector calculated for each frame is visualized as a jpg optical flow map. The reason for using jpg is to reduce the amount of image data and store optical flow information. It is smaller than png. This paper uses color coding for visualization.

[0129] Further, based on the above implementation scheme, in one implementation scheme of the present application, before determining the sampling offset according to the optical flow map and the offset information corresponding to the optical flow map, the following steps are also included:

[0130] (1) determining the maximum offset vector corresponding to the optical flow map according to the magnitude relationship between the offset intensities in the optical flow map;

[0131] (2) obtaining the maximum offset vector of each optical flow map corresponding to the video to be processed;

[0132] (3) Setting each obtained offset vector as the offset information of the optical flow map of the target video frame.

[0133] Specifically, after generating an optical flow map according to the offset vector and the offset direction of each target pixel in the target video frame, the largest first offset vector in the optical flow map is extracted and stored in a descriptive file in txt format, and the descriptive file in txt format stores the second offset vector of the optical flow map corresponding to each video frame in the target video, the second offset vector, that is, the largest offset vector in the optical flow map corresponding to each video frame.

[0134] Specifically, in one implementation scheme of the present application, after obtaining the target video frame to be processed and the reference video frame of the target video frame, the electronic device searches for key point pairs between the target video frame and the reference video frame by searching for key point matches, and analyzes the change information between pixels based on the key point pairs, thereby determining the optical flow corresponding to each pixel, representing the motion information between the two frames, and further encoding the optical flow of each pixel corresponding to the pixel position of the target video frame to obtain an optical flow map corresponding to the target video frame.

[0135] Further, based on the above implementation scheme, see Figure 5 , Figure 5 A schematic flow chart of one implementation scheme for determining a sampling offset in a video processing method provided in an embodiment of the present application, specifically comprising steps S501-S502:

[0136] S501: Calculate the offset intensity difference between the maximum offset intensity and the minimum offset intensity in the optical flow map.

[0137] Specifically, in the implementation scheme of the present application, the offset information includes a preset offset strength and a first offset strength, the maximum offset strength max and the minimum offset strength min in the offset information are extracted, and the offset strength difference max-min between the maximum offset strength and the minimum offset strength is calculated, recorded as flowRange.

[0138] It can be understood that the offset intensity difference represents the overall offset change information of the target video including the target video frame. By combining the overall offset change information to perform blur processing, the accuracy of blur processing is improved.

[0139] S502: Adjust the offset intensities and the offset directions in the optical flow map according to the offset intensity difference and the maximum offset intensity to obtain a sampling offset of the target video frame.

[0140] Specifically, in one of the implementation schemes of the present application, each offset intensities and each offset direction in the optical flow map can be mapped and searched according to the offset intensity difference and the maximum offset intensity to obtain the sampling offset corresponding to the offset intensity difference and the maximum offset intensity for each offset intensities and each offset direction in the optical flow map.

[0141] In another embodiment of the present application, the sampling offset can be calculated by inputting the offset intensity difference, the maximum offset intensity, the offset intensities and the offset directions in the optical flow map into a preset calculation formula.

[0142] Exemplarily, based on the above implementation, the present application provides a specific implementation of determining a sampling offset, including the steps of:

[0143] (1) performing texture mapping on the pixel coordinates of the optical flow map to obtain optical flow texture information corresponding to each of the optical flow maps;

[0144] (2) sampling the optical flow map according to the optical flow texture information through a graphics processor to obtain an offset direction and an offset strength corresponding to each pixel in the optical flow map;

[0145] (3) The offset strength difference, the offset direction, the offset strength, and the maximum offset strength are input into a preset calculation formula to obtain the sampled offset strength.

[0146] Specifically, in the implementation scheme of the present application, after obtaining the optical flow map, that is, reading in the optical flow map information, constructing and generating a texture (optical flow texture information) corresponding to the optical flow map, that is, constructing and generating the optical flow texture information corresponding to the optical flow map; further passing the texture into the shader of the GPU, the GPU samples the optical flow map through the optical flow texture information, and obtains the optical flow stored in the channel corresponding to each pixel, that is, obtains the offset strength and offset direction corresponding to each pixel. Exemplarily, in the implementation scheme of the present application, the optical flow map is in JPG format, and the optical flow map includes three RGB channels, wherein the R channel is meaningless, and the BG channels respectively store the offset strength and offset direction in the optical flow. It can be understood that the present application does not make specific restrictions on what values ​​the three RGB channels in the technical scheme of the present application respectively store, that is, the B channel can also be meaningless, and the R channel stores the offset strength. Specifically, the present application does not make specific restrictions, and it can be set during encoding.

[0147] Furthermore, the offset intensity difference, the offset direction, the offset intensity and the maximum offset intensity are input into a preset calculation formula to obtain the sampling offset intensity. Specifically, the preset formula is described as: multiplying the bg channel by the offset intensity difference flowRange, and for each pixel, calculating the product of the offset intensity difference, the offset direction and the offset intensity. Further, calculating the product and adding the maximum offset intensity max, and then multiplying it by a preset coefficient to obtain the sampling offset flow, which is used to control the intensity of the blur effect, that is, calculating the product of the offset intensity difference, the offset direction and the offset intensity, and merging the product and the maximum offset intensity to obtain the sampling offset.

[0148] Further, based on the above implementation scheme, see Figure 6 , Figure 6 A schematic flow chart of one implementation scheme for determining a sampling offset in a video processing method provided in an embodiment of the present application, specifically comprising steps S601-S605:

[0149] S601: Sort the offset intensities in the optical flow map.

[0150] Specifically, the offset strength of each pixel in the optical flow map is extracted, and the offset strengths in the optical flow map are sorted.

[0151] S602, calculating an offset strength mean of a preset number of target offset strengths in the sorted offset strength sequence, and correcting the sampling offset according to the offset strength mean;

[0152] The preset number may be determined according to the number of pixels in the target video frame. Exemplarily, the preset number is 1 / 8 times the number of pixels in the target video frame.

[0153] Specifically, after sorting the offset intensities in the optical flow map, a preset number of target offset intensities with a higher ranking are extracted, and the offset intensity mean corresponding to the target offset intensities are calculated. It can be understood that in some other implementation schemes of the present application, a preset number of target offset intensities with a lower ranking can also be extracted, and the present application does not make specific limitations on this.

[0154] Specifically, after obtaining the target offset strength, the offset strength mean aspect corresponding to the target offset strength is calculated, and the sampling offset is corrected according to the offset strength mean aspect, that is, the product flow*aspect between the offset strength mean and the sampling offset flow is calculated.

[0155] S603: Determine the number of iterations according to the offset intensity difference between the maximum offset intensity and the minimum offset intensity in the optical flow map.

[0156] Specifically, in one of the embodiments of the present application, the offset intensity difference between the maximum offset intensity and the minimum offset intensity in the optical flow map is calculated as the number of iterations.

[0157] Specifically, in another embodiment of the present application, by calculating the offset intensity difference between the maximum offset intensity and the minimum offset intensity in the optical flow map, and the offset intensity difference between the maximum offset intensity and the minimum offset intensity in the optical flow map corresponding to each video frame of the target video frame, and obtaining the offset intensity difference corresponding to each optical flow map in the target video, the average value of all the offset intensity differences is calculated as the number of iterations. It can be understood that the selection of the number of iterations can be adaptively adjusted according to different actual scenarios.

[0158] S604: Perform sampling processing on the target video frame according to the corrected sampling offset to obtain a blurred target video frame.

[0159] Specifically, the sampling coordinates are calculated according to the corrected sampling offset flow*aspect, that is, the corrected sampling offset flow*aspect is input into the calculation formula: offset uv=uv+flow*aspect; wherein the offset uv is the sampling coordinate, and uv is the original sampling coordinate of each pixel in the target video frame. And the background area in the target video frame is texture sampled according to the offset uv after the offset, so as to obtain the blurred first video frame.

[0160] S605 . Perform sampling processing on the background area in the first video frame according to the sampling offset until the number of sampling times reaches the number of iterations, thereby obtaining a blurred target video frame.

[0161] Further, h. Based on the previously determined number of iterations, the GPU takes the last result (the first video frame) as input, repeats this step multiple times until the sampling number reaches the number of iterations, and mixes the blurred texture with the original image based on the mask, thereby obtaining a clear subject and a dynamic blurred background. The motion blur effect is formed by continuous polishing. Among them, the effect diagram after motion blur is shown in Figure 7 .

[0162] In this scheme, a blur effect that expresses the direction and intensity of movement is achieved through the optical flow map, which can approximately simulate the slow shutter effect; the optical flow map is stored in a jpg format image, with a small amount of data, reducing the pressure of data transmission; it has the function of identifying the main object; it can protect the main object area without adding a blur effect; the blur effect is realized in the GPU, which can greatly improve the efficiency compared to the opencv interface implementation in the CPU; the mask is expanded at the GPU stage to protect the integrity of the main object area.

[0163] In an embodiment of the present application, a video processing method is provided, which obtains an optical flow map of a target video frame in a video to be processed, and offset information corresponding to the optical flow map of each video frame in the video to be processed; determines a sampling offset required for the target video frame to have a motion blur effect according to the optical flow map of the target video frame and the offset information corresponding to the video to be processed; samples the target video frame according to the sampling offset to obtain a blurred target video frame; and fuses the blurred target video frame with the target video frame to obtain a target special effect video frame with a clear main object and a background area having a motion blur effect. In this scheme, the optical flow of the target video frame corresponding to the reference video frame is analyzed by combining the target video frame to be processed and the change information of each pixel before the reference video frame, and the sampling offset is determined by combining the optical flow and the offset corresponding to the optical flow, that is, the sampling offset containing the optical flow characteristics of the target video frame and the corresponding offset characteristics is obtained, and sampling blur is further performed according to the sampling offset to obtain the target video frame, that is, the optical flow information and the offset information of the target video frame are combined with the blurred sampling process, so that the video frame after blurred sampling contains the motion information of the target video frame, which solves the problem that the video blur processing cannot reflect the dynamic sense of the video picture, and realizes the dynamic enhancement while blurring the target video frame. At the same time, the blur processing is performed based on the pixel dimension to ensure the accuracy of the blur processing and the precision of the dynamic effect enhancement, thereby enhancing the dynamic visual experience effect of the video.

[0164] In order to better implement the video processing method in the embodiment of the present application, based on the video processing method, the embodiment of the present application also provides a video processing device, such as Figure 8 As shown, the video processing device includes modules 801-804:

[0165] An acquisition module 801 is used to acquire an optical flow map of a target video frame in a video to be processed, and offset information corresponding to the optical flow map of each video frame in the video to be processed;

[0166] An offset determination module 802 is used to determine a sampling offset required for the target video frame to have a motion blur effect according to the optical flow map of the target video frame and the offset information corresponding to the video to be processed;

[0167] A blur processing module 803 samples the target video frame according to the sampling offset to obtain a blurred target video frame;

[0168] The fusion module 804 is used to fuse the blurred target video frame with the target video frame to obtain a target special effect video frame with a clear main object and a background area having a motion blur effect.

[0169] In one embodiment of the present application, the fusion module 804 is used to fuse the blurred target video frame and the target video frame to obtain a target special effect video frame with a clear main object and a background area having a motion blur effect, specifically including:

[0170] Identify a foreground area of ​​a main object in the target video frame, and generate a first mask image corresponding to the foreground area;

[0171] Performing dilation processing on the first mask image to obtain a second mask image;

[0172] The target video frame and the blurred target video frame are fused according to the second mask image to obtain a target special effect video frame with a clear main object and a background area having a motion blur effect.

[0173] In one embodiment of the present application, the acquisition module 801 is used to acquire an optical flow map of a target video frame in a video to be processed, specifically including:

[0174] Acquire a target pixel in the target video frame and a reference pixel corresponding to the target pixel in a reference video frame in the video to be processed;

[0175] Determining the offset direction of the target pixel according to a directional gradient histogram of a target area corresponding to the target pixel in the target video frame;

[0176] Obtaining an offset strength of the target pixel according to a pixel brightness difference between the target pixel and the reference pixel;

[0177] An optical flow map is generated according to the shift intensity and the shift direction of each of the target pixels in the target video frame.

[0178] In one embodiment of the present application, the acquisition module 801 is used to obtain the offset information corresponding to the optical flow map of each video frame in the video to be processed, which specifically includes:

[0179] Obtaining the maximum offset vector of each optical flow map corresponding to the video to be processed;

[0180] The obtained offset vectors are set as the offset information of the optical flow map of the target video frame.

[0181] In one embodiment of the present application, the offset determination module 802 is used to determine the sampling offset required for the target video frame to have a motion blur effect according to the optical flow map of the target video frame and the offset information corresponding to the video to be processed, specifically including:

[0182] Calculating an offset strength difference between a maximum offset strength and a minimum offset strength in the offset information;

[0183] The offset intensities and offset directions in the optical flow map are adjusted according to the offset intensity difference and the maximum offset intensity to obtain a sampling offset of the target video frame.

[0184] In one embodiment of the present application, the offset determination module 802 is used to adjust each offset strength and each offset direction in the optical flow map according to the offset strength difference and the maximum offset strength to obtain the sampling offset of the target video frame, specifically including:

[0185] Performing texture mapping on the pixel coordinates of the optical flow map to obtain optical flow texture information corresponding to each of the optical flow maps;

[0186] Sampling the optical flow map according to the optical flow texture information by a graphics processor to obtain an offset direction and an offset strength corresponding to each pixel in the optical flow map;

[0187] The product of the offset intensity difference, the offset direction and the offset intensity is calculated, and the product and the maximum offset intensity are fused to obtain a sampling offset.

[0188] In one implementation of the present application, the blur processing module 803 samples the target video frame according to the sampling offset to obtain the blurred target video frame, specifically including:

[0189] Sorting the offset intensities in the optical flow map;

[0190] Calculating an offset intensity average of a preset number of target offset intensities in the sorted offset intensity sequence, and correcting the sampling offset according to the offset intensity average;

[0191] Determining the number of iterations according to the offset intensity difference between the maximum offset intensity and the minimum offset intensity in the optical flow map;

[0192] Sampling the target video frame according to the corrected sampling offset to obtain a blurred first video frame;

[0193] The first video frame is sampled according to the sampling offset until the number of sampling times reaches the number of iterations, thereby obtaining a blurred target video frame.

[0194] Based on the above implementation scheme, the embodiment of the present invention further provides an electronic device, such as Figure 8 As shown, Fig. 9 It is a schematic diagram of the structure of an embodiment of an electronic device provided in the embodiments of the present application.

[0195] Electronic equipment includes:

[0196] One or more processors, wherein the processors include a central processing unit and / or a graphics processing unit;

[0197] Memory; and

[0198] One or more applications, wherein the one or more applications are stored in a memory and are configured to execute, by a processor, the steps of the platform content recommendation method in any of the above platform content recommendation method embodiments.

[0199] Specifically, the electronic device may include one or more processors 1001 of processing cores, one or more computer-readable storage media memories 1002, a power supply 1003, an input unit 1004 and other components. Those skilled in the art will understand that Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0200] Processor 1001 is the content recommendation center of the platform. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in memory 1002, and calling data stored in memory 1002, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. It can be understood that processor 1001 transmits signals with the controller. Optionally, processor 1001 may include one or more processing cores; preferably, processor 1001 can integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application programs, etc., and the modem processor mainly processes wireless communications. It can be understood that the above-mentioned modem processor may not be integrated into processor 1001.

[0201] The memory 1002 can be used to store software programs and modules. The processor 1001 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002. The memory 1002 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 1002 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 1002 may also include a memory controller to provide the processor 1001 with access to the memory 1002.

[0202] In some embodiments of the present application, the platform content recommendation device can be implemented in the form of a computer program. The computer program can be used in Fig. 9 The memory of the electronic device may store various program modules constituting the platform content recommendation method device, for example, Figure 8 The obtained module 801, the offset determination module 802, the blur processing module 803, and the fusion module 804 are shown. The computer program composed of various program modules enables the processor to execute the steps of the platform content recommendation method of each embodiment of the present application described in this specification.

[0203] For example, Fig. 9 The electronic device shown can be Figure 8 The acquisition module 801 in the platform content recommendation method device shown executes step S201. The electronic device can execute step S202 through the offset determination module 802. The electronic device can execute step S203 through the fuzzy processing module 803. The electronic device can execute step S204 through the second fusion module 804. The electronic device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external electronic device through a network connection. When the computer program is executed by the processor, a platform content recommendation method is implemented.

[0204] The electronic device also includes a power supply 1003 for supplying power to each component. Preferably, the power supply 1003 can be logically connected to the processor 1001 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 1003 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0205] The electronic device may further include an input unit 1004, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0206] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 1001 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 1002 according to the following instructions, and the processor 1001 will run the application programs stored in the memory 1002, thereby realizing various functions, as follows:

[0207] Obtaining an optical flow map of a target video frame in a to-be-processed video, and offset information corresponding to the optical flow map of each video frame in the to-be-processed video;

[0208] Determining, according to the optical flow graph of the target video frame and the offset information corresponding to the video to be processed, a sampling offset required for the target video frame to have a motion blur effect;

[0209] Sampling the target video frame according to the sampling offset to obtain a blurred target video frame;

[0210] The blurred target video frame and the target video frame are fused to obtain a target special effect video frame in which the main object is clear and the background area has a motion blur effect.

[0211] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0212] To this end, an embodiment of the present invention provides a computer-readable storage medium (hereinafter referred to as a storage medium), which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any platform content recommendation method provided in an embodiment of the present invention. For example, the computer program may be loaded by a processor to execute the following steps:

[0213] Obtaining an optical flow map of a target video frame in a to-be-processed video, and offset information corresponding to the optical flow map of each video frame in the to-be-processed video;

[0214] Determining, according to the optical flow graph of the target video frame and the offset information corresponding to the video to be processed, a sampling offset required for the target video frame to have a motion blur effect;

[0215] Sampling the target video frame according to the sampling offset to obtain a blurred target video frame;

[0216] The blurred target video frame and the target video frame are fused to obtain a target special effect video frame in which the main object is clear and the background area has a motion blur effect.

[0217] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the detailed description of other embodiments above, and will not be repeated here.

[0218] In specific implementation, the above units or structures can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units or structures can refer to the previous method embodiments, which will not be repeated here.

[0219] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0220] The above is a detailed introduction to a video processing method, device, electronic device and storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A video processing method, characterized in that: include: Obtaining an optical flow map of a target video frame in a to-be-processed video, and offset information corresponding to the optical flow map of each video frame in the to-be-processed video; Determining, according to the optical flow graph of the target video frame and the offset information corresponding to the video to be processed, a sampling offset required for the target video frame to have a motion blur effect; Sampling the target video frame according to the sampling offset to obtain a blurred target video frame; The blurred target video frame and the target video frame are merged to obtain a target special effect video frame in which the main object is clear and the background area has a motion blur effect; The step of obtaining an optical flow graph of a target video frame in a video to be processed includes: Acquire a target pixel in the target video frame and a reference pixel corresponding to the target pixel in a reference video frame in the video to be processed; Determining the offset direction of the target pixel according to a directional gradient histogram of a target area corresponding to the target pixel in the target video frame; Obtaining an offset strength of the target pixel according to a pixel brightness difference between the target pixel and the reference pixel; An optical flow map is generated according to the shift intensity and the shift direction of each of the target pixels in the target video frame.

2. The video processing method according to claim 1, characterized in that: The fusion of the blurred target video frame and the target video frame to obtain a target special effect video frame with a clear main object and a background area having a motion blur effect comprises: Identify a foreground area of ​​a main object in the target video frame, and generate a first mask image corresponding to the foreground area; Performing dilation processing on the first mask image to obtain a second mask image; The target video frame and the blurred target video frame are fused according to the second mask image to obtain a target special effect video frame with a clear main object and a background area having a motion blur effect.

3. The video processing method according to claim 1, characterized in that: The step of obtaining the offset information corresponding to the optical flow map of each video frame in the video to be processed includes: Obtaining the maximum offset vector of each optical flow map corresponding to the video to be processed; The obtained offset vectors are set as the offset information of the optical flow map of the target video frame.

4. The video processing method according to claim 3, characterized in that: The step of determining the sampling offset required for the target video frame to have a motion blur effect according to the optical flow graph of the target video frame and the offset information corresponding to the video to be processed includes: Calculating an offset strength difference between a maximum offset strength and a minimum offset strength in the offset information; The offset intensities and offset directions in the optical flow map are adjusted according to the offset intensity difference and the maximum offset intensity to obtain a sampling offset of the target video frame.

5. The video processing method according to claim 4, characterized in that: The adjusting each offset strength and each offset direction in the optical flow map according to the offset strength difference and the maximum offset strength to obtain the sampling offset of the target video frame includes: Performing texture mapping on the pixel coordinates of the optical flow map to obtain optical flow texture information corresponding to each of the optical flow maps; Sampling the optical flow map according to the optical flow texture information by a graphics processor to obtain an offset direction and an offset strength corresponding to each pixel in the optical flow map; The product of the offset intensity difference, the offset direction and the offset intensity is calculated, and the product and the maximum offset intensity are fused to obtain a sampling offset.

6. The video processing method according to any one of claims 1 to 5, characterized in that: The step of sampling the target video frame according to the sampling offset to obtain a blurred target video frame includes: Sorting the offset intensities in the optical flow map; Calculating an offset intensity average of a preset number of target offset intensities in the sorted offset intensity sequence, and correcting the sampling offset according to the offset intensity average; Determining the number of iterations according to the offset intensity difference between the maximum offset intensity and the minimum offset intensity in the optical flow map; Sampling the target video frame according to the corrected sampling offset to obtain a blurred first video frame; The first video frame is sampled according to the sampling offset until the number of sampling times reaches the number of iterations, thereby obtaining a blurred target video frame.

7. A video processing device, characterized in that: The video processing device comprises: An acquisition module is used to acquire an optical flow map of a target video frame in a video to be processed, and offset information corresponding to the optical flow map of each video frame in the video to be processed; An offset determination module, used to determine a sampling offset required for the target video frame to have a motion blur effect according to the optical flow map of the target video frame and the offset information corresponding to the video to be processed; A blur processing module samples the target video frame according to the sampling offset to obtain a blurred target video frame; A fusion module, used for fusing the blurred target video frame with the target video frame to obtain a target special effect video frame with a clear main object and a background area having a motion blur effect; The acquisition module is used to obtain the optical flow map of the target video frame in the video to be processed, specifically including: Acquire a target pixel in the target video frame and a reference pixel corresponding to the target pixel in a reference video frame in the video to be processed; Determining the offset direction of the target pixel according to a directional gradient histogram of a target area corresponding to the target pixel in the target video frame; Obtaining an offset strength of the target pixel according to a pixel brightness difference between the target pixel and the reference pixel; An optical flow map is generated according to the shift intensity and the shift direction of each of the target pixels in the target video frame.

8. An electronic device, characterized in that: The electronic device comprises: One or more processors, wherein the processors include a central processing unit and / or a graphics processing unit; Memory; and One or more applications, wherein the one or more applications are stored in the memory and are configured to be executed by the processor to implement the steps in the video processing method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in the video processing method according to any one of claims 1 to 6.