Method and device for displaying virtual objects based on light intensity
By obtaining the light intensity of real scenes and virtual objects in AR technology, and adjusting the brightness of virtual objects to match the real scene, the problem of high equipment cost and brightness mismatch is solved, and the integration of virtual objects and real scenes is improved, the realism and user experience are improved. experience.
Patent Information
- Application Number
- CN202110795677.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-14
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2041-07-14
AI Technical Summary
The method of determining the light intensity of virtual objects in existing AR technology has problems such as high equipment cost or brightness mismatch, which affects the user's real experience.
By obtaining the position information of the virtual object in the real scene image, intercepting the partial image, determining the illumination intensity according to the preset channel data of the real scene and the virtual object, adjusting the illumination intensity of the virtual object to match the illumination intensity of the real scene, and displaying the adjusted image.
It improves the lighting consistency between virtual objects and real scenes, enhancing the realism and immersion of user experience.
Smart Images

Figure CN113552942B
Abstract
Description
Technical Field
[0001] The present application relates to the field of augmented reality (AR) technology, and in particular to a method and device for displaying a virtual object based on light intensity. Background Art
[0002] AR technology is a technology that cleverly integrates virtual objects with real scenes. It widely uses a variety of technical means such as multimedia, three-dimensional modeling, real-time tracking and registration, intelligent interaction, and sensing. It simulates computer-generated virtual objects such as text, three-dimensional models, and audio, and applies them to real scenes. The two types of information complement each other, thereby achieving "enhancement" of the real scene and achieving the AR effect.
[0003] The authenticity of AR effects is mainly reflected in geometric consistency, temporal consistency, and lighting consistency. Geometric consistency refers to the accuracy of the position, perspective, and occlusion relationship of the virtual objects generated by the computer in the real scene; temporal consistency refers to the coordination of the movement of the virtual objects and the objects in the real scene; and lighting consistency refers to the matching of the light and dark relationship between the virtual objects and the objects in the real scene.
[0004] In the AR experience, users have a subtle sense of the lighting of the real scene. When the displayed virtual object has no light and shadow or the light and shadow do not reflect the light intensity in the real scene, it will create a visual effect that the virtual object does not belong to the real environment, seriously affecting the user's real experience.
[0005] At present, there are two main ways to determine the light intensity of virtual objects. One is to use a light sensor to obtain the light intensity of the real scene where the virtual object is located, but the equipment cost is relatively high. The other is to set the light intensity of the virtual object to a fixed value, which will cause the surface brightness of the virtual object to not match the brightness of the real scene. When users watch the enhanced picture, they can tell at a glance which is the virtual object, and the picture is not realistic enough. Summary of the invention
[0006] The embodiments of the present application provide a method and device for displaying a virtual object based on light intensity, so as to improve the sense of reality of the fusion of the virtual object and the real scene.
[0007] In a first aspect, an embodiment of the present application provides a method for displaying a virtual object based on light intensity, comprising:
[0008] Acquire position information of a virtual object in a real scene image, and capture a partial image of the virtual object;
[0009] Determining the illumination intensity of the real scene according to the preset channel data in the real scene image, and determining the illumination intensity of the virtual object according to the preset channel data in the partial image;
[0010] Determining a target illumination intensity of the virtual object according to the illumination intensity of the real scene and the illumination intensity of the virtual object;
[0011] The illumination intensity of the virtual object is adjusted to the target illumination intensity, and the adjusted real scene image is displayed.
[0012] In a second aspect, an embodiment of the present application provides a device for displaying a virtual object based on light intensity, including a display, a communication interface, a memory, and a processor;
[0013] The display, connected to the processor, is configured to display an enhanced real scene image;
[0014] The memory is connected to the processor and configured to store computer program instructions;
[0015] The processor is configured to perform the following operations according to the computer program instructions:
[0016] Acquire position information of a virtual object in a real scene image, and capture a partial image of the virtual object;
[0017] Determining the illumination intensity of the real scene according to the preset channel data in the real scene image, and determining the illumination intensity of the virtual object according to the preset channel data in the partial image;
[0018] Determining a target illumination intensity of the virtual object according to the illumination intensity of the real scene and the illumination intensity of the virtual object;
[0019] The illumination intensity of the virtual object is adjusted to the target illumination intensity, and the adjusted real scene image is displayed.
[0020] In a third aspect, the present application provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method for displaying a virtual object based on light intensity provided in an embodiment of the present application.
[0021] In the above-mentioned embodiments of the present application, a partial image is captured based on the position information of the virtual object in the real scene image, and the illumination intensity of the real scene and the illumination intensity of the virtual object are determined respectively according to the preset channel data of the real scene image and the partial image. Furthermore, the illumination intensity of the virtual object is adjusted to the target illumination intensity determined by the two illumination intensities, and the adjusted real scene image is displayed. Since the target illumination intensity of the virtual object is jointly determined by the illumination intensity of the real scene and the illumination intensity of the virtual object, the illumination intensity of the virtual object is consistent with that of the real scene, thereby improving the realism of the fusion of the virtual object and the real scene. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0023] Figure 1 The following is a schematic diagram of an application scenario provided by an embodiment of the present application;
[0024] Figure 2 The flowchart of the method for displaying a virtual object based on light intensity provided by an embodiment of the present application is exemplarily shown;
[0025] Figure 3 A schematic diagram of capturing a partial image of a virtual object provided by an embodiment of the present application is exemplarily shown;
[0026] Figure 4 A schematic diagram of irregular placement of virtual objects provided by an embodiment of the present application is exemplarily shown;
[0027] Figure 5 The flowchart of the complete method for displaying a virtual object based on light intensity provided by an embodiment of the present application is exemplified;
[0028] Figure 6 The structure diagram of a device for displaying a virtual object based on light intensity provided in an embodiment of the present application is exemplified. DETAILED DESCRIPTION
[0029] In order to make the purpose, implementation mode and advantages of the present application clearer, the exemplary implementation mode of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, rather than all the embodiments.
[0030] Based on the exemplary embodiments described in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the claims attached to this application. In addition, although the disclosure in this application is introduced according to one or several exemplary examples, it should be understood that each aspect of the disclosure can also constitute a complete implementation method separately.
[0031] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.
[0032] In addition, the terms "include" and "have" and any variations thereof are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to those components expressly listed but may include other components not expressly listed or inherent to such products or devices.
[0033] The term "module" as used in this application refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.
[0034] Due to the different environments where users are located, the ambient brightness will vary, so it is necessary to adjust the brightness of virtual objects to improve the realism of the enhanced picture. The embodiment of the present application provides a method and device for displaying virtual objects based on light intensity, which determines the target light intensity at the location of the virtual object through the real scene image captured by the camera, and automatically adjusts the light intensity of the virtual object according to the determined target light intensity, so that the virtual object matches the light brightness of the real scene, improves the realism of the picture, and thus improves the user experience.
[0035] The embodiments of the present application provide a method and device for displaying a virtual object based on light intensity, which can be applied to a variety of AR scenarios.
[0036] For example, when a user opens an AR application in a smart terminal (such as a mobile phone or tablet), the user interface will display the real scene image captured by the camera, and the user can place a virtual object at the corresponding position in the real scene image by clicking the touch screen (such as Figure 1 The virtual teapot is placed on the desk), and the lighting intensity of the virtual object is adjusted by the method provided in the embodiment of the present application, so that the brightness of the surface of the virtual object is consistent with the real scene, thereby improving the realism of the fusion of the virtual object and the real scene.
[0037] For another example, a user wears AR glasses, the lenses of the AR glasses have a perspective effect, and the user can see the real scene in front of them through the AR glasses. The AR application is used to present virtual objects on the lenses of the AR glasses. The light intensity of the virtual objects is adjusted by the method provided in the embodiment of the present application to make the enhanced picture realistic.
[0038] It should be noted that the above two scenarios are only examples, and other AR scenarios are also applicable to the method provided in the embodiments of the present application.
[0039] The embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0040] Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present application is shown; Figure 1 As shown, through human-computer interaction, AR technology is used to superimpose a teapot 101 in a real scene. The teapot is a virtual object, and 102_1 to 102_4 are objects in the real scene. In order to make the virtual teapot 101 more naturally integrated into the real scene, in a darker environment, the surface brightness of the virtual teapot 101 should be darker; in a brighter environment, the surface brightness of the virtual teapot 101 should be brighter, so that the surface brightness of the virtual teapot 101 matches the ambient brightness of the real scene, thereby bringing an immersive real experience to the user.
[0041] Figure 2 A flowchart of a method for displaying a virtual object based on light intensity provided by an embodiment of the present application is exemplarily shown; Figure 2 As shown, the process can be performed by a device that displays virtual objects based on light intensity, and mainly includes the following steps:
[0042] S201: Acquire position information of a virtual object in a real scene image, and capture a partial image of the virtual object.
[0043] In this step, the user sends a virtual object adding instruction through the device's touch screen, handle or other control unit. The adding instruction carries the location information of the virtual object. The device adds the virtual object to the real scene image according to the received adding instruction. The virtual object can be drawn by a 3D rendering engine such as Unity or OpenGL. The location information of the virtual object includes the upper left corner coordinates (X, Y) of the area box BOX corresponding to the virtual object and the pixel width W and pixel height H of the virtual object. The device captures a partial image of the virtual object from the real scene image according to the acquired location information, such as Figure 3 shown.
[0044] It should be noted that the embodiments of the present application do not impose any restrictive requirements on the method of adding virtual objects. For example, for a device with a gesture recognition function, a user can also send an adding instruction through a gesture. For another example, the device recognizes a plane in a real scene and automatically places a virtual object on the recognized plane.
[0045] S202: Determine the illumination intensity of the real scene according to the preset channel data in the real scene image, and determine the illumination intensity of the virtual object according to the preset channel data in the partial image.
[0046] In this step, the real scene image is in YUV format, and the preset channel data is brightness (Y) channel data. In specific implementation, the Y channel global data of each pixel in the real scene image is extracted, and the first mean of the extracted Y channel global data is determined, recorded as Lc, and the first mean is used as the illumination intensity of the real scene. At the same time, the Y channel local data of each pixel in the local image is extracted, and the second mean of the extracted Y channel local data is determined, recorded as Lv, and the second mean is used as the illumination intensity of the virtual object.
[0047] S203: Determine a target illumination intensity of the virtual object according to the illumination intensity of the real scene and the illumination intensity of the virtual object.
[0048] In this step, the illumination intensity of the accurately placed virtual object is usually not too different from the illumination intensity of the real scene. If it is too different, it indicates that the virtual object is not placed correctly. Figure 4 As shown in Figure 4 At the position of the dotted box in , the calculated Lv will be too small. Therefore, the target light intensity can be determined based on the difference in light intensity.
[0049] When executing S203, the difference between the illumination intensity Lc of the real scene and the illumination intensity Lv of the virtual object can be determined (Ld=|Lc-Lv|), the determined difference is compared with a preset illumination intensity threshold y, and the target illumination intensity is determined according to the comparison result. Specifically, if Ld<y, the illumination intensity of the virtual object is used as the target illumination intensity (lout=Lv).
[0050] Furthermore, in S203, since the illumination intensity in the real scene image does not have depth information, the illumination intensity in the intercepted partial image does not have depth information either, that is, the illumination intensity of the virtual object displayed in this area is consistent between the virtual object placed 1 meter away from this area and the virtual object placed 2 meters away from this area. Considering that virtual objects are usually placed in front of the real scene, it means that the probability that the real brightness of the virtual object is slightly higher than Lv is relatively high. Therefore, if Ld≥y, the center point of the area frame of the intercepted partial image is used as a reference, the area frame is enlarged by a preset multiple to obtain the enlarged partial image, the Y channel data of each pixel in the enlarged partial image is extracted, and the third mean of the Y channel data is determined to obtain the illumination intensity of the enlarged partial image, and the illumination intensity of the enlarged partial image is determined as the target illumination intensity. Optionally, the preset multiple is 1.5.
[0051] S204: Adjusting the illumination intensity of the virtual object to the target illumination intensity, and displaying the adjusted real scene image.
[0052] In this step, you can adjust the lighting intensity of the virtual object in the following two ways:
[0053] Method 1
[0054] Since the virtual object is a 3D model, its posture can be changed by rotating, moving and other operations, and the illumination intensity of different postures is also different. For example, when one side of the virtual object faces the light, the surface of the virtual object facing the light is brighter, and the surface of the virtual object facing the north light is darker. Therefore, a light source can be set in the virtual scene, and the illumination intensity of the virtual object can be adjusted to the target illumination intensity according to the light source. Specifically, according to the correspondence between the position information of the virtual object in the virtual scene and the position information of the light source, the illumination intensity of the virtual object can be adjusted to the target illumination intensity, and the adjusted real scene image can be displayed.
[0055] Method 2
[0056] The surface of the virtual object is rendered based on the extracted texture data, so the brightness of the virtual object can be adjusted by adjusting the brightness of the texture data. Specifically, the texture data of the virtual object is adjusted according to the target light intensity, the virtual object is redrawn in the real scene image according to the adjusted texture data, and the drawn real scene image is displayed.
[0057] It should be noted that the embodiment of the present application adjusts only the surface brightness of the virtual object, and does not adjust the brightness of the pixels of the non-virtual objects in the local image.
[0058] In the above-mentioned embodiments of the present application, the target light intensity of the virtual object is determined based on the difference between the ambient brightness of the real scene and the ambient brightness of the virtual object and the size of the light intensity threshold, and the light intensity of the virtual object is automatically adjusted to the target light intensity, so that the adjusted light intensity of the target object is consistent with the light intensity of the real scene, so that the virtual object is more realistically integrated into the real scene, giving the user a more realistic immersive experience.
[0059] Figure 5 The following is an exemplary flow chart of a complete method for displaying a virtual object based on light intensity provided by an embodiment of the present application. Figure 5 As shown in FIG. 1 , the process is performed by a device that displays virtual objects based on light intensity and mainly includes the following steps:
[0060] S501: Add a virtual object according to a received instruction for adding a virtual object, where the instruction for adding carries position information of the virtual object.
[0061] S502: According to the position information carried by the adding instruction, a partial image of the virtual object is captured from the acquired real scene image.
[0062] S503: extracting Y channel global data of each pixel in the real scene image, and determining a first mean value of the extracted Y channel global data, and determining the first mean value as the illumination intensity of the real scene.
[0063] S504: extracting Y channel local data of each pixel in the local image, determining a second mean of the extracted Y channel local data, and determining the second mean as the illumination intensity of the virtual object.
[0064] S505: Determine the difference between the illumination intensity of the real scene and the illumination intensity of the virtual object.
[0065] S506: Compare the determined difference with a preset light intensity brightness threshold, if the difference is less than the light intensity brightness threshold, execute S507, otherwise execute S508.
[0066] S507: Taking the illumination intensity of the virtual object as the target illumination intensity.
[0067] S508: Taking the center point of the region frame of the captured partial image as a reference, the region frame is enlarged by a preset multiple to obtain an enlarged partial image.
[0068] S509: extracting Y channel local data of each pixel in the enlarged local image, determining a third mean of the extracted Y channel local data, and using the third mean as the target illumination intensity.
[0069] S510: Adjusting the illumination intensity of the virtual object to the target illumination intensity, and displaying the adjusted real scene image.
[0070] It should be noted that S501 to S510 are not strictly executed in order. For example, S504 may be executed before S503 or may be executed in parallel.
[0071] Based on the same technical concept, an embodiment of the present application provides a device for displaying virtual objects based on light intensity. The device can be a display terminal with interactive functions such as a smart TV, a smart phone, a laptop computer, a desktop computer, a VR device, an AR device, etc. The device can implement the method for displaying virtual objects based on light intensity in the embodiment of the present application, and can achieve the same technical effect, which will not be repeated here.
[0072] See also Figure 6 The device includes a display 601, a memory 602, and a processor 603. The display 601 and the memory 602 are connected to the processor 603 via a bus (in Figure 6 The display 601 is configured to display the enhanced real scene image; the memory 602 is configured to store computer program instructions; the processor 603 is configured to perform the following operations according to the computer program instructions:
[0073] Obtaining the position information of the virtual object in the real scene image and capturing a partial image of the virtual object;
[0074] Determine the illumination intensity of the real scene according to the preset channel data in the real scene image, and determine the illumination intensity of the virtual object according to the preset channel data in the local image;
[0075] Determine the target light intensity of the virtual object according to the light intensity of the real scene and the light intensity of the virtual object;
[0076] The lighting intensity of the virtual object is adjusted to the target lighting intensity, and the adjusted real scene image is displayed.
[0077] Optionally, the processor 603 is specifically configured to:
[0078] Determine the difference between the lighting intensity of the real scene and the lighting intensity of the virtual object;
[0079] The determined difference is compared with a preset light intensity threshold, and the target light intensity is determined according to the comparison result.
[0080] Optionally, the processor 603 is specifically configured to:
[0081] If the difference is less than the light intensity threshold, the light intensity of the virtual object is used as the target light intensity;
[0082] If the difference is not less than the light intensity threshold, the area frame is enlarged by a preset multiple based on the center point of the area frame that captures the local image to obtain an enlarged local image, and the target light intensity is determined according to the light intensity of the enlarged local image.
[0083] Optionally, the processor 603 is specifically configured to:
[0084] Setting a light source in the virtual scene, and adjusting the lighting intensity of the virtual object to the target lighting intensity according to the light source; or
[0085] The texture data of the virtual object is adjusted according to the target light intensity, and the virtual object is redrawn in the real scene image according to the adjusted texture data.
[0086] Optionally, the processor 603 is specifically configured to:
[0087] According to the correspondence between the position information of the virtual object and the position information of the light source in the virtual scene, the illumination intensity of the virtual object is adjusted to the target illumination intensity.
[0088] Optionally, the real scene image is in YUV format, and the processor 603 is specifically configured as follows:
[0089] Extracting Y channel global data from the real scene image, and determining a first mean value of the Y channel global data, and using the first mean value as the illumination intensity of the real scene; and
[0090] Extract local data of the Y channel in the local image, determine a second mean of the local data of the Y channel, and use the second mean as the illumination intensity of the virtual object.
[0091] The embodiment of the present application also provides a computer-readable storage medium for storing some instructions, which, when executed, can complete the method of the aforementioned embodiment.
[0092] The embodiments of the present application also provide a computer program product for storing a computer program, wherein the computer program is used to execute the method of the aforementioned embodiment.
[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
[0094] For the convenience of explanation, the above description has been made in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or limit the embodiments to the specific forms disclosed above. Based on the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are to better explain the principles and practical applications, so that those skilled in the art can better use the embodiments and various different variations of the embodiments suitable for specific use considerations.
Claims
1. A method for displaying a virtual object based on light intensity, characterized in that: Applied to augmented reality (AR) scenarios, including: receiving a virtual object adding instruction sent by a user, acquiring position information of the virtual object in a real scene image based on the adding instruction, and capturing a partial image of the virtual object, wherein the adding instruction carries the position information of the virtual object; Determining the illumination intensity of the real scene according to the preset channel data in the real scene image, and determining the illumination intensity of the virtual object according to the preset channel data in the partial image; Determining a difference between the illumination intensity of the real scene and the illumination intensity of the virtual object according to the illumination intensity of the real scene and the illumination intensity of the virtual object; If the difference is less than a preset light intensity threshold, the light intensity of the virtual object is used as the target light intensity; If the difference is not less than the light intensity threshold, the area frame is enlarged by a preset multiple based on the center point of the area frame that captures the local image to obtain an enlarged local image, and the target light intensity is determined according to the light intensity of the enlarged local image; A light source is set in a virtual scene, and according to the correspondence between the position information of the virtual object in the virtual scene and the position information of the light source, the light intensity of the virtual object is adjusted to the target light intensity, or the texture data of the virtual object is adjusted according to the target light intensity, the virtual object is redrawn in the real scene image according to the adjusted texture data, and the adjusted real scene image is displayed.
2. The method according to claim 1, characterized in that The real scene image is in YUV format, and determining the illumination intensity of the real scene according to preset channel data in the real scene image, and determining the illumination intensity of the virtual object according to preset channel data in the region image of the virtual object, comprises: Extracting Y channel global data from the real scene image, and determining a first mean value of the Y channel global data, and using the first mean value as the illumination intensity of the real scene; and Extract Y channel local data from the local image, determine a second mean value of the Y channel local data, and use the second mean value as the illumination intensity of the virtual object.
3. A device for displaying a virtual object based on light intensity, characterized in that: Including display, communication interface, memory, processor; The display, connected to the processor, is configured to display an enhanced real scene image; The memory is connected to the processor and configured to store computer program instructions; The processor is configured to perform the following operations according to the computer program instructions: receiving a virtual object adding instruction sent by a user, acquiring position information of the virtual object in a real scene image based on the adding instruction, and capturing a partial image of the virtual object, wherein the adding instruction carries the position information of the virtual object; Determining the illumination intensity of the real scene according to the preset channel data in the real scene image, and determining the illumination intensity of the virtual object according to the preset channel data in the partial image; Determining a difference between the illumination intensity of the real scene and the illumination intensity of the virtual object according to the illumination intensity of the real scene and the illumination intensity of the virtual object; If the difference is less than a preset light intensity threshold, the light intensity of the virtual object is used as the target light intensity; If the difference is not less than the light intensity threshold, the area frame is enlarged by a preset multiple based on the center point of the area frame that captures the local image to obtain an enlarged local image, and the target light intensity is determined according to the light intensity of the enlarged local image; A light source is set in a virtual scene, and according to the correspondence between the position information of the virtual object in the virtual scene and the position information of the light source, the light intensity of the virtual object is adjusted to the target light intensity, or the texture data of the virtual object is adjusted according to the target light intensity, the virtual object is redrawn in the real scene image according to the adjusted texture data, and the adjusted real scene image is displayed.
Citation Information
Patent Citations
Image processing method and device
CN107734264A
Virtual object adjustment method and device, storage medium and augmented reality equipment
CN111415422A
Display method, device and equipment and computer readable storage medium
CN111833423A
