Video image blurring method and device, computer device and storage medium

By caching and utilizing asynchronous threads for portrait segmentation and blurring, the problem of untimely blurring of video images is solved, achieving a more efficient blurring effect.

CN115115650BActive Publication Date: 2025-12-30GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110286178.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-17
Publication Date
2025-12-30
Estimated Expiration
2041-03-17

AI Technical Summary

Technical Problem

Existing video image blurring methods suffer from untimely blurring, especially when blurring is performed using a single-frame approach, which can easily lead to a delay in the video blurring effect.

Method used

By acquiring images to be processed corresponding to at least two video frames, caching them, and using the first thread for portrait segmentation, and the second thread for blurring, asynchronous thread processing is adopted to improve the timeliness of blurring.

Benefits of technology

It achieves timeliness and stability of video image blurring, reduces the delay and lag of video image blurring, and improves the real-time performance of the blurring effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115115650B_ABST
    Figure CN115115650B_ABST
Patent Text Reader

Abstract

The application relates to a video image blurring method and device, computer equipment and a storage medium. At least two frames of to-be-processed images corresponding to at least two frames of video images including portraits are acquired and cached. A first thread is used to perform portrait segmentation on the cached at least two frames of to-be-processed images, a second thread is used to perform blurring on the at least two frames of cached RGBA images after the portrait segmentation, and a video image frame after the blurring is output. Compared with the traditional video image blurring through a single frame blurring mode, the application caches at least two frames of RGBA images, determines a stable frame from the at least two frames of RGBA images, performs portrait segmentation through the first thread, and performs blurring on the video image based on the portrait area through the second thread, so that the blurring timeliness is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a video image blurring method, apparatus, computer device, and storage medium. Background Technology

[0002] With the development of computer technology, computers have become increasingly versatile, and their form has undergone tremendous changes. From the first computer, ENIAC, to today's various mobile terminals, computers are becoming increasingly portable. Mobile phones are often referred to as mobile computers, and current mobile terminals can handle most computer tasks, such as video recording. When shooting videos, especially portraits, the background is often blurred to highlight the subject. Currently, blurring portraits in videos is typically done frame-by-frame; however, this method can lead to delays in the blurring effect.

[0003] Therefore, current video image blurring methods suffer from the drawback of untimely blurring. Summary of the Invention

[0004] Therefore, it is necessary to provide a video image blurring method, apparatus, computer equipment, and storage medium that can improve the timeliness of blurring in order to address the aforementioned technical problems.

[0005] A video image blurring method, the method comprising:

[0006] At least two frames of images to be processed corresponding to at least two video images are acquired and the at least two frames of images to be processed are cached; each video image includes a human figure;

[0007] The first thread is invoked to perform portrait segmentation on the at least two cached images to be processed, and the second thread is invoked to blur the at least two images to be processed after portrait segmentation, and output the blurred video image frames; wherein, the first thread and the second thread are different threads.

[0008] In one embodiment, obtaining at least two frames of images to be processed corresponding to at least two video images includes:

[0009] Obtain the texture images corresponding to at least two frames of video images respectively;

[0010] Each texture image is converted into a corresponding RGBA image to obtain at least two frames of images to be processed.

[0011] In one embodiment, before invoking the first thread to perform portrait segmentation on the at least two cached frames of images to be processed, the method further includes:

[0012] Determine a stable frame from the at least two RGBA images; the stable frame is characterized by the fact that the change in the portrait in the RGBA image relative to the portrait in other cached RGBA images is less than a preset threshold.

[0013] The stable frame is segmented to obtain the human image region.

[0014] In one embodiment,

[0015] The caching of the at least two frames of images to be processed includes: sequentially caching the at least two RGBA images to the processing queue;

[0016] Determining the stable frames among the at least two images to be processed includes:

[0017] If the processing queue is detected to be empty at the start of the caching process, the first RGBA image cached in the processing queue is determined as the current stable frame.

[0018] If the processing queue is detected to be non-empty, the current stable frame is re-determined based on the current stable frame in the processing queue and the newly cached RGBA image in the processing queue.

[0019] In one embodiment, the step of re-determining the current stable frame based on the current stable frame in the processing queue and the newly cached RGBA image in the processing queue includes:

[0020] When a new RGBA image is detected and cached in the processing queue, the difference value between the RGBA image corresponding to the current stable frame and the new RGBA image is obtained;

[0021] If the difference value is less than a preset threshold, then the current stable frame is kept unchanged.

[0022] If the difference value is greater than or equal to the preset threshold, the new RGBA image is determined as the new current stable frame.

[0023] In one embodiment, after determining the first RGBA image cached in the processing queue as the current stable frame if the processing queue is detected to be empty at the start of the buffering process, and before outputting the blurred video image frame, the method further includes:

[0024] If the number of cached RGBA images in the processing queue is less than a preset value, the video image frame corresponding to the current stable frame is output.

[0025] In one embodiment, if the processing queue is a first-in-first-out queue, after the step of keeping the current stable frame unchanged if the difference value is less than a preset threshold, the method further includes:

[0026] If it is detected that the current stable frame has been removed from the processing queue, then the middle frame of the cached RGBA image in the processing queue is determined as the new current stable frame.

[0027] In one embodiment, the step of performing portrait segmentation on the stable frame to obtain a portrait region includes:

[0028] According to the portrait segmentation algorithm, the floating-point data corresponding to the portrait in the stable frame is obtained to obtain the portrait region.

[0029] In one embodiment, the step of invoking the first thread to perform portrait segmentation on the cached at least two frames of images to be processed, and invoking the second thread to blur the segmented at least two frames of images to be processed, includes:

[0030] The first thread is invoked to perform portrait segmentation on each frame of RGBA image based on the portrait region, thereby obtaining the portrait region corresponding to the frame of RGBA image.

[0031] The second thread is invoked to obtain the previous RGBA image corresponding to the current RGBA image and the portrait region corresponding to the previous RGBA image. Based on the portrait region corresponding to the previous RGBA image, the blurred region of the previous RGBA image is determined, and the blurred region of the previous RGBA image is blurred.

[0032] A video image blurring device, the device comprising:

[0033] The acquisition module is used to acquire at least two frames of images to be processed corresponding to at least two video images, and to cache the at least two frames of images to be processed; each video image includes a human figure;

[0034] The blurring module is used to call a first thread to perform portrait segmentation on the cached at least two frames of images to be processed, and to call a second thread to blur the at least two frames of images to be processed after portrait segmentation, and to output the blurred video image frames; wherein the first thread and the second thread are different threads.

[0035] A computer device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the method described above.

[0036] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described above.

[0037] The aforementioned video image blurring method, apparatus, computer equipment, and storage medium acquire and cache at least two frames of images to be processed corresponding to at least two video images including human figures. A first thread performs human figure segmentation on the RGBA images, and a second thread blurs the cached at least two RGBA images, outputting the blurred video image frames. Compared to traditional methods of blurring video images using single-frame blurring, this solution improves the timeliness of blurring by caching at least two RGBA images, performing human figure segmentation on the images to be processed using a first thread, and then blurring the video images based on the human figure region using a second thread. Attached Figure Description

[0038] Figure 1 This is a diagram illustrating the application environment of a video image blurring method in one embodiment;

[0039] Figure 2 This is a flowchart illustrating a video image blurring method in one embodiment;

[0040] Figure 3 This is a flowchart illustrating a video image blurring method in another embodiment;

[0041] Figure 4 This is a structural block diagram of a video image blurring device in one embodiment;

[0042] Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0043] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0044] The video image blurring method provided in this application can be applied to, for example... Figure 1In the application environment shown, terminal 102 can acquire the video image to be blurred, and obtain and cache at least two frames of images to be processed corresponding to at least two frames of video images, such as at least two RGBA images. Terminal 102 can also acquire the portrait region corresponding to the target frame image to be processed in at least two RGBA images, for example, by acquiring stable frames in at least two RGBA images, performing portrait segmentation on the stable frames to obtain the portrait region, and blurring the cached at least two RGBA images according to the portrait region, outputting the blurred video image frame. In addition, in one embodiment, a server 104 may also be included, and terminal 102 communicates with server 104 through a network. Terminal 102 can acquire at least two frames of video images from server 104; in addition, after terminal 102 completes the blurring of the RGBA images, it can also send the blurred video image frame to server 104 for storage. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, and tablets, and server 104 can be implemented as a standalone server or a server cluster composed of multiple servers.

[0045] In one embodiment, such as Figure 2 As shown, a video image blurring method is provided, which can be applied to... Figure 1 Taking the terminal in the example, the explanation includes the following steps:

[0046] Step S202: Obtain at least two frames of images to be processed corresponding to at least two video images, and cache at least two frames of images to be processed; each video image includes a human figure.

[0047] When terminal 102 detects the presence of a video image, it can acquire the video image to be blurred, which may include at least two frames. These at least two frames may include a human figure, for example, each frame of the video image contains a human figure; that is, terminal 102 needs to blur the background other than the human figure in the video image. Terminal 102 can acquire at least two frames of images to be processed corresponding to the at least two video frames, for example, at least two RGBA images, and cache the acquired at least two RGBA images; that is, terminal 102 can use the RGBA images corresponding to the video images to blur the video image. Here, RGBA is a color space representing Red, Green, Blue, and Alpha (transparency), meaning that the pixels in the video image can be represented using the RGBA color space.

[0048] Terminal 102 can obtain corresponding RGBA images by converting video images. For example, in one embodiment, obtaining at least two frames of images to be processed corresponding to at least two video images includes: obtaining texture images corresponding to at least two video images respectively; converting each texture image into a corresponding RGBA image to obtain at least two frames of images to be processed. In this embodiment, the at least two video images obtained above can be video images in video texture format. Video texture is equivalent to a 2D image, and each frame of video image is a texture frame in OpenGL (Open Graphics Library). Terminal 102 can obtain the texture images corresponding to the at least two video images respectively, that is, the video textures corresponding to the video images. Terminal 102 can convert each of the texture images to the corresponding RGBA images to obtain the at least two frames of images to be processed. It should be noted that terminal 102 can use any reasonable conversion algorithm to convert the texture images of the video textures into RGBA images.

[0049] In addition, the terminal 102 can also cache the acquired RGBA images. For example, in one embodiment, caching at least two frames of images to be processed includes: sequentially caching at least two frames of RGBA images to a processing queue. The terminal 102 can cache the aforementioned at least two frames of RGBA images to the processing queue, so that the terminal 102 can perform subsequent processing on the aforementioned RGBA images in the processing queue. The processing queue can be a queue with a set capacity, for example, a queue with a capacity of N, where the value of N can be set according to actual conditions, such as 5 frames. The aforementioned queue can be used to cache RGBA images, so that the terminal 102 can process the cached RGBA images in the processing queue.

[0050] Step S204: Call the first thread to perform portrait segmentation on at least two cached frames of images to be processed, and call the second thread to blur the at least two frames of images to be processed after portrait segmentation, and output the blurred video image frames; wherein, the first thread and the second thread are different threads.

[0051] The image to be processed can be an RGBA image. Each of the aforementioned RGBA images can include a human figure. Terminal 102 can perform human figure segmentation on at least two frames of the image to be processed, for example, using stable frames. For instance, in one embodiment, before calling the first thread to perform human figure segmentation on the at least two cached frames of the image to be processed, the method further includes: determining a stable frame among the at least two RGBA images; a stable frame indicates that the change in the human figure in that frame of the RGBA image relative to the human figures in other cached RGBA images is less than a preset threshold; performing human figure segmentation on the stable frame to obtain a human figure region. In this embodiment, a stable frame can be a frame that indicates that the change in the human figure in the corresponding RGBA image is less than a preset threshold. That is, when a stable frame is determined, the human figure in that frame can represent the approximate or accurate position of the human figure in the video image. The more frequently the stable frame changes, the more frequently the position of the human figure in the video image changes; conversely, the less frequently the stable frame changes, the less frequently the position of the human figure in the video image changes. The terminal 102 can determine the variation of the human image in the video image using various methods. For example, the terminal 102 can determine the variation of the human image in at least two RGBA images based on the pixel changes of the human image in the aforementioned RGBA images. The terminal 102 can determine the RGBA image corresponding to the stable frame from the aforementioned at least two RGBA images, and thus the terminal 102 can perform corresponding processing using the RGBA image corresponding to the stable frame. For example, the terminal 102 can determine the stable frame from the aforementioned at least two RGBA images in the aforementioned processing queue.

[0052] Furthermore, the aforementioned stable frame indicates that the variation in the human image in the corresponding RGBA image compared to the human images in other cached RGBA images is less than a preset threshold. Therefore, the RGBA image of the stable frame contains human images. The terminal 102 can perform human image segmentation on the stable frame using a designated thread to obtain the human image region. For example, the first thread can segment the human image in the RGBA image of the stable frame. The first thread can be a sub-thread within the terminal 102 used for human image segmentation. The terminal 102 can perform human image segmentation on the RGBA image of the stable frame using various segmentation algorithms. After performing human image segmentation on the RGBA image of the stable frame, the terminal 102 can obtain the human image region.

[0053] It should be noted that the portrait region can be represented in data form. For example, in one embodiment, terminal 102 can call a first thread to obtain the portrait mask in the stable frame, i.e., the floating-point data corresponding to the portrait, through a portrait segmentation algorithm, thereby achieving portrait segmentation and forming a portrait region. Specifically, the aforementioned floating-point data can be any value from 0 to 1. Terminal 102 can determine whether the region needs to be blurred based on the different values. For example, when the value is 1, the region is not blurred; when the value is 0, the region is blurred; when the value is 0.5, the region is blurred by half, and so on. Since the stable frame indicates that its portrait difference is small compared to other RGBA image frames, terminal 102 can use the portrait region obtained from the stable frame as the portrait region of other RGBA image frames, for example, using the aforementioned obtained portrait region to blur other RGBA image frames. The aforementioned portrait segmentation can be performed by terminal 102 by calling a set thread, for example, by calling the first thread.

[0054] Since the changes in the human image in the stable frame are smaller compared to the human image in other RGBA frames, the terminal 102 can perform blurring processing on the at least two cached RGBA frames based on the human image region determined in the stable frame. For example, the terminal 102 can call a first thread to perform human image segmentation on the current frame of the image to be processed in at least two frames of images to be processed, using the human image region corresponding to the stable frame, to obtain the human image region corresponding to the current frame of the image to be processed, and then call a second thread to perform blurring processing on the image outside the human image region in the previous frame of the RGBA image to be processed corresponding to the current frame of the RGBA image to be processed in the processing queue. The second thread can be a sub-thread in the terminal 102 used for video image blurring, and this sub-thread can be a different thread from the first thread, meaning the first and second threads can run simultaneously. The blurring algorithm can include various methods, such as the Render blurring algorithm. After blurring each of the RGBA frames, the terminal 102 can output the blurred video image frames corresponding to each blurred RGBA frame, thereby achieving video image blurring. For example, terminal 102 can convert the format of the blurred RGBA image to obtain the blurred texture image corresponding to the blurred RGBA image of the frame, and output the blurred texture image to realize the blurring of the video image. That is, terminal 102 can receive the texture image, convert the texture image into an RGBA image for intermediate blurring processing, and finally output the blurred texture image.

[0055] In the aforementioned video image blurring method, at least two frames of images to be processed, corresponding to at least two video images including human figures, are acquired and cached. A first thread performs human figure segmentation on the RGBA images, and a second thread blurs the cached at least two RGBA images, outputting the blurred video image frames. Compared to traditional methods of blurring video images using single-frame blurring, this solution improves the timeliness of blurring by caching at least two RGBA images, performing human figure segmentation on the images to be processed using a first thread, and then blurring the video images based on the human figure region using a second thread.

[0056] In one embodiment, determining a stable frame among at least two frames of images to be processed includes: if it is detected that the processing queue is empty at the start of the buffering process, then determining the first RGBA image cached in the processing queue as the current stable frame; if it is detected that the processing queue is not empty, then re-determining the current stable frame based on the current stable frame in the processing queue and the newly cached RGBA image in the processing queue.

[0057] In this embodiment, the image to be processed can be an RGBA image, and at least two RGBA images can be RGBA format images converted from at least two texture images. The terminal 102 can cache at least two RGBA images into a processing queue, and the terminal 102 can determine the stable frame among the at least two RGBA images in the processing queue in various ways. For example, it can be divided into the cases of caching beginning and caching in progress. When the terminal 102 detects the start of caching and the processing queue is empty, it can determine the first RGBA image cached in the processing queue as the current stable frame. The terminal 102 can also redetermine the current stable frame based on the current stable frame in the processing queue and the newly cached RGBA image in the processing queue during the caching process. For example, when a new RGBA image is cached into the processing queue where the current stable frame exists, the number of cached RGBA images in the processing queue is already greater than one, that is, the processing queue is no longer empty. Then the terminal 102 can compare the RGBA image of the current stable frame with the newly cached RGBA image in the processing queue to redetermine the current stable frame.

[0058] Through this embodiment, the terminal 102 can determine the current stable frame in different ways according to the number of cached RGBA images in the processing queue, and can blur the video image according to the stable frame, thereby improving the timeliness of video image blurring.

[0059] In one embodiment, the process of re-determining the current stable frame based on the current stable frame in the processing queue and the newly cached RGBA image in the processing queue includes: when a new RGBA image is detected to be cached in the processing queue, obtaining the difference value between the RGBA image corresponding to the current stable frame and the new RGBA image; if the difference value is less than a preset threshold, keeping the current stable frame unchanged; if the difference value is greater than or equal to the preset threshold, determining the new RGBA image as the new current stable frame.

[0060] In this embodiment, the terminal 102 can update the current stable frame when the current stable frame already exists in the processing queue. The terminal 102 can update the stable frame by comparison. When the terminal 102 detects that a new RGBA image has been cached in the processing queue, the terminal 102 can obtain the difference value between the RGBA image corresponding to the current stable frame in the processing queue and the new RGBA image cached in the processing queue, and determine the new current stable frame based on the difference value. For example, terminal 102 can use an algorithm to compare the difference between the RGBA image of the current stable frame and the new RGBA image cached in the processing queue. When terminal 102 detects that the difference value is less than a preset threshold, such as a set threshold f, it means that the difference between the current stable frame and the newly cached RGBA image is small, and terminal 102 can continue to retain the current stable frame without updating. When terminal 102 detects that the difference value is greater than or equal to the preset threshold f, it means that the difference between the current stable frame and the new RGBA image cached in the processing queue is large, and terminal 102 can determine the new RGBA image compared with the current stable frame as the new current stable frame, thereby realizing the update of the current stable frame. The algorithm by which the terminal 102 compares the current stable frame with the newly cached RGBA image can include various methods. For example, it can use variance calculation to determine the difference between the current stable frame's RGBA image and the newly cached RGBA image; it can also calculate the difference between the pixel distributions of the current stable frame's RGBA image and the newly cached RGBA image to obtain the difference between the two; or it can use a dithering optical flow algorithm to calculate the difference between the current stable frame's RGBA image and the newly cached RGBA image to determine the new current stable frame.

[0061] Through this embodiment, when a new RGBA image is cached to the queue, the terminal 102 can determine the new current stable frame by comparing the RGBA images. This allows for the reduction of slight image jitter based on the stable frame, resulting in smoother video, more accurate portrait segmentation, and improved stability and timeliness of video image blurring.

[0062] In one embodiment, if the processing queue is detected to be empty at the start of the buffering process, after determining the first RGBA image cached in the processing queue as the current stable frame and before outputting the blurred video image frame, the method further includes: if the number of cached RGBA images in the processing queue is less than a preset value, then outputting the video image frame corresponding to the current stable frame.

[0063] In this embodiment, the terminal 102 can determine the format of the video image to be output based on the number of RGBA images in the cache queue. For example, when the caching begins, the number of images in the processing queue is empty. The terminal 102 then determines the first RGBA image cached in the processing queue as the current stable frame. At this time, the terminal 102 can make a judgment. If the number of cached RGBA images in the processing queue is less than a preset number, the terminal 102 can output the video image frame corresponding to the current stable frame, that is, output the unblurred texture image corresponding to the current stable frame, thereby reducing the display latency of the video image. The preset number can be set according to the actual situation and is usually a small value, such as 3 to 5. When the number of RGBA images in the processing queue has not reached the preset number, the terminal 102 can directly output the texture image corresponding to the RGBA image of the current stable frame in the processing queue to reduce the lag and delay of the video. After the number of RGBA images in the processing queue reaches the preset number, the portrait blurring process is started and the blurred video image is output. The value of the preset number can be less than or equal to the total capacity of the processing queue. Since the preset number is generally small, there will be no abruptness when the user turns the blurring effect on and off.

[0064] Through this embodiment, the terminal 102 can directly output the unblurred texture image corresponding to the current stable frame when the number of RGBA images in the processing queue is small, reducing the latency of video images, and perform portrait blurring after the number of RGBA images in the processing queue reaches a preset number, thereby improving the stability and timeliness of video image blurring.

[0065] In one embodiment, if the processing queue is a first-in-first-out queue, and if the difference value is less than a preset threshold, after keeping the current stable frame from being updated, the method further includes: if it is detected that the current stable frame has been removed from the processing queue, then the middle frame of the cached RGBA image in the processing queue is determined as the new current stable frame.

[0066] In this embodiment, the terminal 102 can continuously cache RGBA images into the processing queue and continuously update the current stable frame in the processing queue. If the difference between the current stable frame and the newly cached RGBA image in the processing queue is less than a preset threshold, it means that the difference between the two is small, and the terminal 102 can retain the current stable frame without updating. However, if the processing queue is a first-in-first-out queue, when the current stable frame is not updated for a long time, that is, when the difference between the newly cached RGBA image in the processing queue and the current stable frame is less than the preset threshold, since new RGBA images are continuously cached into the processing queue and the capacity of the processing queue is limited, the current stable frame that is not updated may be removed from the processing queue. Since there is no current stable frame in the processing queue at this time, it needs to be re-determined. Since the difference between the RGBA image in the processing queue and the removed current stable frame is small at this time, the terminal 102 can determine a frame of RGBA image at a set position in the processing queue as the new current stable frame. For example, the middle frame of the cached RGBA image in the processing queue can be determined as the new current stable frame.

[0067] Through this embodiment, the terminal 102 can determine a new current stable frame in the processing queue after the current stable frame is removed from the processing queue, thereby improving the stability and timeliness of video image blurring.

[0068] In one embodiment, a first thread is invoked to perform portrait segmentation on at least two frames of video images, and a second thread is invoked to blur the at least two frames of images to be processed after portrait segmentation. This includes: invoking the first thread to perform portrait segmentation on each RGBA image frame according to the portrait region to obtain the portrait region corresponding to the RGBA image frame; invoking the second thread to obtain the previous RGBA image frame corresponding to the current RGBA image frame and the portrait region corresponding to the previous RGBA image frame, determining the blurred region of the previous RGBA image frame according to the portrait region corresponding to the previous RGBA image frame, and blurring the blurred region of the previous RGBA image frame.

[0069] In this embodiment, terminal 102 can utilize asynchronous threads to determine the blurred region and perform video blurring separately. For example, terminal 102 can blur the RGBA image in one thread and determine the blurred region of the RGBA image in another thread. These two threads can be asynchronous. Specifically, for each frame of RGBA image in the processing queue, terminal 102 can call the first thread to perform portrait segmentation on the currently processed frame of RGBA image, thereby determining the portrait region. For example, the portrait region in the RGBA image of that frame can be determined based on the portrait region determined from the stable frame, as described above. Terminal 102 can then determine the blurred region in the RGBA image of that frame based on the portrait region. Specifically, terminal 102 can determine the blurred region in the RGBA image based on the portrait region segmented from the RGBA image of the stable frame using the portrait segmentation algorithm, for example, defining the region outside the portrait region in the RGBA image as the blurred region. The portrait region determined from the stable frame can be used in any cached RGBA image as the basis for determining the blurred region. Terminal 102 can also invoke a second thread to retrieve the previous frame's RGBA image corresponding to the currently processed RGBA image from the cache. Based on the portrait region obtained through portrait segmentation using the previous frame's RGBA image, it obtains the corresponding blurred region and blurs the obtained previous frame's RGBA image, for example, using a render blurring algorithm. The first and second threads can be asynchronous. Furthermore, terminal 102 can convert the blurred RGBA image into a corresponding texture image and output the texture image.

[0070] In this embodiment, the terminal 102 uses asynchronous threads to perform portrait segmentation of the current frame and video blurring of the previous frame, thereby improving the algorithm speed and the stability and timeliness of video blurring.

[0071] In one embodiment, such as Figure 3 As shown, Figure 3 This is a flowchart illustrating a video image blurring method in another embodiment. It includes the following steps:

[0072] Terminal 102 can convert the texture images of each frame in the video image that needs to be blurred into RGBA images, and cache each RGBA image in a processing queue. This process can be continuously updated, meaning that new RGBA images are constantly being cached in the processing queue. In the processing queue, terminal 102 can determine the RGBA image of a stable frame using an optical flow algorithm. For example, at the start of caching, if there is only one RGBA image in the processing queue, terminal 102 can use that RGBA image as the current stable frame. As caching progresses, new RGBA images are continuously cached in the processing queue, and at this time, terminal 102 can compare the current stable frame with... The difference between newly cached RGBA images in the processing queue is calculated, for example, by taking the variance. If the difference is less than a set threshold f, the current stable frame remains unchanged. If the difference is greater than or equal to the set threshold f, the new RGBA image compared with the current stable frame is determined as the new current stable frame. Alternatively, if the processing queue is a first-in, first-out queue, since new RGBA images are continuously cached in the processing queue, if the current stable frame is removed from the queue, the terminal 102 can re-determine a new current stable frame in the processing queue, for example, by determining the middle RGBA image in the processing queue as the new current stable frame. After determining the current stable frame, the terminal 102 can perform portrait segmentation based on the current stability, for example, by segmenting the portrait in the stable frame using a portrait segmentation algorithm to obtain the portrait region and cache it.

[0073] Furthermore, if the number of image frames in the processing queue is less than a preset number, the terminal 102 can directly output the texture image corresponding to the current stable frame, i.e., output the unblurred video image; when the number of image frames in the processing queue equals the preset number, the terminal 102 can begin blurring. The terminal 102 can use asynchronous threads to perform portrait segmentation of the RGBA image and video blurring respectively. For example, the terminal 102 can call a first thread to obtain the blurring region of the RGBA image being blurred, based on the aforementioned portrait region, for example, by obtaining the portrait region of the RGBA image through portrait segmentation, and determining the region outside the portrait region as the blurring region; and call a second thread to obtain the previous RGBA image corresponding to the RGBA image being blurred, and using the previous RGBA image and the corresponding portrait region, obtain the blurring region based on the portrait region, and blur the previous RGBA image, for example, by using a render blurring algorithm. The first and second threads can be asynchronous threads. After blurring the RGBA image, terminal 102 can convert the blurred RGBA image into a corresponding blurred texture image, thereby outputting a blurred video image.

[0074] In this embodiment, the terminal 102 caches at least two RGBA images, determines a stable frame from them, obtains the portrait region using the stable frame, and then uses an asynchronous thread to blur the video image based on the portrait region, thereby improving the stability and timeliness of the blurring.

[0075] It should be understood that, although Figures 2-3 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order in which these steps are executed, and they can be performed in other orders. Furthermore, Figures 2-3 At least some of the steps in the process may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but may be executed at different times. The execution order of these steps or stages is not necessarily sequential, but may be executed in turn or alternately with other steps or at least some of the steps or stages in other steps.

[0076] In one embodiment, such as Figure 4 As shown, a video image blurring device is provided, including: an acquisition module 500 and a blurring module 502, wherein:

[0077] The acquisition module 500 is used to acquire at least two frames of images to be processed corresponding to at least two frames of video images, and to cache at least two frames of images to be processed; each frame of video image includes a human image.

[0078] The blurring module 502 is used to call the first thread to perform portrait segmentation on at least two cached images to be processed, and to call the second thread to blur the at least two images to be processed after portrait segmentation, and output the blurred video image frames; wherein the first thread and the second thread are different threads.

[0079] In one embodiment, the acquisition module 500 is specifically used to acquire texture images corresponding to at least two video images respectively; and convert each texture image into a corresponding RGBA image to obtain at least two RGBA images.

[0080] In one embodiment, the acquisition module 500 is specifically used to sequentially cache at least two frames of RGBA images to the processing queue.

[0081] In one embodiment, the above apparatus further includes: a determining module, configured to determine a stable frame in at least two RGBA images; the stable frame indicates that the variation of the portrait in the RGBA image relative to the portrait in other cached RGBA images is less than a preset threshold; and the stable frame is segmented to obtain a portrait region.

[0082] In one embodiment, the aforementioned determining module is specifically configured to determine the first RGBA image cached in the processing queue as the current stable frame if the processing queue is detected to be empty at the start of the caching process; and to re-determine the current stable frame based on the current stable frame in the processing queue and the newly cached RGBA image in the processing queue if the processing queue is detected to be not empty.

[0083] In one embodiment, the aforementioned determining module is specifically used to obtain the difference value between the RGBA image corresponding to the current stable frame and the new RGBA image when a new RGBA image is detected to be cached in the processing queue; if the difference value is less than a preset threshold, the current stable frame is kept unchanged; if the difference value is greater than or equal to the preset threshold, the new RGBA image is determined as the new current stable frame.

[0084] In one embodiment, the above apparatus further includes: an output module, configured to output the video image frame corresponding to the current stable frame if the number of cached RGBA images in the processing queue is less than a preset value.

[0085] In one embodiment, the above apparatus further includes: an update module, configured to, if the processing queue is a first-in-first-out queue, determine the middle frame of the cached RGBA image in the processing queue as the new current stable frame if it is detected that the current stable frame has been removed from the processing queue.

[0086] In one embodiment, the aforementioned determining module is specifically used to obtain floating-point data corresponding to the human image in a stable frame based on a human image segmentation algorithm, thereby obtaining the human image region.

[0087] In one embodiment, the aforementioned blurring module 502 is specifically used to call a first thread to perform portrait segmentation on each frame of RGBA image based on the portrait region, thereby obtaining the portrait region corresponding to the frame of RGBA image; call a second thread to obtain the previous frame of RGBA image corresponding to the current frame of RGBA image and the portrait region corresponding to the previous frame of RGBA image, determine the blurring region of the previous frame of RGBA image based on the portrait region corresponding to the previous frame of RGBA image, and blur the blurring region of the previous frame of RGBA image.

[0088] Specific limitations regarding the video image blurring device can be found in the limitations of the video image blurring method described above, and will not be repeated here. Each module in the aforementioned video image blurring device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.

[0089] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 5 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a video image blurring method. The display screen can be an LCD screen or an e-ink display screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.

[0090] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0091] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement a video image blurring method.

[0092] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements a video image blurring method.

[0093] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0094] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0095] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A method of video image blurring, characterized by, The method comprises: acquiring at least two frames of to-be-processed images corresponding to at least two frames of video images, and buffering the at least two frames of to-be-processed images, comprising: sequentially buffering at least two frames of RGBA images to a processing queue; each frame of video image comprises a portrait; determining a stable frame in the at least two frames of RGBA images, comprising: if it is detected that the processing queue is not empty, re-determining a current stable frame according to a difference value between an RGBA image corresponding to the current stable frame in the processing queue and an RGBA image newly buffered to the processing queue; the difference value is calculated based on an anti-shake optical flow algorithm; the stable frame represents that a change amplitude of a portrait in the frame of RGBA image relative to a portrait in other buffered RGBA images is less than a preset threshold value; performing portrait segmentation on the stable frame to obtain a portrait region, calling a first thread, performing portrait segmentation on the at least two frames of to-be-processed images buffered by using the portrait region corresponding to the stable frame, calling a second thread, performing blurring on the at least two frames of to-be-processed images after portrait segmentation, and outputting a frame of video image after blurring; wherein the first thread and the second thread are different threads.

2. The method of claim 1, wherein, The acquiring at least two frames of to-be-processed images corresponding to at least two frames of video images comprises: respectively acquiring texture images corresponding to at least two frames of video images; converting each texture image into a corresponding RGBA image to obtain the at least two frames of to-be-processed images.

3. The method of claim 1, wherein, The determining a stable frame in the at least two frames of RGBA images comprises: if it is detected that the processing queue is empty at the beginning of buffering, determining a first frame of RGBA image buffered to the processing queue as a current stable frame.

4. The method of claim 1, wherein, The re-determining a current stable frame according to a difference value between an RGBA image corresponding to the current stable frame in the processing queue and an RGBA image newly buffered to the processing queue comprises: when it is detected that a new RGBA image is buffered to the processing queue, acquiring a difference value between the RGBA image corresponding to the current stable frame and the new RGBA image; if the difference value is less than a preset threshold value, maintaining the current stable frame without updating; if the difference value is greater than or equal to the preset threshold value, determining the new RGBA image as a new current stable frame.

5. The method of claim 3, wherein, After the determining a first frame of RGBA image buffered to the processing queue as a current stable frame if it is detected that the processing queue is empty at the beginning of buffering, and before outputting a frame of video image after blurring, the method further comprises: if a number of RGBA images buffered in the processing queue is less than a preset number of values, outputting a frame of video image corresponding to the current stable frame.

6. The method of claim 4, wherein, If the processing queue is a first-in-first-out queue, after the maintaining the current stable frame without updating if the difference value is less than a preset threshold value, the method further comprises: if it is detected that the current stable frame has been removed from the processing queue, determining a middle frame of the RGBA images buffered in the processing queue as a new current stable frame.

7. The method of claim 2, wherein, The performing portrait segmentation on the stable frame to obtain a portrait region comprises: According to the portrait segmentation algorithm, floating point data corresponding to the portrait in the stable frame is obtained, and a portrait region is obtained.

8. The method of claim 2, wherein, The first thread is called to perform portrait segmentation on the at least two buffered frames of to-be-processed images, and the second thread is called to perform blurring on the at least two frames of to-be-processed images after portrait segmentation, including: The first thread is called to perform portrait segmentation on each frame of RGBA image according to the portrait region of the frame of RGBA image, to obtain a portrait region corresponding to the frame of RGBA image. The second thread is called to obtain a previous frame of RGBA image corresponding to the frame of RGBA image and a portrait region corresponding to the previous frame of RGBA image, to determine a blurring region of the previous frame of RGBA image according to the portrait region corresponding to the previous frame of RGBA image, and to perform blurring on the blurring region of the previous frame of RGBA image.

9. A video image blurring apparatus characterized by comprising: The device comprises: The acquisition module is configured to acquire at least two frames of to-be-processed images corresponding to at least two frames of video images, and buffer the at least two frames of to-be-processed images, specifically configured to sequentially buffer at least two frames of RGBA images to a processing queue; each frame of video image includes a portrait; The determination module is configured to determine a stable frame in the at least two frames of RGBA images, including: if it is detected that the processing queue is not empty, a current stable frame is re-determined according to a difference value between an RGBA image corresponding to the current stable frame in the processing queue and an RGBA image newly buffered to the processing queue; the difference value is calculated based on an anti-jitter optical flow algorithm; the stable frame represents that a change amplitude of the portrait in the frame of RGBA image relative to the portrait in other buffered frames of RGBA images is less than a preset threshold value; The blurring module is configured to perform portrait segmentation on the stable frame to obtain a portrait region, call a first thread to perform portrait segmentation on the at least two buffered frames of to-be-processed images by using the portrait region corresponding to the stable frame, call a second thread to perform blurring on the at least two frames of to-be-processed images after portrait segmentation, and output a frame of video image after blurring; wherein the first thread and the second thread are different threads. 10.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-9. The processor executes the computer program to implement the steps of the method in any one of claims 1 to 8.

11. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data processing apparatus and image processing apparatus

    CN101795381A

  • Real-time video face recognition method and system based on vision tracking technology

    CN107609497A

  • Video compression method and device and computer-readable storage medium

    CN109618173A