Method, device and storage medium for generating panoramic images of virtual scenes

By using a virtual camera to emit rays and determine pixel coordinates and values ​​in virtual scenes, the seam problem in panoramic image generation is solved, and high-quality and efficient panoramic image generation is achieved.

CN119784577BActive Publication Date: 2025-05-09SHENZHEN XGRIDS-INNOVATION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510282918.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-11
Publication Date
2025-05-09
Estimated Expiration
2045-03-11

AI Technical Summary

Technical Problem

In the existing panoramic image generation method, the brightness, contrast and color between images do not match, resulting in easy seams at the splicing, which reduces the quality of the panoramic image.

Method used

By setting up a virtual camera in a virtual scene, controlling it to emit multiple rays at a fixed position, determining the angle of each ray on the spherical polar coordinate system, and determining the pixel coordinates and pixel values ​​according to the intersection of the ray and the target object, a panoramic image is generated.

Benefits of technology

This method can generate seamless panoramic images, improve the quality and generation efficiency of panoramic images, and avoid the joint problems caused by image stitching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119784577B_ABST
    Figure CN119784577B_ABST
Patent Text Reader

Abstract

The present application relates to the field of computer vision technology, and discloses a method, device and storage medium for generating a panoramic image of a virtual scene, the method comprising: obtaining a fixed position of a virtual camera in a virtual scene; controlling the virtual camera to emit multiple rays at the fixed position; determining the angle corresponding to each ray in a spherical polar coordinate system; determining the pixel coordinates of each ray on the panoramic image according to the angle corresponding to each ray; determining the pixel value corresponding to each pixel coordinate according to the initial intersection between the ray corresponding to each pixel coordinate and the target object in the virtual scene; generating a panoramic image according to each pixel coordinate and the pixel value corresponding to each pixel coordinate. In the above manner, the present application improves the quality of the panoramic image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer vision technology, and specifically to a method for generating a panoramic image of a virtual scene. Background Art

[0002] A panoramic image is a wide-angle image that can cover 360° or more horizontal viewing angle, and sometimes even vertical viewing angle, thus providing an all-round visual experience.

[0003] Currently, panoramic images are usually formed by stitching together multiple local images. However, the brightness, contrast and color between different images may not match each other, which makes it easy for seams to be generated at the joints between images. These seams are more obvious in the final panoramic image, resulting in reduced quality of the panoramic image. Summary of the invention

[0004] In view of the above problems, the embodiments of the present application provide a method, device and storage medium for generating a panoramic image of a virtual scene, which improves the quality of the panoramic image.

[0005] According to one aspect of an embodiment of the present application, a method for generating a panoramic image of a virtual scene is provided, the method comprising: obtaining a fixed position of a virtual camera in the virtual scene; controlling the virtual camera to emit multiple rays at the fixed position; determining the angle corresponding to each ray in a spherical polar coordinate system; determining the pixel coordinates of each ray on the panoramic image according to the angle corresponding to each ray; determining the pixel value corresponding to each pixel coordinate according to the initial intersection between the ray corresponding to each pixel coordinate and the target object in the virtual scene; and generating a panoramic image according to each pixel coordinate and the pixel value corresponding to each pixel coordinate.

[0006] In an optional manner, the angle includes a horizontal angle and a vertical angle; determining the pixel coordinates of each ray on the panoramic image according to the angle corresponding to each ray, further including: acquiring the width and height of the panoramic image; determining the horizontal pixel coordinates of each ray on the panoramic image according to the horizontal angle and width corresponding to each ray; determining the vertical pixel coordinates of each ray on the panoramic image according to the vertical angle and height corresponding to each ray.

[0007] In an optional manner, the horizontal pixel coordinate u of each ray on the panoramic image is: u=(θ / 2π)·W, where W represents the width of the panoramic image, and θ represents the horizontal angle corresponding to each ray; the vertical pixel coordinate v of each ray on the panoramic image is: v=(φ / 2π)·H, where H represents the height of the panoramic image, and φ represents the vertical angle corresponding to each ray.

[0008] In an optional manner, determining the pixel value corresponding to each pixel coordinate based on the initial intersection between the ray corresponding to each pixel coordinate and the target object in the virtual scene further includes: determining the direction vector of each ray based on the angle of the ray corresponding to each pixel coordinate; determining the ray equation of each ray based on a fixed position and the direction vector of each ray; determining the initial intersection of each ray in the virtual scene with the target object based on the ray equation of each ray and the equation of the surface of the target object; and determining the pixel value of each initial intersection as the pixel value corresponding to each pixel coordinate.

[0009] In an optional manner, the angle includes a horizontal angle and a vertical angle, and the direction vector D of each ray is: D=(sin(θ)cos(φ), sin(θ)sin(φ), cos(θ)), where θ represents the horizontal angle corresponding to each ray, and φ represents the vertical angle corresponding to each ray.

[0010] In an optional manner, the ray equation is: R(t)=P+t*D, where P represents the fixed position of the virtual camera and t represents the parameter along the ray direction.

[0011] In an optional manner, after determining the pixel value corresponding to each pixel coordinate based on the initial intersection between the ray corresponding to each pixel coordinate and the target object in the virtual scene, the method further includes: determining the neighboring pixel coordinates of the abnormal pixel coordinate for which the corresponding pixel value has not been determined; and calculating the pixel value corresponding to the abnormal pixel coordinate by interpolation based on the pixel values ​​corresponding to the neighboring pixel coordinates.

[0012] In an optional manner, controlling the virtual camera to emit a plurality of rays at a fixed position further includes: controlling the virtual camera to emit a plurality of rays along a horizontal direction of 0 to 360 degrees; and controlling the virtual camera to emit a plurality of rays along a vertical direction of 0 to 360 degrees.

[0013] According to another aspect of an embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the method for generating a panoramic image of a virtual scene provided in any of the above embodiments.

[0014] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, on which a computer program is stored, characterized in that when the computer program is executed by a processor, a panoramic image generation method of a virtual scene provided by any of the above embodiments is implemented.

[0015] The embodiment of the present application obtains the fixed position of the virtual camera in the virtual scene, and controls the virtual camera to emit multiple rays at the fixed position, so that the pixel coordinates of each ray on the panoramic image can be determined by the angle of each ray in the spherical polar coordinate system, and then the pixel value corresponding to each pixel coordinate is determined by the initial intersection between the ray corresponding to each pixel coordinate and the target object in the virtual scene, and the panoramic image can be generated by each pixel coordinate and its corresponding pixel value. In the above manner, not only the generation efficiency of the panoramic image can be improved, but also a seamless panoramic image can be generated, and the quality of the panoramic image can be improved.

[0016] The above description is only an overview of the technical solution of the embodiment of the present application. In order to more clearly understand the technical means of the embodiment of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present application. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings. In the accompanying drawings:

[0018] Figure 1 A schematic diagram showing a flow chart of a method for generating a panoramic image of a virtual scene provided in an embodiment of the present application is shown;

[0019] Figure 2 A schematic diagram of the process flow after step 150 is shown;

[0020] Figure 3 A schematic diagram of the structure of a panoramic image generating device for a virtual scene provided in an embodiment of the present application is shown;

[0021] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0022] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein.

[0023] In the existing panoramic image generation methods, multiple cameras are usually used to shoot a scene from different perspectives to obtain multiple images, and then these images are stitched together and integrated through an image stitching algorithm to form a panoramic image. Although the panoramic images obtained by the above method can cover a wide field of view, the brightness, contrast and color between different images may not match each other, which leads to seams at the joints between images. These seams are more obvious in the final panoramic image, especially in high dynamic range panoramic images or panoramic images containing complex scene information, which seriously affects the quality of the panoramic image.

[0024] In addition, during the image stitching process, the images need to be registered and post-processed to eliminate or reduce the traces of image stitching. This process is very likely to introduce stitching errors when dealing with scenes with depth information and complex geometric structures, such as misalignment, distortion or perspective distortion of overlapping areas of images. These errors further reduce the quality of the panoramic image.

[0025] In the fields of virtual reality, architectural visualization, film and television special effects, etc., 3D virtual scenes can provide highly realistic visual effects and immersive experiences. Through highly sophisticated modeling, mapping, lighting and rendering technologies, 3D modeling software can build virtual scenes of the real world and provide users with an immersive experience. For real scenes built with virtual scenes using 3D modeling software, there is no need to use multiple cameras to shoot images of real scenes from different angles and then stitch multiple images into a panoramic image. Instead, panoramic images are generated directly based on virtual scenes, avoiding the seams and stitching errors of panoramic images caused by traditional image stitching technology, and improving the quality of panoramic images.

[0026] Based on this, the present application provides a method for generating a panoramic image of a virtual scene, by controlling a virtual camera to emit rays in the virtual scene so that the rays intersect with the target object in the virtual scene, and determining the pixel coordinates of the intersection point on the panoramic image by the angle of the rays, and then determining the pixel value corresponding to each pixel coordinate by the intersection point between the rays corresponding to each pixel coordinate and the target object in the virtual scene, and finally, generating a panoramic image according to each pixel coordinate and its corresponding pixel value. In the above manner, not only can the generation efficiency of the panoramic image be improved, but also there is no need to stitch images, and a seamless panoramic image can be directly generated, thereby improving the quality of the panoramic image.

[0027] Figure 1 The flowchart of the method for generating a panoramic image of a virtual scene provided by an embodiment of the present application is shown, and the method is executed by an electronic device such as a computer or a server. Figure 1 As shown, the method comprises the following steps:

[0028] Step 110: Obtain a fixed position of the virtual camera in the virtual scene.

[0029] The virtual scene of the embodiments of the present application can be any type of virtual scene, such as a reconstructed scene (a three-dimensional scene reconstructed based on a real environment or data source), an artificially simulated three-dimensional scene (a virtual scene created by a computer), a real-shot panoramic virtual scene, a mixed reality (MR) virtual scene, a holographic projection virtual scene, a virtual reality (VR) and an augmented reality (AR) scene, etc.

[0030] The fixed position means that the virtual camera will not move during the panoramic image generation process. The fixed position can be defined by a three-dimensional coordinate point P (x, y, z).

[0031] At a fixed position, the field of view of the virtual camera can cover at least 360°, and can even cover 720°, that is, a range of 360° in both horizontal and vertical directions.

[0032] Step 120: Control the virtual camera to emit multiple rays at a fixed position.

[0033] Specifically, the virtual camera is controlled to emit rays in different directions, and these rays usually cover all directions within the field of view of the virtual camera, so that the rays intersect with all objects in the virtual scene to sample scene data in each direction of the virtual scene. For example, the virtual camera can be controlled to emit multiple rays in the horizontal direction of 0~360° at a fixed position, and emit multiple rays in the vertical direction of 0~360°.

[0034] In order to obtain a high-quality panoramic image, rays can be emitted non-uniformly in each direction of the virtual scene. In this case, the number of rays can be adjusted according to the importance of the objects in the scene. For example, when there is a key object in a certain direction of the virtual scene, more rays can be emitted in this direction to obtain a clearer image of the object. Rays can also be emitted adaptively according to the complexity of the scene, and the number of rays in a certain direction can be automatically adjusted according to the complexity of the scene, for example, more rays can be emitted in areas with rich scene details, and fewer rays can be emitted in areas with less scene details. Of course, in order to improve the efficiency of generating panoramic images, rays can also be emitted uniformly in each direction. For example, rays can be emitted uniformly along 720°, with one ray emitted every 1°, and a total of 720 rays are emitted. Furthermore, in order to reduce the stretching and distortion of the edges of the panoramic image, the angle difference between adjacent rays can be further reduced, for example, one ray is emitted every 0.5°, 0.1° or 0.01°.

[0035] Step 130: Determine the angle corresponding to each ray in the spherical polar coordinate system.

[0036] In spherical polar coordinates, the angle of each ray includes a horizontal angle θ and a vertical angle φ, where 0°≤θ<2π and 0°≤φ<2π.

[0037] The virtual camera emits each ray at a fixed position, and the ray will intersect with the target object in the virtual scene, so that the intersection point between the ray and the target object can be determined. In this way, the direction vector of the ray can be determined by the fixed position and the intersection point. This vector represents the direction of the ray from the fixed position to any point on the ray. The direction vector can be used to determine the corresponding angle of the ray in the spherical polar coordinate system.

[0038] Specifically, the relationship between the direction vector D of each ray and the horizontal angle θ and vertical angle φ of each ray is as follows:

[0039] D=(sin(θ)cos(φ),sin(θ)sin(φ),cos(θ)). (1)

[0040] Assuming the direction vector of each ray is (a, b, c), we can get:

[0041] a=sin(θ)cos(φ), b=sin(θ)sin(φ), c=cos(θ),

[0042] By calculation, the horizontal angle θ and vertical angle φ of each ray can be obtained. By determining the direction vector of each ray, the corresponding angle of each ray in the spherical polar coordinate system can be further calculated.

[0043] Step 140: Determine the pixel coordinates of each ray on the panoramic image according to the angle corresponding to each ray.

[0044] Specifically, step 140 includes the following steps:

[0045] Step 141: Obtain the width and height of the panoramic image.

[0046] Step 142: Determine the horizontal pixel coordinates of each ray on the panoramic image according to the horizontal angle corresponding to each ray and the width of the panoramic image.

[0047] Step 143: Determine the vertical pixel coordinate of each ray on the panoramic image according to the vertical angle corresponding to each ray and the height of the panoramic image.

[0048] The width and height of the panoramic image refer to the resolution of the panoramic image. For example, the width and height of the panoramic image can be set to 16000×8000.

[0049] When multiple rays are emitted from a fixed position P (x, y, z), the intersection points of each ray with the object are located on the spherical surface with point P as the center of the sphere. By mapping these intersection points on the spherical surface to the plane image, it is possible to ensure that the intersection points of each ray with the virtual scene are seamlessly mapped to the plane image. This mapping process actually converts the intersection points on the spherical surface into pixel positions on the panoramic image. This mapping maintains that adjacent points on the spherical surface are also adjacent on the panoramic image, thereby reproducing the panoramic perspective in three-dimensional space on a two-dimensional plane.

[0050] In order to map the intersection point on the sphere to the two-dimensional image plane, it is necessary to convert the angle corresponding to each ray into pixel coordinates on the panoramic image, that is, to convert the horizontal angle and vertical angle corresponding to each ray into horizontal pixel coordinates and vertical pixel coordinates on the panoramic image.

[0051] Specifically, the calculation formula for the horizontal pixel coordinate u of each ray on the panoramic image is as follows:

[0052] u = (θ / 2π)·W, (2)

[0053] Where W represents the width of the panoramic image, and θ represents the horizontal angle corresponding to each ray;

[0054] The calculation formula for the vertical pixel coordinate v of each ray on the panoramic image is as follows:

[0055] v = (φ / 2π)·H, (3)

[0056] Where H represents the height of the panoramic image, and φ represents the vertical angle corresponding to each ray.

[0057] By using the above formulas (2) and (3), the horizontal angle and vertical angle corresponding to each ray are proportionally mapped to the horizontal coordinate and vertical coordinate of the panoramic image respectively, which ensures that the intersection point of each ray with the virtual scene is mapped to the panoramic image, thereby completely representing the field of view of the entire spherical surface as a rectangular image.

[0058] Step 150: Determine the pixel value corresponding to each pixel coordinate according to the initial intersection point between the ray corresponding to each pixel coordinate and the target object in the virtual scene.

[0059] After confirming the pixel coordinates of each ray on the panoramic image, it is also necessary to determine the pixel value of each pixel coordinate, that is, to determine the color corresponding to each pixel coordinate. Only through each pixel coordinate and its corresponding pixel value can a complete panoramic image be generated.

[0060] Specifically, step 150 includes the following steps:

[0061] Step 151: Determine the direction vector of each ray according to the angle of the ray corresponding to each pixel coordinate.

[0062] The ray corresponding to each pixel coordinate can be directly determined in step 140 according to the corresponding relationship between the ray corresponding angle and the pixel coordinate, or the angle corresponding to each ray can be obtained by re-inferring according to the above formula (2), formula (3) and each pixel coordinate.

[0063] After determining the horizontal angle and vertical angle of each ray, the direction vector D of each ray can be determined according to the horizontal angle and vertical angle of each ray. The specific formula can refer to formula (1).

[0064] Step 152: Determine the ray equation of each ray based on the fixed position and the direction vector of each ray.

[0065] The ray equation is: R(t)=P+t*D, where P represents the fixed position of the virtual camera and t represents the parameter along the ray direction, which can be used to characterize the distance from the starting point to the intersection of the ray with the target object.

[0066] Step 153: Determine the initial intersection point of each ray in the virtual scene with the target object according to the ray equation of each ray and the equation of the surface of the target object.

[0067] For each target object in the virtual scene, its initial intersection point with each ray can be determined based on the ray equation of each ray and the equation of the target object surface. The equation of the target object surface is Y=O+s*N, where O is a point on the object, N is the normal of the object surface, and s is a parameter along the normal.

[0068] By jointly solving the ray equation and the equation of the target object surface, one or more t values ​​can be solved, and these t values ​​correspond to the intersection points where the ray intersects with the target object. The intersection point corresponding to the minimum t value is the intersection point where the ray intersects with the target object for the first time. Therefore, in this step, the intersection point corresponding to the minimum t value is determined as the initial intersection point.

[0069] Step 154: Determine the pixel value of each initial intersection point as the pixel value corresponding to each pixel coordinate.

[0070] The pixel value can be represented by three channel values ​​of R, G, and B. After the initial intersection point is determined, the pixel value of the initial intersection point can be calculated according to information such as the material, lighting, and shadow of the initial intersection point.

[0071] Step 160: Generate a panoramic image according to each pixel coordinate and the pixel value corresponding to each pixel coordinate.

[0072] First, each pixel coordinate and its corresponding pixel value are combined to form a complete image data set, and then the image data set can be rendered into a visible panoramic image using a graphics library or a rendering engine. The generated panoramic image can be in an equirectangular format or a cubemap format.

[0073] In some embodiments, GPU (Graphics Processing Unit) parallel computing can be used to accelerate the rendering of panoramic images. GPU parallel computing can process multiple rays and multiple pixel coordinates simultaneously, thereby accelerating the generation of panoramic images and significantly improving the speed and efficiency of panoramic image rendering.

[0074] The embodiment of the present application obtains the fixed position of the virtual camera in the virtual scene, and controls the virtual camera to emit multiple rays at the fixed position, and can determine the pixel coordinates of each ray on the panoramic image through the angle of each ray in the spherical polar coordinate system, and then determine the pixel value corresponding to each pixel coordinate through the initial intersection between the ray corresponding to each pixel coordinate and the target object in the virtual scene, and then generate a panoramic image through each pixel coordinate and its corresponding pixel value. In the above manner, not only can the generation efficiency of the panoramic image be improved, but also there is no need to stitch images, and a seamless panoramic image can be directly generated, thereby improving the quality of the panoramic image.

[0075] In the process of generating panoramic images, due to data errors or loss, image boundaries or viewing angle limitations, a certain pixel coordinate may not have a corresponding pixel value, which makes the panoramic image visually obvious and reduces the quality of the panoramic image. Therefore, in order to ensure the quality of the generated panoramic image, this application further provides an implementation method, please refer to Figure 2 , Figure 2 The flowchart of the steps after step 150 is shown. As shown in the figure, the following steps are also included after step 150:

[0076] Step 150a: For abnormal pixel coordinates for which corresponding pixel values ​​have not been determined, determine the neighboring pixel coordinates of the abnormal pixel coordinates.

[0077] First, all pixel coordinates are checked to determine abnormal pixel coordinates that have no corresponding pixel values. Then, for each abnormal pixel coordinate, the neighboring pixel coordinates of the abnormal pixel coordinate are determined. For example, after searching for an abnormal pixel coordinate, a 3×3 window can be defined to search for the abnormal pixel coordinate, and the other pixel coordinates in the window can be determined as neighboring pixel coordinates.

[0078] Step 150b: Based on the pixel values ​​corresponding to the neighboring pixel coordinates, the pixel value corresponding to the abnormal pixel coordinates is calculated by interpolation.

[0079] Specifically, the pixel value corresponding to the abnormal pixel coordinates may be calculated using the nearest neighbor interpolation method or the bilinear interpolation method.

[0080] Among them, the nearest neighbor interpolation method calculates the distance between the abnormal pixel coordinate and each neighboring pixel coordinate, determines the pixel coordinate closest to the abnormal pixel coordinate from multiple neighboring pixel coordinates, and then determines the pixel value corresponding to the pixel coordinate as the pixel value corresponding to the abnormal pixel coordinate. For example, when the abnormal pixel coordinate is (64,64), its neighboring pixel coordinates include A(64,63), B(63,64), C(65,64), and D(64,65), and the pixel values ​​corresponding to the pixel coordinates A, B, C, and D are (100,150,200), (110,140,210), (120,160,220), and (130,170,230), respectively, then the distance between the abnormal pixel coordinate (64,64) and the neighboring pixel coordinate A(64,63) is the smallest, therefore, the pixel value (100,150,200) corresponding to A(64,63) is determined as the pixel value corresponding to the abnormal (64,64).

[0081] By determining the pixel values ​​corresponding to the abnormal pixel coordinates through the pixel values ​​corresponding to the adjacent pixel coordinates, the pixel coordinates for which the corresponding pixel values ​​have not been determined can be filled with pixel values ​​to generate a more continuous panoramic image, reduce the visual defects of the panoramic image, and ensure the quality of the panoramic image.

[0082] Figure 3 FIG. 1 is a schematic diagram showing the structure of a panoramic image generation device for a virtual scene provided by an embodiment of the present application. Figure 3 As shown, the device 200 includes: an acquisition module 210, a control module 220, a first determination module 230, a second determination module 240, a third determination module 250 and an image generation module 260. The acquisition module 210 is used to acquire a fixed position of a virtual camera in a virtual scene; the control module 220 is used to control the virtual camera to emit multiple rays at a fixed position; the first determination module 230 is used to determine the angle corresponding to each ray in a spherical polar coordinate system; the second determination module 240 is used to determine the pixel coordinates of each ray on a panoramic image according to the angle corresponding to each ray; the third determination module 250 is used to determine the pixel value corresponding to each pixel coordinate according to the initial intersection between the ray corresponding to each pixel coordinate and the target object in the virtual scene; the image generation module 260 is used to generate a panoramic image according to each pixel coordinate and the pixel value corresponding to each pixel coordinate.

[0083] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown, and the specific embodiment of the present application does not limit the specific implementation of the electronic device.

[0084] like Figure 4 As shown, the electronic device may include: a processor (processor) 302 and a memory (memory) 304.

[0085] The memory 304 is used to store a computer program 306. The memory 304 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. The computer program 306 may include computer executable instructions.

[0086] The processor 302 is used to execute the computer program 306 to implement the above-mentioned embodiment of the method for generating a panoramic image of a virtual scene.

[0087] The processor 302 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the electronic device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.

[0088] An embodiment of the present application provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the embodiment of the method for generating a panoramic image of the virtual scene is implemented.

[0089] An embodiment of the present application provides a computer program, which can be executed by a processor to implement the above-mentioned embodiment of the method for generating a panoramic image of a virtual scene.

[0090] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the embodiment of the method for generating a panoramic image of the virtual scene is implemented.

[0091] In several embodiments provided in the present application, if any function is implemented in the form of a software function module / unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, part or all of the technical solution of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, server or other electronic device) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (RandomAccess Memory, RAM), disk or optical disk and other media that can store computer program code.

[0092] The algorithm or display provided here are not inherently related to any specific computer, virtual system or other equipment. Various general systems can also be used together with the teaching based on this. According to the above description, it is obvious to construct the structure required for this type of system. In addition, the present application embodiment is not directed to any specific programming language yet. It should be understood that various programming languages ​​can be utilized to realize the content of the present application described here, and the above description of specific languages ​​is to disclose the best mode of implementation of the present application.

[0093] It should be noted that the above embodiments illustrate the present application rather than limit the present application, and that those skilled in the art may design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be constructed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of multiple such elements. The present application may be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In the claims that list several devices, several units or modules in these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be understood as limitations on the order of execution.

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

Claims

1. A method for generating a panoramic image of a virtual scene, characterized in that: The method comprises: Obtaining a fixed position of a virtual camera in the virtual scene; Controlling the virtual camera to emit a plurality of rays at the fixed position; Determine the angle corresponding to each ray in the spherical polar coordinate system, wherein the angle includes a horizontal angle and a vertical angle; Determine the pixel coordinates of each ray on the panoramic image according to the angle corresponding to each ray; Determine the pixel value corresponding to each pixel coordinate according to the initial intersection between the ray corresponding to each pixel coordinate and the target object in the virtual scene; Generate the panoramic image according to each pixel coordinate and the pixel value corresponding to each pixel coordinate; The step of determining the pixel coordinates of each ray on the panoramic image according to the angle corresponding to each ray further includes: Obtaining the width and height of the panoramic image; Determine the horizontal pixel coordinate of each ray on the panoramic image according to the horizontal angle corresponding to each ray and the width; Determine the vertical pixel coordinate of each ray on the panoramic image according to the vertical angle corresponding to each ray and the height; The horizontal pixel coordinate u of each ray on the panoramic image is: u=(θ / 2π)·W, Wherein, W represents the width of the panoramic image, and θ represents the horizontal angle corresponding to each ray; The vertical pixel coordinate v of each ray on the panoramic image is: v = (φ / 2π) H, Wherein, H represents the height of the panoramic image, and φ represents the vertical angle corresponding to each ray.

2. The method according to claim 1, characterized in that The step of determining the pixel value corresponding to each pixel coordinate according to the initial intersection point between the ray corresponding to each pixel coordinate and the target object in the virtual scene further comprises: Determine the direction vector of each ray according to the angle of the ray corresponding to each pixel coordinate; Determining a ray equation for each ray based on the fixed position and a direction vector of each ray; Determining an initial intersection point between each ray in the virtual scene and the target object according to a ray equation of each ray and an equation of the surface of the target object; The pixel value of each initial intersection point is determined as the pixel value corresponding to each pixel coordinate.

3. The method according to claim 2, characterized in that The angles include horizontal angles and vertical angles, and the direction vector D of each ray is: D=(sin(θ)cos(φ),sin(θ)sin(φ),cos(θ)), Among them, θ represents the horizontal angle corresponding to each ray, and φ represents the vertical angle corresponding to each ray.

4. The method according to claim 3, characterized in that The ray equation is: R(t)=P+t*D, Wherein, P represents the fixed position of the virtual camera, and t represents the parameter along the ray direction.

5. The method according to claim 1, characterized in that After determining the pixel value corresponding to each pixel coordinate according to the initial intersection point between the ray corresponding to each pixel coordinate and the target object in the virtual scene, the method further includes: For abnormal pixel coordinates for which no corresponding pixel value is determined, determining the neighboring pixel coordinates of the abnormal pixel coordinates; Based on the pixel values ​​corresponding to the adjacent pixel coordinates, the pixel values ​​corresponding to the abnormal pixel coordinates are calculated by interpolation.

6. The method according to claim 1, characterized in that The controlling the virtual camera to emit a plurality of rays at the fixed position further comprises: Control the virtual camera to emit multiple rays along the horizontal direction of 0-360°; The virtual camera is controlled to emit multiple rays along the vertical direction of 0-360 degrees.

7. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the method for generating a panoramic image of a virtual scene as described in any one of claims 1 to 6.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for generating a panoramic image of a virtual scene as described in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method and system for generating a panoramic image

    US20200234404A1

  • Methods of obtaining panoramic images using rotationally symmetric wide-angle lenses and devices thereof

    WO2009017332A1