A method, device, electronic device and storage medium for converting 3D image to 2D image
By 3D scene rendering and hidden rendering of panoramic images, pixel information of the target viewing angle is obtained, and 2D plan view is generated, which solves the problems of inaccurate conversion and high quality in the existing technology, and achieves the effect of rapid loading and accurate conversion.
Patent Information
- Application Number
- CN202111166315.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2041-09-30
AI Technical Summary
When the prior art converts part of the viewing angle of a 3D scene into a 2D plan, it is impossible to accurately convert part of the viewing angle of the panoramic picture, and the converted 2D plan is of high quality, resulting in white screen or crashes and crashes when the program is loaded and displayed.
By rendering the target panoramic image in 3D scene, obtaining the target view angle according to the user-controlled 3D scene rotation process, performing hidden rendering, and saving pixel information in the painting buffer generated during the hidden rendering process, using these pixel information to generate a 2D plan.
It realizes accurate acquisition of 2D plan views corresponding to the area of the panoramic image, and while ensuring clarity, it reduces image quality, improves image loading speed, and shortens white screen time.
Smart Images

Figure CN113989101B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, electronic device and storage medium for converting a 3D image into a 2D image. Background Art
[0002] In the process of software development, in order to show users a more realistic scene, it is often necessary to display a panoramic scene, that is, render a 3D scene. In the existing 3D scene rendering, a panoramic picture is required. However, in actual applications, 2D display and 3D display have different advantages and disadvantages. Sometimes we need to convert part of the perspective of a 3D scene into a 2D plane for 2D display.
[0003] In the prior art, panoramic images can only be directly converted into 2D plane images for 2D display. However, this cannot guarantee the accurate conversion of the 2D plane images of part of the panoramic image's perspective. In addition, the quality of the panoramic image directly converted into a 2D plane image is relatively large. When the program is loaded and displayed, a white screen will appear for a certain period of time, and even a crash may occur. Summary of the invention
[0004] The purpose of the present invention is to propose a method, device, electronic device and storage medium for converting 3D images into 2D images in view of the deficiencies of the above-mentioned prior art. This purpose is achieved through the following technical solutions.
[0005] A first aspect of the present invention provides a method for converting a 3D image into a 2D image, the method comprising:
[0006] After performing 3D scene rendering on the target panoramic image, the target viewing angle is obtained according to the process of the user controlling the rotation of the 3D scene;
[0007] Performing hidden rendering on the target panoramic image according to the target viewing angle;
[0008] Save the pixel information in the drawing buffer generated during the hidden rendering process;
[0009] Generate a 2D plane image using the saved pixel information.
[0010] In some embodiments of the present application, the step of performing 3D scene rendering on the target panoramic image includes:
[0011] The method comprises the steps of: requesting image fragments corresponding to a target panoramic image from an image server through a first image link; the image fragments are obtained by slicing the target panoramic image with different resolutions; creating a first rendering container, wherein a transparency parameter of the first rendering container is a first preset value, which is used to indicate that a rendered 3D scene is visible to a user; obtaining a scene tag pre-set for the target panoramic image; and performing 3D scene rendering according to the first rendering container, the scene tag, and the image fragments.
[0012] In some embodiments of the present application, the step of obtaining a target viewing angle according to a process in which the user controls the rotation of the 3D scene includes:
[0013] When it is detected that the mouse selects the 3D scene, the initial position of the mouse is recorded; when it is detected that the mouse releases the 3D scene, the end position of the mouse is recorded; and the target viewing angle is determined according to the initial position and the end position.
[0014] In some embodiments of the present application, the step of performing hidden rendering on the target panoramic image according to the target viewing angle includes:
[0015] Receive a trigger instruction input from an external source; and when triggered by the trigger instruction, perform hidden rendering on the target panoramic image according to the target viewing angle.
[0016] In some embodiments of the present application, the step of performing hidden rendering on the target panoramic image according to the target viewing angle includes:
[0017] A second rendering container is created, wherein the transparency parameter of the second rendering container is a second preset value, which is used to indicate that the rendered 3D scene is in a hidden state; image fragments corresponding to the target panoramic image are obtained; and according to the image fragments, pixel information corresponding to the target perspective is drawn in a drawing buffer corresponding to the second rendering container to complete hidden rendering.
[0018] In some embodiments of the present application, the step of saving pixel information in a drawing buffer generated during the hidden rendering process includes:
[0019] The timing starts from the time when the hidden rendering process is executed; when the timing reaches a preset time, the pixel information currently drawn in the drawing buffer is stored and used as the pixel information corresponding to the target viewing angle.
[0020] In some embodiments of the present application, the step of generating a 2D plane image using the stored pixel information includes:
[0021] The pixel information is compressed according to a preset ratio; and the compressed pixel information is converted into a 2D plane image.
[0022] In some embodiments of the present application, after generating the 2D plane image using the stored pixel information, the method further includes:
[0023] The 2D plan view is uploaded to a backend server so that the backend server generates a second image link for the 2D plan view; and the second image link returned by the backend server is received and saved.
[0024] A second aspect of the present invention provides a device for converting a 3D image into a 2D image, the device comprising:
[0025] A viewing angle acquisition module is used to acquire a target viewing angle according to a process in which a user controls the rotation of the 3D scene after rendering the target panoramic image in 3D;
[0026] A hidden rendering module, used for performing hidden rendering on the panoramic image according to the target viewing angle;
[0027] A pixel acquisition module is used to save pixel information in the drawing buffer generated during the hidden rendering process;
[0028] The 2D image generation module is used to generate a 2D plane image using the saved pixel information.
[0029] The third aspect of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect when executing the program.
[0030] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the steps of the method described in the first aspect above.
[0031] Based on the 3D image to 2D image conversion method and device described in the first aspect and the second aspect, the present invention has at least the following beneficial effects or advantages:
[0032] By rendering the 3D scene of the panoramic image, the user can rotate the 3D scene to the target scene, so as to obtain the viewing angle of the target scene, and then hide the rendering of the panoramic image according to the target viewing angle, and obtain the pixel information of the area corresponding to the target viewing angle from the drawing buffer used in the hidden rendering process, so as to generate a 2D plane map from these pixel information. In this way, not only can the 2D plane map of the area corresponding to the partial viewing angle of the panoramic image be accurately obtained, but also because the present application only uses the pixels of the area corresponding to the target viewing angle to generate the 2D plane map, compared with the method of directly converting the panoramic image into a 2D plane map in the prior art, it can also reduce the image quality while ensuring the clarity of the 2D plane map, improve the image loading speed, and thus shorten the white screen time. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0034] Figure 1 This is a flow chart of an embodiment of a method for converting a 3D picture to a 2D picture according to an exemplary embodiment of the present invention;
[0035] Figure 2 1 is a schematic diagram of a rendering process of a target panoramic picture according to the embodiment shown in 1 of the present invention;
[0036] Figure 3 This is a schematic diagram of a process of requesting image fragments according to an exemplary embodiment of the present invention;
[0037] Figure 4 1 is a schematic diagram of a hidden rendering process of a target panoramic picture according to the embodiment shown in 1 of the present invention;
[0038] Figure 5 This is a schematic diagram of a complete conversion process from a 3D image to a 2D image according to an exemplary embodiment of the present invention;
[0039] Figure 6 It is a structural schematic diagram of a device for converting a 3D image into a 2D image according to an exemplary embodiment of the present invention;
[0040] Figure 7 A schematic diagram of the hardware structure of an electronic device according to an exemplary embodiment of the present invention;
[0041] Figure 8 The figure is a schematic diagram of the structure of a storage medium according to an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0042] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0043] The terms used in the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The singular forms "a", "the" and "the" used in the present invention and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0044] It should be understood that although the terms first, second, third, etc. may be used in the present invention to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present invention, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0045] At present, the size of a panoramic image is generally between 20M and 30M. When the front-end requests to display it, it will render the panoramic image into a 3D scene and add the scene tag of the panoramic image to the 3D scene. In actual applications, sometimes it is necessary to convert part of the perspective of the 3D scene into a 2D plane map. In order to ensure the smoothness of program loading, the quality of the 2D plane map needs to be within 200K.
[0046] However, the existing technology of directly converting panoramic images into 2D plane images not only fails to achieve the 2D plane image effect of a partial perspective of the panoramic image, but also the quality of the 2D plane images converted within a reasonable clarity range far exceeds 200K, which cannot meet actual needs.
[0047] In order to solve the above technical problems, the present application proposes an improved method for converting 3D images into 2D images, that is, after performing 3D scene rendering on the target panoramic image, the target viewing angle is obtained according to the process of user controlling the rotation of the 3D scene, and then the target panoramic image is hidden rendered according to the target viewing angle, and the pixel information in the painting buffer generated during the hidden rendering process is saved, and then a 2D plane image is generated using the saved pixel information.
[0048] The technical effects that can be achieved based on the technical solution described above are:
[0049] By rendering the 3D scene of the panoramic image, the user can rotate the 3D scene to the target scene, so as to obtain the viewing angle of the target scene, and then hide the rendering of the panoramic image according to the target viewing angle, and obtain the pixel information of the area corresponding to the target viewing angle from the drawing buffer used in the hidden rendering process, so as to generate a 2D plane map from these pixel information. In this way, not only can the 2D plane map of the area corresponding to the partial viewing angle of the panoramic image be accurately obtained, but also because the present application only uses the pixels of the area corresponding to the target viewing angle to generate the 2D plane map, compared with the method of directly converting the panoramic image into a 2D plane map in the prior art, it can also reduce the image quality while ensuring the clarity of the 2D plane map, improve the image loading speed, and thus shorten the white screen time.
[0050] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0051] Embodiment 1:
[0052] Figure 1 FIG. 1 is a flow chart of an embodiment of a method for converting a 3D image to a 2D image according to an exemplary embodiment of the present invention. The method can be applied to any electronic device capable of connecting to the Internet, such as Figure 1 As shown, the method for converting a 3D image to a 2D image includes the following steps:
[0053] Step 101: 3D scene rendering is performed on the target panoramic image.
[0054] The target panoramic image is a panoramic material pre-uploaded to a backend server, which is a server of an application program APP (i.e., a front end) installed on the electronic device.
[0055] In an optional specific embodiment, the rendering of the 3D scene can be performed by using image fragments after image slicing with different resolutions to reduce the blank time of loading images in the panoramic scene.
[0056] Before executing step 101, when the background server receives the panoramic picture uploaded by the user, it can process the panoramic picture with different resolutions, and then cut the panoramic picture of each resolution to obtain picture fragments with different resolutions, and then use the naming information of the panoramic picture and the address of the picture server to generate a first picture link for these picture fragments and return it to the front end.
[0057] Optionally, when the user uploads a panoramic picture, if the upload is successful, the background server returns a notification of successful upload to the front end, and the front end displays a blue progress bar to inform the user that the upload is successful. If the upload fails, the background server returns a notification of failed upload to the front end, and the front end outputs a pop-up prompt and displays a red progress bar indicating failed upload.
[0058] Optionally, you can use the configuration file of the krpano software to cut the panoramic images of each resolution.
[0059] In a specific implementation, the background server can store image fragments of a certain resolution in a file, and when storing, the image fragments can be compressed to a certain extent. In this way, when rendering a 3D scene, the electronic device can first load image fragments with low clarity (i.e., low resolution) for rendering according to the network status, and then replace them with high-definition image fragments, thereby reducing the blank time of loading images.
[0060] Optionally, for the generation process of the first image link, a hash algorithm can be used to generate a first image link named with the naming information of the panoramic image, and the first image link points to an image server, which can be a CDN (Content Delivery Network) image server.
[0061] Based on this, for the process of rendering the target panoramic image into a 3D scene, see Figure 2 As shown, the following steps are included:
[0062] Step 201: Requesting image fragments corresponding to a target panoramic image from an image server through a first image link.
[0063] Optional, for the image fragment request process, such as Figure 3 As shown, when the image server receives a request, it will first search for the requested image fragments locally. If it cannot find them, it will make a back-to-source request to the background server to pull the corresponding image fragments. While returning the pulled image fragments to the front end, it will back them up locally. In this way, when a second request is received later, it can first find the requested image fragments locally and return them to the front end.
[0064] In this embodiment, since the image server can distribute requests according to the distance of the node from which the front-end initiates the request, by using the image server to process the front-end request, the user request can be responded to in the shortest time, the waiting time can be reduced, and the user experience can be improved.
[0065] Step 202: Create a first rendering container.
[0066] The transparency parameter of the first rendering container is a first preset value, which is used to indicate that the rendered 3D scene is visible to the user. For example, when the transparency parameter is 1, it indicates that the rendered 3D scene is visible to the user.
[0067] Optionally, the size of the first rendering container may be a preset size, or may be determined according to the size of the display screen, which is not specifically limited in this application. For example, the size of the first rendering container may be 500px*500px.
[0068] Step 203: Obtain a scene tag pre-set for the target panoramic image.
[0069] The scene tag is set by the user for the target panoramic image and is used to indicate the scene information represented by a certain area in the panoramic image.
[0070] Step 204: Perform 3D scene rendering according to the first rendering container, the scene tag, and the image fragment.
[0071] Specifically, the first rendering container, the image fragments, and the default viewing angle parameters are input into a preset panoramic rendering function, so that the panoramic rendering function draws the pixel information corresponding to the default viewing angle in the drawing buffer corresponding to the first rendering container according to the image fragments, and draws the scene label to the corresponding position of the drawing buffer.
[0072] Since the transparency parameter of the first renderer indicates that it is visible to the user, the scene content and the scene label drawn in the drawing buffer are visible to the user.
[0073] Step 102: Acquire a target viewing angle according to the process of the user controlling the rotation of the 3D scene.
[0074] The target viewing angle is the viewing angle corresponding to the scene content in a certain area of the panoramic image that the user wants to obtain.
[0075] Based on the rendering process described in step 101 above, after the 3D scene is rendered, the user can arbitrarily control the rotation of the 3D scene to view the scene content of the areas corresponding to different perspectives. During the rotation of the 3D scene, the scene content drawn in the drawing buffer corresponding to the first rendering container changes in real time, and the added scene label also changes in real time.
[0076] In an optional specific embodiment, for the process of acquiring the target perspective, when it is detected that the mouse selects the 3D scene, the initial position of the mouse is recorded, and when it is detected that the mouse releases the 3D scene, the end position of the mouse is recorded, so as to determine the target perspective based on the initial position and the end position.
[0077] Among them, the recorded end position of the mouse is the viewing angle position of the scene content that the user wants to obtain. Assuming the initial position is (x1, y1) and the end position is (x2, y2), the target viewing angle of the rotating 3D scene is obtained according to the change of the y value obtained by y2-y1 and the change of the x value obtained by x2-x1.
[0078] It should be noted that since the user can control the rotation of the 3D scene at will, in order to avoid the problem of saving the target viewing angle every time the scene is rotated, a lock button can be added to the 3D scene. Only after the lock button is detected to be triggered, the target viewing angle can be determined based on the initial position and end position recorded during the rotation process.
[0079] Step 103: Perform hidden rendering on the target panoramic image according to the target viewing angle.
[0080] Among them, the hidden rendering principle is similar to the 3D scene rendering principle in the above step 101, except that the rendering result after the target panoramic image is hidden is not visible to the user, and the hidden rendering does not add scene tags, so the rendering result only contains the scene content from the target perspective.
[0081] It should be noted that a setting button can be added to the 3D scene. When it is detected that the setting button is triggered, that is, a trigger instruction input from the outside is received, the process of step 103 is executed under the triggering of the trigger instruction. The generation of the 2D plan view is performed only when the user control needs to be converted, instead of generating a 2D plan view every time the user controls the 3D scene to rotate, thereby meeting the actual needs of the user.
[0082] In an optional specific embodiment, for the hidden rendering process, see Figure 4 As shown, the following steps are included:
[0083] Step 401: Create a second rendering container.
[0084] The transparency parameter of the second rendering container is a second preset value, which is used to indicate that the rendered 3D scene is in a hidden state, that is, invisible to the user.
[0085] It is worth noting that the size of the second rendering container determines the size of the 2D floor plan generated later. Therefore, the size required when creating the second rendering container can be pre-set according to the user's actual needs for the size of the 2D floor plan. For example, if the user needs to generate a 1000*1000 2D floor plan, then a 1000px*1000px second rendering container can be created.
[0086] Step 402: Obtain image fragments corresponding to the target panoramic image.
[0087] The image fragments used in the hidden rendering process are derived from the image fragments requested in the above step 101 .
[0088] Step 403: Draw pixel information corresponding to the target viewing angle in the drawing buffer corresponding to the second rendering container according to the image fragments to complete hidden rendering.
[0089] Specifically, the second rendering container, the image fragments, and the target viewing angle parameters are input into a preset panoramic rendering function, so that the panoramic rendering function draws pixel information corresponding to the target viewing angle in a drawing buffer corresponding to the second rendering container according to the image fragments.
[0090] Since the transparency parameter of the second renderer represents a hidden state, the scene content in the drawing buffer corresponding to the second rendering container is not visible to the user.
[0091] Step 104: Save the pixel information in the drawing buffer generated during the hidden rendering process.
[0092] Among them, a panoramic rendering function is usually used to implement 3D scene rendering. Since the pixel information drawn in the painting buffer changes in real time with the rotation of the 3D scene, the panoramic rendering function will not save the contents of the painting buffer. In order to save the contents of the painting buffer, this application adds preset parameters in the panoramic rendering function to save the contents of the painting buffer.
[0093] In the specific implementation, if you use the panoramic rendering function embedpano provided by krpano, you can save the content of the drawing buffer by adding only+webgl+preserverDrawingBuffer parameters in embedpano.
[0094] In an optional specific embodiment, during the rendering process of the panoramic rendering function, image fragments of different resolutions are loaded and rendered asynchronously, that is, the image fragments with low definition are loaded and rendered first according to the network status, and then the high-definition image fragments are replaced. Therefore, it takes a certain amount of time to render the scene. In order to obtain a clear effect, this application triggers a save event by adding a timer in the panoramic rendering function called by the hidden rendering. Its working principle is: start timing from the execution of the hidden rendering process, and when the timing reaches the preset time, store the pixel information currently drawn in the drawing buffer as the pixel information corresponding to the target perspective.
[0095] The preset time is a time set based on practical experience that can ensure a clear effect.
[0096] In an optional implementation, when saving pixel information, the upper left corner of the painting buffer corresponding to the second rendering container can be defined as (0,0), and the pixel points can be traversed from the upper left corner of the painting buffer for saving to form a two-dimensional array represented by x and y.
[0097] Step 105: Generate a 2D plane image using the saved pixel information.
[0098] The pixel information obtained from the drawing buffer belongs to the scene content of the area corresponding to the target perspective in the panoramic image, so the 2D plane map generated by these pixel information is the scene of the area corresponding to the target perspective in the panoramic image. And the generated 2D plane map is based on the width of the drawing buffer as the width of the 2D plane map, and the height of the drawing buffer as the height of the 2D plane map.
[0099] In an optional specific embodiment, in order to ensure the smoothness of the program loading the 2D plane map, the pixel information is compressed according to a preset ratio, and then the compressed pixel information is converted into a 2D plane map.
[0100] Among them, the pixel information in the drawing buffer is composed of multiple pixel points, each pixel point is represented by four parameters (r, g, b, a), where r represents the red pixel value, g represents the green pixel value, b represents the blue pixel value, and a represents the clarity parameter of the pixel point. If the a value of each pixel point in the pixel information is larger, the quality of the generated 2D plane image will be greater.
[0101] Based on this, when compressing pixel information, the clarity parameter of each pixel in the pixel information is compressed and adjusted according to a preset ratio to ensure that the quality of the generated 2D plan view meets the size requirements for fast loading.
[0102] For example, the preset ratio may be set to 0.8, that is, the clarity parameter in each pixel is multiplied by 0.8 to reduce the clarity parameter of the pixel, thereby compressing the quality of the 2D plane image by 20%.
[0103] It should be noted that after executing step 105, the 2D plan view is uploaded to the backend server so that the backend server generates a second image link for the 2D plan view, and the second image link returned by the backend server is received and saved for subsequent 2D image display.
[0104] In order to respond to user requests in the shortest time, reduce waiting time, and improve user experience, the generated second image link also points to the image server.
[0105] At this point, the above Figure 1The conversion process shown in the figure, by rendering the 3D scene of the panoramic picture, the user can rotate the 3D scene to the target scene, so as to obtain the perspective of the target scene, and then hide the rendering of the panoramic picture according to the target perspective, and obtain the pixel information of the area corresponding to the target perspective from the drawing buffer used in the hidden rendering process, so as to generate a 2D plane map from these pixel information, so that not only can the 2D plane map of the area corresponding to the partial perspective of the panoramic picture be accurately obtained, but also because the present application only uses the pixels of the area corresponding to the target perspective to generate the 2D plane map, compared with the method of directly converting the panoramic picture into a 2D plane map in the prior art, it can also reduce the picture quality while ensuring the clarity of the 2D plane map, improve the picture loading speed, and thus shorten the white screen time.
[0106] Embodiment 2:
[0107] Figure 5 FIG. 1 is a schematic diagram of a complete conversion process from a 3D image to a 2D image according to an exemplary embodiment of the present invention.
[0108] After the front end names the panoramic image according to a certain naming rule (for example, organization id_number of floors_scene), the panoramic image is uploaded to the backend server; the backend server cuts the uploaded panoramic image according to different resolutions, obtains image fragments of different resolutions and saves them to a specified directory, and generates a first image link pointing to the image server for these image fragments and returns it to the front end; the front end requests the image fragments of the panoramic image through the first image link, and uses the image fragments and the scene tags pre-set for the panoramic image to perform 3D scene rendering to generate a 3D scene with a scene tag. The user drags the 3D scene to obtain the target viewing angle, and then when the front end receives the floor plan generation instruction triggered by the user, it performs hidden rendering according to the target viewing angle to generate an invisible 3D scene without a scene tag, and saves the pixel information in the drawing buffer used for the hidden rendering, and then uses the saved pixel information to generate a 2D floor plan that meets the actual needs of the user.
[0109] Based on the above embodiment, by rendering the 3D scene of the panoramic image, the user can rotate the 3D scene to the target scene, so as to obtain the viewing angle of the target scene, and then hide the rendering of the panoramic image according to the target viewing angle, and obtain the pixel information of the area corresponding to the target viewing angle from the drawing buffer used in the hidden rendering process, so as to generate a 2D plane map from these pixel information. In this way, not only can the 2D plane map of the area corresponding to the partial viewing angle of the panoramic image be accurately obtained, but also because the present application only uses the pixels of the area corresponding to the target viewing angle to generate the 2D plane map, compared with the method of directly converting the panoramic image into a 2D plane map in the prior art, it can also reduce the image quality while ensuring the clarity of the 2D plane map, improve the image loading speed, and thus shorten the white screen time.
[0110] Corresponding to the above-mentioned embodiment of the method for converting a 3D picture into a 2D picture, the present invention further provides an embodiment of an apparatus for converting a 3D picture into a 2D picture.
[0111] Figure 6 FIG. 1 is a schematic diagram of a structure of a 3D picture to 2D picture conversion device according to an exemplary embodiment of the present invention. The device is used to execute the 3D picture to 2D picture conversion method provided in any of the above embodiments, such as Figure 6 As shown, the 3D picture to 2D picture conversion device includes:
[0112] A viewing angle acquisition module 610 is used to acquire a target viewing angle according to a process in which a user controls the rotation of the 3D scene after rendering the target panoramic image in 3D;
[0113] A hidden rendering module 620, configured to perform hidden rendering on the panoramic image according to the target viewing angle;
[0114] The pixel acquisition module 630 is used to store pixel information in the drawing buffer generated during the hidden rendering process;
[0115] The 2D image generation module 640 is used to generate a 2D plane image using the stored pixel information.
[0116] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0117] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of the present invention. Ordinary technicians in this field can understand and implement it without paying creative work.
[0118] The embodiments of the present invention further provide an electronic device corresponding to the method for converting a 3D picture into a 2D picture provided in the aforementioned embodiments, so as to execute the aforementioned method for converting a 3D picture into a 2D picture.
[0119] Figure 7This is a hardware structure diagram of an electronic device according to an exemplary embodiment of the present invention, and the electronic device includes: a communication interface 601, a processor 602, a memory 603 and a bus 604; wherein the communication interface 601, the processor 602 and the memory 603 communicate with each other through the bus 604. The processor 602 can execute the above-described method of converting 3D pictures to 2D pictures by reading and executing machine executable instructions corresponding to the control logic of the method of converting 3D pictures to 2D pictures in the memory 603. The specific content of the method is referred to the above embodiment, and will not be repeated here.
[0120] The memory 603 mentioned in the present invention can be any electronic, magnetic, optical or other physical storage device, and can contain storage information, such as executable instructions, data, etc. Specifically, the memory 603 can be RAM (Random Access Memory), flash memory, storage drive (such as hard disk drive), any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 601 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used.
[0121] The bus 604 may be an ISA bus, a PCI bus or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory 603 is used to store programs, and the processor 602 executes the programs after receiving execution instructions.
[0122] The processor 602 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 602. The above processor 602 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be combined and executed.
[0123] The electronic device provided in the embodiment of the present application and the method for converting a 3D image to a 2D image provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, operated or implemented therein.
[0124] The present application also provides a computer-readable storage medium corresponding to the method for converting a 3D image to a 2D image provided in the above embodiment. Figure 8 As shown, the computer-readable storage medium shown is a CD 30 on which a computer program (ie, a program product) is stored. When the computer program is executed by a processor, the method for converting a 3D image to a 2D image provided in any of the aforementioned embodiments will be executed.
[0125] It should be noted that examples of the computer-readable storage medium may also 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 optical or magnetic storage media, which are not listed here one by one.
[0126] The computer-readable storage medium provided in the above-mentioned embodiment of the present application and the method for converting 3D images to 2D images provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the method adopted, run or implemented by the application program stored therein.
[0127] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art not disclosed by the present invention. The description and examples are to be regarded as exemplary only, and the true scope and spirit of the present invention is indicated by the following claims.
[0128] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0129] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for converting a 3D image to a 2D image, characterized in that: The method comprises: After performing 3D scene rendering on the target panoramic image, the target viewing angle is obtained according to the process of the user controlling the rotation of the 3D scene; Performing hidden rendering on the target panoramic image according to the target viewing angle; Save the pixel information in the drawing buffer generated during the hidden rendering process; Generate a 2D plane map using the saved pixel information; The step of performing hidden rendering on the target panoramic image according to the target viewing angle includes: Creating a second rendering container, wherein the transparency parameter of the second rendering container is a second preset value, which is used to indicate that the rendered 3D scene is in a hidden state; Obtain the image fragments corresponding to the target panoramic image; the image fragments are obtained by cutting the target panoramic image into different resolutions According to the image fragments, pixel information corresponding to the target viewing angle is drawn in a drawing buffer corresponding to the second rendering container to complete hidden rendering.
2. The method according to claim 1, characterized in that The 3D scene rendering of the target panoramic image includes: Requesting the image server for image fragments corresponding to the target panoramic image through the first image link; the image fragments are obtained by performing image slicing processing of different resolutions on the target panoramic image; Creating a first rendering container, wherein a transparency parameter of the first rendering container is a first preset value, which is used to indicate that the rendered 3D scene is visible to a user; Obtaining a scene tag pre-set for the target panoramic image; 3D scene rendering is performed according to the first rendering container, the scene tag, and the image fragment.
3. The method according to claim 1, characterized in that The process of obtaining the target viewing angle according to the process of the user controlling the rotation of the 3D scene includes: When it is detected that the mouse selects the 3D scene, the initial position of the mouse is recorded; When it is detected that the mouse releases the 3D scene, the end position of the mouse is recorded; The target viewing angle is determined according to the initial position and the end position.
4. The method according to claim 1, characterized in that The step of performing hidden rendering on the target panoramic image according to the target viewing angle includes: Receive trigger instructions from external input; Under the triggering instruction, the target panoramic picture is hidden and rendered according to the target viewing angle.
5. The method according to claim 1, characterized in that The step of saving pixel information in the drawing buffer generated during the hidden rendering process includes: The timing starts from the time when the hidden rendering process is executed; When the timing reaches a preset time, the pixel information currently drawn in the drawing buffer is stored and used as the pixel information corresponding to the target viewing angle.
6. The method according to claim 1, characterized in that The method of generating a 2D plane image by using the stored pixel information includes: compressing the pixel information according to a preset ratio; Convert the compressed pixel information into a 2D plane image.
7. The method according to claim 6, characterized in that The compressing the pixel information according to a preset ratio includes: The definition parameter of each pixel in the pixel information is compressed and adjusted according to a preset ratio.
8. The method according to claim 1, characterized in that After generating the 2D plane image using the stored pixel information, the method further includes: Uploading the 2D plan view to a backend server so that the backend server generates a second picture link for the 2D plan view; Receive and save the second picture link returned by the backend server.
9. A device for converting a 3D image into a 2D image, characterized in that: The device comprises: A viewing angle acquisition module is used to acquire a target viewing angle according to a process in which a user controls the rotation of the 3D scene after rendering the target panoramic image in 3D; A hidden rendering module, used for performing hidden rendering on the target panoramic image according to the target viewing angle; A pixel acquisition module is used to save pixel information in the drawing buffer generated during the hidden rendering process; A 2D image generation module is used to generate a 2D plane image using the saved pixel information; The hidden rendering module is specifically used to create a second rendering container, the transparency parameter of the second rendering container is a second preset value, which is used to indicate that the rendered 3D scene is in a hidden state; obtain image fragments corresponding to the target panoramic image; according to the image fragments, draw pixel information corresponding to the target perspective in a drawing buffer corresponding to the second rendering container to complete the hidden rendering; the image fragments are obtained by performing image slicing processing of different resolutions on the target panoramic image.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 8 are implemented.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Target object rendering method and device, computer equipment and medium
CN113096254A
Superimposing virtual views of 3D objects with live images
US8878846B1