A method and device for realizing real-virtual environment, electronic equipment, and storage medium

By collecting and analyzing the lighting information of the actual environment in real time, building a dynamic lighting model, combining the rendering algorithm to calculate the shadow effect of the virtual object, and mixing it into the actual environment, it solves the problem of inconsistency between the shadow of the virtual object and the environment in the existing technology. , improving the authenticity and user experience of augmented reality.

CN118097070BActive Publication Date: 2024-09-10HUNAN HAPPLY SUNSHINE INTERACTIVE ENTERTAINMENT MEDIA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311817679.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-26
Publication Date
2024-09-10
Estimated Expiration
2043-12-26

AI Technical Summary

Technical Problem

In existing virtual environment technology, the shadow effect of virtual objects is not coordinated with the actual environment and cannot be adjusted according to actual lighting conditions.

Method used

By collecting visible light images and depth images of the actual environment in real time, detecting light source information, extracting depth data for three-dimensional reconstruction, building a dynamic lighting model, combining the virtual model in the virtual scene, using a rendering algorithm to calculate the shadow effect, and converting the rendering effect of the virtual model The graph is blended into the real environment.

Benefits of technology

It achieves perfect coordination between the shadow of virtual objects and the actual environment, improving the authenticity and user experience of augmented reality content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118097070B
    Figure CN118097070B
Patent Text Reader

Abstract

The present application discloses a method and device for realizing a real-world virtual environment, an electronic device, and a storage medium. The method comprises: collecting visible light images and depth images of multiple directions of a current actual environment in real time; detecting the visible light images through a light source detection model to obtain light source information of each current light source; constructing a current three-dimensional model based on fusion data of depth data of each depth image and environmental texture information; combining the light source information with the current three-dimensional model into a current dynamic lighting model; constructing a virtual scene matching the current actual environment based on the visible light image, the current three-dimensional model, and the current dynamic lighting model, and setting a virtual model therein; calculating the shadow effect of the virtual scene under the lighting corresponding to the current dynamic lighting model through a rendering algorithm to obtain a current rendering effect diagram of the virtual scene; extracting the current rendering effect diagram of the virtual model, and mixing and inserting it into the image of the current actual environment to obtain a current real-world virtual environment rendering diagram.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of real-virtual environment and virtual-real environment, and in particular to a method and device for realizing real-virtual environment, electronic equipment and storage medium. Background Art

[0002] Augmented Reality (AR) technology, also known as virtual reality technology, is a technology that uses the position and angle of camera images and image analysis technology to allow the virtual world on the screen to combine and interact with real-world scenes.

[0003] In order to make virtual objects more closely fit the actual environment, a shadow model is usually set in advance. Then, in the process of realizing the real virtual environment, the shadow of the added virtual model is directly generated using the set shadow model.

[0004] However, the lighting conditions in the actual environment are not fixed, so the existing method of using a fixed shadow model cannot be adjusted according to the actual lighting. As a result, the shadow of the obtained AR content is often poorly coordinated with the actual scene. Summary of the invention

[0005] Based on the above-mentioned deficiencies of the prior art, the present application provides a method and device for realizing a real-virtual environment, an electronic device, and a storage medium to solve the problem that the shadow effect generated by the prior art is not coordinated with the actual scene.

[0006] In order to achieve the above objectives, this application provides the following technical solutions:

[0007] The first aspect of the present application provides a method for realizing a real virtual environment, including:

[0008] Real-time acquisition of visible light images of the current actual environment and depth images in multiple directions;

[0009] Detecting the visible light image using a light source detection model to obtain light source information of each current light source;

[0010] Extracting depth data from each of the depth images and fusing them to obtain fused depth data;

[0011] Performing three-dimensional reconstruction based on the fused depth data and extracting environmental texture information from the visible light image to obtain a current three-dimensional model;

[0012] Combining the light source information of each of the current light sources with the current three-dimensional model to obtain a current dynamic lighting model;

[0013] Based on the visible light image, the current three-dimensional model and the current dynamic illumination model, construct a virtual scene matching the current actual environment, and set a virtual model in the virtual scene;

[0014] Calculating the shadow effect of the object in the virtual scene under the illumination corresponding to the current dynamic illumination model by using the selected rendering algorithm to obtain a current rendering effect diagram of the virtual scene;

[0015] The current rendering effect diagram of the virtual model is extracted from the current rendering effect diagram of the virtual scene, and the current rendering effect diagram of the virtual model is mixed and inserted into the image of the current actual environment to obtain the current real-virtual environment rendering diagram.

[0016] Optionally, in the above-mentioned method for realizing a real-virtual environment, constructing a virtual scene matching the current actual environment based on the visible light image, the current spatial information and the current dynamic lighting model, and setting a virtual model in the virtual scene includes:

[0017] Create the initial virtual scene;

[0018] generating a basic geometric structure of the virtual scene based on the visible light image;

[0019] Constructing the three-dimensional structure and texture of the virtual scene using the current three-dimensional model;

[0020] Setting a transparent area in the virtual scene;

[0021] Importing a virtual model selected by a user, and placing the virtual model in the transparent area;

[0022] The current light sources are set in the virtual scene based on the current dynamic lighting model.

[0023] Optionally, in the above-mentioned method for realizing the real-virtual-virtual environment, calculating the shadow effect of the object in the virtual scene under the illumination reflected by the current dynamic illumination model by using the selected rendering algorithm to obtain the current rendering effect diagram of the virtual scene includes:

[0024] Selecting a rendering algorithm based on the virtual scene and the geometric structure and material properties of the virtual model in the virtual scene;

[0025] Simulating the light of each current light source in the virtual scene based on the current dynamic lighting model, and calculating the color of the intersection of the light of each current light source and the surface of the object in the virtual scene through the selected rendering algorithm;

[0026] The current rendering effect image of the virtual model is generated by using the color of the intersection of the light and the surface of the object in the virtual scene.

[0027] Optionally, in the above-mentioned method for realizing a real-virtual environment, after calculating the shadow effect of the object in the virtual scene under the illumination corresponding to the current dynamic illumination model by the selected rendering algorithm to obtain the current rendering effect diagram of the virtual scene, it also includes:

[0028] Receive shadow parameters input by users in real time;

[0029] Adjusting the current rendering effect image of the virtual scene based on the shadow parameters and performing a preview display;

[0030] When the confirmation instruction sent by the user is received, the current shadow parameters and the current rendering effect image of the virtual scene are saved.

[0031] Optionally, in the above-mentioned method for realizing the real-virtual-virtual environment, the step of mixing and inserting the current rendering effect image of the virtual model into the image of the current actual environment to obtain the current real-virtual-virtual environment rendering image includes:

[0032] Get the internal parameters of the camera of the virtual reality device;

[0033] Using the internal parameters of the camera to perform image distortion transformation on the current rendering effect image of the virtual model;

[0034] Updating the position information of the camera in space;

[0035] The current rendering effect image of the virtual model is mixed with the image of the current actual environment, and occlusion processing and lighting synthesis are performed based on the depth information of the current rendering effect image of the virtual model and the image of the current actual environment to obtain the current real-virtual environment rendering image.

[0036] Optionally, in the above-mentioned method for realizing the real virtual environment, it also includes:

[0037] The environmental information is updated in real time using the inter-frame tracking technology, and the current real-virtual environment effect map is updated using the updated environmental information.

[0038] The second aspect of the present application provides a device for realizing a real virtual environment, including:

[0039] The acquisition unit is used to acquire the visible light image of the current actual environment and the depth images in multiple directions in real time;

[0040] A detection unit, used to detect the visible light image through a light source detection model to obtain light source information of each current light source;

[0041] An information analysis unit, configured to extract depth data from each of the depth images and fuse them to obtain fused depth data, and to perform three-dimensional reconstruction based on the fused depth data and environmental texture information extracted from the visible light image to obtain a current three-dimensional model;

[0042] A combining unit, used to combine the light source information of each of the current light sources with the current three-dimensional model to obtain a current dynamic lighting model;

[0043] A construction unit, configured to construct a virtual scene matching the current actual environment based on the visible light image, the current three-dimensional model and the current dynamic illumination model, and to set a virtual model in the virtual scene;

[0044] A rendering unit, configured to calculate the shadow effect of the object in the virtual scene under the illumination corresponding to the current dynamic illumination model by using a selected rendering algorithm, and obtain a current rendering effect diagram of the virtual scene;

[0045] The mixing unit is used to extract the current rendering effect image of the virtual model from the current rendering effect image of the virtual scene, and mix and insert the current rendering effect image of the virtual model into the image of the current actual environment to obtain the current real-virtual environment effect image.

[0046] Optionally, in the above-mentioned device for realizing the real-virtual-virtual environment, the construction unit includes:

[0047] A creation unit, used to create an initial virtual scene;

[0048] A structure generating unit, configured to generate a basic geometric structure of the virtual scene based on the visible light image;

[0049] A restoration unit, configured to construct a three-dimensional structure and texture of the virtual scene using the current three-dimensional model;

[0050] An area setting unit, used for setting a transparent area in the virtual scene;

[0051] An importing unit, used for importing a virtual model selected by a user and placing the virtual model in the transparent area;

[0052] A light source setting unit is used to set each current light source in the virtual scene based on the current dynamic lighting model.

[0053] Optionally, in the above-mentioned device for realizing real-virtual-virtual environment, the rendering unit includes:

[0054] A selection unit, configured to select a rendering algorithm based on the virtual scene and the geometric structure and material properties of the virtual model in the virtual scene;

[0055] A calculation unit, configured to simulate each of the current light sources in the virtual scene based on the current dynamic lighting model, and calculate the color of the intersection of the light of each of the current light sources and the object in the virtual scene by using the selected rendering algorithm;

[0056] The rendering generation unit is used to generate a current rendering rendering of the virtual model by using the color of the intersection of the light and the object in the virtual scene.

[0057] Optionally, in the above-mentioned device for realizing real-virtual environment, it further includes:

[0058] A receiving unit, used for receiving shadow parameters input by a user in real time;

[0059] An adjustment unit, used to adjust the current rendering effect image of the virtual scene based on the shadow parameters and perform a preview display;

[0060] A saving unit is used to save the current shadow parameters and the current rendering effect image of the virtual scene when receiving a confirmation instruction sent by the user.

[0061] Optionally, in the above-mentioned device for realizing real-virtual environment, the mixing unit includes:

[0062] An internal parameter acquisition unit, used to acquire the internal parameters of the camera of the virtual reality device;

[0063] A distortion transformation unit, used for performing a picture distortion transformation on the current rendering effect image of the virtual model by using the internal parameters of the camera;

[0064] A posture updating unit, used for updating the posture information of the camera in space;

[0065] A combining unit is used to mix the current rendering effect image of the virtual model with the image of the current actual environment, and perform occlusion processing and lighting synthesis based on the depth information of the current rendering effect image of the virtual model and the image of the current actual environment to obtain the current real-virtual environment rendering image.

[0066] Optionally, in the above-mentioned device for realizing real-virtual environment, it further includes:

[0067] The rendering updating unit is used to update the environment information in real time by using the inter-frame tracking technology, and to update the current real-virtual environment rendering by using the updated environment information.

[0068] A third aspect of the present application provides an electronic device, including:

[0069] Memory and processor;

[0070] Wherein, the memory is used to store programs;

[0071] The processor is used to execute the program. When the program is executed, it is specifically used to implement the method for realizing the real virtual environment as described in any one of the above.

[0072] A fourth aspect of the present application provides a computer storage medium for storing a computer program, which, when executed, is used to implement a method for realizing a real-virtual environment as described in any one of the above.

[0073] The embodiment of the present application provides a method for realizing a real-to-virtual environment, which collects visible light images and depth images of multiple directions of the current actual environment in real time, then detects the visible light images through a light source detection model to obtain the light source information of each current light source, and extracts the depth data of each depth image and fuses them to obtain fused depth data, and performs three-dimensional reconstruction based on the fused depth data and the environmental texture information extracted from the visible light image to obtain the current three-dimensional model. Then, the light source information of each current light source is combined with the current three-dimensional model to obtain the current dynamic lighting model, thereby realizing accurate detection and analysis of the lighting of the current actual environment. Then, based on the visible light image, the current three-dimensional model and the current dynamic lighting model, a virtual scene matching the current actual environment is constructed, and a virtual model is set in the virtual scene, thereby constructing a virtual scene consistent with the actual environment, and placing the virtual model in the virtual scene is equivalent to placing the virtual model in the current actual environment, so as to analyze the shadows of the virtual model in the actual environment under various influences of the actual environment. Then, the shadow effect of the objects in the virtual scene under the lighting corresponding to the current dynamic lighting model is calculated through the selected rendering algorithm to obtain the current rendering effect map of the virtual scene. Finally, the current rendering effect map of the virtual model is extracted from the current rendering effect map of the virtual scene, and the current rendering effect map of the virtual model is mixed and inserted into the image of the current actual environment to obtain the current real-simulated virtual environment effect map, thereby realizing a rendering method that places the virtual model in the actual environment as a real object and is affected by various light sources and objects in the environment, so that the shadow of the obtained AR content can be perfectly coordinated with the actual scene. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] 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 only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0075] Figure 1 A flowchart of a method for realizing a real-virtual environment provided in an embodiment of the present application;

[0076] Figure 2 A flowchart of a method for constructing a virtual scene and setting a virtual model provided in an embodiment of the present application;

[0077] Figure 3 A flowchart of a method for generating a current rendering effect diagram of a virtual model provided in an embodiment of the present application;

[0078] Figure 4 A flowchart of a method for adjusting a rendering effect provided in an embodiment of the present application;

[0079] Figure 5 A flowchart of a method for mixing and inserting a current rendering effect image of a virtual model into an image of a current actual environment provided by an embodiment of the present application;

[0080] Figure 6 A schematic diagram of the architecture of a device for realizing a real-virtual environment provided in an embodiment of the present application;

[0081] Figure 7 A schematic diagram of the architecture of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

[0083] In this application, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0084] The present application embodiment provides a method for realizing a real virtual environment. Figure 1 As shown, the following steps are included:

[0085] S101, collecting visible light images of the current actual environment and depth images in multiple directions in real time.

[0086] The visible light image is an RGB image, which can be collected by high-speed image capture technology, such as using a CMOS sensor with a frame rate of more than 60 frames per second, so as to capture the rapid changes of the light source. Optionally, in the embodiment of the present application, a graphical user interface can be further provided to display the results of light source tracking and allow the user to adjust the tracking parameters according to the tracking results, such as the tracking sensitivity of a specific light source.

[0087] In addition, a user feedback mechanism can be implemented to allow users to provide feedback based on the lighting effects in the virtual scene to optimize the light source tracking algorithm.

[0088] The depth image can be collected by a depth camera. Therefore, the current actual environment can be collected by an AR device including an RGB camera and a depth camera, or by using a structured light or time-of-flight (ToF) camera. In order to ensure the completeness of the depth information and avoid information loss, in the embodiment of the present application, depth images of the current actual environment are collected in multiple directions.

[0089] S102: Detect the visible light image using a light source detection model to obtain light source information of each current light source.

[0090] Among them, the visible light image contains the color and texture information of the current scene, so by analyzing it, the light source related information in the current actual environment can be obtained. In the embodiment of the present application, the visible light image is detected by a pre-trained light source detection model to obtain the light source information of each current light source. Optionally, the light source information of the current light source may include the number, category and dynamic parameters of the light source, such as direction, intensity change, moving speed and color change.

[0091] Optionally, the light source detection model can be implemented based on an image processing algorithm, such as an optical flow method and a Kalman filter, to track and predict the movement trajectory of the light source and obtain the light source information.

[0092] The depth image contains the distance information of objects in the current actual environment, so in the embodiment of the present application, the three-dimensional spatial information of the scene is restored by performing three-dimensional reconstruction on the depth image.

[0093] S103, extracting depth data from each depth image and fusing them to obtain fused depth data, and performing three-dimensional reconstruction based on the fused depth data and environmental texture information extracted from the visible light image to obtain a current three-dimensional model.

[0094] Optionally, multi-view geometry technology may be applied to fuse depth data captured at different angles to eliminate blind spots and errors in single-view data.

[0095] Furthermore, since objects in the environment reflect and absorb light and cast shadows, all of which will affect the shadows formed by the added virtual models, and the emission and absorption of light by objects and the shadows they form are related to their textures, and the environmental texture can reflect lighting, etc., therefore, in an embodiment of the present application, the environmental texture is extracted and mapped onto a three-dimensional model to reflect lighting and color changes in the environment.

[0096] Optionally, a deep learning algorithm may be further used for the current constructed 3D model to perform semantic understanding and result optimization, so as to proactively identify and repair errors in the 3D reconstruction process, such as occlusion and discontinuity.

[0097] Also optionally, in an embodiment of the present application, a corresponding interactive interface may also be provided to allow the user to manually adjust the model during the reconstruction process, such as adjusting the scale, improving texture coverage, or repairing errors.

[0098] S104: Combining the light source information of each current light source with the current three-dimensional model to obtain a current dynamic lighting model.

[0099] Specifically, by combining the current three-dimensional model with the parameters such as the direction, intensity and color of the light source in the light source information of each current light source, the corresponding three-dimensional information of each current light source in the three-dimensional scene can be determined, and a current dynamic lighting model can be constructed and updated based on this information. The model can reflect official information such as the real-time position and intensity of the light source, which is convenient for subsequent rendering and calculation of the shadow effect of the virtual model.

[0100] It should be noted that, since the user's perspective may change differently and the environment itself will also change constantly, the inter-frame tracking technology can be used to continuously update the current dynamic lighting model so as to continuously change the virtual lighting effect to adapt it to the actual situation and the user's perspective.

[0101] S105 . Based on the visible light image, the current three-dimensional model and the current dynamic lighting model, a virtual scene matching the current actual environment is constructed, and a virtual model is set in the virtual scene.

[0102] It should be noted that since the shadow of an object in an environment is not only affected by the lighting conditions themselves, but also by the occlusion of other objects, the emission of light, and the overlap of shadows, in the embodiment of the present application, in order to make the shadow of the obtained virtual model more coordinated with the current actual environment and improve the user experience, the shadow of the virtual object is not directly rendered according to the information of each current light source. Instead, the various effects of placing the virtual model in the current actual environment are considered. Since the virtual model is a virtual object that does not exist in the current actual environment and cannot be placed directly in the current actual environment, in order to render the shadow of the virtual model under the lighting conditions of the current actual environment, it is necessary to first construct a virtual scene consistent with the current actual environment, and then set the virtual model in the virtual scene, so as to facilitate the subsequent determination of the shadow of the virtual model in the virtual scene, so that the shadow of the virtual model under the lighting conditions of the current actual environment can be obtained.

[0103] Specifically, based on the information reflected by the visible light image, a two-dimensional virtual scene consistent with the current actual environment can be constructed, and then based on the current three-dimensional model, the two-dimensional virtual scene can be converted into a three-dimensional virtual scene, and based on the current dynamic lighting model, the lighting consistent with the current actual environment can be set in the virtual scene. Finally, the virtual model to be displayed can be added to the virtual scene.

[0104] Optionally, a virtual element library may be provided to the user so that the user can select a desired virtual model from the library and place the virtual model in the constructed virtual scene.

[0105] Optionally, in order to meet the personalized needs of users and to facilitate users to adjust errors in the constructed scene, an interactive editing interface can be further provided to users, so that users can automatically define and adjust the layout and elements in the virtual scene. And the lighting, materials and other visual effects can be adjusted to better simulate or enhance the appearance of the real environment. In addition, after the user makes adjustments, the user's operation records and preferences can be collected, so that when the virtual scene is subsequently constructed, a virtual scene that meets the user's needs can be constructed according to the user's preferences without the user having to make adjustments.

[0106] Optionally, in another embodiment of the present application, a specific implementation of step S105 is as follows: Figure 2 As shown, the following steps are included:

[0107] S201, creating an initial virtual scene.

[0108] Specifically, an initial virtual scene object is created and then set up through subsequent steps.

[0109] S202: Generate a basic geometric structure of a virtual scene based on the visible light image.

[0110] Specifically, the size of the virtual scene can be set and the basic geometric structure of the virtual scene can be generated, such as planes such as walls and floors, based on the color and texture of the visible light image.

[0111] S203: Use the current three-dimensional model to construct the three-dimensional structure and texture of the virtual scene.

[0112] Since the virtual scene generated by the previous steps is only a two-dimensional one, it is also necessary to convert it into a three-dimensional structure based on the current spatial information to obtain the approximate size and layout of the virtual scene.

[0113] S204: Setting a transparent area in the virtual scene.

[0114] Specifically, the specific location where the virtual model needs to be inserted in the virtual scene is set as a transparent area to facilitate mixing the model in this area.

[0115] S205: Import the virtual model selected by the user, and place the virtual model in the transparent area.

[0116] Specifically, the virtual furniture, decoration and other models selected by the user can be imported, and then the size of the virtual model can be adjusted accordingly, and then placed in the transparent area.

[0117] S206: Setting each current light source in the virtual scene based on the current dynamic lighting model.

[0118] Since the current dynamic lighting model reflects the light source information of each current light source, each current light source in the target scene can be set based on the current dynamic lighting model.

[0119] Optionally, multiple virtual scenes may be created, that is, multiple virtual scenes may be created by adjusting corresponding information, and / or different virtual models may be set, thereby constructing multiple virtual scenes for users to choose from.

[0120] S106 , calculating the shadow effects of the objects in the virtual scene under the illumination corresponding to the current dynamic illumination model by using the selected rendering algorithm, and obtaining a current rendering effect diagram of the virtual scene.

[0121] The objects in the virtual scene include objects in the current real environment that correspond to the objects in the virtual scene and virtual models that are added to the virtual scene. Therefore, the embodiment of the present application renders all objects to take into account the shadows of other objects in the scene on the virtual model, ensuring that the shadows of the generated virtual model are more realistic.

[0122] Specifically, considering the scattering and absorption of light by objects, a physically based rendering algorithm (PBR) can be used to render the scattering and absorption of light by objects to more realistically simulate the interaction between light and matter. In addition, ray tracing or rasterization algorithms can be used to calculate the precise interaction between each current light source and reflected light and virtual objects to determine the length, direction, and depth of the shadow. In addition, a pre-developed algorithm is used to calculate the overlap of shadows and the mixing of lighting, thereby adjusting the calculated shadows. Finally, a shadow softening function is introduced to adjust the sharpness and intensity of the shadow according to the ambient lighting conditions and the characteristics of the object surface, thereby obtaining the final rendering effect.

[0123] Optionally, the user can set up the rendering, allowing the user to adjust the intensity, sharpness, color, etc. of the shadows according to their needs.

[0124] Optionally, in another embodiment of the present application, a specific implementation of step S106 is as follows: Figure 3 As shown, the following steps are included:

[0125] S301 : Select a rendering algorithm based on the geometric structure and material properties of the virtual scene and the virtual model in the virtual scene.

[0126] Since different structures and materials have different characteristics such as reflection of light, the shadows formed are also different. Therefore, it is necessary to first select a rendering algorithm based on the geometric structure and material characteristics of the virtual scene and the virtual model in the virtual scene.

[0127] S302: Simulate the light of each current light source in the virtual scene based on the current dynamic lighting model, and calculate the color of the intersection of the light of each current light source and the surface of the object in the virtual scene through the selected rendering algorithm.

[0128] Optionally, in the embodiment of the present application, a Monte Carlo ray tracing algorithm is used for calculation, which is triggered by a camera and tracks the path of light reflected and refracted in the scene, so that the color of the intersection of the light and the model surface can be calculated, and the shadow of the model can be obtained. Therefore, according to the direction and energy of the light source in the current ambient light distribution information, light can be emitted into the virtual scene, and then the selected rendering algorithm is used for tracing, so that the color of the intersection of the light and the surface of the virtual model in the virtual scene can be obtained.

[0129] Optionally, in order to obtain high-quality images, for each light source, the corresponding light can be repeatedly emitted in the scene, so as to obtain multiple lighting results for each point, and then the final lighting result is determined based on the multiple lighting results, thereby improving the accuracy of the calculation results and effectively improving the quality of the obtained image.

[0130] Of course, you can also use algorithms such as Rasterization scanline rendering to synthesize images using processes such as rasterization and shading.

[0131] S303: Generate a current rendering effect diagram of the virtual model using the color of the intersection of the light and the surface of the object in the virtual scene.

[0132] Optionally, in another embodiment of the present application, after executing step S106, the rendering effect may be manually adjusted. Figure 4 As shown, a method for adjusting a rendering effect provided in an embodiment of the present application includes:

[0133] S401 : receiving shadow parameters input by a user in real time.

[0134] It should be noted that in order to allow users to adjust the shadow generation results according to their needs, a corresponding human-computer interaction interface will be provided in the embodiment of the present application, and users can flexibly control the shadow generation results through the interface to obtain the best effect preview.

[0135] Optionally, the provided interface may include interactive components such as sliders, color pickers, and parameter panels. Users can smoothly adjust the contrast, hardening degree, color, and other parameters of the shadow by dragging the slider. You can also directly select the color style of the shadows in different areas through the color picker. Or you can directly enter the value accurately through the parameter panel to adjust the parameters such as the blur size of the shadow edge. In addition, the interface can display the effect changes caused by the user's adjustment in real time, so that the user can try different combinations to obtain the best preview result. Preset modes can also be provided, including common shadow effect templates for users to choose and adjust, and support setting different shadow parameters for different objects to meet the user's needs for detail control. Finally, after the user gets a satisfactory preview, he can save the generated custom shadow effect.

[0136] Therefore, when the user inputs corresponding shadow parameters through the interactive components provided by the interface, the input shadow parameters are received accordingly.

[0137] Furthermore, in order to allow the user to make more detailed adjustments, in the embodiment of the present application, the user can adjust parameters for different regions, that is, test different parameters for different regions. Therefore, step S401 specifically receives the shadow parameters of each region input by the user in real time.

[0138] S402: Adjust the current rendering effect diagram of the virtual scene based on the shadow parameters and perform a preview display.

[0139] Specifically, the selected rendering algorithm is adjusted according to the shadow parameters input by the user, so as to generate the shadow effect defined by the user through the adjusted rendering algorithm.

[0140] S403: When receiving a confirmation instruction issued by the user, save the current shadow parameters and the current rendering effect image of the virtual scene.

[0141] In order to continue using these user-defined parameters for rendering when the user's perspective changes and ensure the continuity of the effect, in an embodiment of the present application, after the user confirms the save, not only the current rendering effect image is saved, but also the current shadow parameters need to be saved.

[0142] S107, extracting the current rendering effect diagram of the virtual model from the current rendering effect diagram of the virtual scene, and inserting the current rendering effect diagram of the virtual model into the image of the current actual environment to obtain the current real-virtual environment rendering diagram.

[0143] Since the virtual world is to display virtual objects in the real picture of reality, it is necessary to merge the current rendering effect of the virtual model with the image of the current actual environment to obtain the current virtual world rendering effect. Therefore, it is necessary to extract the current rendering effect of the virtual model from the current rendering effect of the virtual scene, which includes the rendering effect of the virtual model itself and its shadow. Then, the current rendering effect of the virtual model is inserted into the image of the current actual environment according to its position in the virtual scene, so as to obtain the effect of displaying the virtual model in the current real environment.

[0144] The image of the current actual environment may specifically be a visible light image of the current actual environment. Of course, an additional image of the current actual environment may also be collected.

[0145] Optionally, in another embodiment of the present application, in step S107, a specific implementation method of mixing and inserting the current rendering effect image of the virtual model into the image of the current actual environment is as follows: Figure 5 As shown, the following steps are included:

[0146] S501: Obtain internal parameters of a camera of a virtual reality device.

[0147] In order to make the generated effect image adapt to the user's perspective, it is necessary to first obtain the internal parameters of the camera of the AR device, and then execute step S502.

[0148] Among them, the internal parameters of the camera may include information such as focal length and principal point position.

[0149] S502: Using the internal parameters of the camera to perform image distortion transformation on the current rendering effect image of the virtual model.

[0150] S503: Update the position information of the camera in space.

[0151] In order to ensure that the virtual content is stably covered on the real object, it is necessary to update the camera's position information in space in real time so that the image can be rendered based on the position information to ensure the correct rendering perspective.

[0152] S504: Mix the current rendering effect image of the virtual model with the image of the current actual environment, and perform occlusion processing and lighting synthesis based on the depth information of the current rendering effect image of the virtual model and the image of the current actual environment to obtain a current mixed effect image.

[0153] Specifically, the hybrid rendering technology can be used to mix the current rendering effect of the virtual model with the image of the current actual environment, so that the virtual content can be seamlessly integrated into the environment in terms of visual effects. Then, based on the depth information of the current rendering effect of the virtual model and the image of the current actual environment, occlusion processing is performed between objects in the three-dimensional space. Specifically, the priority of the display content of the pixel can be determined based on the depth information, and then occlusion processing is performed based on the priority. Then, lighting synthesis can be performed, specifically through image-based rendering technology, according to the characteristics of the real-life image, to synthesize realistic shadows, highlights, depth of field and other effects onto the virtual model.

[0154] It should also be noted that as the user's perspective continues to change, the above-mentioned mixed rendering process needs to be repeated accordingly to ensure that the virtual model is stable and matches the current actual environment.

[0155] Optionally, in another embodiment of the present application, after executing step S106, the following may be further included:

[0156] The inter-frame tracking technology is used to update the environmental information in real time, and the updated environmental information is used to update the current real-virtual environment rendering.

[0157] Specifically, the inter-frame tracking algorithm such as the optical flow method can be used to calculate the motion difference between the current frame and the previous frame in real time. Specifically, it can include differences such as the change of screen position and the appearance of new obstacles. In addition, for position changes, it is necessary to update the position of the camera, and re-perform the image distortion, rendering and mixing process to make the virtual content dynamically match the real scene. For new obstacles, it is necessary to use images from a new perspective to reconstruct the virtual scene to avoid illegal occlusion of real objects by virtual content. In addition, from a new perspective, it is necessary to re-capture the image and update the virtual scene lighting settings based on the captured image detection again to ensure that the actual effect is matched. When re-rendering the shadow, the user-defined shadow parameters also need to be applied to it, so as to finally ensure the real-time synchronization update of the augmented reality content and environmental changes.

[0158] The embodiment of the present application provides a method for realizing a real-to-virtual environment, which collects visible light images and depth images of multiple directions of the current actual environment in real time, then detects the visible light images through a light source detection model to obtain the light source information of each current light source, and extracts the depth data of each depth image and fuses them to obtain fused depth data, and performs three-dimensional reconstruction based on the fused depth data and the environmental texture information extracted from the visible light image to obtain the current three-dimensional model. Then, the light source information of each current light source is combined with the current three-dimensional model to obtain the current dynamic lighting model, thereby realizing accurate detection and analysis of the lighting of the current actual environment. Then, based on the visible light image, the current three-dimensional model and the current dynamic lighting model, a virtual scene matching the current actual environment is constructed, and a virtual model is set in the virtual scene, thereby constructing a virtual scene consistent with the actual environment, and placing the virtual model in the virtual scene is equivalent to placing the virtual model in the current actual environment, so as to analyze the shadows of the virtual model in the actual environment under various influences of the actual environment. Then, the shadow effect of the objects in the virtual scene under the lighting corresponding to the current dynamic lighting model is calculated through the selected rendering algorithm to obtain the current rendering effect map of the virtual scene. Finally, the current rendering effect map of the virtual model is extracted from the current rendering effect map of the virtual scene, and the current rendering effect map of the virtual model is mixed and inserted into the image of the current actual environment to obtain the current real-simulated virtual environment effect map, thereby realizing a rendering method that places the virtual model in the actual environment as a real object and is affected by various light sources and objects in the environment, so that the shadow of the obtained AR content can be perfectly coordinated with the actual scene.

[0159] Another embodiment of the present application provides a device for realizing a real-virtual environment, such as Figure 6 As shown, including:

[0160] The acquisition unit 601 is used to acquire the visible light image of the current actual environment and the depth images in multiple directions in real time.

[0161] The detection unit 602 is used to detect the visible light image through the light source detection model to obtain the light source information of each current light source.

[0162] The information analysis unit 603 is used to extract the depth data of each depth image and fuse them to obtain fused depth data, and perform three-dimensional reconstruction based on the fused depth data and the environmental texture information extracted from the visible light image to obtain the current three-dimensional model.

[0163] The combining unit 604 is used to combine the light source information of each current light source with the current three-dimensional model to obtain a current dynamic lighting model.

[0164] The construction unit 605 is used to construct a virtual scene matching the current actual environment based on the visible light image, the current three-dimensional model and the current dynamic lighting model, and set the virtual model in the virtual scene.

[0165] The rendering unit 606 is used to calculate the shadow effect of the object in the virtual scene under the lighting corresponding to the current dynamic lighting model through the selected rendering algorithm, and obtain the current rendering effect diagram of the virtual scene.

[0166] The mixing unit 607 is used to extract the current rendering effect image of the virtual model from the current rendering effect image of the virtual scene, and mix and insert the current rendering effect image of the virtual model into the image of the current actual environment to obtain the current real-virtual environment effect image.

[0167] Optionally, in the device for realizing the real-virtual environment provided in another embodiment of the present application, the construction unit includes:

[0168] The creation unit is used to create an initial virtual scene.

[0169] The structure generation unit is used to generate the basic geometric structure of the virtual scene based on the visible light image.

[0170] The restoration unit is used to construct the three-dimensional structure and texture of the virtual scene using the current three-dimensional model.

[0171] The area setting unit is used to set a transparent area in a virtual scene.

[0172] The import unit is used to import the virtual model selected by the user and place the virtual model in the transparent area.

[0173] The light source setting unit is used to set each current light source in the virtual scene based on the current dynamic lighting model.

[0174] Optionally, in the device for realizing the real-virtual environment provided in another embodiment of the present application, the rendering unit includes:

[0175] The selection unit is used to select a rendering algorithm based on the geometric structure and material characteristics of the virtual scene and the virtual model in the virtual scene.

[0176] The calculation unit is used to simulate each current light source in the virtual scene based on the current dynamic lighting model, and calculate the color of the intersection of the light of each current light source and the object in the virtual scene through the selected rendering algorithm.

[0177] The rendering generation unit is used to generate a current rendering rendering of the virtual model by using the color of the intersection of the light and the object in the virtual scene.

[0178] Optionally, in the device for realizing the real-virtual environment provided in another embodiment of the present application, the device further includes:

[0179] The receiving unit is used to receive the shadow parameters input by the user in real time.

[0180] The adjustment unit is used to adjust the current rendering effect image of the virtual scene based on the shadow parameters and perform preview display.

[0181] The saving unit is used to save the current shadow parameters and the current rendering effect image of the virtual scene when receiving the confirmation instruction issued by the user.

[0182] Optionally, in the device for realizing the real-virtual environment provided in another embodiment of the present application, the mixing unit includes:

[0183] The internal parameter acquisition unit is used to obtain the internal parameters of the camera of the virtual reality device.

[0184] The distortion transformation unit is used to use the internal parameters of the camera to perform image distortion transformation on the current rendering effect image of the virtual model.

[0185] The pose update unit is used to update the pose information of the camera in space.

[0186] The combining unit is used to mix the current rendering effect of the virtual model with the image of the current actual environment, and perform occlusion processing and lighting synthesis based on the depth information of the current rendering effect of the virtual model and the image of the current actual environment to obtain the current real-virtual environment rendering.

[0187] Optionally, in the device for realizing the real-virtual environment provided in another embodiment of the present application, the device further includes:

[0188] The rendering updating unit is used to update the environment information in real time by using the inter-frame tracking technology, and to update the current real-virtual environment rendering by using the updated environment information.

[0189] Another embodiment of the present application provides an electronic device, such as Figure 7 As shown, including:

[0190] Memory 701 and processor 702 .

[0191] The memory 701 is used to store programs.

[0192] The processor 702 is used to execute the program stored in the memory 701. When the program is executed, it is specifically used to implement the return mode testing method provided by any one of the above embodiments.

[0193] Another embodiment of the present application provides a computer storage medium for storing a computer program. When the computer program is executed, it is used to implement the return mode testing method provided in any one of the above embodiments.

[0194] Computer storage media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0195] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0196] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for realizing a real virtual environment, characterized in that: include: Real-time acquisition of visible light images of the current actual environment and depth images in multiple directions; Detecting the visible light image using a light source detection model to obtain light source information of each current light source; Extracting depth data from each of the depth images and fusing them to obtain fused depth data; Performing three-dimensional reconstruction based on the fused depth data and extracting environmental texture information from the visible light image to obtain a current three-dimensional model; Combining the light source information of each of the current light sources with the current three-dimensional model to obtain a current dynamic lighting model; Based on the visible light image, the current three-dimensional model and the current dynamic illumination model, construct a virtual scene matching the current actual environment, and set a virtual model in the virtual scene; Calculating the shadow effect of the object in the virtual scene under the illumination corresponding to the current dynamic illumination model by using the selected rendering algorithm to obtain a current rendering effect diagram of the virtual scene; The current rendering effect diagram of the virtual model is extracted from the current rendering effect diagram of the virtual scene, and the current rendering effect diagram of the virtual model is mixed and inserted into the image of the current actual environment to obtain the current real-virtual environment rendering diagram.

2. The method according to claim 1, characterized in that The step of constructing a virtual scene matching the current actual environment based on the visible light image, the current three-dimensional model and the current dynamic illumination model, and setting a virtual model in the virtual scene comprises: Create the initial virtual scene; generating a basic geometric structure of the virtual scene based on the visible light image; Constructing the three-dimensional structure and texture of the virtual scene using the current three-dimensional model; Setting a transparent area in the virtual scene; Importing a virtual model selected by a user, and placing the virtual model in the transparent area; The current light sources are set in the virtual scene based on the current dynamic lighting model.

3. The method according to claim 1, characterized in that: The step of calculating the shadow effect of the object in the virtual scene under the illumination corresponding to the current dynamic illumination model by using the selected rendering algorithm to obtain the current rendering effect diagram of the virtual scene includes: Selecting a rendering algorithm based on the virtual scene and the geometric structure and material properties of the virtual model in the virtual scene; Simulating the light of each current light source in the virtual scene based on the current dynamic lighting model, and calculating the color of the intersection of the light of each current light source and the surface of the object in the virtual scene by the selected rendering algorithm; The current rendering effect image of the virtual model is generated by using the color of the intersection of the light and the surface of the object in the virtual scene.

4. The method according to claim 1, characterized in that: After calculating the shadow effect of the object in the virtual scene under the illumination corresponding to the current dynamic illumination model by the selected rendering algorithm to obtain the current rendering effect diagram of the virtual scene, the method further includes: Receive shadow parameters input by users in real time; Adjusting the current rendering effect image of the virtual scene based on the shadow parameters and performing a preview display; When the confirmation instruction sent by the user is received, the current shadow parameters and the current rendering effect image of the virtual scene are saved.

5. The method according to claim 1, characterized in that: The step of mixing and inserting the current rendering effect image of the virtual model into the image of the current actual environment to obtain the current real-virtual environment effect image includes: Get the internal parameters of the camera of the virtual reality device; Using the internal parameters of the camera to perform image distortion transformation on the current rendering effect image of the virtual model; Updating the position information of the camera in space; The current rendering effect image of the virtual model is mixed with the image of the current actual environment, and occlusion processing and lighting synthesis are performed based on the depth information of the current rendering effect image of the virtual model and the image of the current actual environment to obtain the current real-virtual environment rendering image.

6. The method according to claim 5, characterized in that Also includes: The environmental information is updated in real time using the inter-frame tracking technology, and the current real-virtual environment effect map is updated using the updated environmental information.

7. A device for realizing a real-virtual environment, characterized in that: include: The acquisition unit is used to acquire the visible light image of the current actual environment and the depth images in multiple directions in real time; A detection unit, used to detect the visible light image through a light source detection model to obtain light source information of each current light source; An information analysis unit, configured to extract depth data from each of the depth images and fuse them to obtain fused depth data, and to perform three-dimensional reconstruction based on the fused depth data and environmental texture information extracted from the visible light image to obtain a current three-dimensional model; A combining unit, used to combine the light source information of each of the current light sources with the current three-dimensional model to obtain a current dynamic lighting model; A construction unit, configured to construct a virtual scene matching the current actual environment based on the visible light image, the current three-dimensional model and the current dynamic illumination model, and to set a virtual model in the virtual scene; A rendering unit, configured to calculate the shadow effect of the object in the virtual scene under the illumination corresponding to the current dynamic illumination model by using a selected rendering algorithm, and obtain a current rendering effect diagram of the virtual scene; The mixing unit is used to extract the current rendering effect image of the virtual model from the current rendering effect image of the virtual scene, and mix and insert the current rendering effect image of the virtual model into the image of the current actual environment to obtain the current real-virtual environment effect image.

8. The device according to claim 7, characterized in that The construction unit comprises: A creation unit, used to create an initial virtual scene; A structure generating unit, configured to generate a basic geometric structure of the virtual scene based on the visible light image; A restoration unit, configured to construct a three-dimensional structure and texture of the virtual scene using the current three-dimensional model; An area setting unit, used for setting a transparent area in the virtual scene; An importing unit, used for importing a virtual model selected by a user and placing the virtual model in the transparent area; A light source setting unit is used to set each current light source in the virtual scene based on the current dynamic lighting model.

9. An electronic device, characterized in that: include: Memory and processor; Wherein, the memory is used to store programs; The processor is used to execute the program, and when the program is executed, it is specifically used to implement the method for realizing the real virtual environment as described in any one of claims 1 to 6.

10. A computer storage medium, characterized in that: Used to store computer programs, which, when executed, are used to implement the method for realizing the real virtual environment as described in any one of claims 1 to 6.