Three-dimensional video fusion method and device based on camera image, and storage medium
By picking up calibration points and calculating extrinsic parameters in the 3D twin scene, and optimizing image cropping and rendering, the problem of low alignment efficiency of camera images in the 3D twin scene is solved, and efficient and accurate 3D video fusion is achieved.
Patent Information
- Application Number
- CN202410723631.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-10-01
AI Technical Summary
In the existing technology, the alignment efficiency of camera images in a three-dimensional twin scene is low, resulting in incorrect pixel fusion positions, and the multi-plane alignment efficiency of the camera is low, affecting the accuracy and efficiency of video fusion.
By picking calibration points in the twin 3D scene, calculating external parameters, and using the internal and external parameters of the camera to crop and deform the image, the image rendering process is optimized to achieve efficient fusion of 3D videos. Specific steps include: establishing a twin 3D scene, calculating external parameters, obtaining pixel coordinate polygons, cropping and deforming the image, and rendering using the digital twin engine.
It improves the accuracy and efficiency of video fusion, reduces camera external parameter errors, realizes multi-plane automatic alignment of cameras, and improves the efficiency of video fusion.
Smart Images

Figure CN118736142A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to a camera image-based three-dimensional video fusion method, device and storage medium. Background Art
[0002] In the field of digital twins, 3D video fusion plays an important role. This technology breaks through the limitations of the traditional single perspective and, combined with the rendering engine's presentation of the real world, can obtain a more comprehensive and three-dimensional information display, providing a richer basis for decision-making.
[0003] Especially in large-scale dynamic scenes, traditional data collection and processing methods often face problems, such as the inability to obtain global information in real time and the susceptibility to information ambiguity. The introduction of multi-plane video fusion technology can intelligently fuse video streams from various planes or angles into twin scenes to generate high-definition, high-dynamic panoramic videos, thereby bringing better information expression and improving the efficiency of information acquisition and processing.
[0004] In addition, this technology solves the fusion problem between heterogeneous video sources through precise time synchronization and spatial alignment, and improves the data quality and user experience in the digital twin system. Due to its powerful data integration and processing capabilities, this technology has broad application prospects in the fields of digital twins, virtual reality, augmented reality, etc.
[0005] In the prior art, the calibration error and efficiency of camera internal and external parameters are low, and the camera video image is distorted. It must be corrected before being fused into the twin scene. The corrected image requires the acquisition of the camera internal parameters. The internal parameters are generally calculated by Zhang Zhengyou's chessboard method, which has certain errors and is cumbersome. The fusion of the corrected image into the three-dimensional twin scene requires knowing the position of the image pixel points in the twin scene. Usually, it is necessary to calculate the external parameters first. The calculation method of the external parameters is to select (at least) four three-dimensional points from the twin scene and the corresponding four pixel coordinates in the camera image. There is a considerable error. The error causes the position of the pixel points fused into the twin three-dimensional to be incorrect.
[0006] In addition, the efficiency of camera multi-plane alignment is low. A camera may obtain images of multiple planes in multiple twin 3D scenes. Each plane is formed by pixels in different areas of the camera image through different deformation methods. The problem of how to align images of different planes after fusing them into the 3D twin scene makes the project implementation relatively inefficient. Summary of the invention
[0007] The purpose of the present invention is to overcome the above-mentioned technical deficiencies and provide a method, device and storage medium for fusion of three-dimensional video based on camera images, so as to solve the technical problem of low alignment efficiency after images of different planes are fused into a three-dimensional twin scene in the prior art.
[0008] In order to achieve the above technical objectives, the technical solution of the present invention provides a method for fusing three-dimensional video based on camera images, comprising the following steps:
[0009] S1. Establish a twin 3D scene, pick up calibration points from the twin 3D space, pick up corresponding calibration points in the twin 3D space from the camera video stream, and calculate the external parameters;
[0010] S2. Select a coplanar polygon with point coordinates as elements from the twin 3D scene, and calculate the camera pixel coordinate point set corresponding to the 3D space fusion polygon point set through the camera's intrinsic parameters and the camera's extrinsic parameters to obtain a pixel coordinate polygon;
[0011] S3. Crop the image according to the pixel coordinate polygon, and deform the image into a polygonal shape of a three-dimensional twin space, and then render it to achieve three-dimensional video fusion.
[0012] In any implementation manner, before rendering in step S3, the process further includes: calculating the optimization level of the camera image, and the image with a high priority is placed in the upper layer for image superposition; the optimization level calculation is jointly determined by the current observation camera position and direction, and the calculation formula of the priority P is as follows:
[0013] P = λ × dist(D o ,D c )+(1-λ)×dist(L o ,L c )
[0014] Where D o is the direction vector of the viewing camera, D c is the direction vector of the physical camera, L o is the position vector of the observation camera, L c is the position vector of the physical camera, and dist is the similarity function of the calculated vector.
[0015] In any implementation manner, in step S2, the intrinsic parameters of the camera are obtained by the following steps:
[0016] A camera internal parameter database is established with the camera model as the key, and an application API is provided to obtain the internal parameters of the camera that can be shared and used.
[0017] In any embodiment, in step S1, the calibration points picked up from the twin three-dimensional space are four or more feature points found from a camera image.
[0018] In any implementation manner, in step S2, the camera pixel coordinate point set corresponding to the three-dimensional space fusion polygon point set is calculated by projectPoints in opencv.
[0019] In any implementation manner, before step S3, the method further includes acquiring the camera image through the pixel coordinate polygon obtained in step S2 and performing correction.
[0020] In any embodiment, the correction is performed by the undistort method in OpenCV.
[0021] In any implementation manner, in step S3, the deformation method is warpPerspective in opencv.
[0022] In any implementation manner, in step S3, three-dimensional video fusion is achieved through decal rendering in the digital twin engine.
[0023] In addition, the present invention also proposes a three-dimensional video fusion device based on camera images, comprising:
[0024] A calculation unit, wherein the external parameter unit is used to establish a twin 3D scene, pick up calibration points from the twin 3D space, and pick up corresponding calibration points in the twin 3D space from the camera video stream to calculate the external parameters;
[0025] An acquisition unit, the acquisition unit is used to select a coplanar polygon with point coordinates as elements from the twin three-dimensional scene, and calculate the camera pixel coordinate point set corresponding to the three-dimensional space fusion polygon point set through the camera's intrinsic parameters and the camera's extrinsic parameters to obtain a pixel coordinate polygon;
[0026] A cropping unit is used to crop the image according to the pixel coordinate polygon, and deform the image into a polygonal shape in a three-dimensional twin space, and then render it to achieve three-dimensional video fusion.
[0027] In addition, the present invention also provides a storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned method for fusing three-dimensional video based on camera images is implemented.
[0028] Compared with the prior art, the beneficial effects of the present invention include: the present invention adjusts the position of the picking point in the twin scene, calculates the external parameters in real time and renders the fusion effect, so as to obtain the best external parameter calibration point. A camera may involve video fusion of multiple planes. It only needs to adjust the alignment of two planes, and the other planes can be automatically aligned, or multiple planes fused by a camera can be aligned at the same time. This method reduces the camera external parameter error by fine-tuning the fusion effect in real time in the twin scene, thereby improving the accuracy of video fusion and greatly improving the efficiency of video fusion. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a flowchart of a method for fusing three-dimensional video based on camera images according to Embodiment 1 of the present invention.
[0030] Figure 2 It is the camera image before fusion in Example 1.
[0031] Figure 3 It is the camera image after fusion in Example 1. DETAILED DESCRIPTION
[0032] The functions of opencv related functions are briefly introduced as follows:
[0033] projectPoints
[0034] Used to project 3D coordinates to the image plane. It accepts 3D coordinates in object space, camera intrinsic parameters, camera distortion coefficients, and rotation and translation vectors, and returns the corresponding 2D image coordinates and Jacobian matrix.
[0035] undistort
[0036] Used to remove lens distortion. It accepts a distorted image taken by a camera, as well as the camera's internal parameters and distortion coefficients, and then returns an image that has been dedistorted.
[0037] warpPerspective
[0038] Used to perform perspective transforms (also called homogeneous transforms). It accepts an image and a 3x3 transformation matrix, and then deforms the input image according to this matrix.
[0039] solvePnP
[0040] It is used to solve the problem of attitude estimation, that is, to estimate the rotation and translation of the camera in the world coordinate system based on certain 3D world coordinates and their projection on the image (2D coordinates). It accepts 3D object coordinates, corresponding 2D image coordinates, camera internal parameters and distortion coefficients, and returns the rotation and translation vectors of the camera.
[0041] This specific implementation provides a method for fusing three-dimensional video based on camera images, comprising the following steps:
[0042] S1. Establish a twin 3D scene, pick up calibration points from the twin 3D space, and pick up corresponding calibration points in the twin 3D space from the camera video stream, and calculate external parameters; the calibration points picked up from the twin 3D space are four or more feature points found in the camera image;
[0043] S2. Select a coplanar polygon with point coordinates as elements from the twin 3D scene, and calculate the camera pixel coordinate point set corresponding to the 3D space fusion polygon point set through the camera's intrinsic parameters and the camera's extrinsic parameters to obtain a pixel coordinate polygon; the camera's intrinsic parameters are obtained by the following steps:
[0044] Establish a camera internal parameter database with camera model as key, and provide application API to obtain the internal parameters of the camera that can be shared;
[0045] The camera pixel coordinate point set corresponding to the three-dimensional space fusion polygon point set is calculated by projectPoints in opencv;
[0046] Then, the camera image is acquired through the pixel coordinate polygon and rectified. Specifically, in some embodiments, the correction is performed through the undistort method in opencv;
[0047] S3, cropping the image according to the pixel coordinate polygon, and deforming the image into a polygonal shape of a three-dimensional twin space, and then rendering it in a decal manner in a digital twin engine to achieve three-dimensional video fusion;
[0048] The deformation method is warpPerspective in opencv.
[0049] In some embodiments, before rendering in step S3, the process further includes: calculating the optimization level of the camera image, with the image with a high priority being placed in the upper layer for image superposition; the optimization level calculation is determined by the current observation camera position and direction, and the calculation formula of the priority P is as follows:
[0050] P = λ × dist(D o ,D c )+(1-λ)×dist(L o ,L c )
[0051] Where D o is the direction vector of the viewing camera, D c is the direction vector of the physical camera, L ois the position vector of the observation camera, L c is the position vector of the physical camera, and dist is the similarity function of the calculated vector.
[0052] This specific implementation also proposes a three-dimensional video fusion device based on camera images, including:
[0053] A calculation unit, wherein the external parameter unit is used to establish a twin 3D scene, pick up calibration points from the twin 3D space, and pick up corresponding calibration points in the twin 3D space from the camera video stream to calculate the external parameters;
[0054] An acquisition unit, the acquisition unit is used to select a coplanar polygon with point coordinates as elements from the twin three-dimensional scene, and calculate the camera pixel coordinate point set corresponding to the three-dimensional space fusion polygon point set through the camera's intrinsic parameters and the camera's extrinsic parameters to obtain a pixel coordinate polygon;
[0055] A cropping unit is used to crop the image according to the pixel coordinate polygon, and deform the image into a polygonal shape in a three-dimensional twin space, and then render it to achieve three-dimensional video fusion.
[0056] This specific implementation also provides a storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned three-dimensional video fusion method based on camera images is implemented.
[0057] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0058] The following are examples of the present application. The examples described below are exemplary and are only used to explain the present application, and should not be construed as limiting the present application. If no specific techniques or conditions are specified in the examples, the techniques described in the literature in the art shall prevail.
[0059] Example 1
[0060] Combination Figure 1 This embodiment proposes a method for fusing three-dimensional video based on camera images, comprising the following steps:
[0061] T0. Establish a camera internal parameter database with camera model as key, and provide application API for third parties to share and use camera internal parameters;
[0062] T1. Build a 3D scene based on the digital twin engine, pull the camera video stream for presentation, use the point selection tool in the engine to pick up calibration points from the twin 3D space, and pick up the corresponding calibration points in the twin 3D space from the camera video stream, and use solvePnP in opencv to calculate the external parameters. The calibration points can be fine-tuned in the twin scene using the calibration point moving tool in the engine, and the best fusion effect can be obtained by fine-tuning the position of the calibration points; pick up four or more calibration points from the twin 3D space with obvious features, and it is easy to find corresponding points from the camera image points;
[0063] T2. Use the point selection tool in the digital twin engine to select a coplanar polygon with point coordinates as elements from the twin 3D scene. This polygon can be adjusted by moving the point position in the twin scene to crop the visible fusion area. The camera pixel coordinate point set corresponding to the 3D space fusion polygon point set is calculated by the camera internal and external parameters. The calculation method uses the projectPoints calculation in opencv to obtain a pixel coordinate polygon; obtain the camera image and correct it. The correction method is the undistort method in opencv;
[0064] T3. Cropping the image according to the aforementioned pixel coordinate polygon, and deforming the image into a 3D twin space polygon shape. The deformation method is warpPerspective in opencv. The final rendering effect is obtained by decal rendering in the digital twin engine, realizing 3D video fusion, adjusting camera external parameters, and aligning the camera image with the 3D space.
[0065] Before rendering, it also includes: when multiple camera images cover the same fusion area, it is necessary to calculate the optimization level of the camera images used, and the images with high priority are placed on the upper layer for image superposition; the optimization level calculation is determined by the current observation camera position and direction, and the calculation formula of the priority P is as follows:
[0066] P = λ × dist(D o ,D c )+(1-λ)×dist(L o ,L c )
[0067] Where D o is the direction vector of the viewing camera, D c is the direction vector of the physical camera, L o is the position vector of the observation camera, L c is the position vector of the physical camera, and dist is the similarity function of the calculated vector.
[0068] Observe the rendering effect of real-time changes. If the fusion effect is different from the actual one, adjust the calibration points in step T2 to obtain a better effect, and then obtain the best fusion effect. Figure 2 and 3 It can be seen that the camera image processed by the fusion method proposed in this embodiment has a good fusion effect.
[0069] This embodiment also proposes a three-dimensional video fusion device based on camera images, including:
[0070] A calculation unit, wherein the external parameter unit is used to establish a twin 3D scene, pick up calibration points from the twin 3D space, and pick up corresponding calibration points in the twin 3D space from the camera video stream to calculate the external parameters;
[0071] An acquisition unit, the acquisition unit is used to select a coplanar polygon with point coordinates as elements from the twin three-dimensional scene, and calculate the camera pixel coordinate point set corresponding to the three-dimensional space fusion polygon point set through the camera's intrinsic parameters and the camera's extrinsic parameters to obtain a pixel coordinate polygon;
[0072] A cropping unit is used to crop the image according to the pixel coordinate polygon, and deform the image into a polygonal shape in a three-dimensional twin space, and then render it to achieve three-dimensional video fusion.
[0073] This embodiment further provides a storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned method for fusing three-dimensional video based on camera images is implemented.
[0074] Other beneficial effects of the present invention:
[0075] 1) The calculation of camera intrinsic parameters is cumbersome. By storing and sharing the intrinsic parameters of cameras of the same model, the camera intrinsic parameters can be reused during project implementation to improve efficiency.
[0076] 2) The camera extrinsic parameters are calculated by selecting more than four sets of twin 3D coordinates and camera pixel coordinates. The picking process is performed by human naked eyes and there are large errors. By adjusting the position of the picking point in the twin scene, the extrinsic parameters are calculated in real time and the fusion effect is rendered, so as to obtain the best extrinsic calibration point.
[0077] 3) A camera may involve video fusion of multiple planes. This method only needs to adjust the alignment of two planes, and the other planes are automatically aligned, or multiple planes fused by a camera can be aligned at the same time, which improves efficiency.
[0078] In the present invention, reference is made to “some embodiments”, “this embodiment”, examples, etc., which describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0079] The specific implementation of the present invention described above does not constitute a limitation on the protection scope of the present invention. Any other corresponding changes and modifications made based on the technical concept of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A method for fusion of three-dimensional video based on camera images, characterized in that: The following steps are involved: S1. Establish a twin 3D scene, pick up calibration points from the twin 3D space, pick up corresponding calibration points in the twin 3D space from the camera video stream, and calculate the external parameters; S2. Select a coplanar polygon with point coordinates as elements from the twin 3D scene, and calculate the camera pixel coordinate point set corresponding to the 3D space fusion polygon point set through the camera's intrinsic parameters and the camera's extrinsic parameters to obtain a pixel coordinate polygon; S3. Crop the image according to the pixel coordinate polygon, and deform the image into a polygonal shape of a three-dimensional twin space, and then render it to achieve three-dimensional video fusion.
2. The method for fusion of three-dimensional video based on camera images according to claim 1, characterized in that: Before rendering in step S3, the process also includes: calculating the optimization level of the camera image, and the image with a high priority is placed in the upper layer for image superposition; the optimization level calculation is determined by the current observation camera position and direction, and the calculation formula of the priority P is as follows: Plλ×dist(D o ,D c )+(1-λ)×dist(L o ,L c ) Where D o is the direction vector of the viewing camera, D c is the direction vector of the physical camera, L o is the position vector of the observation camera, L c is the position vector of the physical camera, and dist is the similarity function of the calculated vector.
3. The method for fusion of three-dimensional video based on camera images according to claim 1, characterized in that: In step S2, the intrinsic parameters of the camera are obtained by the following steps: A camera intrinsic parameter database is established with the camera model as the key, and an application API is provided to obtain the intrinsic parameters of the camera that can be shared; and / or, in step S1, the calibration points picked up from the twin three-dimensional space are four or more feature points found from the camera image.
4. The method for fusion of three-dimensional video based on camera images according to claim 1, characterized in that: In step S2, the camera pixel coordinate point set corresponding to the three-dimensional space fusion polygon point set is calculated by projectPoints in opencv.
5. The method for fusion of three-dimensional video based on camera images according to claim 1, characterized in that: Before step S3, the method further includes acquiring the camera image through the pixel coordinate polygon obtained in step S2 and performing correction.
6. The method for fusion of three-dimensional video based on camera images according to claim 5, characterized in that: The correction is performed using the undistort method in opencv.
7. The method for fusion of three-dimensional video based on camera images according to claim 1, characterized in that: In step S3, the deformation method is warpPerspective in opencv.
8. The method for fusion of three-dimensional video based on camera images according to claim 1, characterized in that: In step S3, the three-dimensional video fusion is achieved through decal rendering in the digital twin engine.
9. A three-dimensional video fusion device based on camera images, characterized in that: include: A calculation unit, wherein the external parameter unit is used to establish a twin 3D scene, pick up calibration points from the twin 3D space, and pick up corresponding calibration points in the twin 3D space from the camera video stream to calculate the external parameters; An acquisition unit, the acquisition unit is used to select a coplanar polygon with point coordinates as elements from the twin three-dimensional scene, and calculate the camera pixel coordinate point set corresponding to the three-dimensional space fusion polygon point set through the camera's intrinsic parameters and the camera's extrinsic parameters to obtain a pixel coordinate polygon; A cropping unit is used to crop the image according to the pixel coordinate polygon, and deform the image into a polygonal shape in a three-dimensional twin space, and then render it to achieve three-dimensional video fusion.
10. A storage medium, characterized in that: A computer program is stored thereon, and when the program is executed by a processor, the method for fusing three-dimensional video based on camera images as claimed in any one of claims 1 to 8 is implemented.
