Bundle adjustment method and electronic equipment

By dividing the bundle adjustment and optimization into two steps, first optimizing the camera pose and some 3D points, and then optimizing the positions of all map points, the problem of too long bundle adjustment time in 3D model reconstruction is solved, and efficient 3D model construction is achieved.

CN117372612BActive Publication Date: 2024-08-27HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311288934.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-03
Publication Date
2024-08-27
Estimated Expiration
2042-08-03

AI Technical Summary

Technical Problem

When reconstructing a three-dimensional model based on the motion structure recovery algorithm, the solution time for bundle adjustment increases exponentially as the number of images and feature points increases, resulting in too long a time.

Method used

The bundle adjustment and optimization is divided into two steps: first optimize the camera pose, some 3D points and camera internal parameters, then optimize the positions of all map points, and select 3D points with higher data quality for optimization through a preset strategy to reduce calculations in the optimization step. quantity.

Benefits of technology

It significantly reduces the optimization time of bundle adjustment, improves efficiency, and ensures optimization accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117372612B
    Figure CN117372612B
Patent Text Reader

Abstract

The embodiment of the present application provides a cluster adjustment method and an electronic device. In this method, first, the electronic device selects some target three-dimensional points from all the three-dimensional points to be optimized according to a preset strategy, and performs cluster adjustment optimization on these target three-dimensional points and the camera pose and camera intrinsic parameters to be optimized to obtain the optimized camera pose and camera intrinsic parameters; then, the electronic device uses the optimized camera pose and camera intrinsic parameters as fixed values, performs cluster adjustment optimization on all the three-dimensional points to be optimized, and obtains all the optimized three-dimensional points. In this way, the cluster adjustment optimization is divided into two steps: first optimizing the camera pose, some three-dimensional points, and camera intrinsic parameters, and then optimizing the positions of all map points, which greatly reduces the time consumption of the cluster adjustment optimization.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application. The name of the original application is Cluster Adjustment Method and Electronic Device. The application number of the original application is 202210926339.9. The original application date is August 3, 2022. All the contents of the original application are incorporated into this application by reference. Technical Field

[0002] The present application relates to the field of image processing technology, and in particular to a bundle adjustment method and electronic equipment. Background Art

[0003] With the development of terminal technology and the improvement of people's ability to process information, two-dimensional images can no longer meet the needs of work and life. Compared with two-dimensional images, three-dimensional models are the most intuitive structures for humans, and observing objects and environments from a three-dimensional perspective allows people to process information efficiently. Therefore, three-dimensional reconstruction has become one of the hot spots in the field of image processing technology. It establishes a mathematical model suitable for computer representation and processing for three-dimensional objects, allowing electronic devices to process, operate and analyze objects in a computer environment.

[0004] At present, reconstructing the 3D model of an object based on the structure from motion (SFM) algorithm is a common method. This method can reconstruct the 3D model of the object by collecting a series of disordered pictures and extracting sufficient feature points from them for analysis. Among them, bundle adjustment is an important part of 3D reconstruction, which is used to eliminate the accumulated errors of camera pose and map point position. However, when the number of pictures and feature points increases, the solution time of bundle adjustment will increase exponentially, which is very time-consuming. Summary of the invention

[0005] In order to solve the above technical problems, the embodiments of the present application provide a bundle adjustment method and an electronic device. In the method, the bundle adjustment optimization is divided into two steps: first optimizing the camera pose, some three-dimensional points, and camera internal parameters, and then optimizing the positions of all map points, which greatly reduces the time consumption of the bundle adjustment optimization.

[0006] In the first aspect, an embodiment of the present application provides a method for cluster adjustment. The method includes: the electronic device obtains the camera pose, camera intrinsic parameters and all three-dimensional points to be optimized; the electronic device determines the target three-dimensional point among all three-dimensional points according to a preset strategy; the electronic device performs cluster adjustment optimization on the camera pose, camera intrinsic parameters and target three-dimensional point to be optimized, and obtains the optimized camera pose and camera intrinsic parameters; the electronic device uses the optimized camera pose and camera intrinsic parameters as fixed values, performs cluster adjustment optimization on all three-dimensional points, and obtains all optimized three-dimensional points.

[0007] In this way, the electronic device divides the bundle adjustment optimization into two steps: first optimizing the camera pose, some three-dimensional points, and the camera internal parameters, and then optimizing only the positions of all map points, which greatly reduces the time consumption of the bundle adjustment optimization.

[0008] According to the first aspect, the data quality of the target 3D point is better than the data quality of all 3D points; wherein the data quality is used to characterize the accuracy of the 3D point when used for 3D reconstruction.

[0009] Among them, data quality can be identified by relevant indicators, such as feature extraction response values ​​of image feature points corresponding to three-dimensional points.

[0010] In this way, in the first step of the bundle adjustment optimization, the electronic device selects some 3D points with better data quality, that is, selects some relatively important 3D points, and performs bundle adjustment optimization together with the camera pose and camera intrinsic parameters to obtain the optimized camera pose and camera intrinsic parameters. Then, in the second step of the bundle adjustment optimization, the optimized camera pose and camera intrinsic parameters are used as fixed values, and only all 3D points are optimized by the bundle adjustment. In this way, not only can the optimization accuracy be guaranteed not to decrease, but also the optimization solution time is greatly reduced.

[0011] According to the first aspect, or any implementation method of the first aspect above, the electronic device determines the target three-dimensional point among all three-dimensional points according to a preset strategy, including: the electronic device traverses the images corresponding to the camera position to be optimized; among the three-dimensional points corresponding to each image, the electronic device selects the target three-dimensional point; wherein the feature extraction response value of the image feature point corresponding to the target three-dimensional point is greater than the first threshold.

[0012] It should be pointed out that the image feature point corresponding to any three-dimensional point is a two-dimensional point in the image.

[0013] In this way, the electronic device selects some three-dimensional points in the first step of the bundle adjustment optimization according to the feature extraction response value of the image feature point corresponding to the three-dimensional point, which effectively ensures the optimization accuracy of the two-step optimization bundle adjustment method.

[0014] According to the first aspect, or any implementation of the first aspect above, the method also includes: the electronic device divides each image into multiple image grids; wherein the number of target feature points included in each image grid is not greater than a second threshold; and the target feature points are image feature points corresponding to the target three-dimensional points.

[0015] In this way, when the electronic device selects some three-dimensional points in the first step of the bundle adjustment optimization, it can ensure the balance of the distribution of these three-dimensional points, thereby improving the optimization accuracy of the two-step optimization bundle adjustment method.

[0016] According to the first aspect, or any implementation of the first aspect above, the electronic device selects a target three-dimensional point from the three-dimensional points corresponding to each image, which may include: the electronic device arranges the three-dimensional points corresponding to each image in descending order of feature extraction response values ​​(i.e., in descending order of feature extraction response values ​​of two-dimensional image feature points corresponding to the three-dimensional points); the electronic device sequentially obtains one three-dimensional point as the current three-dimensional point in descending order of feature extraction response values; if the feature extraction response value of the image feature point corresponding to the current three-dimensional point is greater than a first threshold value, and the total number of target feature points included in the current image grid is not greater than a second threshold value, the electronic device uses the current three-dimensional point as the target three-dimensional point and updates the total number of target feature points included in the current image grid; wherein the current image grid is the image grid where the image feature point corresponding to the current three-dimensional point is located; the electronic device continues to sequentially obtain one three-dimensional point as the current three-dimensional point in descending order of feature extraction response values ​​until all three-dimensional points corresponding to each image are traversed, or until the feature extraction response value of the image feature point corresponding to the current three-dimensional point is traversed and is not greater than the first threshold value.

[0017] In this way, the electronic device selects some 3D points in the first step of the bundle adjustment optimization according to the feature extraction response value of the image feature point corresponding to the 3D point, and can ensure the balance of the distribution of these 3D points, thereby improving the optimization accuracy of the two-step optimization bundle adjustment method. Moreover, for each image, when the feature extraction response value of the image feature point corresponding to the current 3D point is not greater than the first threshold, the traversal of the 3D points corresponding to the image is terminated, which can effectively improve the efficiency of selecting the target 3D point from the 3D points corresponding to each image.

[0018] According to the first aspect, or any implementation of the first aspect above, the difference between the number of all three-dimensional points and the number of camera poses is greater than a first preset number threshold.

[0019] According to the first aspect, or any implementation of the first aspect above, the number of camera poses to be optimized is greater than a second preset number threshold.

[0020] When the number of three-dimensional points is much larger than the number of camera poses, or when the number of images used to construct a three-dimensional model increases, compared with the existing methods, the two-step optimization bundle adjustment method provided in this embodiment can significantly reduce the time consumption of bundle adjustment optimization.

[0021] According to the first aspect, or any implementation of the first aspect above, the electronic device obtains the camera pose, camera intrinsic parameters and all three-dimensional points to be optimized, which may include: the electronic device obtains the camera pose, camera intrinsic parameters and all three-dimensional points to be optimized during local bundle adjustment.

[0022] According to the first aspect, or any implementation of the first aspect above, the electronic device obtains the camera pose, camera intrinsic parameters and all three-dimensional points to be optimized, which may include: the electronic device obtains the camera pose, camera intrinsic parameters and all three-dimensional points to be optimized during global bundle adjustment.

[0023] In this way, the two-step optimization bundle adjustment method provided in this embodiment is applicable to the local bundle adjustment optimization stage, and is also applicable to the global bundle adjustment optimization stage.

[0024] In a second aspect, an embodiment of the present application provides an electronic device. The electronic device includes: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and when the computer programs are executed by the one or more processors, the electronic device performs the cluster adjustment method as described in the first aspect and any one of the first aspects.

[0025] The second aspect and any implementation of the second aspect correspond to the first aspect and any implementation of the first aspect respectively. The technical effects corresponding to the second aspect and any implementation of the second aspect can refer to the technical effects corresponding to the above-mentioned first aspect and any implementation of the first aspect, which will not be repeated here.

[0026] In a third aspect, an embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium includes a computer program, and when the computer program is executed on an electronic device, the electronic device executes the bundle adjustment method of the first aspect and any one of the first aspects.

[0027] The third aspect and any implementation of the third aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the third aspect and any implementation of the third aspect can refer to the technical effects corresponding to the first aspect and any implementation of the first aspect, which will not be repeated here.

[0028] In a fourth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed, enables a computer to execute a bundle adjustment method as described in the first aspect or any one of the first aspects.

[0029] The fourth aspect and any implementation of the fourth aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the fourth aspect and any implementation of the fourth aspect can refer to the technical effects corresponding to the above-mentioned first aspect and any implementation of the first aspect, which will not be repeated here.

[0030] In a fifth aspect, the present application provides a chip, the chip comprising a processing circuit and a transceiver pin, wherein the transceiver pin and the processing circuit communicate with each other through an internal connection path, and the processing circuit executes the cluster adjustment method as in the first aspect or any one of the first aspects to control the receiving pin to receive a signal, and to control the transmitting pin to send a signal.

[0031] The fifth aspect and any implementation of the fifth aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the fifth aspect and any implementation of the fifth aspect can refer to the technical effects corresponding to the first aspect and any implementation of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1a is a schematic diagram of a three-dimensional reconstruction process shown as an example;

[0033] Figure 1b is a schematic diagram of sparse point cloud reconstruction shown as an example;

[0034] Figure 2a is a schematic diagram of feature point matching shown as an example;

[0035] Figure 2b-2f is a schematic diagram of sparse point cloud reconstruction shown as an example;

[0036] Figure 3 Schematic diagram of the Hessian matrix shown as an example;

[0037] Figure 4a is a schematic diagram of the hardware structure of an electronic device shown as an example;

[0038] Figure 4b A schematic diagram of the software structure of an electronic device is shown as an example;

[0039] Figure 5 A schematic diagram of a flow chart of a cluster adjustment method provided in an embodiment of the present application;

[0040] Figure 6a This is a schematic diagram of the Hessian matrix involved in the first step of the bundle adjustment optimization in the embodiment of the present application;

[0041] Figure 6b A schematic diagram of the Hessian matrix involved in the second step of the bundle adjustment optimization in the embodiment of the present application;

[0042] Figure 7 The figure is a schematic diagram showing the comparison results of the time consumption of the bundle adjustment optimization. DETAILED DESCRIPTION

[0043] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0044] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

[0045] The terms "first" and "second" in the description and claims of the embodiments of the present application are used to distinguish different objects rather than to describe a specific order of objects. For example, a first target object and a second target object are used to distinguish different target objects rather than to describe a specific order of target objects.

[0046] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0047] In the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" refers to two or more than two. For example, multiple processing units refer to two or more processing units; multiple systems refer to two or more systems.

[0048] At present, three-dimensional reconstruction has become one of the hot topics in the field of image processing technology. It establishes a mathematical model suitable for computer representation and processing for three-dimensional objects, allowing electronic devices to process, operate and analyze objects in a computer environment.

[0049] like Figure 1a As shown in FIG, a large amount of aerial images, ground images, and GPS (Global Positioning System) information are input into the 3D reconstruction system, and sparse point clouds, dense point clouds, geometric models, and texture models can be obtained through processing by the 3D reconstruction system. The 3D reconstruction system can be roughly divided into a sparse point cloud reconstruction module, a dense point cloud reconstruction module, and a texture model reconstruction module.

[0050] Continue to refer to Figure 1aThe processing procedures involved in the sparse point cloud reconstruction module generally include: image feature extraction, image feature matching, matching point sequence generation, incremental reconstruction and global nonlinear optimization; the processing procedures involved in the dense point cloud reconstruction module generally include: image distortion correction, neighborhood image selection, depth map calculation, depth map filtering and depth map fusion; the processing procedures involved in the texture model reconstruction module generally include point cloud segmentation, point cloud meshing, mesh fusion, mesh simplification and texture mapping.

[0051] like Figure 1b As shown in Figure 2, after the multi-view images are input into the sparse point cloud reconstruction module, the camera pose and scene structure can be obtained through processing by the sparse point cloud reconstruction module. Figure 2a-2f The processing flow involved in the sparse point cloud reconstruction module is explained in detail. The processing flow of the dense point cloud reconstruction module and the texture model reconstruction module can refer to the existing technology and will not be repeated here.

[0052] Reference Figure 1a ,In the sparse point cloud reconstruction stage, the processing flow of the electronic device can be specifically as follows:

[0053] 1. The electronic device acquires an image set including the target object.

[0054] Specifically, the electronic device can capture and obtain multiple images including the target object through a camera configured on the device, and the multiple images can be referred to as an image set including the target object. The electronic device can also obtain an image set including the target object captured by other devices. In other words, the present application does not limit the source of the image set including the target object. In the image set, each image can show the target object in different states (for example, angle, orientation, time, lighting, etc.).

[0055] In a possible implementation, an electronic device may acquire a video sequence including a target object. The video sequence may be acquired by the electronic device through a camera configured on the device, or may be acquired by another device. In the video sequence, each video frame image may display the target object in different states (e.g., angle, orientation, time, illumination, etc.).

[0056] 2. The electronic device extracts feature points of each image in the image set.

[0057] Specifically, the electronic device can extract feature points in each image based on the first algorithm. Feature points are used to describe points in an image that have certain feature information. That is, when the camera is moving, it takes multiple images of the same object or scene. If the actual same places in the object or scene can be identified from the images, the pixel points corresponding to these same places in the images can be called feature points.

[0058] Feature point extraction refers to extracting appropriate descriptive features from the image of the target or scene. These features can not only clearly distinguish the target from the background, but also have robustness in dealing with the scale expansion and contraction of the target, the shape change of the target, the target occlusion, etc. The first algorithm for extracting feature points can be a scale-invariant feature transform (SIFT) algorithm, a speeded uprobust features algorithm (SURF) algorithm, a feature point extraction algorithm based on self-supervision (also called a superpoint algorithm), etc.

[0059] 3. The electronic device matches the feature points extracted between the two images in the image set and removes the outliers.

[0060] Specifically, the electronic device can match feature points between two images based on the second algorithm. Matching feature points between two images refers to matching two feature points with the same feature information but belonging to different images. Feature points with the same feature information that have established a matching relationship can correspond to a feature point set. The second algorithm can be a brute force matching algorithm (also known as a Brute-Froce Matcher), a K-dtree algorithm, etc. For example, Figure 2a Two images are shown, namely, image 101 and image 102. Image 101 and image 102 include the same object 1011. Object 1011 shown in image 101 includes a feature point a. Object 1011 shown in image 102 includes a feature point b. The feature information included in feature point a is the same as the feature information included in feature point b, so feature point a and feature point b can be matched.

[0061] When there is a mismatch between feature points, the mismatched feature points (ie, outliers) can be removed by using a random sample consensus (RANSAC) algorithm. It should be noted that the present application does not limit the method for removing mismatched feature points.

[0062] After the matching relationship between the feature points is established, a feature point set can be generated. Exemplarily, the electronic device can generate a feature point track list based on the matching relationship between the feature points. For example, the feature information contained in the feature point 1 of the first image, the feature point 2 of the second image, and the feature point 3 of the third image is the same, then the above feature points can establish a matching relationship. Assuming that the feature point 1 of the first image is represented by (1,1), the feature point 2 of the second image is represented by (2,2), and the feature point 3 of the third image can be represented by (3,3), then (1,1), (2,2) and (3,3) belong to a track (also referred to as a feature point set with the same feature information). The electronic device 100 can generate a track set according to the above example, and the track set includes one or more tracks, and different tracks correspond to different feature information. Exemplarily, if the same track contains the same image multiple times, it means that multiple feature points in the same image match the same feature point, and an incorrect match occurs, then the track should be eliminated. If the same track contains too few elements, for example, only two elements, indicating that only two images include the same target point, the track should be eliminated.

[0063] 4. The electronic device initializes the three-dimensional reconstruction based on the image pairs matched by feature points.

[0064] The image pair with matched feature points may refer to an image pair with a number of feature points that have established a matching relationship being greater than a quantity threshold (eg, 100, 200, etc.).

[0065] The electronic device can initialize the three-dimensional reconstruction based on an image pair (such as image 1 and image 2) with matching feature points. Specifically, in one possible implementation, a three-dimensional coordinate system is established based on image 1, and the feature points on image 1 can be mapped to the three-dimensional coordinate system to obtain the corresponding three-dimensional point information. Based on the matching relationship between the feature points in image 1 and image 2, the electronic device can calculate and obtain the camera pose of image 2 through the PnP (perspective-n-point) method, including the rotation matrix (also referred to as the R matrix) and the translation vector (also referred to as the t vector). Then, the electronic device can calculate based on the camera intrinsic parameter K, the above R matrix, the t vector and the feature points on image 2 through the direct linear transformation (DLT) algorithm to obtain the corresponding three-dimensional point information. The electronic device can construct a preliminary three-dimensional model based on the three-dimensional point information obtained above.

[0066] The camera pose can be used to map the two-dimensional points on the image to three-dimensional points in the three-dimensional coordinate system. For example, the camera pose corresponding to image 2 can be used to map the feature points on image 2 to three-dimensional points in the three-dimensional coordinate system, or to map the three-dimensional points in the three-dimensional coordinate system to the corresponding feature points on image 2.

[0067] It should be noted that the present application does not limit the method for initializing three-dimensional reconstruction based on image 1 and image 2.

[0068] Next, the electronic device can register image 3 and calculate the three-dimensional point information corresponding to the feature points in image 3. The electronic device registers image 3, which means that the electronic device updates the three-dimensional model of the target object based on image 3 in combination with the aforementioned generated three-dimensional model (that is, the aforementioned incremental reconstruction). The image that has been used to build a three-dimensional model can be referred to as a registered image, and the image that has not been used to build a three-dimensional model can be referred to as an image to be registered. Exemplarily, based on the above description, image 3 can be referred to as an image to be registered, and image 1 and image 2 can be referred to as registered images.

[0069] The electronic device can obtain the mapping relationship between the feature points in image 3 (i.e., the feature points that match the feature points in the registered image) and the corresponding three-dimensional points through the matching relationship between the feature points in image 3 and the registered image (e.g., the track list in the above example), and calculate the camera pose corresponding to image 3 based on the above mapping relationship. Then, the electronic device calculates the corresponding three-dimensional point information (e.g., feature information in the feature points, three-dimensional coordinates, etc.) for the feature points in image 3 that are not mapped to the three-dimensional coordinate system based on the above estimated camera pose corresponding to image 3, and can then reconstruct the three-dimensional model of the target object based on the calculated three-dimensional point information.

[0070] For example, Figure 2b As shown, in the three-dimensional coordinate system, three-dimensional points of area A have been generated based on image 103 (which can be regarded as the image 1 mentioned above) and image 104 (which can be regarded as the image 2 mentioned above). The three-dimensional points of area A are mapped on image 103 as feature points of area A1; the three-dimensional points of area A are mapped on image 104 as feature points of area A2. A matching relationship has been established between the feature points of area A1 on image 103, the feature points of area A2 on image 104, and the feature points of area A3 on image 105 (which can also be regarded as the image 3 mentioned above). In other words, areas A1, A2, and A3 are mapped to the same area in the three-dimensional coordinate system. Therefore, the feature points of area A3 are also mapped to the three-dimensional points of area A in the three-dimensional coordinate system. Based on the feature points of area A3 and the three-dimensional points of area A, the electronic device 100 can calculate the camera pose corresponding to image 105.

[0071] like Figure 2c As shown, the electronic device 100 has calculated the camera pose corresponding to the image 105. The image 105 includes feature points of the A4 area, which are not mapped to the three-dimensional coordinate system. The electronic device can map the feature points of the A4 area to the three-dimensional coordinate system based on the camera pose corresponding to the image 105 to obtain the three-dimensional points of the B area.

[0072] Similarly, the electronic device can also map other feature points in image 3 that are not mapped to the three-dimensional coordinate system to the three-dimensional coordinate system to complete the registration of image 3. Similarly, the electronic device can also complete the registration of other images (such as images 4, 5, 6...) to achieve incremental reconstruction of the three-dimensional model.

[0073] However, in the incremental reconstruction process, the 3D points generated based on the feature points and the estimated camera pose have reprojection errors. Therefore, it is necessary to optimize the camera pose ([R, t]), camera intrinsic parameters (K), and 3D point coordinates (P) to minimize the reprojection error.

[0074] Among them, for the three-dimensional point generated by the feature point, the reprojection error can refer to the distance error generated by reprojecting the three-dimensional point into a two-dimensional coordinate point on the corresponding image, and comparing the two-dimensional coordinate point with the two-dimensional coordinate of the feature point corresponding to the three-dimensional point on the image.

[0075] For example, Figure 2d As shown, there is a three-dimensional point P in the three-dimensional coordinate system, and the three-dimensional point P corresponds to a feature point P1 on the image 106. The two-dimensional coordinate point of the three-dimensional point P reprojected on the image 106 is P2, and there is a reprojection error e between P2 and P1.

[0076] In this embodiment, the electronic device can perform multi-feature bundle adjustment based on the bundle adjustment (BA) algorithm to eliminate the cumulative errors of the camera pose and the map point position. The bundle adjustment method is to construct a nonlinear optimization problem to minimize the reprojection error based on the camera pose to be optimized, the camera internal parameters and the map points. Specifically, the electronic device can perform local bundle adjustment based on the BA algorithm, or it can perform global bundle adjustment.

[0077] For example, the electronic device may adjust the coordinates of the three-dimensional points generated by the image 3 during registration based on a specified direction (e.g., the gradient direction corresponding to each three-dimensional point) through the BA algorithm, so that the sum of the reprojection errors corresponding to the three-dimensional points generated based on the image 3 after adjustment is less than an error threshold (e.g., 0.3, 0.5, etc.). The calculation of the reprojection error may be based on the mapping relationship between each three-dimensional point generated by the image 3 and the corresponding feature point.

[0078] For example, Figure 2e As shown above Figure 2c Taking the embodiment as an example, the three-dimensional points in the B area are generated based on the feature points in the A4 area in the image 105. There are three-dimensional points B1, B2, B3, and B4 in the B area. The three-dimensional points in the B area have no corresponding feature points mapped in the images 103 and 104. Therefore, it is only necessary to calculate the reprojection error on the image 105. Assuming that the reprojection errors of the three-dimensional points B1, B2, B3, and B4 mapped to the image 105 are e1, e2, e3, and e4 respectively, the electronic device can adjust the three-dimensional coordinates of the three-dimensional points B1, B2, B3, and B4 based on the BA algorithm so that the sum of the reprojection errors e1, e2, e3, and e4 is less than the error threshold.

[0079] For another example, the electronic device can use the BA algorithm to adjust the coordinates of the three-dimensional points generated based on the registered image based on a specified direction (e.g., the corresponding gradient direction of each three-dimensional point), so that the sum of the reprojection errors of the three-dimensional points generated based on the registered image after adjustment is less than an error threshold (e.g., 0.3, 0.5, etc.). The calculation of the reprojection error can be based on the mapping relationship between each three-dimensional point generated by the registered image and the corresponding feature point. Exemplarily, the electronic device can perform a global multi-feature bundle adjustment whenever a specified number of images (e.g., 100, etc.) are registered.

[0080] For example, Figure 2f As shown, currently registered images include image 106, image 107 and image 108, and 3D points B5, B6, B7 and B8 are generated based on the above images. Among them, 3D point B5 has corresponding feature points on image 106, image 107 and image 108 respectively; 3D point B6 has corresponding feature points on image 106, image 107 and image 108 respectively; 3D point B7 has corresponding feature points on image 107 and image 108 respectively; 3D point B8 has corresponding feature points on image 106 and image 107 respectively.

[0081] Assume that the reprojection errors of the 3D point B5 on the images 106, 107 and 108 are e5, e6 and e7 respectively; the reprojection errors of the 3D point B6 on the images 106, 107 and 108 are e8, e9 and e10 respectively; the reprojection errors of the 3D point B7 on the images 107 and 108 are e11 and e12 respectively; the reprojection errors of the 3D point B8 on the images 106 and 1078 are e13 and e14 respectively. The electronic device can adjust the 3D coordinates of the 3D points B5, B6, B7 and B8 based on the BA algorithm so that the sum of the reprojection errors e5, e6, e7, e8, e9, e10, e11, e12, e13 and e14 is less than the error threshold.

[0082] Similarly, when all images in the image set are registered, the electronic device can use the BA algorithm to adjust the coordinates of the three-dimensional points generated based on all images and the camera poses (or camera coordinates) corresponding to all images based on a specified direction (e.g., the gradient direction corresponding to each three-dimensional point), so that the sum of the reprojection errors corresponding to the three-dimensional points generated based on all images after adjustment is less than the error threshold. The processing flow of the electronic device can refer to the previous text and will not be repeated here. At this time, the calculation of the reprojection error is based on the mapping relationship between each three-dimensional point generated by all images and the corresponding feature points.

[0083] After completing the global multi-feature bundle adjustment, the electronic device can output a three-dimensional model of the target object, which can include a sparse three-dimensional point cloud and the positions of each camera.

[0084] Among them, the bundle adjustment method is to construct a nonlinear optimization problem to minimize the reprojection error based on the camera pose to be optimized and the map points. The sum of the reprojection errors corresponding to the three-dimensional points can be expressed as:

[0085]

[0086] Where C = {C 1 ,C 2 ,…,C N}, P = {P 1 ,P 2 ,…,P D}, N is the number of images, D is the number of feature points, P j is the 3D point coordinate corresponding to the jth feature point, p ji is the two-dimensional coordinate of the j-th feature point in the i-th image.

[0087] Among them, Ci = Ki[Ri,ti], K is the camera internal parameter, [R,t] is the camera pose, R is the rotation matrix, and t is the translation vector. Ki[Ri,ti]Pj = Ki*(Ri*Pj+ti), which is used to indicate the corresponding two-dimensional coordinates obtained by reprojecting the 3D point into the image. Then, It can represent the reprojection error of the j-th 3D point in the i-th image.

[0088] Furthermore, the nonlinear optimization problem involved in the bundle adjustment method can be expressed as:

[0089]

[0090] In this nonlinear optimization problem, the quantities to be optimized are the camera parameters C and the three-dimensional point P, where the camera parameters C include the camera intrinsic parameters (K) and the camera pose ([R, t]).

[0091] To solve nonlinear problems, the Gauss-Newton method or the LM (Levenberg-Marquardt) method is usually used, and the state increment in each iteration is calculated based on the Hessian matrix, so that the camera parameters C and the three-dimensional point P obtained after multiple iterations make the sum of the reprojection errors less than the error threshold.

[0092] Among them, the general form of the incremental linear equation based on the Hessian matrix is ​​HΔx=b.

[0093] The incremental linear equation is written in the form of camera parameters and three-dimensional points (or map points):

[0094] Where Δx C is the increment of camera parameter C, Δx P is the increment of the coordinates of the three-dimensional point P.

[0095] exist Middle, H CC is a diagonal matrix, only in H i,i There is a non-zero block, H CC The dimension of H is the number of camera parameters C; PP is a diagonal matrix, only in H j,j There is a non-zero block, H PP The dimension is the number of three-dimensional points (i.e., map points) P; H CP Yes H PC The transposed matrix may be a sparse matrix or a dense matrix, which depends on the specific observation data.

[0096] Usually the number of 3D points is much greater than the number of camera parameters, so in practice the H matrix will be as follows Figure 3 As shown, the upper left corner (i.e. H CC ) appears very small, and the lower right corner (i.e. H PP ) occupies a large space, and scattered observation data are distributed in the upper right corner and the lower left corner. At this time, the H matrix can be called an arrow-shaped matrix or a pickaxe-shaped matrix.

[0097] In order to speed up the solution of incremental linear equations, the Schur's elimination method is usually used. The incremental linear equation after the Schur's elimination method is in the form of:

[0098]

[0099] Then, the following incremental solution formula can be obtained:

[0100] Δx C =(H CC -H CP H PP - 1 H PC)- 1 (b C -H CP H PP - 1 b P );

[0101] Δx P =H PP -1 (b P -H PC Δx C ).

[0102] However, as the number of images and feature points increases, the time required to solve the bundle adjustment increases exponentially. When the camera pose, camera intrinsic parameters, and the number of 3D points are very large, even if the bundle adjustment solution is accelerated based on the Schur complementary elimination method, the time required to solve the bundle adjustment is still very long compared to the time required for other modules in 3D reconstruction.

[0103] In order to solve the above problems, an embodiment of the present application provides a cluster adjustment method to reduce the time consumption of cluster adjustment solution and improve the efficiency of cluster adjustment. In this method, first, the electronic device selects some relatively important or relatively good data quality three-dimensional points from all three-dimensional points (or map points) to be optimized according to a preset strategy, and performs cluster adjustment optimization on these relatively important three-dimensional points and the camera pose and camera intrinsic parameters to be optimized through the BA algorithm to obtain the optimized camera pose and camera intrinsic parameters; then, the electronic device uses the optimized camera pose and camera intrinsic parameters as fixed values, and performs cluster adjustment optimization on all three-dimensional points to be optimized through the BA algorithm to obtain all optimized three-dimensional points.

[0104] In this way, the bundle adjustment method provided in the embodiment of the present application is implemented in a two-step optimization manner, which can not only ensure the optimization accuracy, but also greatly reduce the optimization solution time, thereby improving the efficiency of the bundle adjustment.

[0105] like Figure 4a It is a schematic diagram of the hardware structure of the electronic device 100.

[0106] The electronic device 100 may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, an in-vehicle device, a smart home device and / or a smart city device. The embodiments of the present application do not impose any special restrictions on the specific type of the electronic device.

[0107] The electronic device 100 may include a processor 110, a memory 120, a wireless communication module 130, and a display screen 140. The above modules may be connected via a bus or other means, and the embodiment of the present application takes the connection via a bus as an example.

[0108] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0109] The processor 110 may include one or more processor units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated into one or more processors. The controller may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions.

[0110] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0111] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0112] The memory 120 is coupled to the processor 110 and is used to store various software programs and / or multiple groups of instructions. In a specific implementation, the memory 120 may include a volatile memory, such as a random access memory (RAM); it may also include a non-volatile memory, such as a ROM, a flash memory, a hard disk drive (HDD) or a solid state drive (SSD); the memory 120 may also include a combination of the above-mentioned types of memories. The memory 120 may store some program codes (for example, SFM algorithm program codes, etc.) so that the processor 110 calls the program codes stored in the memory 120 to implement the implementation method of the embodiment of the present application in the electronic device 100. The memory 120 may store an operating system, such as an embedded operating system such as uCOS, VxWorks, RTLinux, etc.

[0113] The wireless communication module 130 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 130 can be one or more devices integrating at least one communication processing module. The wireless communication module 130 receives electromagnetic waves via an antenna, modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 130 can also receive the signal to be sent from the processor 110, modulate the frequency of the signal, amplify it, and convert it into electromagnetic waves for radiation through the antenna. In some embodiments, the electronic device 100 can communicate with the processor 110 through the Bluetooth module ( Figure 4a Not shown), WLAN module ( Figure 4a The WLAN module may provide a solution for WLAN communication including one or more of classic Bluetooth (basic rate / enhanced data rate, BR / EDR) or Bluetooth low energy (bluetooth low energy, BLE). The WLAN module may provide a solution for WLAN communication including one or more of Wi-Fi direct, Wi-Fi LAN or Wi-Fi softAP.

[0114] The display screen 140 can be used to display images, videos, etc. The display screen 140 may include a display panel. The display panel may be a liquid crystal display (LCD), an organic light emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (AMOLED), a flexible light emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 140, where N is a positive integer greater than 1.

[0115] Optionally, the electronic device 100 may further include a camera ( Figure 4a (not shown). The camera can be used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal oxide semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras, where N is a positive integer greater than 1.

[0116] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes an operating system of a layered architecture as an example to exemplify the software structure of the electronic device 100.

[0117] Figure 4b It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.

[0118] The layered architecture of the electronic device 100 divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the hardware abstraction layer (HAL) and the kernel layer.

[0119] The application layer can include a series of application packages.

[0120] like Figure 4b As shown, the application package may include applications such as camera, AR application, 3D application, etc. The application package may also include applications such as calendar, weather, memo, game, video and music.

[0121] The application framework layer provides an application programming interface (API) and programming framework for applications in the application layer, including various components and services to support developers' Android development. The application framework layer includes some predefined functions.

[0122] like Figure 4b As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, a camera service, etc.

[0123] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0124] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0125] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0126] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).

[0127] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0128] The notification manager allows applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, notification information is used to inform the completion of downloads, message reminders, etc. Notification information can also appear in the system top status bar in the form of icons or scroll bar text, such as notifications of applications running in the background, or in the form of dialog windows on the screen. For example, text messages are displayed in the status bar, prompts sound, electronic devices vibrate, indicator lights flash, etc.

[0129] The camera service is used to call the camera (including the front camera and the rear camera) in response to the application's request.

[0130] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.

[0131] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.

[0132] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0133] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0134] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.

[0135] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0136] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0137] A 2D graphics engine is a drawing engine for 2D drawings.

[0138] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, and sensor driver. The hardware may include devices such as camera, display, processor, and memory.

[0139] Understandably, Figure 4b The layers in the software structure shown and the components included in each layer do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer layers than shown, and each layer may include more or fewer components, which is not limited in the present application.

[0140] It is understandable that in order to implement the cluster adjustment method in the embodiment of the present application, the electronic device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to be beyond the scope of the present application.

[0141] Figure 5 FIG. 4 is a flow chart showing a method for adjusting the bundle provided in an embodiment of the present application. Figure 5 As shown, the process of the bundle adjustment method provided in the embodiment of the present application specifically includes:

[0142] S201, the electronic device obtains camera posture, three-dimensional points (or map points), and camera internal parameters.

[0143] In this step, the camera pose, map point and camera intrinsic parameter obtained by the electronic device are the camera pose, map point and camera intrinsic parameter to be optimized. The camera pose, map point and camera intrinsic parameter to be optimized may be the camera pose, map point and camera intrinsic parameter to be optimized during global cluster adjustment, or the camera pose, map point and camera intrinsic parameter to be optimized during local cluster adjustment, which is not limited in this embodiment.

[0144] Generally, the number of camera poses to be optimized is much smaller than the number of 3D points. For example, the order of magnitude of 3D points is greater than the order of magnitude of camera poses, for example, the number of 3D points is about a thousand times or even ten thousand times the number of camera poses.

[0145] S202, the electronic device sequentially obtains one image from multiple images corresponding to the camera posture as the current image.

[0146] Among them, when there are multiple camera poses to be optimized, there will be multiple images corresponding to the corresponding three-dimensional modeling.

[0147] The electrons traverse each of the multiple images and select some relatively important 3D points from the 3D points corresponding to each image as the 3D points to be optimized in the first step of the bundle adjustment. These 3D points can be called target 3D points.

[0148] S203, the electronic device divides the current image into multiple networks.

[0149] For each image, the electronic device first divides it into a plurality of equal grids, for example, a grid of M*N pixels.

[0150] S204: The electronic device sequentially obtains one 3D point from a plurality of 3D points corresponding to the current image in descending order of feature extraction response values ​​as the current 3D point.

[0151] The feature extraction response value refers to the response value of the feature point extracted from the image during the image feature extraction stage. The response value of the feature point is used to characterize the strength of the feature point, or more precisely, the degree of the corner point of the point.

[0152] For each image, all 3D points corresponding to the image are traversed to select the target 3D point. The traversal order may be in descending order of feature extraction response value. Descending order of feature extraction response value refers to the order of feature extraction response values ​​of image feature points corresponding to the 3D point from large to small. It should be noted that the image feature points corresponding to the 3D point can be understood as the image feature points used to generate the 3D point.

[0153] S205, the electronic device determines whether the feature extraction response value of the feature point corresponding to the current three-dimensional point is greater than a first threshold, if so, executes S206, if not, executes S208.

[0154] In this embodiment, the feature extraction response value of the image feature point corresponding to the target 3D point needs to be greater than the first threshold value. That is, the 3D point to be optimized in the first step of bundle adjustment needs to be generated based on the 2D image feature point with a larger feature extraction response value.

[0155] S206, the electronic device determines whether the number of selected three-dimensional points corresponding to the grid where the feature point corresponding to the current three-dimensional point is located is greater than a second threshold, if not, execute S207, if yes, execute S208.

[0156] In this embodiment, in order to ensure the distribution balance of the three-dimensional points to be optimized in the first step of the bundle adjustment, the electronic device limits the distribution of the two-dimensional image feature points corresponding to the target three-dimensional points. Among them, in each image, the upper limit of the number of selected three-dimensional points corresponding to the same grid is the second threshold. It should be pointed out that the number of selected three-dimensional points corresponding to a grid can be understood as the number of image feature points corresponding to the target three-dimensional point falling into the network. In other words, the number of target feature points included in each image grid is not greater than the second threshold, and the target feature point is the image feature point corresponding to the target three-dimensional point.

[0157] In this embodiment, when the electronic device traverses the three-dimensional points in descending order of feature extraction response values ​​to determine the target three-dimensional point, if the feature extraction response value of the two-dimensional image feature point corresponding to a certain three-dimensional point is greater than the first threshold, but the number of selected three-dimensional points currently corresponding to the image grid where the two-dimensional image feature point is located is greater than the second threshold, or in other words, the total number of image feature points included in the image grid where the image feature point is located is greater than the second threshold, then the three-dimensional point can no longer be selected as the target three-dimensional point.

[0158] S207: The electronic device uses the current 3D point as a target 3D point, and updates the number of selected 3D points corresponding to each grid of the current image.

[0159] In this embodiment, when the electronic device traverses the three-dimensional points in descending order of feature extraction response values ​​to determine the target three-dimensional point, if the feature extraction response value of the image feature point corresponding to a certain three-dimensional point is greater than the first threshold, and the number of selected three-dimensional points currently corresponding to the image grid where the image feature point is located is not greater than the second threshold, or in other words, the total number of image feature points included in the image grid where the image feature point is located is not greater than the second threshold, then the three-dimensional point can be selected as the target three-dimensional point.

[0160] After the electronic device selects a certain 3D point as the target 3D point, the number of selected 3D points corresponding to the image grid where the image feature point corresponding to the 3D point is located can be updated, that is, the value of the number of selected 3D points is accumulated by 1. In each image, the initial value of the number of selected 3D points corresponding to each image grid is 0, or in other words, the initial value of the total number of target feature points included in each image grid is 0.

[0161] S208, the electronic device determines whether all three-dimensional points corresponding to the current image have been traversed, if so, executes S209, if not, executes S204.

[0162] Referring to S204-S207, the electronic device traverses each three-dimensional point corresponding to the current image until all three-dimensional points corresponding to the current image are traversed, and all target three-dimensional points corresponding to the current image are determined.

[0163] In an optional implementation, referring to S204-S207, the electronic device traverses each 3D point corresponding to the current image until the feature extraction response value of the image feature point corresponding to the current 3D point is not greater than the first threshold. In this way, the electronic device does not need to process other 3D points that are ranked later (the feature extraction response values ​​of the image feature points corresponding to them must be less than the first threshold), thereby improving the selection efficiency of the target 3D point.

[0164] S209, the electronic device determines whether all images corresponding to the camera posture have been traversed, if not, execute S202, and if so, execute S210.

[0165] Referring to S202-S208, the electronic device traverses each image corresponding to each camera pose to be optimized until all images corresponding to the camera pose to be optimized are traversed, and all target three-dimensional points are determined, that is, the three-dimensional points to be optimized in the first step of bundle adjustment are determined.

[0166] S210, the electronic device performs a bundle adjustment on the target three-dimensional point, the camera pose and the camera intrinsic parameters to obtain optimized camera pose and camera intrinsic parameters.

[0167] After the electronic device selects some relatively important 3D points (i.e., target 3D points) from all 3D points, it can perform cluster adjustment on the target 3D points, the camera pose to be optimized, and the camera intrinsic parameters to obtain the optimized camera pose and camera intrinsic parameters.

[0168] In the first step of the bundle adjustment optimization, the state increments to be solved are the increments of the camera parameters (including the camera pose and camera intrinsic parameters) and the increments of some three-dimensional point coordinates.

[0169] In the first step of bundle adjustment optimization, the incremental linear equation is written as:

[0170] Where Δx C is the increment of camera parameter C, Δx P′ is the increment of the coordinates of the target 3D point P.

[0171] exist Middle, H CC is a diagonal matrix, only in H i,i There is a non-zero block, H CC The dimension of H is the number of camera parameters C; P′P′ is a diagonal matrix, only in H j,j There is a non-zero block, H P′P′ The dimension of H is the number of target 3D points (i.e., selected map points) P′; CP′ Yes H P′C The transposed matrix may be a sparse matrix or a dense matrix, which depends on the specific observation data.

[0172] In this embodiment, since the bundle adjustment in this step optimizes some 3D points (i.e., target 3D points) and camera parameters (including camera pose and camera intrinsic parameters), The matrix (H matrix) can be expressed as Figure 6a As shown in the figure. This step of bundle adjustment optimizes some 3D points (i.e., target 3D points), and the number of target 3D points is relatively reduced. For example, the number of all 3D points is about a thousand times or even ten thousand times the number of camera poses, and the number of target 3D points is about a hundred times or even ten times the number of camera poses. In this way, the lower left corner of the H matrix (i.e., H P′C ) and the upper right corner (i.e. H CP′ ) is greatly reduced, that is, the number of observations distributed in the upper right and lower left corners of the H matrix is ​​greatly reduced. As a result, the time required to solve the first step of the bundle adjustment optimization is also reduced.

[0173] S211, the electronic device uses the optimized camera posture and camera internal parameters as fixed values, performs cluster adjustment on all three-dimensional points, and obtains all optimized three-dimensional points.

[0174] After completing the first step of optimization to obtain the optimized camera pose and camera internal parameters, in the second step of optimization, only cluster adjustment is performed on all three-dimensional points to obtain all optimized three-dimensional points.

[0175] In the second step of bundle adjustment optimization, the state increment to be solved is the increment of the coordinates of all three-dimensional points.

[0176] In the second step of bundle adjustment optimization, the incremental linear equation is written as:

[0177] H PP Δx P =b P ;in,

[0178] H PP is a diagonal matrix, only in H j,j There is a non-zero block, H PP The dimension is the number of all three-dimensional points P.

[0179] In this embodiment, since the current step of cluster adjustment optimizes only all three-dimensional points, H PP The matrix can be Figure 6b As shown. At this time, the incremental linear equation H PP Δx P =b P The solution can be found directly without the need for Shure elimination, and the second step of bundle adjustment optimization will take less time to solve.

[0180] At this point, the electronic device can obtain the optimized camera pose, camera internal parameters and all three-dimensional points, and can update the camera pose, three-dimensional points (or map points) and camera internal parameters acquired in S201.

[0181] At this point, the electronic device has completed the two-step optimization of the camera pose, three-dimensional points (or map points), and camera internal parameters obtained by the electronic device in S201. Then, the electronic device can reconstruct a three-dimensional model based on the optimized data, and the three-dimensional model can include a sparse three-dimensional point cloud and each camera pose.

[0182] Thus, in the method provided in this embodiment, the optimization of the bundle adjustment is divided into two steps: first optimizing the camera pose, the positions of some map points, and the camera internal parameters, and then optimizing the positions of all map points. Among them, the first step of optimizing some map points is selected according to a certain strategy. The two-step optimization method greatly reduces the optimization solution time while ensuring that the optimization accuracy is not reduced.

[0183] Figure 7 The figure shows the time consumption comparison results of cluster adjustment based on the general method and the method of this solution. Figure 7 As shown in the figure, when the number of 3D modeling images is the same, the time consumption of the bundle adjustment using the method of the present invention is less than that of the bundle adjustment using the general method. Moreover, as the number of 3D modeling images increases, the reduction of the time consumption of the bundle adjustment using the method of the present invention becomes more obvious.

[0184] This embodiment further provides a computer storage medium, in which computer instructions are stored. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned related method steps to implement the cluster adjustment method in the above-mentioned embodiment.

[0185] This embodiment further provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the above-mentioned related steps to implement the bundle adjustment method in the above-mentioned embodiment.

[0186] In addition, an embodiment of the present application also provides a device, which may specifically be a chip, a component or a module, and the device may include a connected processor and a memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor may execute the computer-executable instructions stored in the memory so that the chip executes the cluster adjustment method in the above-mentioned method embodiments.

[0187] Among them, the electronic device, computer storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above and will not be repeated here.

[0188] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0189] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0190] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A bundle adjustment method, characterized in that: include: Get the camera pose, camera intrinsic parameters and all 3D points to be optimized; Determine a target 3D point among all the 3D points according to a preset strategy; wherein determining the target 3D point among all the 3D points according to the preset strategy comprises: traversing the images corresponding to the camera position to be optimized; selecting the target 3D point among the 3D points corresponding to each image; wherein a feature extraction response value of an image feature point corresponding to the target 3D point is greater than a first threshold; Performing cluster adjustment optimization on the camera pose to be optimized, the camera intrinsic parameters, and the target three-dimensional point to obtain optimized camera pose and camera intrinsic parameters; Taking the optimized camera pose and camera internal parameters as fixed values, performing cluster adjustment optimization on all the three-dimensional points to obtain all the optimized three-dimensional points; Among them, the processing of the bundle adjustment optimization is: solving the three-dimensional point reprojection error according to the camera pose, camera intrinsic parameters, the three-dimensional coordinates of the three-dimensional point, and the two-dimensional coordinates of the three-dimensional point in each image, and performing nonlinear optimization processing to minimize the three-dimensional point reprojection error.

2. The method according to claim 1, characterized in that The data quality of the target three-dimensional point is better than the data quality of all three-dimensional points; wherein the data quality is used to characterize the accuracy of the three-dimensional point when used for three-dimensional reconstruction.

3. The method according to claim 1, characterized in that Also includes: Divide each image into multiple image grids; wherein the number of target feature points included in each image grid is not greater than a second threshold; The target feature point is an image feature point corresponding to the target three-dimensional point.

4. The method according to claim 3, characterized in that Selecting the target three-dimensional point from the three-dimensional points corresponding to each image includes: Arrange the three-dimensional points corresponding to each image in descending order according to the feature extraction response value; Acquire a three-dimensional point as the current three-dimensional point in descending order of the feature extraction response values; If the feature extraction response value of the image feature point corresponding to the current 3D point is greater than the first threshold value, and the total number of target feature points included in the current image grid is not greater than the second threshold value, the current 3D point is used as the target 3D point, and the total number of target feature points included in the current image grid is updated; wherein the current image grid is the image grid where the image feature point corresponding to the current 3D point is located; Continue to obtain a 3D point as the current 3D point in descending order of the feature extraction response value until all 3D points corresponding to each image are traversed, or until the feature extraction response value of the image feature point corresponding to the current 3D point is not greater than the first threshold.

5. The method according to claim 1 or 2, characterized in that: The difference between the number of all three-dimensional points and the number of camera poses is greater than a preset number threshold.

6. The method according to claim 1 or 2, characterized in that: Get the camera pose, camera internal parameters and all 3D points to be optimized, including: Get the camera pose, camera intrinsic parameters and all 3D points to be optimized during local bundle adjustment.

7. The method according to claim 1 or 2, characterized in that: Get the camera pose, camera internal parameters and all 3D points to be optimized, including: Get the camera pose, camera intrinsic parameters and all 3D points to be optimized during global bundle adjustment.

8. The method according to claim 1, characterized in that According to the camera pose, the camera intrinsic parameters, the three-dimensional coordinates of the three-dimensional point, and the two-dimensional coordinates of the three-dimensional point in each image, the three-dimensional point reprojection error is solved, and a nonlinear optimization process is performed to minimize the three-dimensional point reprojection error, including: The nonlinear optimization process of minimizing the three-dimensional point reprojection error is implemented based on the following formula: Where f(C,P) is the sum of the reprojection errors corresponding to the three-dimensional points, N is the number of images, D is the number of feature points, and P j is the 3D point coordinate corresponding to the jth feature point, p ji is the two-dimensional coordinate of the j-th feature point in the i-th image, Ci=Ki[Ri,ti], K is the camera intrinsic parameter, [R,t] is the camera pose, R is the rotation matrix, and t is the translation vector.

9. An electronic device, characterized in that: include: one or more processors; Memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and when the computer programs are executed by the one or more processors, the electronic device performs the bundle adjustment method according to any one of claims 1 to 8.

10. A computer-readable storage medium comprising a computer program, characterized in that: When the computer program runs on an electronic device, the electronic device is enabled to execute the bundle adjustment method according to any one of claims 1 to 8.