Background image generation method, device, computer equipment and storage medium

By identifying and extracting background occlusion areas and combining multiple captured images for local background image synthesis, the problem of background occlusion affecting collection accuracy is solved, image collection efficiency is improved, operations are simplified, and background image generation without clearing the field is achieved.

CN113592781BActive Publication Date: 2024-09-27BEIJING AIBI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110761383.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-06
Publication Date
2024-09-27
Estimated Expiration
2041-07-06

AI Technical Summary

Technical Problem

When the existing technology collects background images of specific scenes, moving human bodies or objects cause occlusion, affecting the accuracy of the image, and the scene clearing process is difficult and inefficient.

Method used

By acquiring multiple captured images, identify and extract images outside the background occlusion area, combine the target background occlusion area in the reference image and other images, synthesize the local background image, and generate a complete background image to avoid clearing the field.

Benefits of technology

The purpose of removing background occlusions and restoring the complete background image is achieved, the image collection efficiency is improved, the operation process is simplified, and the resource overhead is small.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113592781B
    Figure CN113592781B
Patent Text Reader

Abstract

The present application relates to a method, device, computer equipment and storage medium for generating a background image. The method includes: obtaining multiple captured images containing a target background; identifying background occlusion areas in the multiple captured images, and extracting images outside the background occlusion areas to obtain a background reference image corresponding to each captured image; extracting a target image of the target background occlusion area from background reference images corresponding to captured images other than the reference image according to the target background occlusion area corresponding to the reference image in the multiple captured images; determining a local background image corresponding to the target background occlusion area according to the extracted target image, and synthesizing the local background image with the background reference image corresponding to the reference image to obtain a background image of the target background. The present method can remove background occlusion objects and restore a complete background image, greatly improving the efficiency of image acquisition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a method, device, computer equipment and storage medium for generating a background image. Background Art

[0002] In the actual application of computer vision technology, it is usually necessary to collect background images of specific scenes. When there are moving people or objects in the collected images, the background images will be blocked. For example, when modeling indoor maps of shopping malls, it is necessary to collect background images of various areas of the shopping mall. If there are obstructions such as pedestrians in the images, it will greatly affect the accuracy of map modeling.

[0003] In the related art, in order to obtain a complete background image of a specific scene, it is necessary to clear the scene before performing image acquisition, which is difficult to implement and has low image acquisition efficiency. Summary of the invention

[0004] Based on this, it is necessary to provide a method, device, computer equipment and storage medium for generating a background image that removes background obstructions in an image and restores the background image in response to the above technical problems.

[0005] A method for generating a background image, the method comprising:

[0006] Acquire multiple captured images including target background;

[0007] Identify background occlusion areas in the multiple captured images, and extract images outside the background occlusion areas to obtain a background reference image corresponding to each of the captured images;

[0008] According to the target background occlusion area corresponding to the reference image in the multiple captured images, extracting the target image of the target background occlusion area from the background reference images corresponding to the captured images other than the reference image;

[0009] A local background image corresponding to the target background occlusion area is determined according to the extracted target image, and the local background image is synthesized with a background reference image corresponding to the benchmark image to obtain a background image of the target background.

[0010] In one embodiment, extracting the image outside the background occlusion area to obtain the background reference image corresponding to each of the captured images includes:

[0011] Generate a first image mask corresponding to each of the captured images according to the multiple captured images and the background occlusion area;

[0012] The image outside the background occlusion area is extracted from the multiple captured images through the first image mask to obtain a background reference image corresponding to each of the captured images.

[0013] In one of the embodiments, extracting the target image of the target background occlusion area from the background reference images corresponding to the captured images other than the reference image according to the target background occlusion area corresponding to the reference image in the multiple captured images includes:

[0014] generating a second image mask according to a reference image in the plurality of captured images and a target background occlusion area corresponding to the reference image;

[0015] The target image is extracted from the background reference image corresponding to the captured image other than the reference image through the second image mask.

[0016] In one embodiment, the identifying the background occlusion area in the plurality of captured images and extracting the image outside the background occlusion area to obtain the background reference image corresponding to each of the captured images includes:

[0017] Using a preset image detection algorithm, detecting background obstructions in the plurality of captured images, and determining an area where the background obstructions are located as a background obstruction area;

[0018] Determine a moving target background occluder among the detected background occluders according to a background occluder area of ​​the background occluder in the plurality of captured images;

[0019] The image outside the background occlusion area of ​​the target background occlusion object is extracted to obtain a background reference image corresponding to each of the captured images.

[0020] In one of the embodiments, determining the moving target background occluder among the detected background occluders according to the background occluder area of ​​the background occluder in the multiple captured images includes:

[0021] For each background occlusion area of ​​the background occlusion object contained in the reference image, calculate the area intersection-and-union ratio of the background occlusion area in each captured image other than the reference image to the background occlusion area of ​​the background occlusion object in the reference image, and determine the maximum value of the area intersection-and-union ratios corresponding to each captured image;

[0022] Calculating an average value of the maximum values ​​of the intersection-and-union ratios of the areas corresponding to each captured image;

[0023] If the average value is less than a preset threshold, the background occluder is determined as a target background occluder.

[0024] In one of the embodiments, determining the local background image corresponding to the target background occlusion area according to the extracted target image includes:

[0025] The average pixel value of each pixel in the extracted target image is calculated to obtain a local background image corresponding to the target background occlusion area.

[0026] In one embodiment, the method further comprises:

[0027] Calculating the total area of ​​the background occlusion region in each of the captured images;

[0028] The captured image with the smallest total area of ​​the background occlusion region is determined as the reference image.

[0029] In one embodiment, the method further comprises:

[0030] Calculating the total number of background occlusion objects in each of the captured images according to the background occlusion area in each of the captured images;

[0031] The captured image with the least total number of background obstructions is determined as the reference image.

[0032] A device for generating a background image, the device comprising:

[0033] An acquisition module, used for acquiring a plurality of captured images including a target background;

[0034] A first extraction module, used for identifying background occlusion areas in the plurality of captured images, and extracting images outside the background occlusion areas to obtain a background reference image corresponding to each of the captured images;

[0035] A second extraction module, configured to extract a target image of the target background occlusion area from background reference images corresponding to captured images other than the reference image, according to the target background occlusion area corresponding to the reference image in the multiple captured images;

[0036] The synthesis module is used to determine the local background image corresponding to the target background occlusion area according to the extracted target image, and synthesize the local background image with the background reference image corresponding to the benchmark image to obtain the background image of the target background.

[0037] In one embodiment, the first extraction module is specifically used to:

[0038] Generate a first image mask corresponding to each of the captured images according to the multiple captured images and the background occlusion area;

[0039] The image outside the background occlusion area is extracted from the multiple captured images through the first image mask to obtain a background reference image corresponding to each of the captured images.

[0040] In one embodiment, the second extraction module is specifically used to:

[0041] generating a second image mask according to a reference image in the plurality of captured images and a target background occlusion area corresponding to the reference image;

[0042] The target image is extracted from the background reference image corresponding to the captured image other than the reference image through the second image mask.

[0043] In one embodiment, the first extraction module is specifically used to:

[0044] Using a preset image detection algorithm, detecting background obstructions in the plurality of captured images, and determining an area where the background obstructions are located as a background obstruction area;

[0045] Determine a moving target background occluder among the detected background occluders according to a background occluder area of ​​the background occluder in the plurality of captured images;

[0046] The image outside the background occlusion area of ​​the target background occlusion object is extracted to obtain a background reference image corresponding to each of the captured images.

[0047] In one embodiment, the first extraction module is specifically used to:

[0048] For each background occlusion area of ​​the background occlusion object contained in the reference image, calculate the area intersection-and-union ratio of the background occlusion area in each captured image other than the reference image to the background occlusion area of ​​the background occlusion object in the reference image, and determine the maximum value of the area intersection-and-union ratios corresponding to each captured image;

[0049] Calculating an average value of the maximum values ​​of the intersection-and-union ratios of the areas corresponding to each captured image;

[0050] If the average value is less than a preset threshold, the background occluder is determined as a target background occluder.

[0051] In one embodiment, the synthesis module is specifically used for:

[0052] The average pixel value of each pixel in the extracted target image is calculated to obtain a local background image corresponding to the target background occlusion area.

[0053] In one embodiment, the device further comprises:

[0054] A first determination module, used for calculating the total area of ​​the background occlusion region in each of the captured images;

[0055] The captured image with the smallest total area of ​​the background occlusion region is determined as the reference image.

[0056] In one embodiment, the device further comprises:

[0057] A second determination module, configured to calculate the total number of background occlusion objects in each of the captured images according to the background occlusion area in each of the captured images;

[0058] The captured image with the least total number of background obstructions is determined as the reference image.

[0059] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0060] Acquire multiple captured images including the target background;

[0061] Identify background occlusion areas in the multiple captured images, and extract images outside the background occlusion areas to obtain a background reference image corresponding to each of the captured images;

[0062] According to the target background occlusion area corresponding to the reference image in the multiple captured images, extracting the target image of the target background occlusion area from the background reference images corresponding to the captured images other than the reference image;

[0063] A local background image corresponding to the target background occlusion area is determined according to the extracted target image, and the local background image is synthesized with a background reference image corresponding to the benchmark image to obtain a background image of the target background.

[0064] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0065] Acquire multiple captured images including the target background;

[0066] Identify background occlusion areas in the multiple captured images, and extract images outside the background occlusion areas to obtain a background reference image corresponding to each of the captured images;

[0067] According to the target background occlusion area corresponding to the reference image in the multiple captured images, extracting the target image of the target background occlusion area from the background reference images corresponding to the captured images other than the reference image;

[0068] A local background image corresponding to the target background occlusion area is determined according to the extracted target image, and the local background image is synthesized with a background reference image corresponding to the benchmark image to obtain a background image of the target background.

[0069] The above-mentioned background image generation method, device, computer equipment and storage medium obtain multiple captured images containing the target background; identify the background occlusion area in the multiple captured images, and extract the image outside the background occlusion area to obtain the background reference image corresponding to each captured image; according to the target background occlusion area corresponding to the benchmark image in the multiple captured images, extract the target image of the target background occlusion area from the background reference image corresponding to the captured images other than the benchmark image; determine the local background image corresponding to the target background occlusion area according to the extracted target image, and synthesize the local background image with the background reference image corresponding to the benchmark image to obtain the background image of the target background. This solution achieves the purpose of removing background occlusion objects and restoring the complete background image by extracting target pixels from multiple captured images and synthesizing images. It does not need to clear the target background, has strong feasibility, fast processing speed, low resource overhead, and greatly improves image acquisition efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] Figure 1 is a schematic diagram of a process of generating a background image in one embodiment;

[0071] Figure 2 is a schematic diagram of a process of obtaining a background reference image in one embodiment;

[0072] Figure 3 A schematic diagram of a process of extracting a target image in one embodiment;

[0073] Figure 4 is a schematic diagram of a process of obtaining a background reference image in another embodiment;

[0074] Figure 5 A schematic diagram of a flow chart of determining a moving target background obstruction in one embodiment;

[0075] Figure 6 is a structural block diagram of a device for generating a background image in one embodiment;

[0076] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0077] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0078] First of all, before specifically introducing the technical solutions of the embodiments of the present application, the technical background or technical evolution context on which the embodiments of the present application are based is introduced. In the research and application of computer vision technology, it is usually necessary to collect background images of specific scenes. For example, when modeling indoor maps of shopping malls, it is necessary to collect background images of various areas of the shopping mall. If background obstructions such as pedestrians, vehicles, and animals appear in the scene, it will greatly affect the accuracy of map modeling. Therefore, under normal circumstances, it is necessary to clear the scene before collecting images. However, in actual operation, it is difficult to implement clearing of many scenes, and the efficiency of image acquisition is very low. Based on this background, the applicant has proposed a method for generating background images of the present application through long-term research and development and experimental verification. It does not require clearing of the scene, is highly feasible, and greatly improves the efficiency of collecting background images of scenes. In addition, it should be noted that the applicant has devoted a lot of creative work to the discovery of the technical problems of the present application and the technical solutions introduced in the following embodiments.

[0079] The method for generating a background image provided by the present application can be applied to a terminal, a server, or a system including a terminal and a server, and can be implemented through the interaction between the terminal and the server. The terminal can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices, and the server can be implemented as an independent server or a server cluster consisting of multiple servers.

[0080] In one embodiment, Figure 1 As shown, a method for generating a background image is provided, and the method is applied to a terminal as an example for description, and includes the following steps:

[0081] Step 101: Acquire multiple captured images containing a target background.

[0082] In implementation, the terminal can continuously shoot the target background through an image shooting device to obtain multiple captured images containing the target background. In one example, a fixed camera can be used to record a video of a specific background to obtain a video segment containing the target background, and the terminal can extract video frames from the video segment to obtain multiple captured images containing the target background.

[0083] Step 102 , identifying background occlusion areas in a plurality of captured images, and extracting images outside the background occlusion areas to obtain a background reference image corresponding to each captured image.

[0084] The background occlusion area may be an area where moving background occlusion objects such as people, vehicles, and animals are located.

[0085] In implementation, for each captured image acquired, the terminal can detect the background obstructions contained in the captured image through a preset image detection algorithm, and the area where the background obstructions are located is the background obstruction area. Among them, the image detection algorithm can adopt algorithms such as Region based Convolutional Neural Networks features (R-CNN), You Only Look Once (YOLO), Single Shot MultiBox Detector (SSD), etc., which are not limited in the embodiments of the present application. Then, the terminal can extract the image outside the background obstruction area from the captured image through an image extraction strategy to obtain a background reference image corresponding to the captured image. Among them, the extraction strategy can adopt image segmentation techniques such as binary masks. Optionally, if there are multiple background obstruction areas in the captured image, the image other than the multiple background obstruction areas is extracted to obtain a background reference image corresponding to the captured image.

[0086] Step 103 , based on the target background occlusion area corresponding to the reference image in the plurality of captured images, extract a target image of the target background occlusion area from background reference images corresponding to the captured images other than the reference image.

[0087] In implementation, the terminal may select a captured image from the multiple captured images obtained as a reference image, and may use the background occlusion area in the reference image as the target background occlusion area, wherein the step of selecting the reference image may be performed before step 103, and the present embodiment does not limit the execution order of the steps. The terminal may extract the target image corresponding to the target background occlusion area from the background reference image corresponding to each captured image other than the reference image through an image extraction strategy. The image extraction strategy may use image segmentation techniques such as binary masks. The determination of the reference image may be a random selection or may be through a certain selection strategy.

[0088] Step 104, determining a local background image corresponding to the target background occlusion area according to the extracted target image, and synthesizing the local background image with a background reference image corresponding to the benchmark image to obtain a background image of the target background.

[0089] In implementation, the terminal may use an image stitching or fusion method to determine a local background image corresponding to the target background occlusion area based on the extracted target image, and then synthesize the local background image with a background reference image corresponding to the benchmark image to obtain a background image of the target background.

[0090] When background obstructions appear in the target background, such as pedestrians in a shopping mall, pedestrians, vehicles, pets and other moving objects in a community, in order to collect a complete background image of the target background, in the background image generation method of this embodiment, the target background is first continuously photographed or video recorded by a camera or other shooting device, and the terminal obtains the continuously shot images or video frames, and then uses an image detection algorithm to identify the background obstructions in the shot images, and extracts the part outside the background obstruction area by using image segmentation techniques such as binary masks to obtain a background reference image, selects one image as a benchmark image, and based on the target background obstruction area in the benchmark image, uses image segmentation techniques such as binary masks to extract parts of the target background obstruction area from other shot images other than the benchmark image to obtain multiple target images, and then splices or merges the target images to obtain a local background image of the target background obstruction area, and synthesizes the local background image with the background reference image of the benchmark image to obtain the target background image. This method does not require clearing the target background. It only requires continuous shooting or video recording of the target background with a fixed camera. A relatively complete background image can be obtained by processing the captured images or video frames through computer equipment. It has strong feasibility and greatly improves the image acquisition efficiency.

[0091] In one embodiment, Figure 2 As shown, the process of obtaining the background reference image in step 102 specifically includes the following steps:

[0092] Step 201 : generating a first image mask corresponding to each captured image according to a plurality of captured images and a background occlusion area.

[0093] In the implementation, for each captured image, after the terminal identifies the background occlusion area, it generates a first image mask corresponding to the captured image according to a preset rule. The size of the first image mask is consistent with the size of the captured image, and the pixel value of the area corresponding to the background occlusion area of ​​the captured image in the first image mask is set to 0, and the pixel value of the area corresponding to the part other than the background occlusion area is set to 1.

[0094] Step 202 : extracting images outside the background occlusion area from a plurality of captured images through a first image mask to obtain a background reference image corresponding to each captured image.

[0095] In implementation, the terminal can segment the corresponding captured image through the first image mask in step 201, and extract the image outside the background occlusion area in the captured image. Specifically, the first image mask is multiplied by the corresponding captured image to calculate the pixel value of each pixel point, wherein the pixel value calculation result of the background occlusion area is 0, and the pixel value of the part outside the background occlusion area is consistent with the pixel value of the corresponding pixel point in the captured image, that is, the image except the background occlusion area in each captured image is extracted to obtain the background reference image.

[0096] In this embodiment, a corresponding binary mask is generated according to the background occlusion area of ​​each captured image, and the image outside the background occlusion area is extracted by the binary mask. This method can process multiple captured images at the same time, and the method is simple and effective, with fast processing speed and low resource consumption.

[0097] In one embodiment, Figure 3 As shown, step 103 specifically includes the following steps:

[0098] Step 301 : generating a second image mask according to a reference image in a plurality of captured images and a target background occlusion area corresponding to the reference image.

[0099] In implementation, the terminal can select a captured image from the multiple captured images obtained as a reference image, and can use the background occlusion area in the reference image as the target background occlusion area, wherein the step of selecting the reference image can be performed before step 301, and the present embodiment does not limit the execution order of this step. After the terminal identifies the target background occlusion area of ​​the reference image, it generates a second image mask according to a preset rule. The size of the second image mask is consistent with the size of the reference image, and the pixel value of the area corresponding to the target background occlusion area of ​​the reference image in the second image mask is set to 1, and the pixel value of the area corresponding to the part other than the target background occlusion area is set to 0.

[0100] Step 302: extracting a target image from a background reference image corresponding to a captured image other than the reference image through a second image mask.

[0101] In implementation, the terminal can perform segmentation processing on the background reference image of each other captured image except the reference image through the second image mask generated in step 301. Specifically, the second image mask is multiplied by the background reference image corresponding to each other captured image, and the pixel value of each pixel is calculated, wherein the pixel value calculation result of the part corresponding to the target background occlusion area in the background reference image is consistent with the pixel value in the background reference image, and the pixel value calculation result of the other parts is 0, that is, the image of the part corresponding to the target background occlusion area of ​​the reference image in the background reference image is extracted to obtain the target image.

[0102] In this embodiment, a binary mask is generated based on the target background occlusion area of ​​the reference image, and the image of the portion corresponding to the target background occlusion area in the captured image other than the reference image is extracted through the binary mask. This method can quickly obtain the target image with fewer operation steps and less resource overhead.

[0103] In one embodiment, in order to remove background occluders such as pedestrians, vehicles, and animals in the target background, the moving target background occluders can be first screened out, and then the background image without the target background occluders can be restored to improve the accuracy of the restored background image. Figure 4 As shown, step 102 specifically includes the following steps:

[0104] Step 401 , using a preset image detection algorithm, detect background occlusions in a plurality of captured images, and determine the area where the background occlusions are located as the background occlusion area.

[0105] In implementation, the terminal can identify background obstructions in each captured image, such as people, vehicles, animals, etc., through a preset image detection algorithm. The image detection algorithm can adopt R-CNN, YOLO, SSD and other algorithms, which are not limited in the embodiments of the present application.

[0106] Step 402 : determining a moving target background occluder from among the detected background occluders according to the background occluder regions of the background occluders in the plurality of captured images.

[0107] In implementation, the terminal can detect whether the position of the background occluder in the acquired captured image moves by using a preset motion detection algorithm to determine the target background occluder that moves. The motion detection algorithm can use a target tracking algorithm, an area intersection and union ratio calculation method, and the like.

[0108] Step 403 , extracting the image outside the background occlusion area of ​​the target background occlusion object to obtain a background reference image corresponding to each captured image.

[0109] In implementation, after the terminal determines the target background occluder in the captured image, the image outside the background occlusion area of ​​the target background occluder is extracted from the captured image through an image extraction strategy to obtain a background reference image corresponding to the captured image. The extraction strategy may use image segmentation techniques such as binary masking. Optionally, if there are multiple target background occluders in the captured image, the images outside the background occlusion areas of the multiple background occluders are extracted to obtain a background reference image corresponding to the captured image.

[0110] In this embodiment, a target tracking algorithm or an area intersection ratio calculation method is used to detect whether each background occluder in the captured image moves during the image capture period, and the target background occluder that moves during the image capture period is determined, and then the image other than the target background occluder is extracted to obtain a background reference image. This method first screens out the target background occluder that moves, and then restores the background image without the target background occluder, thereby improving the accuracy of the restored background image.

[0111] In one embodiment, Figure 5 As shown, step 402 specifically includes the following steps:

[0112] Step 501, for each background occlusion area contained in the reference image, calculate the area intersection and union ratio of the background occlusion area in each captured image except the reference image and the background occlusion area of ​​the background occlusion object in the reference image, and determine the maximum value of the corresponding area intersection and union ratio of each captured image.

[0113] In implementation, the terminal may calculate the area intersection and union ratio of the background occlusion area of ​​each background occlusion area in the captured images other than the reference image and the background occlusion area of ​​each background occlusion area in the reference image based on the background occlusion area of ​​each background occlusion object in the identified captured image, and determine the maximum value of the area intersection and union ratio. Specifically, for the reference image I b The i-th background occluder in , its corresponding background occlusion area is The t-th captured image I except the reference image t The background occlusion area of ​​each background occluder in Calculate the area intersection-over-union ratio and determine the maximum value of the area intersection-over-union ratio IoU it , the area intersection and union ratio is the largest, that is, the overlap of the two background occluders is the largest. In this way, the maximum value of the background occluder area intersection and union ratio of the i-th background occluder in the reference image is calculated in each captured image to determine whether the i-th background occluder moves.

[0114] Step 502: Calculate the average value of the maximum values ​​of the intersection-over-union ratios of the areas corresponding to each captured image.

[0115] In implementation, the terminal calculates the average value of the maximum values ​​of the area intersection-and-union ratios in each captured image obtained in step 501. Specifically, for the reference image I b The terminal uses the captured image I determined in step 501 to obtain the background occlusion area of ​​the i-th background occlusion object in the image. t The maximum value of the intersection over union (IoU) of the area it Calculate the average The calculation formula is as follows,

[0116]

[0117] Wherein, ∑ represents summation; T represents the total number of captured images.

[0118] Step 503: If the average value is less than a preset threshold, the background occluder is determined as a target background occluder.

[0119] In implementation, the terminal uses the average value obtained in step 502 The average value is compared with the preset threshold. If it is less than the preset threshold, it is considered that the background occluder has moved during the image capture and is determined as the target background occluder. In one example, the preset threshold can be 0.7. When it is less than 0.7, the reference image I b The i-th background occluder in has moved during the image capture period.

[0120] In this embodiment, whether the background obstruction moves during shooting is detected by simply calculating the average value of the area intersection-to-union ratio and comparing it with a preset threshold. The method is simple and effective, and the processing speed is fast.

[0121] In one embodiment, the specific step of determining the local background image in step 104 includes: calculating the average pixel value of each pixel in the extracted target image to obtain the local background image corresponding to the target background occlusion area.

[0122] In the implementation, the terminal obtains the pixel values ​​of the pixels at the same position in each target image according to the extracted target image, calculates the average pixel value of the pixel, and uses it as the pixel value of the corresponding pixel in the target background occlusion area in the reference image, that is, the local background image corresponding to the target background occlusion area is obtained. The local background image is added to the background reference image corresponding to the reference image to obtain the background image of the target background.

[0123] In one example, a background image of a target background is generated. The specific formula is as follows:

[0124]

[0125] Among them, I t represents the tth captured image; M t I represents the first image mask corresponding to the t-th captured image; b represents the reference image; M b represents the first image mask corresponding to the reference image; (1-M b) represents the second image mask corresponding to the reference image; ∑ represents image summation, that is, the pixel values ​​of the pixels at the same position in the image are added together; ∈ is a positive constant with a value less than 0.1, in order to avoid the situation where the denominator is 0. Optionally, ∈ takes a value of 0.01.

[0126] formula The local background image can be calculated, formula M b ⊙I b The background reference image corresponding to the reference image can be calculated, and the two images are added to obtain the background reference image based on the reference image I b Generated background image

[0127] In an embodiment, the method further comprises the step of determining a reference image:

[0128] Implementation method 1: Calculate the total area of ​​the background occlusion region in each captured image; determine the captured image with the smallest total area of ​​the background occlusion region as the reference image.

[0129] In implementation, after the terminal identifies the background obstructions in the captured image, it calculates the total area of ​​the background obstructions in the captured image based on the area of ​​the background obstructions where each background obstruction is located, and determines the captured image with the smallest total area of ​​the background obstructions as the reference image.

[0130] In this embodiment, by selecting the captured image with the smallest area blocked by the background obstruction as the reference image, fewer pixels are involved in pixel calculation, resource overhead is minimized, and the background image restoration effect is better.

[0131] Implementation method 2: Calculate the total number of background occluders in each captured image based on the background occluded area in each captured image, and determine the captured image with the least total number of background occluders as the reference image.

[0132] In implementation, after the terminal identifies the background occluders in the captured image, it calculates the total number of the background occluders in the captured image, and determines the captured image with the least total number of background occluders as the reference image.

[0133] In this embodiment, by selecting a captured image with the least number of background obstructions as the reference image, the number of image splicing locations is minimized, and the generated background image is relatively more natural.

[0134] The present application also provides an example of a method for generating a background image. Specifically, the method is described in detail by taking the calculation of the pixel value of a pixel point p(x, y) with coordinates (x, y) in a local background image as an example.

[0135] First, a camera with a fixed lens is used to record the target background. The terminal extracts video frames from the recorded video segment. For the convenience of demonstration calculation, 5 video frames are extracted in this example, that is, 5 captured images I are obtained. t , where the value of t is 1 to 5, and the order of the captured images is generally sorted according to the shooting time. In this example, the background occlusion object is only the human body. An image detection algorithm such as YOLO-v5 (v5 is the version number of the YOLO algorithm) is used to detect the human body in each of the above captured images. The human body area is marked by a detection frame, and the human body area is the background occlusion area. Calculate the number of detection frames for detecting the human body in each captured image. In this example, the number of detection frames of the first captured image is calculated to be the least, so the first captured image is determined as the reference image I. b , where b = 1. Reference image I b The human body area in is the target background occlusion area. The target background occlusion area is the area where a local background image needs to be generated. Therefore, the pixel point p(x, y) is in the target background occlusion area.

[0136] According to the above human body detection results, the captured image I is generated according to the preset rules. t The corresponding first image mask M t , in this example, the first image mask M 1 To M 5 The pixel values ​​of the pixel points p(x, y) are 0, 0, 1, 1, 1 respectively. At the same time, the reference image I can be generated according to the preset rules based on the above human body detection results. b The second image mask can also be obtained by using the first image mask M corresponding to the reference image. b Converted to M b The pixel value of 1 is converted to 0, and the pixel value of 0 is converted to 1, and the second image mask can be obtained, which can be expressed as (1-M b ), the pixel value of the pixel point p(x,y) in the second image mask is 1.

[0137] Next, the first image mask M t The corresponding captured image I t Multiply, that is, multiply the pixel values ​​of the pixels at the same position to obtain the captured image I t The corresponding background reference image is expressed as M t ⊙I t In this example, the calculated image I 1 to I 5 The pixel values ​​of the corresponding pixel point p(x,y) in the background reference image are 0, 0, p 3 , p 4 , p 5 . Where p 3With the captured image I 3 The pixel value of this pixel is consistent, p 4 and p 5 Same reason.

[0138] Again, the second image mask is combined with the reference image I b Other captured images I t (t≠b) multiply the corresponding background reference image to obtain other captured images I t (t≠b) corresponds to the target image, the formula is expressed as (1-M b )⊙M t ⊙I t , where t≠b, since b=1 here, t≠1. In this example, the calculation is performed on the captured image I 2 to I 5 The pixel values ​​of the corresponding pixel points p(x,y) in the target image are 0, p 3 , p 4 , p 5 .

[0139] Finally, according to the pixel values ​​of the pixels at the same position in each target image, the average pixel value of the pixels at that position is calculated, that is, the pixel value of the pixels at the same position in the local background image is obtained. The formula is expressed as ∈ is set to 0.01 to avoid the denominator being 0. In this example, the pixel value of the pixel point p(x,y) in the local background image is:

[0140]

[0141] It should be understood that although Figure 1-5 The steps in the flowchart are shown in sequence 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 restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-5 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0142] In one embodiment, Figure 6 As shown, a background image generation device is provided, comprising: an acquisition module, a first extraction module, a second extraction module and a synthesis module, wherein:

[0143] An acquisition module 601 is used to acquire a plurality of captured images including a target background;

[0144] A first extraction module 602 is used to identify background occlusion areas in a plurality of captured images, and extract images outside the background occlusion areas to obtain a background reference image corresponding to each captured image;

[0145] A second extraction module 603 is used to extract a target image of a target background occlusion area from background reference images corresponding to captured images other than the reference image, according to the target background occlusion area corresponding to the reference image in the plurality of captured images;

[0146] The synthesis module 604 is used to determine the local background image corresponding to the target background occlusion area according to the extracted target image, and synthesize the local background image with the background reference image corresponding to the benchmark image to obtain the background image of the target background.

[0147] In another embodiment, the first extraction module 602 is specifically used for:

[0148] A first image mask corresponding to each captured image is generated according to multiple captured images and the background occlusion area; and an image outside the background occlusion area is extracted from the multiple captured images through the first image mask to obtain a background reference image corresponding to each captured image.

[0149] In another embodiment, the second extraction module 603 is specifically used for:

[0150] A second image mask is generated according to a reference image in a plurality of captured images and a target background occlusion area corresponding to the reference image; and a target image is extracted from a background reference image corresponding to the captured images other than the reference image through the second image mask.

[0151] In another embodiment, the first extraction module 602 is specifically used for:

[0152] Through a preset image detection algorithm, background occluders are detected in multiple captured images, and the area where the background occluders are located is determined as the background occlusion area; based on the background occlusion areas of the background occluders in the multiple captured images, the moving target background occluders are determined among the detected background occluders; the images outside the background occlusion areas of the target background occluders are extracted to obtain the background reference image corresponding to each captured image.

[0153] In another embodiment, the first extraction module 602 is specifically used for:

[0154] For the background occlusion area of ​​each background occlusion object contained in the baseline image, calculate the area intersection and union ratio of the background occlusion area in each captured image except the baseline image and the background occlusion area of ​​the background occlusion object in the baseline image, and determine the maximum value of the corresponding area intersection and union ratio of each captured image; calculate the average value of the maximum value of the corresponding area intersection and union ratio of each captured image; if the average value is less than a preset threshold, determine the background occlusion object as the target background occlusion object.

[0155] In another embodiment, the synthesis module 604 is specifically configured to:

[0156] The average pixel value of each pixel in the extracted target image is calculated to obtain the local background image corresponding to the target background occlusion area.

[0157] In another embodiment, the apparatus further comprises:

[0158] The first determination module is used to calculate the total area of ​​the background occlusion region in each captured image; and determine the captured image with the smallest total area of ​​the background occlusion region as the reference image.

[0159] In another embodiment, the apparatus further comprises:

[0160] The second determination module is used to calculate the total number of background occlusion objects in each captured image according to the background occlusion area in each captured image; and determine the captured image with the least total number of background occlusion objects as the reference image.

[0161] The specific definition of the background image generation device can be found in the definition of the background image generation method in the above text, which will not be repeated here. Each module in the above-mentioned background image generation device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0162] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 7As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer 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 communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for generating a background image is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0163] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0164] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0165] In one embodiment, a computer-readable storage medium is further provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0166] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database 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 memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0167] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, 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.

[0168] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for generating a background image, characterized in that: The method comprises: Acquire multiple captured images including target background; Using a preset image detection algorithm, detecting background obstructions in the plurality of captured images, and determining an area where the background obstructions are located as a background obstruction area; Determine a moving target background occluder among the detected background occluders according to a background occluder area of ​​the background occluder in the plurality of captured images; Extracting images outside the background occlusion area of ​​the target background occlusion object to obtain a background reference image corresponding to each of the captured images; According to the target background occlusion area corresponding to the reference image in the multiple captured images, extracting the target image of the target background occlusion area from the background reference images corresponding to the captured images other than the reference image; A local background image corresponding to the target background occlusion area is determined according to the extracted target image, and the local background image is synthesized with a background reference image corresponding to the benchmark image to obtain a background image of the target background.

2. The method according to claim 1, characterized in that The extracting the image outside the background occlusion area to obtain the background reference image corresponding to each of the captured images includes: Generate a first image mask corresponding to each of the captured images according to the multiple captured images and the background occlusion area; The image outside the background occlusion area is extracted from the multiple captured images through the first image mask to obtain a background reference image corresponding to each of the captured images.

3. The method according to claim 1, characterized in that The step of extracting the target image of the target background occlusion area from background reference images corresponding to captured images other than the reference image according to the target background occlusion area corresponding to the reference image in the multiple captured images comprises: generating a second image mask according to a reference image in the plurality of captured images and a target background occlusion area corresponding to the reference image; The target image is extracted from the background reference image corresponding to the captured image other than the reference image through the second image mask.

4. The method according to claim 1, characterized in that: The step of determining a moving target background occluder among the detected background occluders according to the background occluder area of ​​the background occluder in the plurality of captured images includes: For each background occlusion area of ​​the background occlusion object contained in the reference image, calculate the area intersection-and-union ratio of the background occlusion area in each captured image other than the reference image to the background occlusion area of ​​the background occlusion object in the reference image, and determine the maximum value of the area intersection-and-union ratios corresponding to each captured image; Calculating an average value of the maximum values ​​of the intersection-and-union ratios of the areas corresponding to each captured image; If the average value is less than a preset threshold, the background occluder is determined as a target background occluder.

5. The method according to claim 1, characterized in that The step of determining the local background image corresponding to the target background occlusion area according to the extracted target image includes: The average pixel value of each pixel in the extracted target image is calculated to obtain a local background image corresponding to the target background occlusion area.

6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Calculating the total area of ​​the background occlusion region in each of the captured images; The captured image with the smallest total area of ​​the background occlusion region is determined as the reference image.

7. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Calculating the total number of background occlusion objects in each of the captured images according to the background occlusion area in each of the captured images; The captured image with the least total number of background obstructions is determined as the reference image.

8. A background image generating device, characterized in that: The device comprises: An acquisition module, used for acquiring a plurality of captured images including a target background; A first extraction module is used to detect background occluders in the multiple captured images by using a preset image detection algorithm, and determine the area where the background occluders are located as the background occlusion area; determine the target background occluders that have moved among the detected background occluders according to the background occlusion areas of the background occluders in the multiple captured images; and extract images outside the background occlusion area of ​​the target background occluders to obtain a background reference image corresponding to each of the captured images; A second extraction module, configured to extract a target image of the target background occlusion area from background reference images corresponding to captured images other than the reference image, according to the target background occlusion area corresponding to the reference image in the multiple captured images; The synthesis module is used to determine the local background image corresponding to the target background occlusion area according to the extracted target image, and synthesize the local background image with the background reference image corresponding to the benchmark image to obtain the background image of the target background.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.