A 360° panoramic image stitching method for both air and underwater use
By establishing the corresponding relationship between camera parameters and the polynomial fitting method, the problem of field angle and image height changes in panoramic image splicing in underwater environments is solved, and accurate 360° panoramic images are generated in air and underwater environments, expanding It improves the usage scenarios of panoramic lenses and improves stitching accuracy.
Patent Information
- Application Number
- CN202111611548.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-27
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2041-12-27
AI Technical Summary
The existing 360° panoramic image stitching method is only suitable for air environments and cannot generate correct panoramic images in underwater environments because the refractive index of water is greater than the refractive index of air, resulting in changes in the field of view and image height. The original calculation The parameter no longer applies.
By establishing the corresponding relationship between the internal and external parameters of the camera, using the polynomial fitting method to correct the image height, combining the corner point method and the least squares method to calculate the external parameters, a 360° panoramic coordinate system is established, and based on the camera image sensor pixel coordinate system and panoramic coordinates According to the corresponding relationship between the two images, the two images are spliced.
Generate accurate 360° panoramic images in diverse environments, expand the use scenarios of panoramic lenses, and improve the accuracy of stitched images by correcting image height issues.
Smart Images

Figure CN114298906B
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of optical imaging, and in particular relates to a method for stitching 360° panoramic images for both air and underwater use. Background Art
[0002] A 360° panoramic image is usually generated by stitching together images taken by two fisheye lenses with a field of view greater than 180°. To generate a correct panoramic image, it is necessary to calibrate the internal and external parameters of the two cameras and establish a corresponding relationship between the pixel coordinate systems of the two camera image sensors and the panoramic image coordinate system.
[0003] A panoramic image stitching algorithm is proposed in the paper “Design and assessment of a 360° panoramic and high-performance capture system with two tiled catadioptric imaging channels, Applied Optics, 2018.” The paper first calibrates the relationship between the pixel coordinate systems of the two camera image sensors and the world coordinate system, and then obtains the positional relationship between the two camera coordinate systems. Then, a panoramic image coordinate system is established, and the correspondence between the two camera coordinate systems and the panoramic image coordinate system is calculated. According to the correspondence, the two images are stitched to obtain a 360° panoramic image.
[0004] Since the refractive index of water is greater than that of air, when the panoramic lens is placed in an underwater environment, the field of view angle and the image height at each field of view angle will change, and the original calculation parameters will no longer be applicable. It is necessary to recalibrate the internal and external parameters of the camera to obtain the correspondence between the underwater panoramic image coordinate system and the pixel coordinate systems of the two camera image sensors in order to generate a correct panoramic image underwater. The 360° panoramic image stitching method in Technology 1 only considers the situation where the panoramic lens is placed in the air, and this stitching method is not suitable for underwater panoramic image generation. Summary of the invention
[0005] In view of this, an object of the present invention is to provide a 360° panoramic image stitching method for both air and underwater use, which can generate accurate 360° panoramic images in diverse environments.
[0006] A 360° panoramic image stitching method for both air and underwater use, comprising:
[0007] The first step is to use the internal parameters of the camera to establish two camera coordinate systems (x ci ,y ci ,z ci ) T With pixel coordinate system (xpi ,y pi ) T The corresponding relationship between them:
[0008]
[0009]
[0010] Where i=1, 2 represents camera 1 and camera 2 respectively; p xi , p yi Represents the size of the sensor pixel in the x and y directions;
[0011] (x 0i ,y 0i ) T represents the pixel coordinate of the center pixel of the sensor; h i (θ) represents the image height at each field angle θ, which is a polynomial about θ:
[0012] h i (θ)=f1θ+f2θ 2 +... (3)
[0013] According to the optical parameter design values of the panoramic lens in air or water, multiple pairs of (θ, h i The corresponding value of (θ)) is obtained by polynomial fitting method to obtain polynomial coefficients f1, f2, ...;
[0014] In the second step, based on the initial values of the internal parameters of the two cameras, the external parameters of the cameras are calculated using the corner point method and the least squares method to establish the two camera coordinate systems (x ci ,y ci ,z ci ) T With the world coordinate system (X W ,Y W ,Z W ) T The corresponding relationship between them;
[0015] The third step is to establish a 360° panoramic coordinate system in the form of a spherical coordinate system;
[0016] The fourth step is to establish the correspondence between the two camera coordinate systems and the 360° panoramic coordinate system;
[0017] The fifth step is to establish two camera coordinate systems (x ci ,y ci ,z ci ) T With pixel coordinate system (x pi ,y pi ) TThe corresponding relationship between the pixel coordinate systems of the two camera image sensors and the 360° panoramic coordinate system is established;
[0018] In the sixth step, according to the correspondence between the pixel coordinate systems of the two camera image sensors and the 360° panoramic coordinate system, the two images larger than 180° are stitched together to obtain a 360° panoramic image.
[0019] Preferably, the corresponding relationship of the second step is:
[0020]
[0021] Where R i , T i is the external parameter of the camera, R i is the rotation matrix of the camera coordinate system relative to the world coordinate system, T i is the translation matrix of the camera coordinate system relative to the world coordinate system.
[0022] Preferably, the correspondence between the two camera coordinate systems and the 360° panoramic coordinate system in the fourth step is:
[0023]
[0024]
[0025] Preferably, in the sixth step, the grayscale of each pixel of the stitched panoramic image is expressed as:
[0026]
[0027] in, Represents the image pixel grayscale in the 360° panoramic coordinate system, I1(x p1 ,y p1 ) represents the pixel grayscale of camera 1 image, I2(x p2 ,y p2 ) represents the grayscale of the camera 2 image; 2Δ represents the overlapping part of the field of view of the camera 1 image and the camera 2 image in the 360° panoramic image.
[0028] Preferably, when the two cameras are in the air, the two cameras are placed opposite to each other, staggered, or combined through a folding refracting prism.
[0029] Preferably, when the two cameras are in water, they are placed opposite to each other or staggered.
[0030] The present invention has the following beneficial effects:
[0031] The present invention provides a 360° panoramic image stitching method for both air and underwater use, and simultaneously considers the correspondence between the panoramic image coordinate system and the pixel coordinate systems of two camera image sensors when the panoramic lens is placed in the air and underwater environments. The two images are stitched according to the correspondence, and a correct 360° panoramic image can be generated in a variety of environments, thereby expanding the use scenarios of the panoramic lens.
[0032] By placing the image high h i (θ) is modified from a simple linear relationship to a polynomial form, which can overcome the distortion problem of the fisheye lens and make the stitched image more accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 This is a schematic diagram of the relative placement of two fisheye lenses in the air;
[0034] Figure 2 This is a schematic diagram of the misaligned placement of two fisheye lenses in the air;
[0035] Figure 3 Schematic diagram of two fisheye lenses in air combined through a catadioptric prism;
[0036] Figure 4 is the relationship between the world coordinate system, the camera 1 coordinate system, the camera 2 coordinate system and the 360° panoramic image coordinate system;
[0037] Figure 5 This is the stitched field of view of the 360° panoramic image in the air, and 2Δ represents the overlapping part of the field of view of the two fisheye lenses;
[0038] Figure 6 The relative placement of two fisheye lenses in water, where the field angle and image height change;
[0039] Figure 7 The relationship between the two fisheye lenses placed in the water is misaligned, and the field of view and image height change;
[0040] Figure 8 This is the stitched field of view of the underwater 360° panoramic image, and 2Δ represents the overlapping part of the field of view of the two fisheye lenses. DETAILED DESCRIPTION
[0041] The present invention is described in detail below with reference to the accompanying drawings and embodiments.
[0042] A 360° panoramic image is usually generated by stitching together images taken by two fisheye lenses with a field of view angle greater than 180°. To generate a correct panoramic image, it is necessary to calculate the correspondence between the panoramic image coordinate system and the pixel coordinate systems of the two camera image sensors. The current 360° panoramic image stitching method only considers the situation where the panoramic lens is placed in the air. Since the refractive index of water is greater than that of air, when the panoramic lens is placed in an underwater environment, the field of view angle and the image height at each field of view angle will change, and the original calculation parameters are no longer applicable. It is necessary to recalculate the internal and external parameters of the camera to obtain the correspondence between the underwater panoramic image coordinate system and the pixel coordinate systems of the two camera image sensors. The present invention also considers the correspondence between the panoramic image coordinate system and the pixel coordinate systems of the two camera image sensors when the panoramic lens is placed in the air and underwater environments. According to the correspondence, the two images are stitched together to generate a correct 360° panoramic image in a variety of environments, expanding the use scenarios of the panoramic lens.
[0043] When the panoramic lens is placed in the air, Figures 1 to 3 The panoramic image is generated by stitching images taken by two fisheye lenses with a field of view greater than 180°. The two fisheye lenses can be placed opposite to each other, or staggered, or combined through a catadioptric prism. The detailed steps for 360° panoramic images are as follows:
[0044] The first step is to use the camera's intrinsic parameters to establish two camera coordinate systems (x ci ,y ci ,z ci ) T With pixel coordinate system (x pi ,y pi ) T The corresponding relationship between them can be written as:
[0045]
[0046]
[0047] Where i=1,2 represents camera 1 and camera 2 respectively; p xi , p yi Represents the size of the sensor pixel in the x and y directions; (x 0i ,y 0i ) T represents the pixel coordinate of the center pixel of the sensor; h i (θ) represents the image height corresponding to each field angle θ.
[0048] Due to the serious distortion of the fisheye lens, the field of view angle θ and the image height are no longer in a simple linear relationship. i (θ) should be expressed as a polynomial with respect to θ, which can be written as:
[0049] h i (θ)=f1θ+f2θ 2 +...=H(θ) (i=1,2) (3)
[0050] According to the optical parameter design values of the panoramic lens in air, we can get multiple pairs of (θ, h i The corresponding values of (θ)). From the corresponding values of the field of view angle and the image height in air, the polynomial coefficients f1, f2, ... can be obtained by the polynomial fitting method.
[0051] The second step is to establish two camera coordinate systems (x ci ,y ci ,z ci ) T With the world coordinate system (X W ,Y W ,Z W ) T The corresponding relationship between them can be written as:
[0052]
[0053] Where R i , T i is the external parameter of the camera, R i is the rotation matrix of the camera coordinate system relative to the world coordinate system, which is a 3×3 rotation matrix, T i is the translation matrix of the camera coordinate system relative to the world coordinate system, which is a 3×1 translation vector.
[0054] The third step is to calculate the external parameters of the cameras using the corner point method and the least square method based on the initial values of the internal parameters of the two cameras expressed by formula (5);
[0055]
[0056] Where N x ,N y is the number of pixels in the x and y directions of the camera sensor. Using the given initial values, the external parameters of the camera can be calculated by the least squares method. At this point, the correspondence between the two camera coordinate systems and the world coordinates has been established.
[0057] The fourth step is to establish a 360° panoramic coordinate system in the form of a spherical coordinate system:
[0058] Panoramic coordinate system (X P ,Y P ,Z P ) TThe origin is the center of the line connecting the origins of the two camera coordinate systems, where the XYZ axis of the panoramic coordinate system is parallel to the XYZ axis of the first camera; the panoramic coordinate system is converted into a 360° panoramic coordinate system in the form of a spherical coordinate system The corresponding relationship between the two is:
[0059]
[0060] Where R represents the distance from any point P in the spherical coordinate system to the origin, and θ represents the distance between the origin and point P and the panoramic coordinate system (X P ,Y P ,Z P ) T The angle between the positive Z axis, Represents the angle between the projection line of the line from the origin to point P on the XY plane and the positive X-axis.
[0061] The fifth step is to establish the correspondence between the two camera coordinate systems and the 360° panoramic coordinate system. First, based on the external parameters of the two cameras, the correspondence between the coordinate systems of camera 1 and camera 2 can be expressed as:
[0062]
[0063] Panoramic coordinate system (X P ,Y P ,Z P ) T The origin of the panoramic coordinate system is the center of the line connecting the origins of the two camera coordinate systems, and the X, Y, and Z axes of the panoramic coordinate system are parallel to the X, Y, and Z axes of the first camera. Therefore, the corresponding relationship between the two camera coordinate systems and the 360° panoramic coordinate system can be expressed as:
[0064]
[0065]
[0066] The sixth step is to establish the correspondence between the pixel coordinate systems of the two camera image sensors and the 360° panoramic coordinate system. Substituting equations (8) to (9) into equations (1) to (2) yields the point in the 360° panoramic coordinate system: Pixel coordinates in the two camera image sensors
[0067] Step 7: According to the correspondence between the pixel coordinate systems of the two camera image sensors and the 360° panoramic coordinate system, the two images with an angle greater than 180° are stitched together to obtain a 360° panoramic image. The grayscale of each pixel in the panoramic image can be expressed as:
[0068]
[0069] in, Represents the image pixel grayscale in the 360° panoramic coordinate system, I1(x p1 ,y p1 ) represents the grayscale of the camera 1 image pixel, I2(x p2 ,y p2 ) represents the grayscale of camera 2 image. 2Δ represents the overlapped part of the field of view of camera 1 image and camera 2 image in the 360° panoramic image, as Figure 5 As shown, the grayscale of the panoramic image of this area is equal to the average grayscale of the two images.
[0070] When the panoramic lens is placed underwater, Figures 6-7 As shown in the figure. The panoramic image is generated by stitching images taken by two fisheye lenses with underwater field of view angles greater than 180°. The two fisheye lenses can be placed opposite to each other or offset. Since the refractive index of water is greater than that of air, the field of view of the fisheye lens underwater and the image height corresponding to each field of view angle change, and the internal and external parameters of the two cameras need to be recalculated.
[0071] When the camera is placed underwater, the image height h corresponding to each field of view is i_water (θ) can be expressed as:
[0072] h i_water (θ) = f 1_water θ+f 2_water θ 2 +...=H water (θ) (i=1,2) (11)
[0073] According to the optical parameter design values of the panoramic lens under water, multiple pairs of (θ, h i_water (θ)). Based on the corresponding values of multiple pairs of underwater field of view angles and image heights, the polynomial coefficient f is obtained by polynomial fitting method. 1_water , f 2_water , the initial value of … can be obtained.
[0074] According to h i_water (θ), recalculate the internal and external parameters of the two cameras, and the remaining calculation steps are the same as when the cameras are placed in the air, which is consistent with the above seven steps.
[0075] When panoramic images are stitched underwater, the field of view of the two fisheye lenses becomes smaller, so the overlap 2Δ between the camera 1 image and the camera 2 image in the 360° panoramic image becomes smaller, as shown in FIG. Figure 8 shown.
[0076] In summary, the above are only preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for stitching 360° panoramic images in air and underwater, characterized in that: include: The first step is to use the internal parameters of the camera to establish two camera coordinate systems (x ci ,y ci ,z ci ) T With pixel coordinate system (x pi ,y pi ) T The corresponding relationship between them: Where i=1, 2 represents camera 1 and camera 2 respectively; p xi , p yi Represents the size of the sensor pixel in the x and y directions; (x 0i ,y 0i ) T represents the pixel coordinate of the center pixel of the sensor; h i (θ) represents the image height at each field angle θ, which is a polynomial about θ: h i (θ)=f1θ+f2θ 2 +... (3) According to the optical parameter design values of the panoramic lens in air or water, multiple pairs of (θ, h i The corresponding value of (θ)) is obtained by polynomial fitting method to obtain polynomial coefficients f1, f2, ...; In the second step, based on the initial values of the internal parameters of the two cameras, the external parameters of the cameras are calculated using the corner point method and the least squares method to establish the two camera coordinate systems (x ci ,y ci ,z ci ) T With the world coordinate system (X W ,Y W ,Z W ) T The corresponding relationship between them; The third step is to establish a 360° panoramic coordinate system in the form of a spherical coordinate system; The fourth step is to establish the correspondence between the two camera coordinate systems and the 360° panoramic coordinate system; The fifth step is to establish two camera coordinate systems (x ci ,y ci ,z ci ) T With pixel coordinate system (x pi ,y pi ) T The corresponding relationship between the pixel coordinate systems of the two camera image sensors and the 360° panoramic coordinate system is established; Step 6: According to the correspondence between the pixel coordinate systems of the two camera image sensors and the 360° panoramic coordinate system, the two images with an angle greater than 180° are stitched together to obtain a 360° panoramic image. The corresponding relationship of the second step is: Where R i , T i is the external parameter of the camera, R i is the rotation matrix of the camera coordinate system relative to the world coordinate system, T i is the translation matrix of the camera coordinate system relative to the world coordinate system; The corresponding relationship between the two camera coordinate systems and the 360° panoramic coordinate system in the fourth step is: In the sixth step, the grayscale of each pixel of the stitched panoramic image is expressed as: in, Represents the image pixel grayscale in the 360° panoramic coordinate system, I1(x p1 ,y p1 ) represents the grayscale of the camera 1 image pixel, I2(x p2 ,y p2 ) represents the grayscale of the camera 2 image; 2Δ represents the overlapping part of the field of view of the camera 1 image and the camera 2 image in the 360° panoramic image; The panoramic image is generated by stitching images taken by two fisheye lenses with underwater field of view angles greater than 180°. The two fisheye lenses can be placed opposite to each other or offset. Since the refractive index of water is greater than that of air, the field of view angle of the fisheye lens underwater and the image height corresponding to each field of view angle change, and the internal and external parameters of the two cameras need to be recalculated. When the camera is placed underwater, the image height h corresponding to each field of view is i_water (θ) can be expressed as: h i_water (θ)=f 1_water θ+f 2_water i 2 +...=H water (θ)(i=1,2) (11) According to the optical parameter design values of the panoramic lens under water, multiple pairs of (θ, h i_water (θ)) corresponding value; Based on the corresponding values of multiple pairs of underwater field of view angles and image heights, the polynomial coefficient f is fitted by a polynomial fitting method. 1_water , f 2_water , the initial value of … can be obtained.
2. The method for stitching 360° panoramic images in air and underwater as claimed in claim 1, characterized in that: When the two cameras are in the air, they are placed opposite to each other, offset from each other, or combined through a folding refracting prism.
3. The method for stitching 360° panoramic images in air and underwater as claimed in claim 1, characterized in that: When the two cameras are in water, they are placed relative to each other or offset from each other.
