Virtual object shadow generation method and device, equipment, storage medium and product

CN115761107BActive Publication Date: 2026-10-20BIGO TECH PTE LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211430576.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-15
Publication Date
2026-10-20
Estimated Expiration
2042-11-15

AI Technical Summary

Technical Problem

[0004]本申请实施例提供虚拟对象阴影生成方法、装置、设备、存储介质及产品,以解决相关技术中通过人工生成阴影时,存在阴影生成效率和生成质量较差的技术问题,以提高阴影的生成效率和生成质量

Benefits of technology

[0020]本申请实施例通过基于所述待处理虚拟对象图像生成第一上衣掩膜图像和第一阴影掩膜图像,并将第一上衣掩膜图像和第一阴影掩膜图像输入到阴影生成模型,由阴影生成模型根据第一上衣掩膜图像和第一阴影掩膜图像生成第一阴影图像,并基于第一阴影图像和待处理虚拟对象图像生成目标虚拟对象图像,本方案通过训练好的阴影生成模型在待处理虚拟对象图的阴影掩膜图像上准确生成第一阴影图像,并将第一阴影图像准确地添加在待处理虚拟对象图像上,不需要人工在待处理图像上添加阴影,有效提高阴影的生成效率和生成质量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115761107B_ABST
    Figure CN115761107B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a virtual object shadow generation method, device, equipment, storage medium and product. The technical scheme provided by the embodiment of the present application generates a first upper garment mask image and a first shadow mask image based on the to-be-processed virtual object image, inputs the first upper garment mask image and the first shadow mask image into a shadow generation model, generates a first shadow image according to the first upper garment mask image and the first shadow mask image by the shadow generation model, and generates a target virtual object image based on the first shadow image and the to-be-processed virtual object image. According to the scheme, the trained shadow generation model accurately generates a first shadow image on the shadow mask image of the to-be-processed virtual object image, and accurately adds the first shadow image on the to-be-processed virtual object image, so that manual addition of a shadow on the to-be-processed image is not needed, and the generation efficiency and generation quality of the shadow are effectively 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 methods, apparatus, devices, storage media, and products for generating shadows of virtual objects. Background Technology

[0002] To enhance the realism of images, shadows are often added to improve their three-dimensionality. For example, in e-commerce content generation, it's common to create product images by placing clothing images on virtual objects (such as models). Adding shadows at the seams of the clothing on these virtual objects can improve the realism of the garments.

[0003] Realism is crucial for product images, and shadows can effectively enhance their three-dimensionality and realism. Currently, shadows in product images are generally generated manually, which results in poor shadow generation efficiency and quality. Summary of the Invention

[0004] This application provides a method, apparatus, device, storage medium, and product for generating virtual object shadows, in order to solve the technical problem of poor shadow generation efficiency and quality when shadows are generated manually in related technologies, and to improve the shadow generation efficiency and quality.

[0005] In a first aspect, embodiments of this application provide a method for generating virtual object shadows, comprising:

[0006] Obtain the image of the virtual object to be processed;

[0007] Generate a first upper garment mask image and a first shadow mask image based on the virtual object image to be processed;

[0008] The first shirt mask image and the first shadow mask image are input into the trained shadow generation model, and the shadow generation model generates a first shadow image based on the first shirt mask image and the first shadow mask image.

[0009] A target virtual object image is generated based on the first shadow image and the virtual object image to be processed.

[0010] In a second aspect, embodiments of this application provide a virtual object shadow generation apparatus, including an image acquisition module, a mask extraction module, a shadow generation module, and a target generation module, wherein:

[0011] The image acquisition module is configured to acquire an image of the virtual object to be processed;

[0012] The mask extraction module is configured to generate a first upper garment mask image and a first shadow mask image based on the virtual object image to be processed;

[0013] The shadow generation model is configured to input the first upper garment mask image and the first shadow mask image into the trained shadow generation model, and generate a first shadow image based on the first upper garment mask image and the first shadow mask image through the shadow generation model;

[0014] The target generation module is configured to generate a target virtual object image based on the first shadow image and the virtual object image to be processed.

[0015] In a third aspect, embodiments of this application provide a virtual object shadow generation device, including: a memory and one or more processors;

[0016] The memory is used to store one or more programs;

[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement the virtual object shadow generation method as described in the first aspect.

[0018] In a fourth aspect, embodiments of this application provide a non-volatile storage medium for storing computer-executable instructions, which, when executed by a computer processor, are used to perform the virtual object shadow generation method as described in the first aspect.

[0019] In a fifth aspect, embodiments of this application provide a computer program product comprising a computer program stored in a computer-readable storage medium, wherein at least one processor of the device reads from the computer-readable storage medium and executes the computer program, causing the device to perform the virtual object shadow generation method as described in the first aspect.

[0020] This application embodiment generates a first upper garment mask image and a first shadow mask image based on the virtual object image to be processed. The first upper garment mask image and the first shadow mask image are then input into a shadow generation model. The shadow generation model generates a first shadow image based on the first upper garment mask image and the first shadow mask image. Based on the first shadow image and the virtual object image to be processed, a target virtual object image is generated. This solution accurately generates the first shadow image on the shadow mask image of the virtual object image to be processed through a trained shadow generation model, and accurately adds the first shadow image to the virtual object image to be processed. There is no need to manually add shadows to the image to be processed, which effectively improves the efficiency and quality of shadow generation. Attached Figure Description

[0021] Figure 1 This is a flowchart of a virtual object shadow generation method provided in an embodiment of this application;

[0022] Figure 2 This is a flowchart of another virtual object shadow generation method provided in the embodiments of this application;

[0023] Figure 3 This is a schematic diagram of a first shadow mask image generation provided in an embodiment of this application;

[0024] Figure 4 This is a schematic diagram of the structure of a virtual object shadow generation device provided in an embodiment of this application;

[0025] Figure 5 This is a schematic diagram of the structure of a virtual object shadow generation device provided in an embodiment of this application. Detailed Implementation

[0026] To make the objectives, technical solutions, and advantages of this application clearer, specific embodiments of this application will be described in further detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely for explaining this application and not for limiting it. It should also be noted that, for ease of description, only the parts relevant to this application are shown in the drawings, not all of them. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but additional steps not included in the drawings may also be present. The above processes can correspond to methods, functions, procedures, subroutines, subroutines, etc.

[0027] The proposed method for generating virtual object shadows can be applied to shadow generation in virtual object images to enhance their three-dimensionality and realism. For example, in AI (artificial intelligence) e-commerce material generation scenarios, a virtual object image is generated by placing a clothing image (including top and bottom images) on a designated virtual object (e.g., a model). Shadows are added at the seams between the top and bottom of the virtual object image. The aim is to generate a first shadow image based on a trained shadow generation model using a first top mask image and a first shadow mask image on the virtual object image to be processed. Then, a target virtual object image is generated based on the first shadow image and the virtual object image to be processed, achieving automatic and efficient shadow generation on the virtual object image to be processed. Traditional shadow generation typically involves manually adding shadows at the seams after generating the virtual object image. This manual method is inefficient and struggles to guarantee shadow generation quality. Therefore, this application provides a virtual object shadow generation method to address the problem of low efficiency in existing virtual object image shadow generation techniques.

[0028] Figure 1 A flowchart of a virtual object shadow generation method provided in this application embodiment is given. The virtual object shadow generation method provided in this application embodiment can be executed by a virtual object shadow generation device, which can be implemented by hardware and / or software and integrated into a virtual object shadow generation device.

[0029] The following description uses the virtual object shadow generation device to perform the virtual object shadow generation method as an example.

[0030] refer to Figure 1 The method for generating shadows for virtual objects includes:

[0031] S101: Obtain the image of the virtual object to be processed.

[0032] The virtual object image to be processed provided in this solution can be understood as a virtual object image that needs to have shadows added at the junction of the upper and lower garments (upper and lower garments). For example, a shadow of a corresponding shape is added to the top of the lower garment based on the shape of the bottom (hem) of the upper garment to improve the three-dimensionality and realism of the virtual object image to be processed. The lower garment can be clothing worn by the lower body of the virtual object (such as pants, skirt, etc.) or limbs of the virtual object (such as arms, legs, etc.).

[0033] The image of the virtual object to be processed can be obtained by rendering a virtual object with a top and bottom added. Currently, adding the top and bottom to the virtual object is done independently, and the addition of the top and bottom does not interfere with each other. However, after adding the top and bottom to the virtual object, the sense of separation between the top and bottom is quite serious, and the sense of realism is not strong. It is necessary to add appropriate shadows at the junction of the top and bottom to transition the junction of the top and bottom and improve the three-dimensionality and realism of the virtual object image.

[0034] For example, the image of the virtual object to be processed to which shadows need to be added is obtained. The image of the virtual object to be processed can be obtained at the same time as generating the image of the virtual object to be processed, or it can be obtained all at once after generating multiple images of the virtual object to be processed. For example, different images of the virtual object to be processed can be generated according to different combinations of tops and bottoms and different rendering angles, and then these images of the virtual object to be processed can be obtained all at once for shadow generation processing.

[0035] S102: Generate a first shirt mask image and a first shadow mask image based on the image of the virtual object to be processed.

[0036] For example, when acquiring the image of the virtual object to be processed for which shadows need to be generated, a first upper garment mask image and a first shadow mask image are determined in the image of the virtual object to be processed.

[0037] It should be explained that the first upper garment mask image provided in this solution can be understood as an image including the mask area corresponding to the upper garment in the virtual object image to be processed, and the first shadow mask image can be understood as an image including the mask area where a shadow needs to be added to the virtual object image to be processed. For example, if the virtual object image to be processed includes image ranges corresponding to the upper garment and the lower garment, the upper garment mask image includes the image corresponding to the upper garment range, and the shadow mask image includes the image corresponding to the range where the upper garment and the lower garment connect (e.g., the range where the top of the lower garment connects to the upper garment).

[0038] S103: Input the first upper garment mask image and the first shadow mask image into the trained shadow generation model, and generate the first shadow image based on the first upper garment mask image and the first shadow mask image through the shadow generation model.

[0039] The shadow generation model provided in this solution is used to generate a first shadow image based on the input upper garment mask image and shadow mask image. The shadow generation model can be built based on a neural learning network and configured in the virtual object shadow generation device provided in this application embodiment after training.

[0040] For example, after determining the first upper garment mask image and the first shadow mask image of the virtual object image to be processed, the first upper garment mask image and the first shadow mask image are input into the shadow generation model. The shadow generation model generates a first shadow image based on the first upper garment mask image and the first shadow mask image. This first shadow image is the image that needs to be added to the virtual object image to be processed (for example, adding the first shadow image portion of the first shadow image to the position of the shadow mask image corresponding to the virtual object image to be processed).

[0041] S104: Generate the target virtual object image based on the first shadow image and the virtual object image to be processed.

[0042] For example, the first shadow image output by the shadow generation model is obtained, and a target virtual object image is generated based on the first shadow image and the virtual object image to be processed. At this time, the shadow corresponding to the first shadow image is added to the joint between the top and bottom in the target virtual object image.

[0043] In one possible embodiment, the image sizes of the first upper garment mask image, the first shadow mask image, and the first shadow image provided by this solution are consistent with the image size of the virtual object image to be processed. The position of the shadow generated in the first shadow image corresponds to the position of the shadow mask area in the first shadow mask image relative to the virtual object image to be processed. After generating the first shadow image, the first shadow image can be superimposed on the virtual object image to be processed, thereby generating a shadow on the virtual object image to be processed.

[0044] The above-described method generates a first shirt mask image and a first shadow mask image based on the image of the virtual object to be processed. These images are then input into a shadow generation model, which generates a first shadow image based on the first shirt mask image and the first shadow mask image. Finally, a target virtual object image is generated based on the first shadow image and the image of the virtual object to be processed. This method accurately generates the first shadow image on the shadow mask image of the virtual object image to be processed using a trained shadow generation model, and accurately adds the first shadow image to the image of the virtual object to be processed. This eliminates the need for manual addition of shadows to the image to be processed, effectively improving the efficiency and quality of shadow generation.

[0045] Based on the above embodiments, Figure 2 A flowchart of another virtual object shadow generation method provided in this application embodiment is given, which is a concretization of the above-described virtual object shadow generation method. (Reference) Figure 2 The method for generating shadows for virtual objects includes:

[0046] S201: Obtain the image of the virtual object to be processed.

[0047] S202: Perform human body analysis processing on the image of the virtual object to be processed, and generate a first upper garment mask image and a first lower garment mask image based on the human body analysis processing results.

[0048] For example, after acquiring the image of the virtual object to be processed, human parsing is performed on the image to determine the regions corresponding to the upper garment and lower garment in the image, and the human parsing result corresponding to the image is determined based on the regions corresponding to the upper garment and lower garment. The human parsing result records the mask regions of the upper garment and lower garment in the image to be processed.

[0049] Furthermore, a first upper garment mask image is generated based on the upper garment mask region corresponding to the human body analysis processing result of the virtual object image to be processed, and a first lower garment mask image is generated based on the lower garment mask region corresponding to the human body analysis processing result of the virtual object image to be processed. The image sizes of the first upper garment mask image and the first lower garment mask image are consistent with the image size of the virtual object image to be processed.

[0050] S203: Determine the first shadow mask image based on the first upper garment mask image and the first lower garment mask image.

[0051] For example, a first shadow mask image is generated based on a first upper garment mask image and a first lower garment mask image. The first shadow mask image has the same image size as the virtual object image to be processed, and the corresponding shadow mask region in the first shadow mask image is located on the area where the upper and lower garments connect in the virtual object image to be processed.

[0052] This solution performs human body analysis on the image of the virtual object to be processed. Based on the results of the human body analysis, it accurately generates a first upper garment mask image and a first lower garment mask image. The first upper garment mask image and the first lower garment mask image accurately determine the connection area between the upper and lower garments in the image of the virtual object to be processed, thereby generating a first shadow mask image that accurately reflects the position where a shadow needs to be added. The generated shadow position is more consistent with the connection between the upper and lower garments in the image of the virtual object to be processed, effectively improving the quality of shadow generation.

[0053] In one possible embodiment, such as Figure 3 As shown in the schematic diagram of generating a first shadow mask image, the virtual object shadow generation method provided in this solution, when determining the first shadow mask image based on the first upper garment mask image and the first lower garment mask image, includes:

[0054] S2031: Perform dilation processing on the first upper garment mask image.

[0055] S2032: The intersection of the first upper garment mask image after dilation processing and the first lower garment mask image is determined as the first shadow mask image.

[0056] For example, after obtaining the first upper garment mask image and the first lower garment mask image, the first upper garment mask image is dilated, and the intersection of the dilated first upper garment mask image and the first lower garment mask image is determined. The area corresponding to the intersection is the area where a shadow needs to be added, and a first shadow mask image is generated based on the intersection. That is, a first shadow mask image containing the intersection and whose image size is consistent with the image size of the virtual object image to be processed is generated.

[0057] Optionally, when performing dilation processing on the first upper garment mask image, it can be based on a set image processing algorithm or software. For example, the image dilation function provided by OpenCV image processing software (e.g., using a kernel of size 11 iterating 3 times) can be used to dilate the first upper garment mask image, or the dilation (magnification) factor can be set to dilate the first upper garment mask image. Optionally, for different types of upper and lower garment connection positions (e.g., the connection position between the upper garment and pants, or the upper garment and limbs), different dilation methods, kernel sizes, number of iterations, or dilation factors can be used to improve the adaptability of the first shadow mask image generation.

[0058] This solution dilates the first upper garment mask image and generates a first shadow mask image based on the intersection of the dilated first upper garment mask image and the first lower garment mask image. This accurately generates a first shadow mask image that reflects the area where shadows need to be added, and the generated shadow position is more consistent with the connection between the upper and lower garments in the virtual object image to be processed, effectively improving the quality of shadow generation.

[0059] S204: Input the first upper garment mask image and the first shadow mask image into the trained shadow generation model, and generate the first shadow image based on the first upper garment mask image and the first shadow mask image through the shadow generation model.

[0060] For example, the first upper garment mask image and the first shadow mask image obtained above are input into a pre-configured shadow generation model, and the shadow generation model generates a first shadow image based on the first upper garment mask image and the first shadow mask image.

[0061] In one possible embodiment, the shadow generation model provided by this solution is trained based on shadow data pairs. The shadow data pairs provided by this solution include a first sample image and a second sample image, wherein the first sample image is obtained by performing shadow removal processing on the shadow at the junction of the upper and lower garments in the second sample image using a trained shadow removal model.

[0062] For example, before training the shadow generation model, a set number of shadow data pairs are collected. Second sample images showing shadows at the seam between the top and bottom garments are collected, and each second sample image is input into the trained shadow removal model. The shadow removal model removes the shadows at the seam between the top and bottom garments in the second sample images, obtaining a first sample image corresponding to each second sample image. Shadow data pairs are then constructed based on the corresponding first and second sample images. It can be understood that the difference between the first and second sample images in a shadow data pair lies in the seam between the top and bottom garments; the second sample image has shadows at the seam between the top and bottom garments, while the shadows at the seam between the top and bottom garments are removed in the first sample image.

[0063] After collecting a set number of shadow data pairs, the shadow generation model is trained using these data pairs until a set shadow generation accuracy is achieved (which can be constrained using a set loss function). For example, the shadow generation model is trained using the third shirt mask image and the third shadow mask image from the first sample image as input, where the output of the shadow generation model is the second shadow image. The second shadow image and the first sample image are combined (e.g., by performing a multiply blending operation) to obtain a training output image with a shadow added at the seam between the shirt and the upper garment. The shadow generation model is then constrained using the second sample image and the training output image based on a loss function (loss constraint). The third shirt mask image, the third shadow mask image, the second shadow image, and the first and second sample images all have the same image size.

[0064] Specifically, the third upper garment mask image and the third lower garment mask image are obtained by performing human body analysis on the first sample image. The third shadow mask image is determined by dilating the third upper garment mask image and then intersecting it with the third lower garment mask image. This scheme trains the shadow generation model using shadow data composed of the first and second sample images, resulting in a more accurate shadow generation model. It eliminates the need for manually adding shadows to the seam between the upper and lower garments of the virtual object image, effectively improving the efficiency and quality of shadow generation.

[0065] In one possible embodiment, the shadow generation model can be optimized by applying global constraint functions (e.g., global loss function, L1 loss function, Vgg loss function) to the shadow data pairs and local constraint functions (e.g., L1 loss function, Vgg loss function) to the shadow regions. The shadow regions provided in this scheme are determined based on a third shadow mask image of the shadow data pairs. For example, the rectangular region enclosed by the leftmost (leftmost coordinate of the shadow region), rightmost (rightmost coordinate of the shadow region), topmost (topmost coordinate of the shadow region), and bottommost (bottommost coordinate of the shadow region) positions corresponding to the third shadow mask image is used as the shadow region. This scheme processes the shadow generation model through global and local constraint functions, improving the smoothness of the shadows generated at the shadow regions within the shadow mask regions, effectively improving the efficiency and quality of adding shadows to the virtual object images to be processed.

[0066] In one possible embodiment, the shadow removal model provided by this solution is trained based on a second shadow mask image corresponding to a third sample image where no shadow exists at the seam between the upper and lower garments. Specifically, the fourth upper garment mask image and the fourth lower garment mask image can be determined by performing human body analysis on the collected third sample image. The fourth upper garment mask image is then dilated, and the second shadow mask image is determined based on the intersection of the dilated fourth upper garment mask image and the fourth lower garment mask image.

[0067] For example, a third sample image without shadows at the seam between the top and bottom garments is collected. Human body analysis is performed on the third sample image to determine the fourth top garment mask region and the fourth bottom garment mask region. A fourth top garment mask image and a fourth bottom garment mask image are then generated based on these regions. Further, the fourth top garment mask image is dilated, and a second shadow mask image is generated based on the intersection of the dilated fourth top garment mask image and the fourth bottom garment mask image. The image sizes of the fourth top garment mask image, the fourth bottom garment mask image, and the second shadow mask image are consistent with the image sizes of the three sample images.

[0068] Furthermore, the second shadow mask image is used as input to the shadow erasure model, and the third sample image is used as the target image to train the shadow erasure model. Optionally, the shadow erasure model can be optimized by applying global constraint functions (e.g., global loss function, L1 loss function, Vgg loss function) to the third sample image and local constraint functions (e.g., L1 loss function, Vgg loss function) to the second shadow mask image. Processing the shadow erasure model with global and local constraint functions effectively improves the efficiency and quality of shadow erasure in the image. After training the shadow erasure model, first sample data containing shadows at the seam of the upper and lower garments can be collected and input into the shadow erasure model. The shadow erasure model then analyzes and processes the first sample data and outputs corresponding second sample data for erasing the shadows, thereby constructing corresponding shadow data pairs and improving the collection efficiency of shadow data pairs.

[0069] S205: Perform multiply blending on the first shadow image and the virtual object image to be processed to generate the target virtual object image.

[0070] For example, the first shadow image output by the shadow generation model and the image of the virtual object to be processed are processed using a multiply blending mode to generate the target virtual object image. This solution uses a multiply blending mode to overlay the first shadow image onto the image of the virtual object to be processed. Without changing the color of the virtual object image used as the base image, the shadow graphic corresponding to the first shadow mask area is overlaid on the image of the virtual object to be processed. This ensures the color representation of the target virtual object image while providing a smoother transition of the shadow within the target virtual object image, thus improving the quality of shadow generation.

[0071] In one possible embodiment, the first shadow image provided by this solution is a single-channel image (i.e., a grayscale image), and the virtual object image to be processed is a three-channel image (e.g., an RGB image). Correspondingly, before performing multiply processing on the first shadow image and the virtual object image to be processed, the virtual object shadow generation method provided by this solution further includes: converting the first shadow image into a three-channel image. For example, the first shadow image is concatenated with itself to obtain a three-channel first shadow image. For instance, when the color value corresponding to the single-channel first shadow image is A, the color value corresponding to the three-channel first shadow image is (A, A, A). Correspondingly, when training the shadow generation model, its output second shadow image is also configured as a single-channel image to reduce the learning difficulty of the shadow generation model for the shadow image and improve the learning accuracy and efficiency of the shadow generation model for the shadow image.

[0072] The above-described method generates a first shirt mask image and a first shadow mask image based on the image of the virtual object to be processed. These images are then input into a shadow generation model, which generates a first shadow image based on them. Finally, based on the first shadow image and the image of the virtual object to be processed, a target virtual object image is generated. This method uses a trained shadow generation model to accurately generate the first shadow image on the shadow mask image of the virtual object image and accurately adds it to the virtual object image, eliminating the need for manual shadow addition and effectively improving shadow generation efficiency and quality. Furthermore, by processing the shadow generation model with global and local constraint functions, the smoothness of the shadows generated in the shadow area within the shadow mask region is improved, further enhancing the efficiency and quality of adding shadows to the virtual object image. Finally, the shadow generation model is trained using shadow data composed of first and second sample images, resulting in a more accurate shadow generation model and further improving shadow generation efficiency and quality.

[0073] Figure 4 This is a schematic diagram of a virtual object shadow generation device provided in an embodiment of this application. (Reference) Figure 4 The virtual object shadow generation device includes an image acquisition module 41, a mask extraction module 42, a shadow generation module 43, and a target generation module 44.

[0074] The image acquisition module 41 is configured to acquire an image of the virtual object to be processed; the mask extraction module 42 is configured to generate a first shirt mask image and a first shadow mask image based on the image of the virtual object to be processed; the shadow generation module 43 is configured to input the first shirt mask image and the first shadow mask image into a trained shadow generation model, and generate a first shadow image based on the first shirt mask image and the first shadow mask image through the shadow generation model; and the target generation module 44 is configured to generate a target virtual object image based on the first shadow image and the image of the virtual object to be processed.

[0075] The above-described method generates a first shirt mask image and a first shadow mask image based on the image of the virtual object to be processed. These images are then input into a shadow generation model, which generates a first shadow image based on the first shirt mask image and the first shadow mask image. Finally, a target virtual object image is generated based on the first shadow image and the image of the virtual object to be processed. This method accurately generates the first shadow image on the shadow mask image of the virtual object image to be processed using a trained shadow generation model, and accurately adds the first shadow image to the image of the virtual object to be processed. This eliminates the need for manual addition of shadows to the image to be processed, effectively improving the efficiency and quality of shadow generation.

[0076] In one possible embodiment, when generating the first upper garment mask image and the first shadow mask image based on the image of the virtual object to be processed, the mask extraction module 42 is configured as follows:

[0077] The image of the virtual object to be processed is subjected to human body analysis processing, and a first upper garment mask image and a first lower garment mask image are generated based on the human body analysis processing results;

[0078] The first shadow mask image is determined based on the first upper garment mask image and the first lower garment mask image.

[0079] In one possible embodiment, when the mask extraction module 42 determines the first shadow mask image based on the first upper garment mask image and the first lower garment mask image, it is configured as follows:

[0080] Dilation processing is applied to the first upper garment mask image;

[0081] The intersection of the first upper garment mask image and the first lower garment mask image after dilation processing is determined as the first shadow mask image.

[0082] In one possible embodiment, when generating the target virtual object image based on the first shadow image and the virtual object image to be processed, the target generation module 44 is configured as follows:

[0083] The first shadow image and the image of the virtual object to be processed are processed with multiply blending to generate the target virtual object image.

[0084] In one possible embodiment, the first shadow image is a single-channel image, and the target generation module 44 is further configured to convert the first shadow image into a three-channel image before performing multiply processing on the first shadow image and the virtual object image to be processed.

[0085] In one possible embodiment, the shadow generation model is trained based on a shadow data pair, which includes a first sample image and a second sample image. The first sample image is obtained by using a trained shadow erasure model to remove the shadow at the junction of the upper and lower garments in the second sample image.

[0086] In one possible embodiment, the shadow removal model is trained based on the second shadow mask image corresponding to the third sample image where there is no shadow at the seam between the top and bottom garments. The model is obtained by performing human body analysis on the collected third sample images to determine the fourth top garment mask image and the fourth bottom garment mask image of the third sample images. The fourth top garment mask image is then dilated, and the second shadow mask image is determined based on the intersection of the dilated fourth top garment mask image and the fourth bottom garment mask image.

[0087] In one possible embodiment, the shadow generation model fine-tunes the global constraint function of the shadow data pair and the local constraint function of the shadow region, which is determined based on a third shadow mask image of the shadow data pair.

[0088] It is worth noting that in the embodiments of the virtual object shadow generation device described above, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of the present invention.

[0089] This application also provides a virtual object shadow generation device, which can integrate the virtual object shadow generation apparatus provided in this application. Figure 5 This is a schematic diagram of the structure of a virtual object shadow generation device provided in an embodiment of this application. (Reference) Figure 5The virtual object shadow generation device includes: an input device 53, an output device 54, a memory 52, and one or more processors 51; the memory 52 is used to store one or more programs; when one or more programs are executed by one or more processors 51, the one or more processors 51 implement the virtual object shadow generation method provided in the above embodiments. The virtual object shadow generation device, apparatus, and computer provided above can be used to execute the virtual object shadow generation method provided in any of the above embodiments, and have corresponding functions and beneficial effects.

[0090] This application also provides a non-volatile storage medium storing computer-executable instructions, which, when executed by a computer processor, are used to perform the virtual object shadow generation method provided in the above embodiments. Of course, the computer-executable instructions provided in this application are not limited to the virtual object shadow generation method provided above, but can also perform related operations in the virtual object shadow generation method provided in any embodiment of this application. The virtual object shadow generation apparatus, device, and storage medium provided in the above embodiments can execute the virtual object shadow generation method provided in any embodiment of this application. Technical details not described in detail in the above embodiments can be found in the virtual object shadow generation method provided in any embodiment of this application.

[0091] Based on the above embodiments, this application also provides a computer program product. The technical solution of this application, in essence or in other words, the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer program product is stored in a storage medium and includes several instructions to cause a computer device, mobile terminal, or processor therein to execute all or part of the steps of the virtual object shadow generation method provided in the various embodiments of this application.

Claims

1. A method for generating shadows for virtual objects, characterized in that, include: Obtain the image of the virtual object to be processed; The process includes generating a first upper garment mask image and a first shadow mask image based on the virtual object image to be processed, wherein: performing human body analysis processing on the virtual object image to be processed, generating a first upper garment mask image and a first lower garment mask image based on the human body analysis processing result, performing dilation processing on the first upper garment mask image, and determining the intersection of the dilated first upper garment mask image and the first lower garment mask image as the first shadow mask image; The first shirt mask image and the first shadow mask image are input into the trained shadow generation model, and the shadow generation model generates a first shadow image based on the first shirt mask image and the first shadow mask image. A target virtual object image is generated based on the first shadow image and the virtual object image to be processed.

2. The virtual object shadow generation method according to claim 1, characterized in that, The step of generating a target virtual object image based on the first shadow image and the virtual object image to be processed includes: The first shadow image and the virtual object image to be processed are subjected to multiply blending to generate the target virtual object image.

3. The virtual object shadow generation method according to claim 2, characterized in that, The first shadow image is a single-channel image. Before performing multiply processing on the first shadow image and the virtual object image to be processed, the method further includes: The first shadow image is converted into a three-channel image.

4. The virtual object shadow generation method according to claim 1, characterized in that, The shadow generation model is trained based on shadow data pairs, which include a first sample image and a second sample image. The first sample image is obtained by using a trained shadow erasure model to remove the shadow at the junction of the upper and lower garments in the second sample image.

5. The virtual object shadow generation method according to claim 4, characterized in that, The shadow removal model is trained based on the second shadow mask image corresponding to the third sample image where there is no shadow at the junction of the upper and lower garments. The model is obtained by performing human body analysis on the collected third sample images to determine the fourth upper garment mask image and the fourth lower garment mask image of the third sample images. The fourth upper garment mask image is then dilated, and the second shadow mask image is determined based on the intersection of the dilated fourth upper garment mask image and the fourth lower garment mask image.

6. The virtual object shadow generation method according to claim 4, characterized in that, The shadow generation model optimizes the global constraint function of the shadow data pair and the local constraint function of the shadow region. The shadow region is determined based on the third shadow mask image of the shadow data pair.

7. A virtual object shadow generation device, characterized in that, It includes an image acquisition module, a mask extraction module, a shadow generation module, and a target generation module, wherein: The image acquisition module is configured to acquire an image of the virtual object to be processed; The mask extraction module is configured to generate a first upper garment mask image and a first shadow mask image based on the virtual object image to be processed. Specifically, the mask extraction module is configured to: perform human body analysis processing on the virtual object image to be processed, and generate a first upper garment mask image and a first lower garment mask image based on the human body analysis processing result; perform dilation processing on the first upper garment mask image; and determine the intersection of the dilated first upper garment mask image and the first lower garment mask image as the first shadow mask image. The shadow generation module is configured to input the first upper garment mask image and the first shadow mask image into a trained shadow generation model, and generate a first shadow image based on the first upper garment mask image and the first shadow mask image through the shadow generation model; The target generation module is configured to generate a target virtual object image based on the first shadow image and the virtual object image to be processed.

8. A virtual object shadow generation device, characterized in that, include: Memory and one or more processors; The memory is used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the virtual object shadow generation method as described in any one of claims 1-6.

9. A non-volatile storage medium for storing computer-executable instructions, characterized in that, The computer-executable instructions, when executed by a computer processor, are used to perform the virtual object shadow generation method as described in any one of claims 1-6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the virtual object shadow generation method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Virtual clothes changing method and related equipment

    CN112258389A

  • Portrait background blurring method and device

    CN113538270A

  • Clothes deformation method, virtual fitting method and related devices

    CN115293958A