Panoramic picture cutting method and device, electronic equipment and storage medium
By splitting the cube map of the panoramic image into multiple slices and creating a tile pyramid, the computer resource pressure problem caused by the large resolution of the panoramic image is solved, and the tile image is dynamically loaded to improve performance.
Patent Information
- Application Number
- CN202411743580.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-30
- Publication Date
- 2025-02-25
AI Technical Summary
Since panoramic images are usually very large, resolutions can reach thousands or even tens of thousands of pixels, directly loading and displaying high-resolution panoramic images using cube maps will put huge pressure on computer resources, resulting in performance degradation or application crashes.
By determining the slice hierarchy configuration of each decent map in the cube map of the panoramic picture, we can obtain the slice picture corresponding to each decent map, and create a tile pyramid of the panoramic picture based on these slice pictures. The original image resolution of each hierarchy slice is different.
It realizes dynamic loading of tile pictures of corresponding zoom levels based on the user's view area and network conditions, reducing the pressure on computer resources and avoiding the problems of performance degradation and application crashes.
Smart Images

Figure CN119516155A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method, device, electronic device and storage medium for cutting a panoramic image. Background Art
[0002] Panoramic images are images that provide a panoramic view, usually covering a 360-degree horizontal field of view and a certain range of vertical field of view. Panoramic images make viewers feel as if they are in the scene represented by the image, thus providing a more immersive viewing experience.
[0003] Panoramic pictures are usually composed of a series of overlapping images, which are taken by special panoramic cameras or general cameras in different directions and angles. During the shooting process, the photographer will place the camera in a fixed position and rotate or tilt it in different directions to capture various aspects of the surrounding environment. In order to achieve a panoramic effect, the captured images need to be post-processed, including stitching, correction, cropping, etc., to finally generate a continuous panoramic image. Panoramic images can exist in different forms, such as cylindrical projection, spherical projection, and cubic projection light. Each projection form has its own unique characteristics and applicable scenarios.
[0004] Splitting a panoramic image into cubemaps is a common technique used to create panoramic effects in virtual reality environments. However, the inventors have found that since panoramic images are usually very large and their resolutions may be as high as thousands or even tens of thousands of pixels, using cubemaps will still directly load and display high-resolution panoramic images, which will put tremendous pressure on computer resources, resulting in performance degradation or application crashes. Summary of the invention
[0005] In this regard, the present application provides a panoramic image cutting method, device, electronic device and storage medium to solve the problem that panoramic images are usually very large and the resolution may be as high as thousands or even tens of thousands of pixels. Using cube maps will still directly load and display high-resolution panoramic images, which will put tremendous pressure on computer resources and cause performance degradation or application crashes.
[0006] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:
[0007] In a first aspect, the present application discloses a panoramic picture cutting method, which is applied to a client, and the method comprises:
[0008] Determine a slice level configuration of each dimension map in the cube map of the panoramic image, wherein the slice level configuration of each dimension map includes the number of slice levels of the dimension map and the image size of each level slice;
[0009] Slice the corresponding decent map in the cubic map of the panoramic image according to the slice level configuration of each decent map, and obtain a slice image corresponding to each decent map in the cubic map of the panoramic image;
[0010] A tile pyramid corresponding to the panoramic image is created according to slice images corresponding to all the volume maps in the cubic map of the panoramic image, wherein the original image resolution corresponding to each level slice in the tile pyramid corresponding to the panoramic image is different.
[0011] Optionally, in the above-mentioned panoramic image slicing method, determining the slice level configuration of each face map in the cubic map of the panoramic image includes:
[0012] Determine the maximum size of the cubemap, the tile map and the minimum size of the tile map of the panoramic image;
[0013] For each volume map in the cubic map, processing is performed according to the image size of the volume map, the maximum size of the tile map, and the minimum size of the tile map to obtain a slice level configuration of each volume map in the cubic map of the panoramic image.
[0014] Optionally, in the above-mentioned panoramic image slicing method, for each face map in the cubic map, processing is performed according to the image size of the face map, the maximum size of the tile map, and the minimum size of the tile map to obtain a slice level configuration of each face map in the cubic map of the panoramic image, including:
[0015] For each face map in the cube map, taking a layer with the highest zoom level as the image size of the first-level slice according to the image size of the face map;
[0016] The image width is preferentially satisfied as a multiple of the maximum size of the tile image. When the image width does not satisfy the multiple of the maximum size of the tile image, the unsatisfied part is adjusted to be a multiple of the minimum size of the tile image. The image size of the first-level slice is recursively processed until the image size of the current-level slice is smaller than the maximum size of the tile image. The number of slice layers and the image size of the current-level slice are stored in each recursion to obtain the slice layer configuration of each face map in the cube map of the panoramic image.
[0017] Optionally, in the above-mentioned panoramic image slicing method, slicing the corresponding decent map in the cubic map of the panoramic image according to the slice level configuration of each decent map to obtain the slice image corresponding to each decent map in the cubic map of the panoramic image, including:
[0018] For each of the cubemaps of the cubemap, traverse each level slice in the slice level configuration of the cubemap, and determine the row and column parameters of the tile map in each level slice according to the maximum size of the tile map, wherein the row and column parameters of the tile map include: the number of rows and columns of the tile map and the row and column width and height of the tile map;
[0019] Drawing the respect map to a temporary canvas and scaling the respect map according to the image size of each level slice in the slice level configuration of the respect map;
[0020] For each level of slice, the image data at the corresponding position is extracted from the temporary canvas according to the row and column parameters of the tile map in the level of slice and drawn to the tile canvas to obtain a slice image corresponding to each of the face maps.
[0021] Optionally, in the above-mentioned panoramic image slicing method, for each of the cubemaps, traversing each level of slices in the slice hierarchy configuration of the cubemap, and determining row and column parameters of the tile images in each level of slices according to the maximum size of the tile images, including:
[0022] For each of the decent maps of the cube map, each level slice in the slice hierarchy configuration of the decent map is traversed, and the number of rows and columns of the tile image in each level slice is obtained by rounding down the ratio of the image size of each level slice to the maximum size of the tile image, and the remainder after rounding down the ratio of the image size of each level slice to the maximum size of the tile image is used as the width and height of the last row and last column of the tile image in the corresponding level slice.
[0023] Optionally, in the above-mentioned panoramic picture cutting method, creating a tile pyramid corresponding to the panoramic picture according to the slice pictures corresponding to all the face maps in the cubic map of the panoramic picture includes:
[0024] Numbering each tile in the slice image corresponding to all the face maps in the cubic map of the panoramic image;
[0025] The creation is performed according to the numbers of the tiles in the slice images corresponding to all the volume maps in the cubic map of the panoramic image, so as to obtain a tile pyramid corresponding to the panoramic image.
[0026] Optionally, in the above-mentioned panoramic picture slicing method, numbering each tile in the sliced picture corresponding to all the cube maps in the cubic map of the panoramic picture comprises:
[0027] Determine the coordinate position of each tile image in the slice image corresponding to each of the body maps in the cubic map of the panoramic image, wherein the coordinate position of the tile image includes: the surface position of the body map where the tile image is located in the cubic map, the slice level of the tile image in the body map where the tile image is located, and the row and column number of the slice level of the tile image in the body map where the tile image is located;
[0028] The tiles are numbered according to the coordinate positions of the tiles in the slice image corresponding to each of the cube maps in the panoramic image.
[0029] The second aspect of the present application discloses a panoramic picture cutting device, which is applied to a client, and the device includes:
[0030] A determining unit, configured to determine a slice level configuration of each dimension map in the cubic map of the panoramic image, wherein the slice level configuration of each dimension map includes a number of slice levels of the dimension map and a picture size of each level of slice;
[0031] A segmentation unit, configured to segment the corresponding decent map in the cubic map of the panoramic image according to the slice level configuration of each decent map, to obtain a slice image corresponding to each decent map in the cubic map of the panoramic image;
[0032] The creating unit is used to create a tile pyramid corresponding to the panoramic picture according to the slice pictures corresponding to all the volume maps in the cubic map of the panoramic picture, wherein the original image resolution corresponding to each level slice in the tile pyramid corresponding to the panoramic picture is different.
[0033] The third aspect of the present application discloses an electronic device, including: a memory and a processor;
[0034] Wherein, the memory is used to store computer programs;
[0035] The processor is used to execute the computer program, specifically to implement the panoramic picture cutting method as described in any one of the items disclosed in the first aspect.
[0036] A fourth aspect of the present application discloses a computer storage medium for storing a computer program. When the computer program is executed, it is specifically used to implement the panoramic image cutting method as described in any one of the items disclosed in the first aspect.
[0037] The present invention provides a panoramic picture cutting method, which can be applied to a client. The method comprises: determining a slice level configuration of each face map in a cubic map of the panoramic picture, wherein the slice level configuration of each face map includes the number of slice levels of the face map and the image size of each level slice; cutting the corresponding face map in the cubic map of the panoramic picture according to the slice level configuration of each face map to obtain a slice image corresponding to each face map in the cubic map of the panoramic picture; creating a tile pyramid corresponding to the panoramic picture according to the slice images corresponding to all face maps in the cubic map of the panoramic picture, wherein the original image resolution corresponding to each level slice in the tile pyramid corresponding to the panoramic picture is different, and the tile image of the corresponding zoom level can be dynamically loaded according to the user's view area and network status, thereby solving the problem that the panoramic image is usually very large and the resolution may be as high as thousands or even tens of thousands of pixels, and the high-resolution panoramic image will still be directly loaded and displayed when the cubic map is used, which will generate huge pressure on computer resources, resulting in performance degradation or application crash. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present invention 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 invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0039] Figure 1 A flowchart of a panoramic image cutting method provided in this application;
[0040] Figure 2 A flowchart of slice-level configuration of a decent map provided by an embodiment of the present application;
[0041] Figure 3 A flow chart for determining a slice image corresponding to a cube map provided in an embodiment of the present application;
[0042] Figure 4 A flowchart of creating a tile pyramid corresponding to a panoramic picture provided in an embodiment of the present application;
[0043] Figure 5 A schematic diagram of a process of a panoramic picture cutting method provided in an embodiment of the present application;
[0044] Figure 6 A schematic diagram of the structure of a panoramic picture cutting device provided in an embodiment of the present application;
[0045] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0046] Figure 8 An example diagram of a hierarchical slicing image cutting provided in an embodiment of the present application;
[0047] Fig. 9 A tile image loaded in a poor network state provided in an embodiment of the present application;
[0048] Fig.10 A tile image loaded when the network status is good is provided in an embodiment of the present application. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] First of all, it should be noted that panoramic images are widely used in virtual reality (VR), panoramic photography, tourism promotion, map services and other fields. They can provide users with an immersive visual experience and enhance their perception and cognition of the scene.
[0051] In practice, building a 3D application requires three elements: scene, camera, and renderer. The scene, as a 3D space, is a container for all objects. When adding objects to the scene, the objects in the scene are a combination of material and geometry, which can show different rendering effects with different lights. The camera is equivalent to the human eye, which determines the field of view and the angle and position of observing the scene. The renderer will continuously refresh, constantly recalculate the objects in the space and update the mapping on the screen.
[0052] The embodiments of the present application provide a panoramic image cutting method, device, electronic device and storage medium to solve the problem that panoramic images are usually very large and the resolution may be as high as thousands or even tens of thousands of pixels. Using cube maps will still directly load and display high-resolution panoramic images, which will put great pressure on computer resources and cause performance degradation or application crashes.
[0053] See also Figure 1 The panorama image cutting method can be applied to the client, and mainly includes the following steps:
[0054] S101, determining the slice level configuration of each face map in the cube map of the panoramic image.
[0055] The cube map of the panoramic image includes 6 face maps, and the slice level configuration of each face map includes the number of slice layers of the face map and the image size of each level slice.
[0056] In practical applications, the panoramic image can be segmented to obtain a cubemap of the panoramic image. Segmenting the panoramic image into cubemaps is a common technique for creating a panoramic effect in a virtual reality environment.
[0057] The cubemap of the panoramic image is composed of 6 square faces, each of which corresponds to a facemap, which respectively corresponds to the six faces of the cube, namely, front, back, top, bottom, left, and right. In some embodiments, the specific process of determining each facemap in the cubemap of the panoramic image can be as follows:
[0058] Step 1: Determine the tile size for each face of the cubemap.
[0059] Among them, since the aspect ratio of a panoramic image is usually 2:1, the slice size of each face of the cube map should be one-sixth of the width or height of the panoramic image, so the slice size of each face is half of the width or height of the panoramic image.
[0060] Step 2: Divide the panorama according to the slice size of each face of the cubemap.
[0061] The panoramic image is divided into 6 square slices, which correspond to the six faces of the cube. Specifically, this can be achieved by cropping the panoramic image, and the cropping method can be selected as needed, such as according to isometric projection, cubic projection, etc.
[0062] Step 3: Save the segmented panoramic image.
[0063] Among them, the slices of each face can be saved as separate image files to obtain a decent face map for subsequent use.
[0064] Specifically, commonly saved image formats may be JPEG, PNG, etc.; of course, it is not limited thereto, and may also be determined based on the application environment and user needs, all within the scope of protection of this application.
[0065] Step 4: Combine the six face maps in the order of a cube, corresponding to the front, back, top, bottom, left, and right faces of the cube, to obtain the cube map of the panoramic image.
[0066] The combination process can be implemented through code, and each slice will know the corresponding cube face.
[0067] It should be noted that the cube map of the panoramic image can be used in a virtual reality environment or a panoramic viewer; the panoramic effect can be achieved by applying the cube map of the panoramic image to a cube model or using it as a background map of the panoramic image.
[0068] In some embodiments, the specific process of step S101, determining the slice level configuration of each face map in the cubic map of the panoramic image, can be as follows: Figure 2 As shown, it mainly includes steps S201 to S202:
[0069] S201, determining a cube map, a maximum tile map size, and a minimum tile map size of the panoramic image.
[0070] In actual applications, the default maximum tile size is 512, and the minimum tile size is 64. Larger tile sizes will take up more memory, while smaller tile sizes will cause too many network requests, which will prolong the loading time. Specifically, the size of the tile can be adjusted to a power of 2 (such as 256, 512, 1024), because texture images with a size of a power of 2 can better adapt to the requirements of the graphics processor (GPU) and reduce edge artifacts in rendering.
[0071] Of course, this is not limited to this. The specific values of the maximum size and the minimum size of the tile image can also be determined according to the application environment and user needs, all within the protection scope of this application.
[0072] In practical applications, the cube map of the panoramic image can be determined by the method shown in the above embodiment, which will not be repeated here; the maximum size of the tile image of the panoramic image is the maximum size of the tile image in the tile pyramid constructed for the panoramic image, and the minimum size of the tile image of the panoramic image is the minimum size of the tile image in the tile pyramid constructed for the panoramic image. The specific values can be determined according to the application environment and user needs, and are all within the protection scope of the present application.
[0073] S202 , for each face map in the cube map, processing is performed according to the image size of the face map, the maximum size of the tile map, and the minimum size of the tile map to obtain a slice level configuration of each face map in the cube map of the panoramic image.
[0074] In practical applications, the specific implementation process of step S202, for each face map in the cube map, processing according to the image size of the face map, the maximum size of the tile map, and the minimum size of the tile map to obtain the slice level configuration of each face map in the cube map of the panoramic image may include steps S301 and S302:
[0075] S301 . For each face map in the cube map, according to the image size of the face map, use the layer with the highest zoom level as the image size of the first-level slice.
[0076] In practical applications, since the structure of the tile pyramid is a multi-layer structure, the image size of the face map can be taken as the image size of the first-level slice (top layer) by taking the layer with the highest zoom level. The image sizes of the slices at other levels are obtained by recursively processing the slices at the first level. For the specific process, see step S302.
[0077] For example, the first-level slices are divided from top to bottom and from left to right for a total of 4 divisions to form the second-level structure of the pyramid. This operation is repeated until the size of the divided image meets the requirements at a certain level. In this structure, each slice can be named according to the rule of (surface-layer-row-column).
[0078] S302, according to the priority that the image width must be a multiple of the maximum size of the tile map, when the image width does not meet the multiple of the maximum size of the tile map, adjust the unsatisfied part to a multiple of the minimum size of the tile map, recursively process the image size of the first-level slice until the image size of the current-level slice is smaller than the maximum size of the tile map, and store the number of slice layers and the image size of the current-level slice in each recursion to obtain the slice level configuration of each face map in the cube map of the panoramic image.
[0079] In practical applications, after the image size of the decent map is set to the highest zoom level as the image size of the first-level slice (top layer), the image width can be preferentially satisfied with the multiple of the maximum size of the tile map. When the image width does not meet the multiple of the maximum size of the tile map, the unsatisfied part is adjusted to the multiple of the minimum size of the tile map as a recursive condition, and the image size of the first-level slice is recursively processed until the image size of the current level slice does not meet the requirements. Each recursion puts the number of slice layers and the image size of the level slice into a list and stores them, which is recorded as levelConfig (the slice level configuration of each decent map in the cubic map of the panoramic image). Among them, the image size of the current level slice does not meet the requirements can be that the image size of the current level slice is larger than the maximum size of the tile map, but is smaller than the maximum size of the tile map after recursive segmentation again.
[0080] It can be understood that the slice level configuration of each face map in the cubic map of the panoramic image can be clarified through the above processing. The slice level configuration of each face map includes the number of slice levels of the face map and the image size of each level slice.
[0081] S102 . Slice the cubemap corresponding to the panoramic image according to the slice level configuration of each cubemap to obtain a slice image corresponding to each cubemap in the panoramic image.
[0082] In some embodiments, the execution process of step S102, dividing the cubic map corresponding to the panoramic image according to the slice level configuration of each cubic map, and obtaining the slice image corresponding to each cubic map in the panoramic image can be as follows: Figure 3 As shown, it mainly includes steps S401 to S403:
[0083] S401 , for each cube map of the cube map, traverse each level of slices in the slice level configuration of the cube map, and determine row and column parameters of the tile map in each level of slices according to the maximum size of the tile map.
[0084] The row and column parameters of the tile image include: the number of rows and columns of the tile image and the width and height of the rows and columns of the tile image.
[0085] In practical applications, for each face map of the cube map, each level slice in the slice level configuration of the face map can be traversed, and the number of rows and columns of the tile map in each level slice can be obtained by rounding down the ratio of the image size of each level slice to the maximum size of the tile map, and the remainder after rounding down the ratio of the image size of each level slice to the maximum size of the tile map is used as the width and height of the last row and the last column of the tile map in the corresponding level slice.
[0086] Assuming that the image size of a certain level slice is maxTileSize, and the maximum size of the tile image is level.size, the number of rows and columns required for the level slice can be calculated by rounding down level.size / maxTileSize, and the remainder level.size%maxTileSize is used as the width and height of the last row lastRowWidth and the last column lastColHeight. For example, Figure 8 As shown, maxTileSize represents the maximum tile size, lastRowWidth represents the width of the last row, and lastRowHeight represents the height of the last row.
[0087] S402: Draw the decent map to the temporary canvas, and scale the decent map according to the image size of each level slice in the slice level configuration of the decent map.
[0088] In practical applications, you can use the document.createElement method to create two empty canvases: tempCanvas and tileCanvas, which are used to store the intermediate data and result data of the original panoramic image slicing process. Use the tempCanvas.getContext('2d').putImageData(imageData,0,0) method, which can render the decent map data imageData onto the temporary canvas, and use the tempCanvas.getContext('2d').scale(level.size / imageData.width,level.size / imageData.width) method, which can scale the decent map data imageData horizontally and vertically according to the size of the current level. The scaling multiple is level.size / imageData.width. Here, the value is less than or equal to 1 and greater than 0, which means shrinking the canvas content.
[0089] S403 . For each level slice, extract the image data at the corresponding position from the temporary canvas according to the row and column parameters of the tile map in the level slice and draw it to the tile canvas to obtain the slice image corresponding to each face map.
[0090] In practical applications, for each level of slices, the tile map of the level slices can be traversed according to the number of rows and columns of cols, and the image data at the corresponding position can be extracted from the temporary canvas and drawn to the tile canvas to obtain the slice image corresponding to each face map.
[0091] The specific code for extracting the image data at the corresponding position from the temporary canvas and drawing it to the tile canvas can be as follows:
[0092]
[0093]
[0094]
[0095] It should be noted that after each slice image corresponding to the decent map, the file name and path of the slice image corresponding to each decent map can be constructed according to the specified naming rules, using the tilesCanvas.toDataURL('image / jpeg') method, which can convert the slice image information on the canvas into a URL link containing the image data and store it locally through base64 encoding.
[0096] S103: Create a tile pyramid corresponding to the panoramic image according to the slice image corresponding to each cube map in the panoramic image.
[0097] Among them, the original image resolution corresponding to each level slice in the tile pyramid corresponding to the panoramic image is different.
[0098] In some embodiments, the specific execution process of step S103, creating a tile pyramid corresponding to the panoramic image according to the slice image corresponding to each cube map in the panoramic image, can be as follows: Figure 4 As shown, it mainly includes steps S501 and S502:
[0099] S501 , numbering each tile in a slice image corresponding to all the face maps in a cubic map of a panoramic image.
[0100] In practical applications, the specific process of numbering each tile in the sliced image corresponding to all the face maps in the cubic map of the panoramic image mainly includes steps S601 and S602:
[0101] S601: Determine the coordinate position of each tile image in the slice image corresponding to each face map in the cubic map of the panoramic image.
[0102] The coordinate position of the tile image includes: the surface position of the cube map where the tile image is located, the slice level of the cube map where the tile image is located, and the row and column number of the slice level of the cube map where the tile image is located.
[0103] S602: numbering the tiles in the slice image according to the coordinate position of each tile image in the cube map of the panoramic image.
[0104] It can be understood that the tile images in the slice images corresponding to all the face maps in the cube map of the panoramic image can be divided into<a,l,x,y> The coordinate form of , where a represents a face of the cubemap, l represents the slice level, and x and y represent the row and column numbers of the tile in the slice level.
[0105] S502: Create a tile pyramid corresponding to the panoramic image according to the numbers of the tiles in the slice images corresponding to all the face maps in the cubic map of the panoramic image, and obtain a tile pyramid corresponding to the panoramic image.
[0106] It should be noted that the tile images in the slice images corresponding to all the face maps in the cube map of the panoramic image are divided into<a,l,x,y> The coordinate form of , where a represents a certain face of the cube map, l represents the slice level, x and y represent the row number and column number of the tile in the slice level. A tile pyramid can be formed according to this organizational form. Each level of the tile pyramid contains tiles of different resolutions of the original image.
[0107] It should also be noted that the panoramic image slicing method provided in the present application can be purely applied to the front end, using a canvas to process and generate slices of panoramic images; in the slicing process, the panoramic image is converted into images of multiple resolutions and sliced row by row and column by column; the organization and naming rules of the tile images use a tile pyramid to organize and store the sliced panoramic images.
[0108] Based on the above, combined Figure 5 It can be understood that the present application can construct a playful pyramid structure of the panoramic image by further dividing the cube map of the six faces of the panoramic image into multiple small blocks, also called tiles, so as to dynamically load the corresponding tiles according to the user's viewing area and zoom level, thereby solving the problem that since panoramic images are usually very large and the resolution may be as high as thousands or even tens of thousands of pixels, the use of cube maps will still directly load and display high-resolution panoramic images, which will put great pressure on computer resources and cause performance degradation or application crashes.
[0109] It should be noted that when the network status is poor, you can load tiles with a lower zoom level, such as Fig. 9 When the network status is good, you can load tiles with higher zoom levels, such as Fig.10 As shown, it is possible to dynamically load tile images of corresponding zoom levels according to the user's viewing area and network conditions, solving the problem that the existing method may cause heavy resource pressure, performance degradation and application crashes.
[0110] Based on the above principles, the panoramic image slicing method provided in the present embodiment can be applied to a client, and the method includes: determining a slice level configuration of each face map in a cubic map of the panoramic image, wherein the slice level configuration of each face map includes the number of slice levels of the face map and the image size of each level slice; slicing the corresponding face map in the cubic map of the panoramic image according to the slice level configuration of each face map, and obtaining a slice image corresponding to each face map in the cubic map of the panoramic image; creating a tile pyramid corresponding to the panoramic image according to the slice images corresponding to all face maps in the cubic map of the panoramic image, wherein the original image resolution corresponding to each level slice in the tile pyramid corresponding to the panoramic image is different, and the tile image of the corresponding zoom level can be dynamically loaded according to the user's viewing area and network conditions, thereby solving the problem that the panoramic image is usually very large and the resolution may be as high as thousands or even tens of thousands of pixels, and the use of the cubic map will still directly load and display the high-resolution panoramic image, which will generate huge pressure on computer resources, resulting in performance degradation or application crash.
[0111] In addition, the panorama image cutting method provided by the present application is usually more efficient in loading and displaying small tiles than directly loading the entire large image, because it can be loaded in batches and only loaded when needed, which can optimize performance. Moreover, by using the panorama image cutting method provided by the present application, tile images can be loaded in a hierarchical manner, thereby reducing network transmission volume, reducing bandwidth requirements, and improving loading speed.
[0112] It is worth noting that the common image cutting technology on the market is usually processed through paid image cutting tools and cannot be applied to the client. The panoramic image cutting method provided in this application can be implemented through JS (JavaScript) without downloading any software. After deployment, it can be accessed through a browser to achieve panoramic image cutting.
[0113] Optionally, another embodiment of the present application further provides a panoramic image cutting device, see Figure 6 The panoramic image cutting device can be applied to the client, and mainly includes:
[0114] A determining unit 101 is used to determine a slice level configuration of each face map in a cubic map of a panoramic image, wherein the slice level configuration of each face map includes the number of slice levels of the face map and the image size of each level of slice;
[0115] A segmentation unit 102 is used to segment the corresponding body map in the cubic map of the panoramic image according to the slice level configuration of each body map, so as to obtain a slice image corresponding to each body map in the cubic map of the panoramic image;
[0116] The creation unit 102 is used to create a tile pyramid corresponding to the panoramic picture according to the slice pictures corresponding to all the face maps in the cubic map of the panoramic picture, wherein the original image resolution corresponding to each level slice in the tile pyramid corresponding to the panoramic picture is different.
[0117] In some embodiments, the determining unit 101 includes:
[0118] A first determining subunit, configured to determine a cubemap, a maximum tile size, and a minimum tile size of the panoramic image;
[0119] The processing unit is used to process each volume map in the cubic map according to the image size of the volume map, the maximum size of the tile map and the minimum size of the tile map to obtain a slice level configuration of each volume map in the cubic map of the panoramic image.
[0120] In some embodiments, the processing unit includes:
[0121] As a unit, for each volume map in the cube map, according to the image size of the volume map, a layer with the highest zoom level is used as the image size of the first level slice;
[0122] A recursive processing unit is used to prioritize the image width to be a multiple of the maximum size of the tile map, and when the image width does not meet the multiple of the maximum size of the tile map, adjust the unsatisfied part to be a multiple of the minimum size of the tile map, recursively process the image size of the first-level slice until the image size of the current-level slice is smaller than the maximum size of the tile map, and store the number of slice layers and the image size of the current-level slice in each recursion to obtain the slice layer configuration of each face map in the cube map of the panoramic image.
[0123] In some embodiments, the segmentation unit 102 includes:
[0124] A second determining subunit is configured to traverse each level slice in the slice level configuration of the cube map for each of the cube maps, and determine row and column parameters of the tile map in each level slice according to the maximum size of the tile map, wherein the row and column parameters of the tile map include: the number of rows and columns of the tile map and the row and column width and height of the tile map;
[0125] A drawing and scaling unit, used for drawing the decent map to a temporary canvas, and scaling the decent map according to the image size of each level slice in the slice level configuration of the decent map;
[0126] The extraction and drawing unit is used to extract the image data of the corresponding position from the temporary canvas according to the row and column parameters of the tile map in the hierarchical slice and draw it to the tile canvas to obtain the slice image corresponding to each of the face maps.
[0127] In some embodiments, the second determining subunit is specifically configured to:
[0128] For each of the decent maps of the cube map, each level slice in the slice hierarchy configuration of the decent map is traversed, and the number of rows and columns of the tile image in each level slice is obtained by rounding down the ratio of the image size of each level slice to the maximum size of the tile image, and the remainder after rounding down the ratio of the image size of each level slice to the maximum size of the tile image is used as the width and height of the last row and last column of the tile image in the corresponding level slice.
[0129] In some embodiments, the creation unit 103 includes:
[0130] A numbering unit, used for numbering each tile in the sliced image corresponding to all the cubic maps in the panoramic image;
[0131] The creation subunit is used to create a tile pyramid corresponding to the panoramic picture according to the numbers of the tiles in the slice pictures corresponding to all the volume maps in the cubic map of the panoramic picture, so as to obtain the tile pyramid corresponding to the panoramic picture.
[0132] In some embodiments, the numbering unit includes:
[0133] A third determining subunit is used to determine the coordinate position of each tile image in the slice image corresponding to each of the body maps in the cubic map of the panoramic image, wherein the coordinate position of the tile image includes: the surface position of the body map where the tile image is located in the cubic map, the slice level of the tile image in the body map where the tile image is located, and the number of rows and columns of the slice level of the tile image in the body map where the tile image is located;
[0134] The numbering subunit is used to number the tile images in the slice image corresponding to each of the cubic maps in the panoramic image according to the coordinate position of each tile image in the slice image.
[0135] The panoramic image cutting device provided in this embodiment can be applied to a client, and mainly includes: a determining unit 101 is used to determine the slice level configuration of each face map in the cubic map of the panoramic image, and the slice level configuration of each face map includes the number of slice levels of the face map and the image size of each level slice; a segmenting unit 102 is used to segment the corresponding face map in the cubic map of the panoramic image according to the slice level configuration of each face map, and obtain the slice image corresponding to each face map in the cubic map of the panoramic image; a creating unit 103 is used to create a tile pyramid corresponding to the panoramic image according to the slice images corresponding to all face maps in the cubic map of the panoramic image, and the original image resolution corresponding to each level slice in the tile pyramid corresponding to the panoramic image is different, and the tile image of the corresponding zoom level can be dynamically loaded according to the user's viewing area and network conditions, which solves the problem that the panoramic image is usually very large and the resolution may be as high as thousands or even tens of thousands of pixels. The use of the cubic map will still directly load and display the high-resolution panoramic image, which will generate huge pressure on computer resources, resulting in performance degradation or application crash.
[0136] It should be noted that, for the relevant description of each unit in the panoramic picture cutting device, reference can be made to the corresponding method embodiments described above, and they will not be described one by one here.
[0137] Optionally, another embodiment of the present application further provides a computer storage medium for storing a computer program, which, when executed, is specifically used to implement the panoramic image cutting method provided in any embodiment of the present application.
[0138] It should be noted that, for the relevant description of the panoramic image cutting method, reference can be made to the above embodiment, which will not be repeated here.
[0139] Optionally, another embodiment of the present application further provides an electronic device, such as Figure 7 As shown, the electronic device includes a memory 601 and a processor 602 .
[0140] Wherein, the memory 601 is used to store computer programs;
[0141] The processor 602 is used to execute a computer program, specifically to implement the panoramic image cutting method provided in any embodiment of the present application.
[0142] It should be noted that, for the relevant description of the panoramic image cutting method, reference can also be made to the above embodiment, which will not be repeated here.
[0143] The features recorded in the various embodiments in this specification can be replaced or combined with each other, and the same and similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The system and system embodiments described above are 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 can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work. Professionals can also further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article 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 the function. Whether these functions are executed 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 the present invention.
[0144] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one 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 invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0145] It should also be noted that, in this article, relational terms such as first and second, etc. are only used 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 "include", "comprise" 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, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for cutting a panoramic picture, characterized in that: Applied to a client, the method comprises: Determine a slice level configuration of each dimension map in the cube map of the panoramic image, wherein the slice level configuration of each dimension map includes the number of slice levels of the dimension map and the image size of each level slice; Slice the corresponding decent map in the cubic map of the panoramic image according to the slice level configuration of each decent map, and obtain a slice image corresponding to each decent map in the cubic map of the panoramic image; A tile pyramid corresponding to the panoramic image is created according to slice images corresponding to all the volume maps in the cubic map of the panoramic image, wherein the original image resolution corresponding to each level slice in the tile pyramid corresponding to the panoramic image is different.
2. The method for cutting a panoramic picture according to claim 1, characterized in that: Determining a slice level configuration for each face map in a cube map of the panoramic image includes: Determine the maximum size of the cubemap, the tile map and the minimum size of the tile map of the panoramic image; For each volume map in the cubic map, processing is performed according to the image size of the volume map, the maximum size of the tile map, and the minimum size of the tile map to obtain a slice level configuration of each volume map in the cubic map of the panoramic image.
3. The method for cutting a panoramic picture according to claim 2, characterized in that: For each face map in the cube map, processing is performed according to the image size of the face map, the maximum size of the tile map, and the minimum size of the tile map to obtain a slice level configuration of each face map in the cube map of the panoramic image, including: For each face map in the cube map, taking a layer with the highest zoom level as the image size of the first-level slice according to the image size of the face map; The image width is preferentially satisfied as a multiple of the maximum size of the tile image. When the image width does not satisfy the multiple of the maximum size of the tile image, the unsatisfied part is adjusted to be a multiple of the minimum size of the tile image. The image size of the first-level slice is recursively processed until the image size of the current-level slice is smaller than the maximum size of the tile image. The number of slice layers and the image size of the current-level slice are stored in each recursion to obtain the slice layer configuration of each face map in the cube map of the panoramic image.
4. The method for cutting a panoramic picture according to claim 1, characterized in that: Slicing the corresponding decent map in the cubic map of the panoramic image according to the slice level configuration of each decent map, and obtaining a slice image corresponding to each decent map in the cubic map of the panoramic image, comprising: For each of the cubemaps of the cubemap, traverse each level slice in the slice level configuration of the cubemap, and determine the row and column parameters of the tile map in each level slice according to the maximum size of the tile map, wherein the row and column parameters of the tile map include: the number of rows and columns of the tile map and the row and column width and height of the tile map; Drawing the respect map to a temporary canvas and scaling the respect map according to the image size of each level slice in the slice level configuration of the respect map; For each level of slice, the image data at the corresponding position is extracted from the temporary canvas according to the row and column parameters of the tile map in the level of slice and drawn to the tile canvas to obtain a slice image corresponding to each of the face maps.
5. The method for cutting a panoramic picture according to claim 4, characterized in that: For each of the cubemaps, traverse each level slice in the slice level configuration of the cubemap, and determine row and column parameters of the tile map in each level slice according to the maximum size of the tile map, including: For each of the decent maps of the cube map, each level slice in the slice hierarchy configuration of the decent map is traversed, and the number of rows and columns of the tile image in each level slice is obtained by rounding down the ratio of the image size of each level slice to the maximum size of the tile image, and the remainder after rounding down the ratio of the image size of each level slice to the maximum size of the tile image is used as the width and height of the last row and last column of the tile image in the corresponding level slice.
6. The method for cutting a panoramic picture according to claim 1, characterized in that: Creating a tile pyramid corresponding to the panoramic image according to the slice images corresponding to all the face maps in the cubic map of the panoramic image, comprising: Numbering each tile in the slice image corresponding to all the face maps in the cubic map of the panoramic image; The creation is performed according to the numbers of the tiles in the slice images corresponding to all the volume maps in the cubic map of the panoramic image, so as to obtain a tile pyramid corresponding to the panoramic image.
7. The method for cutting a panoramic picture according to claim 6, characterized in that: Numbering each tile in the slice image corresponding to all the volume maps in the cube map of the panoramic image comprises: Determine the coordinate position of each tile image in the slice image corresponding to each of the body maps in the cubic map of the panoramic image, wherein the coordinate position of the tile image includes: the surface position of the body map where the tile image is located in the cubic map, the slice level of the tile image in the body map where the tile image is located, and the row and column number of the slice level of the tile image in the body map where the tile image is located; The tiles are numbered according to the coordinate positions of the tiles in the slice image corresponding to each of the cube maps in the panoramic image.
8. A panoramic picture cutting device, characterized in that: Applied to a client, the device comprises: A determining unit, configured to determine a slice level configuration of each dimension map in the cubic map of the panoramic image, wherein the slice level configuration of each dimension map includes a number of slice levels of the dimension map and a picture size of each level of slice; A segmentation unit, configured to segment the corresponding decent map in the cubic map of the panoramic image according to the slice level configuration of each decent map, to obtain a slice image corresponding to each decent map in the cubic map of the panoramic image; The creating unit is used to create a tile pyramid corresponding to the panoramic picture according to the slice pictures corresponding to all the volume maps in the cubic map of the panoramic picture, wherein the original image resolution corresponding to each level slice in the tile pyramid corresponding to the panoramic picture is different.
9. An electronic device, characterized in that: include: Memory and processor; Wherein, the memory is used to store computer programs; The processor is used to execute the computer program, specifically to implement the panoramic picture cutting method according to any one of claims 1-7.
10. A computer storage medium, characterized in that: Used to store a computer program, which, when executed, is specifically used to implement the panoramic picture cutting method according to any one of claims 1 to 7.