Image synthesis method, device, electronic device and storage medium

By receiving viewing angle switching instructions and using camera parameter projection and filling technology to generate synthetic images, it solves the problem of high viewing angle switching costs in large-scale live broadcasts, achieving more flexible viewing angle switching and reducing costs.

CN113870165BActive Publication Date: 2024-10-29BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111194061.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-13
Publication Date
2024-10-29
Estimated Expiration
2041-10-13

AI Technical Summary

Technical Problem

In large-scale online TV live broadcasts or film and television shooting, in order to achieve image presentation from different viewing angles, a large number of cameras are required for shooting, resulting in high deployment costs during the viewing angle switching process.

Method used

By receiving the viewing angle switching command, the image to be projected is obtained and projected to the target viewing angle coordinate system based on the camera parameters, and the pixel information of the hole area is used to fill in the synthetic image, thus reducing the dependence on the actual camera.

Benefits of technology

It reduces the deployment cost required in the process of switching perspectives, provides more perspectives for switching, and improves the display effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113870165B_ABST
    Figure CN113870165B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide an image synthesis method, device, electronic device and storage medium. The scheme is as follows: receiving a perspective switching instruction including a first perspective; acquiring an image to be projected, the image to be projected is an image captured by at least one first camera within a first preset range of the first perspective; based on the camera parameters of the first camera, projecting the image to be projected into the image coordinate system corresponding to the first perspective to obtain a projection image including a hole area; filling the holes of the projection image according to the image information of the pixel points within the second preset range of the hole area in the projection image to obtain a synthesis image of the first perspective; displaying the synthesis image of the first perspective. The technical scheme provided by the embodiments of the present application reduces the deployment cost required for the perspective switching process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image synthesis method, device, electronic device and storage medium. Background Art

[0002] Currently, in large-scale network / TV live broadcasts or film and television shooting processes, in order to present images corresponding to different perspectives to the audience, a large number of cameras need to be used during the shooting process.

[0003] For example, in a large-scale evening party, 100 high-definition cameras are set up in the shooting scene to shoot the stage in 360 degrees. During the live broadcast of the evening party, the director switches the viewing angle so that the audience can watch the video images shot by the camera corresponding to the switched viewing angle.

[0004] Since the completion of perspective switching requires the reliance on a large number of cameras, the perspective switching process requires a large amount of deployment costs. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide an image synthesis method, device, electronic device and storage medium to reduce the deployment cost required for the perspective switching process. The specific technical solution is as follows:

[0006] In a first aspect of the present application, a method for image synthesis is first provided, the method comprising:

[0007] Receiving a perspective switching instruction including a first perspective;

[0008] Acquire an image to be projected, where the image to be projected is an image captured by at least one first camera within a first preset range of the first viewing angle;

[0009] Based on the camera parameters of the first camera, projecting the image to be projected into an image coordinate system corresponding to the first viewing angle to obtain a projected image including a hole area;

[0010] Filling holes in the projected image according to image information of pixels within a second preset range of the hole area in the projected image to obtain a composite image of the first viewing angle;

[0011] A composite image of the first perspective is displayed.

[0012] Optionally, the step of filling holes in the projected image according to image information of pixels within a second preset range of the hole area in the projected image to obtain a synthetic image of the first viewing angle includes:

[0013] Expanding the hole area in the projection image outwardly to a second preset range to obtain a first expanded area;

[0014] Acquire an image to be restored of the projection image, where the image to be restored is an image including the hole area and the first extended area;

[0015] Using the image information of each pixel point in the first extended area of ​​the image to be repaired, the hole area is filled to obtain a repaired image;

[0016] The projection image and the repaired image are fused to obtain a composite image of the first viewing angle.

[0017] Optionally, the step of expanding the hole area in the projection image outwardly by a second preset range to obtain a first extended area includes:

[0018] Determine each edge pixel point of the hole area in the projection image;

[0019] Each edge pixel point of the hole area in the projection image is expanded outwardly to a second preset range to obtain a first expanded area.

[0020] Optionally, the step of obtaining the image to be repaired of the projection image includes:

[0021] The image to be repaired of the projection image is obtained using the following formula:

[0022] I in =I prj *M exp

[0023] Among them, I in is the image to be repaired, I prj is the projection image, M exp It is a mask image of the first extended area corresponding to the hole area in the projection image.

[0024] Optionally, the step of filling the hole area using the image information of each pixel point in the first extended area in the image to be repaired to obtain the repaired image includes:

[0025] The image to be repaired is input into a pre-trained image repair model to obtain a repaired image; wherein the image repair model is trained using a preset training set; the preset training set includes sample images captured by multiple second cameras at different viewing angles and camera parameters of each second camera.

[0026] Optionally, the image restoration model is trained by the following steps:

[0027] Obtaining the preset training set;

[0028] Based on the camera parameters of each second camera, projecting the sample images in the preset training set except the second viewing angle into the image coordinate system corresponding to the second viewing angle to obtain a sample projection image including the hole area;

[0029] Expanding the hole area in the sample projection image outwards to a second preset range to obtain a second expanded area;

[0030] Acquire a sample image to be repaired of the sample projection image, wherein the sample image to be repaired is an image including the hole area and the second extended area;

[0031] Inputting the sample image to be repaired into a preset deep network model to obtain a sample repaired image;

[0032] Performing image fusion on the sample projection image and the sample restoration image to obtain a sample composite image of the second viewing angle;

[0033] Calculating the loss value of the preset deep network model according to the sample synthetic image and the sample image of the second perspective in the preset training set;

[0034] When the loss value is greater than a preset loss value threshold, adjusting the parameters of the preset deep network model, and returning to the step of inputting the sample image to be repaired into the preset deep network model to obtain a sample repaired image;

[0035] When the loss value is not greater than the preset loss value threshold, the current preset deep network model is determined as the trained image restoration model.

[0036] Optionally, the step of calculating the loss value of the preset deep network model according to the sample synthetic image and the sample image of the second perspective in the preset training set includes:

[0037] The loss value of the preset deep network model is calculated using the following formula:

[0038] loss=||I prd ′*M in ′-I true ′*M in ′||

[0039] Among them, loss is the loss value, || || is the norm operation, I prd ′ is the sample synthetic image of the second viewing angle, M in 'The mask image corresponding to the hole area and the extended area in the sample image to be repaired, I true ' is the sample image of the second viewing angle.

[0040] Optionally, the step of fusing the projection image with the restoration image to obtain a composite image of the first viewing angle includes:

[0041] The projection image and the repaired image are fused using the following formula to obtain a composite image of the first viewing angle:

[0042] I prd =I out *M hole +[(1-α)I out *M exp +α*I in *M exp ]+(I in -I in *M in )

[0043] Among them, I prd is the synthetic image of the first viewing angle, I out is the repaired image, M hole is the hole mask corresponding to the hole area in the projection image, α is the preset weight, M exp is the mask image of the first extended area corresponding to the hole area in the projection image, I in is the image to be repaired, M in It is the mask image corresponding to the hole area and the extended area in the image to be repaired.

[0044] Optionally, the camera parameters include camera external parameters and camera internal parameters;

[0045] The step of projecting the image to be projected into an image coordinate system corresponding to the first viewing angle based on the camera parameters of the first camera to obtain a projected image including a hole area comprises:

[0046] For each pixel point in the image to be projected, calculate a second coordinate value of the pixel point in the camera coordinate system according to the first coordinate value of the pixel point and the camera intrinsic parameter of the first camera;

[0047] For each pixel point in the image to be projected, calculate a third coordinate value of the pixel point in the world coordinate system according to the second coordinate value of the pixel point and the camera extrinsic parameter of the first camera;

[0048] For each pixel point in the image to be projected, calculate a fourth coordinate value of the pixel point in the camera coordinate system corresponding to the first viewing angle according to the third coordinate value of the pixel point and the camera extrinsic parameter of the virtual camera at the first viewing angle;

[0049] For each pixel point in the image to be projected, calculate a fifth coordinate value of the pixel point in the image coordinate system corresponding to the first viewing angle according to the fourth coordinate value of the pixel point and the camera intrinsic parameter of the virtual camera at the first viewing angle;

[0050] The image to be projected is projected according to the fifth coordinate value of each pixel point in the image to be projected in the image coordinate system corresponding to the first viewing angle to obtain a projected image including a hole area.

[0051] In a second aspect of the present application, there is also provided an image synthesis device, the device comprising:

[0052] A receiving module, configured to receive a perspective switching instruction including a first perspective;

[0053] A first acquisition module, used to acquire an image to be projected, where the image to be projected is an image captured by at least one first camera within a first preset range of the first viewing angle;

[0054] A first projection module, configured to project the image to be projected into an image coordinate system corresponding to the first viewing angle based on camera parameters of the first camera, to obtain a projection image including a hole area;

[0055] A synthesis module, configured to fill holes in the projected image according to image information of pixels within a second preset range of the hole area in the projected image, so as to obtain a synthesized image of the first viewing angle;

[0056] A display module is used to display the composite image of the first perspective.

[0057] In a third aspect of the implementation of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0058] Memory, used to store computer programs;

[0059] The processor is used to implement any of the above-mentioned steps of the image synthesis method when executing the program stored in the memory.

[0060] In a fourth aspect of the implementation of the present application, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any of the above-mentioned steps of the image synthesis method is implemented.

[0061] In a fifth aspect of the implementation of the present application, there is also provided a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-mentioned image synthesis methods.

[0062] The technical solution provided in the embodiment of the present application, after receiving the perspective switching instruction, obtains a projection image including a hole area by projecting the acquired image to be projected into the image coordinate system corresponding to the first perspective, thereby using the image information of each pixel point within the second preset range of the hole area to fill the hole area, obtain a composite image of the first perspective, and display the composite image.

[0063] Since the synthetic image of the first perspective is synthesized based on the image to be projected captured by at least one camera within the first preset range of the first perspective, the image corresponding to the first perspective can be synthesized using the images captured by the cameras at the perspectives adjacent to the first perspective during the perspective switching process, thereby avoiding the deployment of cameras at the position corresponding to the first perspective, reducing the number of cameras to be deployed, and thus greatly reducing the deployment cost required for the perspective switching process.

[0064] Furthermore, by receiving a perspective switching instruction including the first perspective, the synthetic image corresponding to the first perspective is displayed. This reduces the deployment cost required for the perspective switching process while providing more perspectives to switch to, meets the user's needs for perspective switching, and improves the display effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0066] Figure 1 A schematic diagram of a TV live broadcast scene;

[0067] Figure 2 A schematic diagram of a first process flow of the image synthesis method provided in an embodiment of the present application;

[0068] Figure 3-a The image is obtained by the camera capturing the image of cube A at the viewing angle A;

[0069] Figure 3-b The image is obtained by the camera capturing the image of cube A at the viewing angle B;

[0070] Figure 4-a A schematic diagram of a projection image provided by an embodiment of the present application;

[0071] Figure 4-b for Figure 4-a A mask image of the hole region of the projected image shown;

[0072] Figure 5 A schematic diagram of a flow chart of an image projection method provided in an embodiment of the present application;

[0073] Figure 6 A second flow chart of the image synthesis method provided in the embodiment of the present application;

[0074] Figure 7-a A projection image provided by an embodiment of the present application;

[0075] Figure 7-b for Figure 7-a The mask image corresponding to the projection image shown;

[0076] Figure 7-c for Figure 7-a The projection image shown corresponds to the image to be repaired;

[0077] Figure 7-d for Figure 7-c The mask image corresponding to the image to be repaired is shown;

[0078] Figure 8 A schematic diagram of a flow chart of an image model training method provided in an embodiment of the present application;

[0079] Fig. 9 A schematic diagram of the structure of an image synthesis device provided in an embodiment of the present application;

[0080] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0081] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0082] For ease of understanding, combined Figure 1 The view angle switching process in a certain TV live broadcast process in the related art is explained. Figure 1 A schematic diagram of a live TV broadcast scene.

[0083] During stage deployment, 7 cameras were set up in front of the stage, namely Figure 1 The camera 0 shown, the cameras L1 to L3 on the left side of the camera 0, and the cameras R1 to R3 on the right side of the camera 0. Figure 1 Each of the 7 cameras shown has a different distance from the stage and a different shooting angle, so Figure 1 Each camera shown corresponds to a different viewing angle.

[0084] The viewing angle corresponding to the above-mentioned camera is expressed as the shooting angle corresponding to the camera, that is, the viewing angle corresponding to the audience when watching the stage picture through the camera. The viewing angle corresponding to the above-mentioned camera is affected by factors such as the shooting angle, shooting distance and shooting height corresponding to the camera. Figure 1The viewing angle corresponding to each camera is not specifically limited.

[0085] At a certain moment of live TV broadcast, the current live broadcast picture is the video picture collected by camera 0. Now the director wants to show the live broadcast picture from the corresponding angle of view of camera L3 to the audience, and the currently played live broadcast picture can be switched from the video picture collected by camera 0 to the video picture collected by camera L3.

[0086] Therefore, in the related art, in order to allow users to freely switch video images at any perspective, corresponding cameras need to be set at different perspectives, which results in a large amount of deployment cost for the perspective switching process.

[0087] In order to solve the problems in the related art, the present application provides an image synthesis method. The method can be applied to any electronic device. Figure 2 As shown, Figure 2 The first flow chart of the image synthesis method provided in the embodiment of the present application is as follows.

[0088] Step S201, receiving a perspective switching instruction including a first perspective.

[0089] Step S202: Acquire an image to be projected, where the image to be projected is an image captured by at least one first camera within a first preset range of a first viewing angle.

[0090] Step S203 : Based on the camera parameters of the first camera, the image to be projected is projected into an image coordinate system corresponding to the first viewing angle to obtain a projected image including the hole area.

[0091] Step S204 , filling holes in the projected image according to the image information of the pixels in the second preset range of the hole area in the projected image, to obtain a composite image of the first viewing angle.

[0092] Step S205, displaying the synthesized image of the first perspective.

[0093] In the embodiment of the present application, the electronic device may be a server for pushing video images, or may be a user device for a user to watch video images. Here, the electronic device is not specifically limited.

[0094] pass Figure 1 The method shown, after receiving the perspective switching instruction, obtains a projection image including a hole area by projecting the acquired image to be projected into the image coordinate system corresponding to the first perspective, thereby filling the hole area with the image information of each pixel point within the second preset range of the hole area, obtaining a composite image of the first perspective, and displaying the composite image.

[0095] Since the synthetic image of the first perspective is synthesized based on the image to be projected captured by at least one camera within the first preset range of the first perspective, the image corresponding to the first perspective can be synthesized using the images captured by the cameras at the perspectives adjacent to the first perspective during the perspective switching process, thereby avoiding the deployment of cameras at the position corresponding to the first perspective, reducing the number of cameras to be deployed, and thus greatly reducing the deployment cost required for the perspective switching process.

[0096] Furthermore, by receiving a perspective switching instruction including the first perspective, the synthetic image corresponding to the first perspective is displayed. This reduces the deployment cost required for the perspective switching process while providing more perspectives to switch to, meets the user's needs for perspective switching, and improves the display effect.

[0097] The embodiments of the present application are described below through specific examples.

[0098] With respect to the above step S201, a perspective switching instruction including a first perspective is received.

[0099] In this step, when the user needs to switch the perspective of the image displayed by the current perspective, the electronic device can be triggered to switch the perspective of the currently displayed image. At this time, the electronic device will receive a perspective switching instruction, which includes the perspective after switching, that is, the first perspective.

[0100] In the embodiment of the present application, the first viewing angle may be a virtual viewing angle, that is, the first viewing angle is a viewing angle when no camera is deployed in the shooting scene. Here, the first viewing angle is not specifically limited.

[0101] With respect to the above step S202, that is, obtaining an image to be projected, the image to be projected is an image captured by at least one first camera within a first preset range of a first viewing angle.

[0102] In this step, after receiving the above-mentioned viewing angle switching instruction, the electronic device can obtain images captured by all cameras within a first preset range of the first viewing angle according to the first viewing angle included in the viewing angle switching instruction as images to be projected.

[0103] In an optional embodiment, the first preset range may be expressed in the form of distance.

[0104] For ease of understanding, the above Figure 1 Assume that the first perspective is Figure 1 The first preset range of the viewing angle corresponding to the camera 0 (at this time, the camera 0 is a virtual camera, that is, no camera is deployed at the position corresponding to the camera) is 2 meters.

[0105] After receiving the above-mentioned view switching instruction, the electronic device determines all cameras in a circular area with a radius of 2 meters and the center point of the position of camera 0 as the center, thereby obtaining images captured by all cameras in the circular area as images to be projected.

[0106] In an embodiment of the present application, the first preset range can be set according to user needs. The first preset range of the first viewing angle includes at least one camera. Since the number of cameras included in the first preset range of the first viewing angle is affected by the size of the first preset range, the more cameras are included in the first preset range of the first viewing angle, the more images to be projected acquired by the electronic device. Here, the number of images to be projected acquired is not specifically limited. For ease of description, only one image to be projected is used as an example for illustration in the embodiment of the present application, which does not serve any limiting role.

[0107] With respect to step S203 , that is, based on the camera parameters of the first camera, the image to be projected is projected into the image coordinate system corresponding to the first viewing angle to obtain a projected image including the hole area.

[0108] In an optional embodiment, the electronic device may project each pixel point in the above-mentioned image to be projected into an image coordinate system corresponding to the first viewing angle using a preset projection technology, such as a three-dimensional (3D) projection technology, according to the camera parameters of the first camera to obtain a projection image. Here, the preset projection technology is not specifically limited.

[0109] In an embodiment of the present application, since the viewing angle corresponding to the image to be projected is different from the viewing angle corresponding to the projection image (i.e., the first viewing angle mentioned above), when the image to be projected is projected into the image coordinate system corresponding to the first viewing angle, due to the existence of occlusion, this will cause some pixels in the image to be projected to be occluded, or some occluded pixels cannot be projected into the image coordinate system corresponding to the first viewing angle. At this time, a hole area will appear in the projection image.

[0110] For ease of understanding, the above projection process is described by taking a pixel point in the image to be projected, such as pixel point A, as an example. Now assume that the pixel point after pixel point A is projected to the image coordinate system corresponding to the above first viewing angle using the above preset projection technology is pixel point B. At this time, the image information of pixel point A will be filled into pixel point B. The method for determining pixel point B corresponding to pixel point A can be found in the following description and will not be described in detail here.

[0111] However, due to the existence of occlusion, multiple pixels in the image to be projected may be projected to the same pixel in the image coordinate system corresponding to the first viewing angle, or the occluded part of the image to be projected may not be projected to the image coordinate system corresponding to the first viewing angle, which will result in the appearance of pixels without image information in the projected image to be projected, and the area where one or more pixels without image information are located is recorded as a hole area. That is, the above-mentioned hole area is the area composed of pixels without image information in the above-mentioned projected image.

[0112] The above image information includes but is not limited to red, green, and blue (RGB) values ​​and depth values ​​corresponding to the pixels.

[0113] For ease of understanding, combined Figure 3-a and Figure 3-b Herein, Figure 3-a The image is obtained by the camera capturing the image of cube A at viewing angle A. Figure 3-b The image is obtained by the camera capturing the cube A at the viewing angle B.

[0114] Now assume that the electronic device projects the image corresponding to viewing angle A into the image coordinate system corresponding to viewing angle B.

[0115] exist Figure 3-a The image A shown includes only one face of the cube A, namely face 301, that is, Figure 3-b In the image B shown, faces 302 and 303 are occluded by face 301. Therefore, Figure 3-a After the image A shown is projected to the image coordinate system corresponding to the viewing angle B, the projected image only includes one face of the cube A, namely face 301. That is, in the projected image, Figure 3-b There is no image information for the pixels in the area where the surface 302 and the surface 303 are located. Figure 3-b The area where the surface 302 and the surface 303 are located is a hollow area.

[0116] The number of hole areas included in the above-mentioned projection image is at least one. When the projection image includes multiple hole areas, the shapes of the hole areas may be the same or different. The number of pixels included in each hole area in the projection image may be one or more. In the embodiment of the present application, affected by factors such as the viewing angle difference between the viewing angle of the above-mentioned image to be projected and the first viewing angle, the number of images to be projected, etc., the number of hole areas included in the above-mentioned projection image, and the size of each hole area are different. Here, the number of hole areas included in the above-mentioned projection image, the size of each hole area, and the number of pixels included in each hole area are not specifically limited. For the convenience of description, only one hole area is used as an example in the embodiment of the present application, which does not play any limiting role.

[0117] In an optional embodiment, when there are multiple images to be projected, the electronic device may project all the images to be projected into the same image when projecting the images to be projected into the image coordinate system corresponding to the first viewing angle.

[0118] The method for obtaining the above-mentioned projection image can be found in the following description and will not be described in detail here.

[0119] In the embodiment of the present application, the camera parameters of the first camera include camera intrinsic parameters and camera extrinsic parameters.

[0120] The above camera intrinsic parameters include the focal length, origin X-axis offset and origin Y-axis offset of the camera. The camera intrinsic parameters can be expressed as the intrinsic matrix intrinsics cam ,Right now:

[0121]

[0122] Among them, cam represents the camera, f cam is the focal length of the camera cam, cx cam is the X-axis offset of the origin of the camera cam, cy cam The Y-axis offset of the origin of the camera cam.

[0123] The above-mentioned camera external parameters include the position and direction in the world coordinate system, which can be expressed as a camera rotation matrix and a camera displacement matrix.

[0124] The above camera rotation matrix R cam It can be expressed as:

[0125]

[0126] The above camera displacement matrix t cam It can be expressed as:

[0127]

[0128] The camera extrinsics of the above camera can be specifically expressed as the extrinsics matrix cam ,Right now

[0129]

[0130] Among them, cam represents the camera, R represents the direction in the world coordinate system, t represents the position in the world coordinate system, x represents the X-axis direction in the world coordinate system, y represents the Y-axis direction in the world coordinate system, and z represents the Z-axis direction in the world coordinate system.

[0131] The camera intrinsic parameters and camera extrinsic parameters of the above-mentioned camera can be obtained by a corresponding preset calibration method. Taking the camera intrinsic parameters as an example, the camera intrinsic parameters of the camera can be calibrated using Zhang's calibration method. Here, the method for obtaining the camera intrinsic parameters and camera extrinsic parameters of the above-mentioned camera is not specifically limited.

[0132] In an optional embodiment, when the first preset range of the above-mentioned first viewing angle includes multiple cameras, in order to reduce the differences in resolution, color, etc. of the images captured by each camera and ensure the image quality of the image after the viewing angle is switched, the camera internal parameters of each camera can be the same or similar.

[0133] In the embodiment of the present application, when the first preset range of the first viewing angle includes multiple cameras, since the viewing angles corresponding to each camera are different, the camera extrinsic parameters of each camera are different.

[0134] With respect to the above step S204, the holes in the projected image are filled according to the image information of the pixels in the second preset range of the hole area in the projected image to obtain a synthetic image of the first viewing angle.

[0135] In the embodiment of the present application, since the image information of each pixel in the image has a certain correlation with the image information of its surrounding pixels, for the hole area in the above-mentioned projection image, the electronic device can use the image information of the pixels around the hole area to fill the hole area, that is, according to the image information of the pixels within the second preset range of the hole area in the projection image, the image information of each pixel in the hole area is determined, thereby obtaining a composite image of the first perspective.

[0136] The second preset range may be set according to user experience or user needs, and the second preset range is not specifically limited herein.

[0137] For ease of understanding, combined Figure 4-a and Figure 4-b Take this as an example to illustrate. Figure 4-a A schematic diagram of a projection image provided in an embodiment of the present application. Figure 4-b for Figure 4-a The mask image of the hole region of the projected image is shown.

[0138] according to Figure 4-b In the mask image shown, the white area is the hole area, such as area 401 and area 402, and the black area is the non-hole area (i.e., the valid pixel area). Figure 4-b The mask image shown can be used to determine Figure 4-a Region 401 and region 402 are hole regions. The non-hole region (or effective pixel region) is a region composed of pixels with image information.

[0139] Electronic equipment in Figure 4-a When filling holes in regions 401 and 402, image information of regions 401 and 402 can be determined based on image information of the areas to the right of regions 401 and 402, and holes in regions 401 and 402 can be filled based on the determined image information.

[0140] The image information of the above pixel includes but is not limited to the RGB value and depth value of the pixel. Here, the above image information is not specifically limited.

[0141] The above-mentioned method of filling the voids can be found in the following description and will not be described in detail here.

[0142] Regarding the above step S205, the synthesized image of the first viewing angle is displayed.

[0143] In this step, after synthesizing the synthesized image of the first perspective, that is, obtaining the virtual synthesized image of the first perspective, the electronic device can display the synthesized image of the first perspective, for example, by displaying the synthesized image on a display interface.

[0144] The data switched during the perspective switching process is video data. In the embodiment of the present application, only one frame of video image in the video data is taken as an example to illustrate the image synthesis method for switching to the virtual perspective (i.e., the first perspective mentioned above). Each frame of video image in the virtual perspective after switching can be synthesized by referring to the method for synthesizing images of the first perspective mentioned above, and no specific description is given here.

[0145] In an optional embodiment, Figure 5 As shown, Figure 5A flowchart of an image projection method provided in an embodiment of the present application. The above step S203, i.e., based on the camera parameters of the first camera, projects the image to be projected into the image coordinate system corresponding to the first viewing angle to obtain a projection image including the hole area, can be specifically refined into the following steps, steps S501 to S505.

[0146] Step S501 : for each pixel point in the image to be projected, a second coordinate value of the pixel point in the camera coordinate system is calculated according to the first coordinate value of the pixel point and the camera intrinsic parameter of the first camera.

[0147] For ease of understanding, the following description is made by taking a pixel point in the image to be projected, that is, pixel point P, as an example. The coordinate value of pixel point P in the image to be projected is (u src , v src ), where src represents the camera that captures the image to be projected, u src is the horizontal coordinate value of the pixel point P in the image to be projected, v src is the vertical coordinate value of the pixel point P in the image to be projected.

[0148] The coordinate value of the pixel point P is (u src , v src ) is the coordinate value of the pixel point P in the image coordinate system, and the coordinate value is converted into homogeneous coordinates, that is,

[0149] In an optional embodiment, for each pixel point in the image to be projected, the electronic device may calculate the second coordinate value of the pixel point in the camera coordinate system using the following formula:

[0150]

[0151] in, is the second coordinate value of the pixel point P in the camera coordinate system, x src is the coordinate value of the pixel point P in the X-axis direction of the camera coordinate system, y src is the coordinate value of pixel point P in the Y-axis direction of the camera coordinate system, z src is the coordinate value of the pixel point P in the Z-axis direction of the camera coordinate system, intrinsics src is the intrinsic parameter matrix of camera src, I represents the inverse operation, and d is the depth value corresponding to the pixel point P in the image to be projected.

[0152] Step S502 : for each pixel point in the image to be projected, a third coordinate value of the pixel point in the world coordinate system is calculated according to the second coordinate value of the pixel point and the camera extrinsic parameter of the first camera.

[0153] For ease of understanding, the above pixel point P is still taken as an example for description.

[0154] In an optional embodiment, for each pixel point in the image to be projected, the electronic device may calculate the third coordinate value of the pixel point in the world coordinate system using the following formula:

[0155]

[0156] in, is the third coordinate value of the pixel point P in the world coordinate system, X is the coordinate value of the pixel point P in the X-axis direction of the world coordinate system, Y is the coordinate value of the pixel point P in the Y-axis direction of the world coordinate system, and Z is the coordinate value of the pixel point P in the Z-axis direction of the world coordinate system. src The external parameter matrix of camera src, I represents the inverse operation.

[0157] Step S503, for each pixel in the image to be projected, according to the third coordinate value of the pixel and the camera extrinsic parameters of the virtual camera at the first viewing angle, calculate the fourth coordinate value of the pixel in the camera coordinate system corresponding to the first viewing angle.

[0158] For ease of understanding, the above pixel point P is still taken as an example for description.

[0159] In an optional embodiment, for each pixel point in the image to be projected, the electronic device may calculate the fourth coordinate value of the pixel point in the camera coordinate system corresponding to the first viewing angle by using the following formula:

[0160]

[0161] Among them, tar represents the virtual camera corresponding to the first-person perspective. is the fourth coordinate value of the pixel point P projected to the camera coordinate system corresponding to the first viewing angle, x tar y is the coordinate value of the pixel point P projected to the X-axis direction in the camera coordinate system corresponding to the first viewing angle, tar is the coordinate value of the pixel point P projected to the Y-axis direction in the camera coordinate system corresponding to the first viewing angle, z tar The coordinate value of the pixel point P projected to the Z-axis direction in the camera coordinate system corresponding to the first perspective, extrinsics tar is the external parameter matrix of the virtual camera tar.

[0162] Step S504, for each pixel in the image to be projected, calculate the fifth coordinate value of the pixel in the image coordinate system corresponding to the first viewing angle according to the fourth coordinate value of the pixel and the camera intrinsic parameter of the virtual camera at the first viewing angle.

[0163] For ease of understanding, the above pixel point P is still taken as an example for description.

[0164] In an optional embodiment, for each pixel point in the image to be projected, the electronic device may calculate the fifth coordinate value of the pixel point in the image coordinate system corresponding to the first viewing angle using the following formula:

[0165]

[0166] in, is the fifth coordinate value of the pixel point P projected to the image coordinate system corresponding to the first viewing angle, u tar v is the coordinate value of the pixel point P projected to the X-axis direction in the image coordinate system corresponding to the first viewing angle, tar is the coordinate value of the pixel point P projected to the Y-axis direction in the image coordinate system corresponding to the first perspective, intrinsics tar It is the internal parameter matrix of the virtual camera tar.

[0167] In an optional embodiment, in order to reduce the differences between the synthetic image of the first perspective and the image to be projected in terms of resolution, color, etc., the intrinsic parameter matrix of the virtual camera tar may be the same as the intrinsic parameter matrix of the camera src.

[0168] The external parameter matrix of the virtual camera tar can be calibrated according to the position of the first viewing angle. Here, the external parameter matrix of the virtual camera tar is not specifically limited.

[0169] Step S505 , projecting the image to be projected according to the fifth coordinate value of each pixel point in the image to be projected in the image coordinate system corresponding to the first viewing angle to obtain a projected image including the hole area.

[0170] In this step, after determining the position coordinate value (i.e., the fifth coordinate value) of each pixel point in the image to be projected in the image coordinate system corresponding to the first viewing angle, the electronic device can project each pixel point in the image to be projected to obtain a projected image including a hole area.

[0171] In an optional embodiment, the above projection process can be specifically expressed as: filling the image information of each pixel in the image to be projected into the pixel corresponding to the fifth coordinate value of the pixel in the image coordinate system at the first viewing angle. For example, the above image information of pixel A is filled into pixel B.

[0172] In the embodiment of the present application, due to the existence of the occlusion phenomenon, when the image information of a pixel point in the image to be projected is filled into the pixel point corresponding to the fifth coordinate value corresponding to the pixel point, the image information of multiple pixels in the image to be projected may be filled into the same pixel point in the projected image. At this time, the image information of the pixel point in the projected image can be determined in a variety of ways.

[0173] For example, the image information of a pixel point in the projection image may be an average value, a mode, etc. of the image information corresponding to each pixel point projected to the pixel point in the image to be projected.

[0174] For ease of understanding, the process of projecting the pixel point P to the image coordinate system corresponding to the second viewing angle is described by taking the coordinates of the pixel point P as (0,0) as an example. The homogeneous coordinates corresponding to the pixel point P are:

[0175] Now assume that the intrinsic parameter matrix of the camera src corresponding to the image to be projected is: The external parameter matrix of the camera src corresponding to the image to be projected is: The internal parameter matrix of the virtual camera tar corresponding to the projection image is: The external parameter matrix of the virtual camera tar corresponding to the projection image is:

[0176] The second coordinate value of pixel point P in the camera coordinate system:

[0177]

[0178] [] -1 It is the inverse operation of the matrix.

[0179] The third coordinate value of pixel point P in the world coordinate system:

[0180]

[0181] The fourth coordinate value of the pixel point P in the camera coordinate system corresponding to the first viewing angle:

[0182]

[0183] The fifth coordinate value of the pixel point P in the image coordinate system corresponding to the first viewing angle:

[0184]

[0185] Therefore, the coordinates of the pixel point P in the image to be projected in the projection image are: (51.84695977, 26.45017069). The electronic device can project the image information of the pixel point P in the image to be projected to the pixel point with the coordinate value of (51.84695977, 26.45017069) in the projection image.

[0186] Through the above steps S501 to S505, the electronic device can accurately project each pixel point in the image to be projected into the image coordinate system corresponding to the first viewing angle, thereby obtaining a projected image including the hole area.

[0187] exist Figure 5 In the method shown, the electronic device directly projects each pixel point in the image to be projected by using the calculated fifth coordinate value. In addition, the electronic device can also first perform coordinate conversion on the pixel points in the image to be projected according to the calculated second coordinate value and third coordinate value, and then project each pixel point in the image to be projected in the world coordinate system to the camera coordinate system corresponding to the first viewing angle, thereby performing coordinate conversion on each pixel point in the camera coordinate system corresponding to the first viewing angle to obtain the above-mentioned projected image.

[0188] In an optional embodiment, according to Figure 2 The method shown in the figure, the embodiment of the present application also provides an image synthesis method. Figure 6 As shown, Figure 6 The second flow chart of the image synthesis method provided in the embodiment of the present application is as follows: The above step S204 is specifically divided into the following steps, namely step S2041 to step S2044.

[0189] Step S2041: Expand the hole area in the projection image outward by a second preset range to obtain a first expanded area.

[0190] In this step, the electronic device may expand the hole area in the projected image according to the second preset range, that is, expand the hole area outward by the second preset range, and the expanded area is the first expanded area.

[0191] In an optional embodiment, the above step S2041, expanding the hole area in the projection image outward by a second preset range to obtain a first expansion area, can be specifically represented by the following steps, namely step one to step two.

[0192] Step 1: determine the edge pixel points of the hole area in the projection image.

[0193] Step 2: Expand each edge pixel point of the hole area in the projection image outward by a second preset range to obtain a first expanded area.

[0194] The above-mentioned edge pixel points are pixel points included in the area where the edge of the hole area is located.

[0195] In an optional embodiment, each edge pixel point of the hole area in the projected image is expanded outward by a second preset range to obtain a first expansion area, which can be expressed as: taking each edge pixel point of the hole area in each projected image as the center of the circle and the second preset range as the radius, the circular expansion area corresponding to each edge pixel point is determined, and thus the area other than the hole area in the union area of ​​the circular expansion areas corresponding to each edge pixel point of the hole area is determined as the first expansion area of ​​the hole area.

[0196] For example, when the above-mentioned second preset range is represented by a preset number of pixels, the electronic device can determine, for each edge pixel of the hole area in the projected image, a circular expansion area formed by a preset number of pixels around the edge pixel, and determine the union area of ​​the circular expansion areas corresponding to each edge pixel, and the area in the union area except the above-mentioned hole area is the above-mentioned first expansion area.

[0197] The second preset range may be expressed in the form of distance in addition to being expressed in the form of pixels, such as 2 mm, etc. Here, the expression method of the second preset range is not specifically limited, and the value of the second preset range is not specifically limited.

[0198] When the second preset range is represented by a preset distance, the method for determining the first extended area may refer to the method for determining the first extended area when the second preset range is represented by a preset number of pixels, which is not described in detail here.

[0199] In an embodiment of the present application, when determining the first expansion area, the electronic device may, in addition to expanding outwardly the second preset range for each edge pixel point of the above-mentioned hole area, also expand outwardly the second preset range for each pixel point in the hole area, thereby determining the area other than the hole area in the union area after each pixel point is expanded by the second preset range as the first expansion area of ​​the hole area.

[0200] For ease of understanding, combined Figure 7-a to Figure 7-d Take this as an example to illustrate. Figure 7-a A projection image provided in an embodiment of the present application. Figure 7-b for Figure 7-a The projection image shown corresponds to the mask image. Figure 7-c for Figure 7-a The projection image shown corresponds to the image to be repaired. Figure 7-d for Figure 7-c The mask image corresponding to the image to be repaired is shown.

[0201] exist Figure 7-aIn the projection image 701 (denoted as I prj ) contains a hole region, namely region 702 (denoted as M hole ). The black area is the effective pixel area formed after each pixel point in the image to be projected is projected to the image coordinate system corresponding to the first viewing angle. By obtaining the hole mask corresponding to the projected image 701, the following is obtained: Figure 7-b The mask image 703 is shown. The area 704 is the area 702 in the projection image 701.

[0202] According to the mask image 703, the electronic device can accurately determine the edge pixels of the area 702 in the projected image 701, that is, Figure 7-b The outermost pixel point in the circular area shown in the middle area 704.

[0203] The electronic device can expand each edge pixel point in the area 704 outward to a second preset range, and obtain Figure 7-d The area 709 (denoted as M in ). At this time, the electronic device can remove the hole area from the area 709, that is, Figure 7-b The circular area outside the middle area 704 is determined as the first extended area (denoted as M exp ), that is, Figure 7-c The area 707 in is determined as the first extended area.

[0204] The above M in 、M exp and M hole The relationship between the three can be expressed as: in =M exp +M hole .

[0205] Through the above-mentioned second preset range, the electronic device can accurately determine the position of the first extended area in the projected image, ensuring the correlation between the image information of each pixel in the hole area determined later and the image information of each pixel in the first extended area, thereby ensuring the accuracy of the restored image.

[0206] Step S2042, obtaining an image to be restored of the projection image, where the image to be restored is an image including the hole area and the first extended area.

[0207] In this step, the electronic device may intercept the image corresponding to the hole area and the first extension area in the projection image according to the hole area and the first extension area to obtain the image to be repaired.

[0208] Still with the above Figure 7-a , Figure 7-c and Figure 7-d The electronic device determines that the first extension area is Figure 7-c After the area 707 shown, the electronic device can expand the first expansion area (ie Figure 7-c The region 707 in the middle) and the hole region (i.e. Figure 7-c Region 706 in Figure 7-a The area 702 in the figure is used as the area to be repaired (i.e. Figure 7-d The image to be repaired is obtained from the projection image 701, and the image to be repaired is obtained as the area 709 in the mask image 708 shown.

[0209] In an optional embodiment, the electronic device may use the following formula to obtain the image to be repaired of the projection image:

[0210] I in =I prj *M exp

[0211] Among them, I in is the image to be repaired, I prj is the projected image, M exp It is the mask image of the first extended area corresponding to the hole area in the projection image.

[0212] In an embodiment of the present application, by obtaining the image to be repaired from the projection image, the subsequent hole filling can be performed only on the area to be repaired in the image to be repaired, which effectively reduces the amount of calculation in the hole filling process and improves the efficiency of hole filling.

[0213] Step S2043, using the image information of each pixel in the first extended area of ​​the image to be repaired, the hole area is filled to obtain a repaired image.

[0214] In an optional embodiment, in the above step S2043, the hole area is filled by using the image information of each pixel in the first extended area of ​​the image to be repaired to obtain a repaired image, which can be specifically expressed as:

[0215] The image to be repaired is input into a pre-trained image repair model to obtain a repaired image; wherein the image repair model is trained using a preset training set; the preset training set includes sample images captured by multiple second cameras at different viewing angles and camera parameters of each second camera.

[0216] In an embodiment of the present application, the hole areas in the image to be repaired are filled using an image repair model, which can effectively improve the accuracy of the repaired image and the efficiency of filling the hole areas.

[0217] The training process of the above image restoration model can be found in the description below and will not be explained in detail here.

[0218] Step S2044: performing image fusion on the projected image and the restored image to obtain a composite image of the first perspective.

[0219] In this step, after obtaining the above-mentioned repaired image, the electronic device performs image fusion processing on the above-mentioned repaired image and the projected image, and determines the fused image as a composite image at the first viewing angle.

[0220] In an optional embodiment, the electronic device may fuse the image information at the location of the hole region included in the projected image in the repaired image into the hole region of the projected image to obtain a composite image at the first viewing angle.

[0221] In another optional embodiment, in the above step S2044, the projected image and the repaired image are fused to obtain a composite image of the first perspective, which can be specifically expressed as:

[0222] The following formula is used to fuse the projected image and the repaired image to obtain a composite image of the first perspective:

[0223] I prd =I out *M hole +[(1-α)I out *M exp +α*I in *M exp ]+(I in -I in *M in )

[0224] Among them, I prd is the synthetic image of the first perspective, I out To repair the image, M hole is the hole mask corresponding to the hole area in the projected image, α is the preset weight, M exp is the mask image of the first extended area corresponding to the hole area in the projection image, I in is the image to be repaired, M in It is the mask image corresponding to the hole area and the extended area in the image to be repaired.

[0225] pass Figure 6 In the method shown, the electronic device only fills the hole areas in the image to be repaired to obtain the repaired image, thereby performing image fusion on the projected image and the repaired image, so that the final composite image of the first perspective does not include the hole areas, thereby ensuring the integrity and accuracy of the composite image of the first perspective.

[0226] Based on the same inventive concept, according to the image synthesis method provided in the above-mentioned embodiment of the present application, the embodiment of the present application also provides an image restoration model training method, such as Figure 8 As shown, Figure 8 A flow chart of an image model training method provided in an embodiment of the present application. The method comprises the following steps.

[0227] Step S801, obtaining a preset training set.

[0228] The preset training set includes sample images captured by multiple second cameras at different viewing angles and camera parameters of each second camera.

[0229] For ease of understanding, the above Figure 1 No description given.

[0230] The above preset training set may include: Figure 1 The image obtained by each camera shooting the stage at the corresponding viewing angle, i.e., the sample image, and Figure 1 The camera parameters of each camera in .

[0231] In the embodiment of the present application, the sample images and camera parameters included in the above-mentioned preset training set can be one set of training data or multiple sets of training data. The shooting scenes, camera viewpoints, etc. corresponding to the sample images included in the same set of training data are the same. The shooting scenes, camera viewpoints, etc. corresponding to the sample images in different sets of training data can be different or the same. Here, the above-mentioned preset training set is not specifically limited. For ease of understanding, the embodiment of the present application is only illustrated by taking one set of training data as an example, which does not serve any limiting role.

[0232] Step S802 , based on the camera parameters of each second camera, project the sample images in the preset training set except the second viewing angle into the image coordinate system corresponding to the second viewing angle to obtain a sample projection image including the hole area.

[0233] In this step, the electronic device may select a viewing angle corresponding to any sample image as the second viewing angle. For each sample image in the preset training set except the sample image corresponding to the second viewing angle, the electronic device may project the sample image into the image coordinate system corresponding to the second viewing angle according to the camera parameters of the camera corresponding to the sample image, and obtain a sample projection image including the hole area.

[0234] The projection method of the sample image may refer to the projection method of the image to be projected, which will not be described in detail here.

[0235] Step S803: Expand the hole area in the sample projection image outward by a second preset range to obtain a second expanded area.

[0236] The second extension area may be determined by referring to the method for determining the first extension area, which will not be described in detail here.

[0237] Step S804: obtaining a sample image to be repaired of the sample projection image, where the sample image to be repaired is an image including the hole area and the second extended area.

[0238] The method for obtaining the above-mentioned sample image to be repaired can refer to the method for obtaining the above-mentioned image to be repaired, and will not be described in detail here.

[0239] Step S805: input the sample image to be repaired into a preset deep network model to obtain a sample repaired image.

[0240] The dimensions included in the input data of the above preset deep network model are the same as the dimensions included in the output data.

[0241] For example, the input sample image to be repaired includes the RGB value and depth value of each pixel, and the sample repaired image output by the preset deep network model also includes the RGB value and depth value of each pixel.

[0242] In the embodiment of the present application, the preset deep network model may be a deep residual network (ResNet) model or a visual geometry group (Visual Geometry Group, VGG) model. Here, the preset deep network model is not specifically limited.

[0243] Step S806: perform image fusion on the sample projection image and the sample restoration image to obtain a sample composite image of a second viewing angle.

[0244] The above-mentioned image fusion method for the sample projection image and the sample restoration image can refer to the above-mentioned image fusion method for the projection image and the restoration image, and will not be described in detail here.

[0245] Step S807, calculating the loss value of the preset deep network model according to the sample synthetic image and the sample image of the second perspective in the preset training set.

[0246] In an optional embodiment, the electronic device may calculate the loss value of the preset deep network model using the following formula:

[0247] loss=||I prd ′*M in ′-I true ′*M in ′||

[0248] Among them, loss is the loss value, || || is the norm operation, I prd ′ is the sample synthetic image of the second perspective, Min ′The mask image corresponding to the hole area and the extended area in the sample image to be repaired, I true ′ is the sample image of the second viewing angle.

[0249] In an embodiment of the present application, the loss value of the above-mentioned preset deep network model can be calculated by other methods. For example, the electronic device can calculate the difference and value between the image information of each pixel in the sample synthetic image and the image information of the pixel at the corresponding position in the sample image of the second perspective in the preset training set, and determine the difference and value as the loss value of the preset deep network model. Here, the calculation method of the loss value of the above-mentioned preset deep network model is not specifically limited.

[0250] In the embodiment of the present application, after calculating the above loss value, the electronic device can compare the loss value with a preset loss value threshold. If the loss value is greater than the preset loss value threshold, step S808 is executed. If the loss value is not greater than the preset loss value threshold, step S809 is executed.

[0251] Step S808, when the loss value is greater than the preset loss value threshold, adjust the parameters of the preset deep network model and return to execute step S805.

[0252] When the above loss value is greater than the preset loss value threshold, the electronic device may determine that the preset deep network model has not converged. At this time, the electronic device may adjust the parameters of the preset deep network model and return to execute the above step S805, that is, return to the step of inputting the sample image to be repaired into the preset deep network model to obtain the sample repaired image.

[0253] In the embodiment of the present application, the parameters of the preset deep network model include but are not limited to weights and biases. The electronic device can adjust the parameters of the preset deep network model using a gradient descent method or a reverse adjustment method.

[0254] Step S809, when the loss value is not greater than the preset loss value threshold, the current preset deep network model is determined as the trained image restoration model.

[0255] In this step, when the above loss value is less than or equal to the preset loss value threshold, the electronic device can determine that the preset deep network model converges. At this time, the electronic device can determine the current preset deep network model as a trained image restoration model, that is, the pre-trained image restoration model input by the above image to be restored.

[0256] pass Figure 8According to the method shown, the electronic device can use the sample images in the preset training set to complete the training of the above-mentioned preset deep network model, thereby ensuring the accuracy of the trained image restoration model, the accuracy of the restored image obtained by filling holes in the image to be restored using the image restoration model, and the accuracy of the synthesized image obtained based on the restored image.

[0257] Based on the same inventive concept, according to the image synthesis method provided in the above embodiment of the present application, the embodiment of the present application also provides an image synthesis device. Fig. 9 As shown, Fig. 9 A schematic diagram of the structure of an image synthesis device provided in an embodiment of the present application. The device includes the following modules.

[0258] A receiving module 901 is used to receive a perspective switching instruction including a first perspective;

[0259] A first acquisition module 902 is used to acquire an image to be projected, where the image to be projected is an image captured by at least one first camera within a first preset range of a first viewing angle;

[0260] A first projection module 903 is used to project the image to be projected into an image coordinate system corresponding to the first viewing angle based on the camera parameters of the first camera, so as to obtain a projection image including a hole area;

[0261] A synthesis module 904, configured to fill the holes in the projected image according to the image information of the pixels in the second preset range of the hole area in the projected image, so as to obtain a synthesized image of the first viewing angle;

[0262] The display module 905 is used to display the composite image of the first perspective.

[0263] Optionally, the synthesis module 904 includes:

[0264] An expansion submodule, used to expand the hole area in the projection image outwardly to a second preset range to obtain a first expansion area;

[0265] An acquisition submodule, used for acquiring an image to be restored of the projection image, where the image to be restored is an image including the hole area and the first extended area;

[0266] A repair submodule, used to fill the hole area using the image information of each pixel point in the first extended area of ​​the image to be repaired, so as to obtain a repaired image;

[0267] The fusion submodule is used to fuse the projection image and the restoration image to obtain a composite image of the first perspective.

[0268] Optionally, the above-mentioned expansion submodule can be specifically used to determine each edge pixel point of the hole area in the projection image; expand each edge pixel point of the hole area in the projection image outwardly by a second preset range to obtain a first expansion area.

[0269] Optionally, the acquisition submodule may be used to acquire the image to be restored of the projection image using the following formula:

[0270] I in =I prj *M exp

[0271] Among them, I in is the image to be repaired, I prj is the projected image, M exp It is the mask image of the first extended area corresponding to the hole area in the projection image.

[0272] Optionally, a restoration submodule can be specifically used to input the image to be restored into a pre-trained image restoration model to obtain a restored image; wherein the image restoration model is trained using a preset training set; the preset training set includes sample images captured by multiple second cameras at different viewing angles and the camera parameters of each second camera.

[0273] Optionally, the above-mentioned image synthesis device may further include:

[0274] A second acquisition module is used to acquire a preset training set;

[0275] A second projection module, configured to project sample images other than the second viewing angle in the preset training set to an image coordinate system corresponding to the second viewing angle based on the camera parameters of each second camera, to obtain a sample projection image including a hole area;

[0276] An expansion module, used to expand the hole area in the sample projection image outward to a second preset range to obtain a second expansion area;

[0277] A third acquisition module is used to acquire a sample image to be repaired of the sample projection image, where the sample image to be repaired is an image including the hole area and the second extended area;

[0278] A restoration module is used to input the sample image to be restored into a preset deep network model to obtain a sample restoration image;

[0279] A fusion module is used to fuse the sample projection image and the sample restoration image to obtain a sample composite image of a second perspective;

[0280] A calculation module, used to calculate the loss value of a preset deep network model according to the sample synthetic image and the sample image of the second perspective in the preset training set;

[0281] An adjustment module, used for adjusting the parameters of the preset deep network model when the loss value is greater than a preset loss value threshold, and returning to call the repair module to execute the step of inputting the sample image to be repaired into the preset deep network model to obtain a sample repaired image;

[0282] The determination module is used to determine the current preset deep network model as a trained image restoration model when the loss value is not greater than a preset loss value threshold.

[0283] Optionally, the above calculation module can be used to calculate the loss value of the preset deep network model using the following formula:

[0284] loss=||I prd ′*M in ′-I true ′*M in ′||

[0285] Among them, loss is the loss value, || || is the norm operation, I prd ′ is the sample synthetic image of the second perspective, M in ′The mask image corresponding to the hole area and the extended area in the sample image to be repaired, I true ′ is the sample image of the second viewing angle.

[0286] Optionally, the fusion submodule may be used to fuse the projection image and the restoration image using the following formula to obtain a composite image of the first perspective:

[0287] I prd =I out *M hole +[(1-α)I put *M exp +α*I in *M exp ]+(I in -I in *M in )

[0288] Among them, I prd is the synthetic image of the first perspective, I out To repair the image, M hole is the hole mask corresponding to the hole area in the projected image, α is the preset weight, M exp is the mask image of the first extended area corresponding to the hole area in the projection image, I in is the image to be repaired, M in It is the mask image corresponding to the hole area and the extended area in the image to be repaired.

[0289] Optionally, the above-mentioned camera parameters include camera external parameters and camera internal parameters;

[0290] The first projection module 903 may be specifically configured to calculate, for each pixel in the image to be projected, a second coordinate value of the pixel in the camera coordinate system according to the first coordinate value of the pixel and the camera intrinsic parameter of the first camera;

[0291] For each pixel point in the image to be projected, calculate the third coordinate value of the pixel point in the world coordinate system according to the second coordinate value of the pixel point and the camera extrinsic parameter of the first camera;

[0292] For each pixel point in the image to be projected, calculate the fourth coordinate value of the pixel point in the camera coordinate system corresponding to the first viewing angle according to the third coordinate value of the pixel point and the camera extrinsic parameter of the virtual camera at the first viewing angle;

[0293] For each pixel point in the image to be projected, calculate the fifth coordinate value of the pixel point in the image coordinate system corresponding to the first viewing angle according to the fourth coordinate value of the pixel point and the camera intrinsic parameter of the virtual camera at the first viewing angle;

[0294] The image to be projected is projected according to the fifth coordinate value of each pixel point in the image to be projected in the image coordinate system corresponding to the first viewing angle to obtain a projection image including the hole area.

[0295] Through the device provided in the embodiment of the present application, after receiving the perspective switching instruction, the acquired image to be projected is projected into the image coordinate system corresponding to the first perspective to obtain a projection image including a hole area, so as to fill the hole area with the image information of each pixel point within the second preset range of the hole area, obtain a composite image of the first perspective, and display the composite image.

[0296] Since the synthetic image of the first perspective is synthesized based on the image to be projected captured by at least one camera within the first preset range of the first perspective, the image corresponding to the first perspective can be synthesized using the images captured by the cameras at the perspectives adjacent to the first perspective during the perspective switching process, thereby avoiding the deployment of cameras at the position corresponding to the first perspective, reducing the number of cameras to be deployed, and thus greatly reducing the deployment cost required for the perspective switching process.

[0297] Furthermore, by receiving a perspective switching instruction including the first perspective, the synthetic image corresponding to the first perspective is displayed. This reduces the deployment cost required for the perspective switching process while providing more perspectives to switch to, meets the user's needs for perspective switching, and improves the display effect.

[0298] Based on the same inventive concept, according to the image synthesis method provided in the above-mentioned embodiment of the present application, the embodiment of the present application also provides an electronic device, such as Fig.10 As shown, it includes a processor 1001, a communication interface 1002, a memory 1003 and a communication bus 1004, wherein the processor 1001, the communication interface 1002, and the memory 1003 communicate with each other through the communication bus 1004.

[0299] Memory 1003, used for storing computer programs;

[0300] The processor 1001 is used to execute the program stored in the memory 1003, and implements the following steps:

[0301] Receiving a perspective switching instruction including a first perspective;

[0302] Acquire an image to be projected, where the image to be projected is an image captured by at least one first camera within a first preset range of a first viewing angle;

[0303] Based on the camera parameters of the first camera, the image to be projected is projected into an image coordinate system corresponding to the first viewing angle to obtain a projected image including the hole area;

[0304] Filling the holes in the projected image according to the image information of the pixels in the second preset range of the hole area in the projected image to obtain a composite image of the first viewing angle;

[0305] Composite image showing a first-person perspective.

[0306] Through the electronic device provided in the embodiment of the present application, after receiving the perspective switching instruction, the acquired image to be projected is projected into the image coordinate system corresponding to the first perspective to obtain a projection image including a hole area, thereby using the image information of each pixel point within the second preset range of the hole area to fill the hole area, obtain a composite image of the first perspective, and display the composite image.

[0307] Since the synthetic image of the first perspective is synthesized based on the image to be projected captured by at least one camera within the first preset range of the first perspective, the image corresponding to the first perspective can be synthesized using the images captured by the cameras at the perspectives adjacent to the first perspective during the perspective switching process, thereby avoiding the deployment of cameras at the position corresponding to the first perspective, reducing the number of cameras to be deployed, and thus greatly reducing the deployment cost required for the perspective switching process.

[0308] Furthermore, by receiving a perspective switching instruction including the first perspective, the synthetic image corresponding to the first perspective is displayed. This reduces the deployment cost required for the perspective switching process while providing more perspectives to switch to, meets the user's needs for perspective switching, and improves the display effect.

[0309] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0310] The communication interface is used for communication between the above electronic device and other devices.

[0311] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0312] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0313] Based on the same inventive concept, according to the image synthesis method provided in the above-mentioned embodiments of the present application, the embodiments of the present application also provide a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the image synthesis method described in any one of the above-mentioned embodiments is implemented.

[0314] Based on the same inventive concept, according to the image synthesis method provided in the above-mentioned embodiments of the present application, the embodiments of the present application also provide a computer program product containing instructions, which, when executed on a computer, enables the computer to execute any of the image synthesis methods described in the above-mentioned embodiments.

[0315] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.

[0316] It should 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 existence of other identical elements in the process, method, article or device including the elements.

[0317] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for embodiments such as devices, electronic devices, computer-readable storage media, and computer program products, since they are basically similar to method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0318] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims

1. An image synthesis method, characterized in that: The method comprises: Receiving a perspective switching instruction including a first perspective; Acquire an image to be projected, where the image to be projected is an image captured by at least one first camera within a first preset range of the first viewing angle; Based on the camera parameters of the first camera, projecting the image to be projected into an image coordinate system corresponding to the first viewing angle to obtain a projected image including a hole area; Filling holes in the projected image according to image information of pixels within a second preset range of the hole area in the projected image to obtain a composite image of the first viewing angle; displaying a composite image of the first perspective; The step of filling the holes in the projected image according to the image information of the pixels within the second preset range of the hole area in the projected image to obtain the synthetic image of the first viewing angle comprises: Expanding the hole area in the projection image outwardly to a second preset range to obtain a first expanded area; Acquire an image to be restored of the projection image, where the image to be restored is an image including the hole area and the first extended area; Using the image information of each pixel point in the first extended area of ​​the image to be repaired, the hole area is filled to obtain a repaired image; Performing image fusion on the projected image and the restored image to obtain a composite image of the first viewing angle; The step of filling the hole area by using the image information of each pixel point in the first extended area of ​​the image to be repaired to obtain the repaired image comprises: Inputting the image to be repaired into a pre-trained image repair model to obtain a repaired image; wherein the image repair model is trained using a preset training set; the preset training set includes sample images captured by multiple second cameras at different viewing angles and camera parameters of each second camera; The image restoration model is trained by following the steps below: Obtaining the preset training set; Based on the camera parameters of each second camera, projecting the sample images in the preset training set except the second viewing angle into the image coordinate system corresponding to the second viewing angle to obtain a sample projection image including the hole area; Expanding the hole area in the sample projection image outwards to a second preset range to obtain a second expanded area; Acquire a sample image to be repaired of the sample projection image, wherein the sample image to be repaired is an image including the hole area and the second extended area; Inputting the sample image to be repaired into a preset deep network model to obtain a sample repaired image; Performing image fusion on the sample projection image and the sample restoration image to obtain a sample composite image of the second viewing angle; Calculating the loss value of the preset deep network model according to the sample synthetic image and the sample image of the second perspective in the preset training set; When the loss value is greater than a preset loss value threshold, adjusting the parameters of the preset deep network model, and returning to the step of inputting the sample image to be repaired into the preset deep network model to obtain a sample repaired image; When the loss value is not greater than the preset loss value threshold, determining the current preset deep network model as a trained image restoration model; The step of calculating the loss value of the preset deep network model according to the sample synthetic image and the sample image of the second perspective in the preset training set includes: The loss value of the preset deep network model is calculated using the following formula: loss=||I prd ′*M in ′-I true ′*M in ′|| Among them, loss is the loss value, ‖ ‖ is the norm operation, I prd ′ is the sample synthetic image of the second viewing angle, M in 'The mask image corresponding to the hole area and the extended area in the sample image to be repaired, I true ' is the sample image of the second viewing angle; The step of fusing the projection image and the restoration image to obtain a composite image of the first viewing angle includes: The projection image and the repaired image are fused using the following formula to obtain a composite image of the first viewing angle: I prd =I out *M hole +[(1-α)I out *M exp +α*I in *M exp ]+(I in -I in *M in ) Among them, I prd is the synthetic image of the first viewing angle, I out is the repaired image, M hole is the hole mask corresponding to the hole area in the projection image, α is the preset weight, M exp is the mask image of the first extended area corresponding to the hole area in the projection image, I in is the image to be repaired, M in It is the mask image corresponding to the hole area and the extended area in the image to be repaired.

2. The method according to claim 1, characterized in that The step of expanding the hole area in the projection image outwardly to a second preset range to obtain a first extended area includes: Determine each edge pixel point of the hole area in the projection image; Each edge pixel point of the hole area in the projection image is expanded outwardly to a second preset range to obtain a first expanded area.

3. The method according to claim 1, characterized in that The step of obtaining the image to be repaired of the projection image comprises: The image to be repaired of the projection image is obtained using the following formula: I in =I prj *M exp Among them, I in is the image to be repaired, I prj is the projection image, M exp It is a mask image of the first extended area corresponding to the hole area in the projection image.

4. The method according to claim 1, characterized in that: The camera parameters include camera external parameters and camera internal parameters; The step of projecting the image to be projected into an image coordinate system corresponding to the first viewing angle based on the camera parameters of the first camera to obtain a projected image including a hole area comprises: For each pixel point in the image to be projected, calculate a second coordinate value of the pixel point in the camera coordinate system according to the first coordinate value of the pixel point and the camera intrinsic parameter of the first camera; For each pixel point in the image to be projected, calculate a third coordinate value of the pixel point in the world coordinate system according to the second coordinate value of the pixel point and the camera extrinsic parameter of the first camera; For each pixel point in the image to be projected, calculate a fourth coordinate value of the pixel point in the camera coordinate system corresponding to the first viewing angle according to the third coordinate value of the pixel point and the camera extrinsic parameter of the virtual camera at the first viewing angle; For each pixel point in the image to be projected, calculate a fifth coordinate value of the pixel point in the image coordinate system corresponding to the first viewing angle according to the fourth coordinate value of the pixel point and the camera intrinsic parameter of the virtual camera at the first viewing angle; The image to be projected is projected according to the fifth coordinate value of each pixel point in the image to be projected in the image coordinate system corresponding to the first viewing angle to obtain a projected image including a hole area.

5. An image synthesis device, characterized in that: The device comprises: A receiving module, configured to receive a perspective switching instruction including a first perspective; A first acquisition module, used to acquire an image to be projected, where the image to be projected is an image captured by at least one first camera within a first preset range of the first viewing angle; A first projection module, configured to project the image to be projected into an image coordinate system corresponding to the first viewing angle based on camera parameters of the first camera, to obtain a projection image including a hole area; A synthesis module, configured to fill holes in the projected image according to image information of pixels within a second preset range of a hole area in the projected image, so as to obtain a synthesized image of the first viewing angle; A display module, used to display the composite image of the first perspective; The synthesis module includes an expansion submodule, which is used to expand the hole area in the projection image outward to a second preset range to obtain a first expansion area; An acquisition submodule, used for acquiring an image to be restored of the projection image, where the image to be restored is an image including the hole area and the first extended area; A repair submodule, used to fill the hole area using the image information of each pixel point in the first extended area of ​​the image to be repaired, so as to obtain a repaired image; A fusion submodule is used to fuse the projected image and the repaired image to obtain a composite image of the first perspective; The restoration submodule is specifically used to input the image to be restored into a pre-trained image restoration model to obtain a restored image; wherein the image restoration model is trained using a preset training set; the preset training set includes sample images captured by multiple second cameras at different viewing angles and camera parameters of each second camera; The image synthesis device also includes: A second acquisition module is used to acquire a preset training set; A second projection module, configured to project sample images other than the second viewing angle in the preset training set to an image coordinate system corresponding to the second viewing angle based on the camera parameters of each second camera, to obtain a sample projection image including a hole area; An expansion module, used to expand the hole area in the sample projection image outward to a second preset range to obtain a second expansion area; A third acquisition module is used to acquire a sample image to be repaired of the sample projection image, where the sample image to be repaired is an image including the hole area and the second extended area; A restoration module is used to input the sample image to be restored into a preset deep network model to obtain a sample restoration image; A fusion module is used to fuse the sample projection image and the sample restoration image to obtain a sample composite image of a second perspective; A calculation module, used to calculate the loss value of a preset deep network model according to the sample synthetic image and the sample image of the second perspective in the preset training set; An adjustment module, used for adjusting the parameters of the preset deep network model when the loss value is greater than a preset loss value threshold, and returning to call the repair module to execute the step of inputting the sample image to be repaired into the preset deep network model to obtain a sample repaired image; A determination module, used for determining the current preset deep network model as a trained image restoration model when the loss value is not greater than a preset loss value threshold; The calculation module is specifically used to calculate the loss value of the preset deep network model using the following formula: loss=||I prd ′*M in -I true ′*M in ′|| Among them, loss is the loss value, ‖ ‖ is the norm operation, I prd ′ is the sample synthetic image of the second perspective, M in ′The mask image corresponding to the hole area and the extended area in the sample image to be repaired, I true ′ is the sample image of the second viewing angle; The fusion submodule is specifically used to fuse the projection image and the restoration image using the following formula to obtain a composite image of the first perspective: I prd =I out *M hole +[(1-α)I out *M exp +α**I in *M exp ]+(I in -I in *M in ) Among them, I prd is the synthetic image of the first perspective, I out To repair the image, M hole is the hole mask corresponding to the hole area in the projected image, α is the preset weight, M exp is the mask image of the first extended area corresponding to the hole area in the projection image, I in is the image to be repaired, M in It is the mask image corresponding to the hole area and the extended area in the image to be repaired.

6. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 4 when executing a program stored in a memory.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Multi-angle free viewing angle image data processing method and device, medium and equipment

    CN111669561A

  • Three-dimensional point cloud restoration method and device and electronic equipment

    CN112530027A