An incremental structure-from-motion method with optimized image addition order
Optimizing image matching and basic matrix calculation through SIFT and RANSAC algorithms solves the problems of initial image pair selection and image addition order in the incremental motion restoration structure method, improves the accuracy and robustness of three-dimensional reconstruction, and reduces the number of duplicates. Projection errors restore a more detailed object structure.
Patent Information
- Application Number
- CN202210669547.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-14
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-06-14
AI Technical Summary
Existing incremental motion restoration structure methods have problems in the selection of initial image pairs and the order of image addition, resulting in insufficient three-dimensional space points, many outliers, and large reprojection errors in the reconstruction results, making it difficult to restore detailed object structures.
The SIFT algorithm is used to detect feature points, the optimal basic matrix is obtained based on the RANSAC algorithm, the matching score of the image pair is calculated, the image pair with the highest matching score is selected as the initial image pair, and the image addition order is optimized to improve the accuracy of the three-dimensional reconstruction through geometric verification. accuracy.
It improves the robustness of 3D reconstruction, increases the number of 3D space points, reduces outliers, reduces reprojection errors, and recovers more detailed information.
Smart Images

Figure CN115147619B
Abstract
Description
Technical Field
[0001] The invention belongs to the field of three-dimensional reconstruction, and in particular relates to an incremental motion recovery structure method for optimizing the order of image addition. Background Art
[0002] Determining the spatial geometry of the target object through the movement of the camera is a common method for achieving 3D reconstruction. The biggest difference between this method and the 3D reconstruction technology based on depth cameras (such as Kinect) is that it only requires an ordinary RGB camera, is low-cost, is less constrained by the environment, and can be used both indoors and outdoors.
[0003] Among them, the technology of obtaining camera parameters by analyzing a series of multi-view images and performing 3D reconstruction is called Structure from Motion (SFM). Simply put, SFM takes multi-view images (including multiple images) as input, detects and matches feature points on these images, and then uses the motion of the camera to restore the 3D coordinates of the matching points, thereby using 3D points to represent the structure of the scene. Throughout the process, the SFM method requires that the camera is moving and the target object to be reconstructed is stationary.
[0004] Over the years, the SFM algorithm has undergone tremendous evolution and is currently divided into incremental SFM methods, global SFM methods, and hybrid SFM methods. Among them, the incremental SFM method usually starts with the reconstruction of two images, and then gradually adds new images. After each addition, the scene data needs to be bundle adjusted to optimize the camera pose and the three-dimensional spatial structure of the object. The reconstruction quality of the incremental SFM method depends largely on the selection of the initial image pair and the order of subsequent image additions. Once the quality of the initial image pair is poor, the entire processing process will fall into a local optimum and cause the subsequent bundle adjustment to fall into an infinite loop, and the global optimum cannot be correctly solved.
[0005] In the prior art, the image pair with the most matching points is often selected from the multi-view images as the initial image pair; wherein the matching points of the image pair are usually determined based on the similarity of SIFT (Scale invariant feature Transform) feature descriptors. However, the actual reconstruction effect of this method often has more outliers and a certain reprojection error. Summary of the invention
[0006] In order to solve the above problems existing in the prior art, the present invention provides an incremental motion recovery structure method for optimizing the order of image addition.
[0007] The technical problem to be solved by the present invention is achieved through the following technical solutions:
[0008] An incremental motion recovery structure method for optimizing the order of adding images, comprising:
[0009] Acquire a multi-view image captured by a camera; the multi-view image includes a plurality of images;
[0010] The SIFT algorithm is used to detect the feature points of each image, and every two images are taken as an image pair, and the matching points between each image pair are determined based on the detected feature points;
[0011] For each image pair, the RANSAC algorithm is used to find the optimal basic matrix based on its matching points; wherein, among the pairs of matching points between the image pairs, the number of matching point pairs C that satisfy the constraints of the optimal basic matrix is the largest;
[0012] The ratio of the number of matching point pairs C of the image pair to the total number of matching point pairs of the image pair is used as the matching score of the image pair;
[0013] An incremental structure-from-motion (SFM) method is performed, wherein an image pair with the highest matching score is selected as an initial image pair, and an additional image is determined based on the matching scores of the image pairs.
[0014] Optionally, determining matching points between each image pair based on the detected feature points includes:
[0015] Calculate the Euclidean distance between every two feature points of the image pair to obtain the calculation result;
[0016] For each feature point, if the ratio of the minimum Euclidean distance and the second minimum Euclidean distance associated with the feature point in the calculation result is less than a preset first threshold, another feature point associated with the minimum Euclidean distance is determined as an initial matching point for the feature point;
[0017] Each pair of feature points in the image pair that are initial matching points to each other is used as the matching points between the image pair.
[0018] Optionally, for each image pair, the RANSAC algorithm is used to find the optimal basic matrix based on its matching points, including:
[0019] A. Initialize the number of iterations and set the upper limit of the number of iterations;
[0020] B. Randomly select 8 pairs of matching points of the image pair as random samples, and calculate a basic matrix of the image pair based on the random samples;
[0021] C. Based on the calculated basic matrix, calculate the distance from each pair of matching points of the image pair to the corresponding epipolar line;
[0022] D. Compare each calculated distance with a preset second threshold value. If the calculated distance is less than the second threshold value, record the pair of matching points with the distance as an inlier. Otherwise, do not record them as inliers. Count the number of inliers in this iteration, then end this iteration and increase the number of iterations by 1.
[0023] E. Determine whether the current number of iterations has reached the upper limit of the number of iterations; if not, return to step B; if it has reached, use the basic matrix calculated in the iteration with the largest number of internal points as the optimal basic matrix for the image pair.
[0024] Optionally, the upper limit of the number of iterations is estimated by the following formula:
[0025]
[0026] Among them, w 8 It is expected that the probability that the 8 pairs of matching points selected in step B will be recorded as internal points in step D, and p represents the probability that the optimal basic matrix can be obtained after k iterations.
[0027] Optionally, the performing of the incremental structure from motion (SFM) method comprises:
[0028] The multi-view images are sorted to form an image sequence; in the image sequence, the initial image pair is the first two images, and the newly added image adjacent to the i-th image is the image with the highest matching score with the i-th image; 2≤i≤X, X is the total number of the multiple images included in the multi-view images;
[0029] The image pairs formed by every two adjacent images in the image sequence are processed in turn, including: calculating the three-dimensional space coordinates of the object photographed by the camera according to the optimal basic matrix of the image pair, the homogeneous coordinates of the matching points, and the intrinsic parameter matrix of the camera; after calculating the three-dimensional space coordinates, if the processing object is not the initial image pair, performing cluster adjustment.
[0030] Optionally, the method further comprises:
[0031] After processing the last image pair in the image sequence, outliers whose reprojection errors exceed a preset third threshold are deleted from the finally obtained three-dimensional space coordinates.
[0032] Optionally, after deleting the outlier points whose reprojection errors exceed a preset third threshold, the method further includes:
[0033] Using a matching point with known three-dimensional spatial coordinates as an initial seed point, and using a zero-mean normalized correlation coefficient of the image and an image continuity constraint as a matching criterion, performing matching point diffusion in the spatial region where the photographed object is located to obtain a diffusion result;
[0034] Based on the diffusion result, the incremental structure from motion (SFM) method is executed again to restore a dense point cloud of the photographed object.
[0035] Optionally, after recovering the dense point cloud, the method further includes:
[0036] Outlier points in the dense point cloud are deleted according to the principle of statistical filtering.
[0037] Optionally, w=0.9, p=0.97.
[0038] Optionally, the first threshold is 0.7±0.1.
[0039] In the incremental motion restoration structure method for optimizing the order of image addition provided by the present invention, the RANSAC (Random Sample Consensus) algorithm is used to obtain the optimal basic matrix based on the matching points of the image pair; since the optimal basic matrix is defined as: among the matching points of each pair between the image pairs, the number of matching point pairs (denoted as C) that meet the constraints of the optimal basic matrix is the largest; therefore, the number of matching point pairs that meet the constraints of the optimal basic matrix is the matching point that is truly useful for the image pair in the three-dimensional reconstruction process. Based on this, the ratio of the number of matching point pairs C that meet the constraints of the optimal basic matrix to the total number of matching point pairs is used as the matching score of the image pair, so that the initial image pair and the newly added image are selected based on the matching score, which is equivalent to selecting the image pair that contributes the most to the accurate three-dimensional reconstruction as the initial image pair through geometric verification, and optimizing the order of adding the newly added image, thereby increasing the number of three-dimensional space points in the reconstruction result, reducing outliers, reducing reprojection errors, and restoring more details of the photographed object. Therefore, compared with the existing incremental SFM method, the present invention improves the robustness of the incremental SFM method to a certain extent.
[0040] The present invention will be further described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is a flow chart of an incremental motion recovery structure method for optimizing the order of image addition provided by an embodiment of the present invention;
[0042] Figure 2 is a flow chart of obtaining an optimal basic matrix using the RANSAC algorithm in an embodiment of the present invention;
[0043] Figure 3 and Figure 4 It is a schematic diagram of the principle of reprojection error;
[0044] Figure 5 is a schematic diagram of performing matching point diffusion in an embodiment of the present invention;
[0045] Figure 6 It is a schematic diagram of a process of realizing dense point cloud recovery by using an incremental SFM method provided by an embodiment of the present invention;
[0046] FIG. 7( a ) is a rendering of a three-dimensional reconstruction of a David sculpture using the incremental SFM method provided by the present invention;
[0047] FIG7( b ) is a rendering of a 3D reconstruction of a David sculpture using the traditional incremental SFM method;
[0048] FIG8( a ) is a diagram showing the effect of three-dimensional reconstruction of a rabbit model using the incremental SFM method provided by the present invention;
[0049] FIG8( b ) is a diagram showing the effect of three-dimensional reconstruction of a rabbit model using the traditional incremental SFM method;
[0050] FIG9( a ) is a diagram showing the effect of three-dimensional reconstruction of a box using the incremental SFM method provided by the present invention;
[0051] FIG9( b ) is a diagram showing the effect of three-dimensional reconstruction of a box using the traditional incremental SFM method;
[0052] FIG. 10( a ) is a diagram showing the effect of three-dimensional reconstruction of a pillow using the incremental SFM method provided by the present invention;
[0053] FIG10( b ) is a diagram showing the effect of three-dimensional reconstruction of a pillow using the traditional incremental SFM method. DETAILED DESCRIPTION
[0054] The present invention is further described in detail below with reference to specific embodiments, but the embodiments of the present invention are not limited thereto.
[0055] In order to improve the accuracy of 3D reconstruction and restore more details of the photographed object, the embodiment of the present invention provides an incremental motion recovery structure method that optimizes the order of image addition. Figure 1 As shown, the method comprises the following steps:
[0056] S1: Acquire a multi-view image taken by a camera; the multi-view image includes multiple images.
[0057] The camera mentioned here can be an ordinary RGB camera, or an infrared camera, etc., but is not limited to these.
[0058] In addition, it can be understood that the depth camera can also be used to capture the multi-view images used in the embodiments of the present invention.
[0059] S2: Use SIFT algorithm to detect feature points of each image, and take every two images as an image pair, and determine the matching points between each image pair based on the detected feature points.
[0060] Among them, using SIFT algorithm to detect the feature points of an image is a mature image feature extraction technology, which will not be described in detail in the embodiment of the present invention. In practice, each detected feature point is represented by a 128-dimensional feature vector.
[0061] In step S2, there are many specific implementation methods for determining the matching points between each image pair based on the detected feature points.
[0062] Exemplarily, in one implementation, determining the matching points between each image pair based on the detected feature points may include:
[0063] (1) Calculate the Euclidean distance between every two feature points of the image pair and obtain the calculation result.
[0064] The specific calculation formula is:
[0065]
[0066] R i =(r i1 ,r i2 ,…,r i128 ),
[0067] S j =(s j1 ,s j2 ,…,s j128 );
[0068] Among them, R i Represents the 128-dimensional feature vector corresponding to the i-th feature point of image R in the image pair, S j Indicates the 128-dimensional feature vector corresponding to the j-th feature point of image S in the image pair, d(R i ,S j ) represents the Euclidean distance between these two feature points.
[0069] (2) For each feature point, another feature point associated with the minimum Euclidean distance in the calculation result of step (1) is determined as the initial matching point of the feature point.
[0070] For example, for the i-th feature point of image R, if the minimum Euclidean distance in the calculation result of step (1) is the Euclidean distance between the i-th feature point and the j-th feature point of image S, then the initial matching point of the i-th feature point of image R is the j-th feature point of image S.
[0071] (3) Each pair of feature points in the image pair that are initial matching points to each other is used as the matching points between the image pair.
[0072] Still taking image R and image S as an example, if the initial matching point of the i-th feature point of image R is determined to be the j-th feature point of image S, and the initial matching point of the j-th feature point of image S is determined to be the i-th feature point of image R, then the i-th feature point of image R and the j-th feature point of image S are the matching points of image R and image S.
[0073] Otherwise, if the initial matching point of the i-th feature point of image R is determined to be the j-th feature point of image S, but the initial matching point of the j-th feature point of image S is not the i-th feature point of image R, then the i-th feature point of image R and the j-th feature point of image S cannot be determined as the matching points of image R and image S.
[0074] Similarly, if the initial matching point of the j-th feature point of image S is determined to be the i-th feature point of image R, but the initial matching point of the i-th feature point of image R is not the j-th feature point of image S, then the i-th feature point of image R and the j-th feature point of image S cannot be determined as the matching points of image R and image S.
[0075] In another implementation, in order to improve the recognition accuracy of the matching points, determining the matching points between each image pair based on the detected feature points may include:
[0076] (1) Calculate the Euclidean distance between every two feature points of the image pair and obtain the calculation result.
[0077] The specific implementation method of this step is the same as the previous implementation method.
[0078] (2) For each feature point, if in the calculation result of step (1), the ratio of the minimum Euclidean distance and the second minimum Euclidean distance associated with the feature point is less than a preset first threshold, then another feature point associated with the minimum Euclidean distance is determined as the initial matching point for the feature point.
[0079] For example, for the i-th feature point of image R, if the minimum Euclidean distance d in the calculation result of step (1) is min1 The next smallest Euclidean distance d min2 Ratio is less than the first threshold, assuming that min1 The relevant feature points are the i-th feature point of image R and the j-th feature point of image S, that is, d min1 is the Euclidean distance between the i-th feature point of image R and the j-th feature point of image S, then the j-th feature point of image S is determined as the initial matching point of the i-th feature point of image R.
[0080] Among them, the inventors of the embodiments of the present invention conducted experimental tests on a large number of image pairs with scale changes, rotations and brightness changes, and determined that when the first threshold is set to 0.7±0.1 (preferably 0.7), the recognition accuracy of matching points is higher.
[0081] (3) Each pair of feature points in the image pair that are initial matching points to each other is used as the matching points between the image pair.
[0082] The specific implementation method of this step is the same as step (3) in the previous implementation method.
[0083] S3: For each image pair, the RANSAC algorithm is used to obtain the optimal basic matrix based on its matching points; wherein, among each pair of matching points between the image pairs, the number of matching point pairs C that satisfy the constraints of the optimal basic matrix is the largest.
[0084] For details, see Figure 2 As shown, for each image pair, the following multiple sub-steps are performed:
[0085] A. Initialize the number of iterations and set the upper limit of the number of iterations.
[0086] B. Randomly select 8 pairs of matching points of the image pair as random samples, and calculate a basic matrix of the image pair based on the random samples.
[0087] It is understood that the fundamental matrix should satisfy:
[0088] m T Fm′=0;
[0089] Among them, F represents the basic matrix, the actual size of which is 3×3; m and m' are the homogeneous coordinates of the projection points of the same spatial point in the two images in the pixel coordinate systems of the two images respectively, and the superscript T represents the matrix transpose.
[0090] Specifically, let m = (u i , v i , 1) T ,m'=(u' i , v′ i , 1) T , then according to the conditions that the basic matrix should satisfy, we can get:
[0091]
[0092] in, is the basic matrix.
[0093] Simplifying the above formula, we get:
[0094]
[0095] Where F'=[f 11 f 12 f 13 f 21 f 22 f 23 f 31 f 32 f 33 ] T , n is the number of matching point pairs used to calculate the basic matrix F, for example, n can be equal to 8.
[0096] From the above formula, we can know that each pair of matching points can provide a linear equation about F; there are 3×3=9 elements in the basic matrix F. Since the scale is arbitrary, when at least 8 pairs of matching points in the given image pair are in the pixel coordinate system, a basic matrix F can be calculated. The so-called arbitrary scale means that the proportional relationship between the reconstructed 3D model and the corresponding real object size is arbitrary.
[0097] C. Based on the calculated fundamental matrix, calculate the distance from each pair of matching points of the image pair to the corresponding epipolar line.
[0098] The specific calculation method can be expressed by the following formula:
[0099]
[0100] Among them, m and m' are the homogeneous coordinates of the projection points of the same spatial point in the two images in the pixel coordinate systems of the two images respectively, F is the basic matrix; Fm represents the multiplication of F and m, F T m′ is F T and m' multiplied; Fm and F T m′ represents the polar line vector corresponding to m and m', respectively, (Fm) i is the i-th element of the polar vector Fm, (F T m′) i is the polar vector F T The i-th element of m′; d p is the calculated distance.
[0101] D. Compare each calculated distance with the preset second threshold. If it is less than the second threshold, the pair of matching points with the distance is recorded as an inlier, otherwise it is not recorded as an inlier. Count the number of inliers in this iteration, then end this iteration and increase the number of iterations by 1.
[0102] The second threshold is preferably set to 0.01, but is not limited thereto.
[0103] E. Determine whether the current number of iterations has reached the upper limit of the number of iterations; if not, return to step B; if it has, take the basic matrix calculated in the iteration with the largest number of internal points as the optimal basic matrix for the image pair.
[0104] In a preferred implementation, in order to reduce the number of iterations and thus speed up the algorithm execution efficiency, the upper limit of the number of iterations set in step A can be estimated by the following formula:
[0105]
[0106] Among them, w represents the probability that a pair of randomly selected matching points can be recorded as internal points, so w 8 It is expected that the probability that the 8 pairs of matching points selected in step B will be recorded as internal points in step D, and p represents the probability that the optimal basic matrix can be obtained after k iterations.
[0107] In one embodiment, w may be set to 0.9 and p may be set to 0.97, but this is not limiting.
[0108] S4: The ratio of the number of matching point pairs C of the image pair to the total number of matching point pairs of the image pair is used as the matching score of the image pair.
[0109] It can be understood that the number of matching point logarithms C used as the numerator when calculating the ratio in step S4 is the number of internal points counted in the iteration in which the optimal basic matrix is calculated, and the total number of matching point logarithms used as the denominator is the sum of the number of matching point logarithms determined based on the feature points in step S2.
[0110] S5: Execute an incremental structure-from-motion (SFM) method; wherein, an image pair with the highest matching score is selected as an initial image pair, and a newly added image is determined based on the matching score of the image pair.
[0111] Specifically, an incremental motion recovery structure SFM method is performed, including:
[0112] (1) The multi-view images are sorted to form an image sequence; in the image sequence, the initial image pair is the first two images, and the newly added image adjacent to the i-th image is the image with the highest matching score with the i-th image; 2≤i≤X, where X is the total number of images included in the multi-view image.
[0113] For example, assuming that the multi-view image includes I 1 ,I 2 ,I 3 ,I 4 There are 4 images in total. Sort these 4 images: I 2 and I 3 The matching score is the highest, then I 2and I 3 As the first two images in the image sequence; assuming I 2 In front, I 3 After that, with I 3 The adjacent newly added images are the remaining images with I 3 I with the highest matching score 4 ; Finally, the remaining image is only I 1 , then with I 4 The adjacent newly added image is I 1 Thus, the image sequence formed is [I 2 ,I 3 ,I 4 ,I 1 ].
[0114] (2) processing each image pair consisting of two adjacent images in the image sequence in turn, including: calculating the three-dimensional spatial coordinates of the object photographed by the camera according to the optimal basic matrix of the image pair, the homogeneous coordinates of the matching points, and the intrinsic parameter matrix of the camera; after calculating the three-dimensional spatial coordinates, if the processing object is not the initial image pair, performing bundle adjustment.
[0115] For example, if the image sequence is [I 2 ,I 3 ,I 4 ,I 1 ], then first 2 and I 3 Then, the image pair I 3 and I 4 Finally, the image pairs formed by I 4 and I 1 The formed image pairs are processed.
[0116] Among them, the intrinsic parameter matrix of the camera can be obtained by estimation. Generally speaking, the intrinsic parameter matrix of the camera is as follows:
[0117]
[0118] Among them, f x and f y represent the physical size of the pixel on the horizontal axis x and the vertical axis y respectively; assuming that the pixel is a square, then f x =f y =f, f is the focal length of the camera, (u, v) is the vertical and horizontal offset of the center point of the image relative to the imaging point of the camera optical center; the vertical and horizontal offset is usually small and has little effect on the reconstruction result, so (u, v) = (0, 0) can be set. At this time, the intrinsic parameter matrix of the camera is:
[0119]
[0120] It can be seen that by obtaining the focal length of the camera, the intrinsic parameter matrix of the camera can be obtained. The focal length of the camera is estimated as follows:
[0121] The focal length of the camera is estimated by combining the exchangeable image file (EXIF) of the image. The specific formula is:
[0122]
[0123] w p =max(width,height);
[0124] Where, f represents the focal length of the camera, in pixels; f L is the focal length of the camera read from the EXIF file, in millimeters; width and height represent the width and height of the image, in pixels; w p It represents the largest value of the image length and width, and the unit is also pixel; w represents the width of the photosensitive element in the camera, and the unit is millimeter; although the value of w cannot be obtained directly from the EXIF file, the camera model can be read from the EXIF file, and the width of its photosensitive element can be obtained by looking up the corresponding camera model.
[0125] After calculating the camera's intrinsic matrix, we can use the intrinsic matrix and the optimal basic matrix of the image pair to calculate the camera pose corresponding to the image pair. The specific calculation process is as follows:
[0126] First, the essential matrix E is calculated based on the intrinsic parameter matrix K and the optimal basic matrix F of the image pair:
[0127] E=K T FK.
[0128] Then, the essential matrix E is subjected to singular value decomposition to obtain the rotation matrix R and translation matrix T, that is, the camera pose corresponding to the image pair is obtained.
[0129] Then, the three-dimensional space point coordinates of the object captured in the image pair are further calculated based on the camera pose. The specific calculation process is as follows:
[0130] For each image pair, let the world coordinate system coincide with the camera coordinate system corresponding to one of the images in the image pair, then the projection matrix of the camera corresponding to the image is:
[0131] P 1 =K[I 0];
[0132] Among them, K is the camera intrinsic parameter matrix and I is the 3×3 unit matrix.
[0133] Correspondingly, the projection matrix of the camera corresponding to the other image in the image pair is:
[0134] P 2 =K[RT];
[0135] Among them, R represents the rotation matrix of the image relative to the camera corresponding to the previous image, and T represents the translation matrix of the image relative to the camera corresponding to the previous image.
[0136] Understandably, P 1 and P 2 Both are projection matrices of size 3×4.
[0137] According to the projection relationship, we can get:
[0138]
[0139]
[0140] Simplifying the above formula, we can get:
[0141]
[0142]
[0143] Where s represents the scale factor; P 11 ,P 12 ,P 13 They are the projection matrix P 1 The row vector of 21 ,P 22 ,P 23 They are the projection matrix P 2 The row vector of i , v i , 1) is the i-th pair of matching points, located at P 1 The homogeneous coordinates of the point on the corresponding image, (u′ i ,v′ i ,1) is the i-th pair of matching points, located at P 2 Homogeneous coordinates of the points on the corresponding image; s, P 1 , P 2 and homogeneous coordinates are all known quantities. i is the coordinate of the three-dimensional space point corresponding to the i-th matching point, which is a three-dimensional vector to be solved.
[0144] Combining the above two equations, we get:
[0145]
[0146] It can be seen that based on this simultaneous equation, a system containing three unknowns (A iTherefore, the least squares method can be used to solve the three-dimensional space coordinates A of the three-dimensional space point corresponding to the i-th pair of matching points. i Following the same calculation process, the three-dimensional spatial coordinates corresponding to each pair of matching points in the image pair can be solved. This calculation process is also called triangulation reconstruction.
[0147] Then, if the currently processed image pair is not the initial image pair, the bundle adjustment is continued. It can be understood that the timing of the bundle adjustment is each time a new image pair is processed, that is, each time a new image is involved in the triangulation reconstruction process.
[0148] The method of performing bundle adjustment is as follows:
[0149] Substitute all the currently calculated three-dimensional space coordinates and projection matrices into the objective function in turn. The objective function is a function that calculates the total reprojection error. The principle of reprojection error can be found in Figure 3 and Figure 4 As shown in Figure 2. By minimizing the value of the objective function, we can obtain the projection matrix and three-dimensional space coordinates with the minimum total reprojection error.
[0150] The above objective function is:
[0151]
[0152] Among them, P i is the projection matrix of the i-th image in the image sequence, A j is the three-dimensional spatial coordinate of the jth spatial point, a ij is the two-dimensional coordinate of the corresponding point of the j-th spatial point on the i-th image, P i A j Represents the coordinates of the projection point of the j-th spatial point on the i-th image.
[0153] When the value of the objective function is minimized, the corresponding P i and A j This is the optimization target obtained, and this cluster adjustment is completed.
[0154] It can be understood that after the processing of the last image pair in the image sequence is completed, three-dimensional reconstruction can be achieved according to the finally obtained projection matrix and three-dimensional space coordinates.
[0155] In addition, in order to further improve the reconstruction accuracy, after processing the last image pair in the image sequence, the outliers whose reprojection errors exceed the preset third threshold value can be deleted from the final three-dimensional space coordinates. This process is expressed by the formula:
[0156] |a ij -P iA j | <threshold;
[0157] Wherein, threshold is the third threshold, and the other parameters can be found above. It can be understood that if the three-dimensional space coordinate A j If the above formula is satisfied, the coordinate is retained; otherwise, the three-dimensional space coordinate is deleted, that is, the space point corresponding to the three-dimensional space coordinate is deleted.
[0158] Preferably, the third threshold may be set to 2 pixels, but is certainly not limited thereto.
[0159] In the incremental motion restoration structure method for optimizing the order of image addition provided by the embodiment of the present invention, the RANSAC algorithm is used to obtain the optimal basic matrix based on the matching points of the image pair; since the optimal basic matrix is defined as: among the pairs of matching points between the image pairs, the number of matching point pairs C that satisfy the optimal basic matrix constraint is the largest; therefore, the number of matching point pairs that satisfy the optimal basic matrix constraint is the matching point that is truly useful for the image pair in the three-dimensional reconstruction process. Based on this, the ratio of the number of matching point pairs C that satisfy the optimal basic matrix constraint to the total number of matching point pairs is used as the matching score of the image pair, so that the initial image pair and the newly added image are selected based on the matching score, which is equivalent to selecting the image pair that contributes the most to the accurate three-dimensional reconstruction as the initial image pair through geometric verification, and optimizing the order of adding the newly added image, thereby increasing the number of three-dimensional space points in the reconstruction result, reducing outliers, reducing reprojection errors, and restoring more details of the photographed object. Therefore, compared with the existing incremental SFM method, the embodiment of the present invention improves the robustness of the incremental SFM method to a certain extent.
[0160] Therefore, by using the incremental motion recovery structure method provided by the embodiment of the present invention to restore a dense point cloud for a photographed object, the point cloud density of the obtained dense point cloud can be made higher.
[0161] Specifically, the process of restoring a dense point cloud for a photographed object using the incremental structure-from-motion method provided by an embodiment of the present invention may include:
[0162] (1) After deleting the outlier points whose reprojection errors exceed the third threshold, continue to use the matching points with known three-dimensional spatial coordinates as the initial seed points, and use the zero-mean normalized cross correlation coefficient (ZNCC) of the image and the image continuity constraint as the matching criteria to perform matching point diffusion in the spatial area where the photographed object is located to obtain the diffusion result;
[0163] (2) Based on the diffusion result, the incremental motion recovery SFM method is performed again to recover the dense point cloud of the photographed object.
[0164] Specifically, for each image pair in the image sequence, the matching points with known three-dimensional spatial coordinates are used as initial seed points, and their zero-mean normalized mutual correlation coefficients and image continuity constraints are used as matching criteria. The matching points are diffused in the spatial area where the photographed objects are located to obtain diffusion results.
[0165] Among them, the expression of the zero-mean normalized cross-correlation coefficient is:
[0166]
[0167] In this formula, and Respectively represent the average gray value of all pixels in the neighborhood window w on the two images, I(x+i, y+j) and I′(x+i, y+j) represent the gray value of the pixel in the window w on the two images that is offset (i, j) from the center point. The larger the ZNCC value, the greater the similarity between the two points, and the higher the probability of being a correct match.
[0168] See also Figure 5 As shown, when performing matching point diffusion, a feature point L on the first image in the known image pair t and the feature point R on the second image t is a matching relationship, then L t A point L in the neighborhood b The matching point R on the second image b Must be located at R t The red box in the figure represents a 3×3 neighborhood window. Therefore, point R b The search range is reduced from the entire image to the feature point R t In the neighborhood of , in practical applications, the neighborhood window size is generally selected to be 3×3 or 5×5. In the search process, ZNCC is introduced to measure the similarity between two points.
[0169] In addition, since ZNCC uses the grayscale value of pixels to measure the similarity between two points, the grayscale values of pixels in areas with very little texture information and extremely consistent grayscale are extremely close, which can easily cause mismatches. In order to avoid this situation, the diffusion area of the feature points can be constrained so that they only propagate in the matching area to ensure image continuity. Specifically, the grayscale can be used to constrain the area. If the maximum grayscale value of the area is greater than a certain set threshold, it is a matching area. The mathematical expression of this constraint is:
[0170] C(x)>p,
[0171] C(x)=max|I(x+Δx)-I(x)|,
[0172] Δx∈(0,-1),(0,1),(1,0),(-1,0);
[0173] Wherein, C(x) represents the maximum grayscale difference between the feature point I and its adjacent four points above, below, left and right. p is a set threshold value, which can be 0.01, but is not limited thereto.
[0174] In practical applications, the specific implementation process of the above step (1) can be seen as follows:
[0175] (a) First, create a priority queue, then calculate the ZNCC values of the matching points in the two images and put the feature points into the queue in descending order of their ZNCC values.
[0176] (b) For each image, create a matrix of the same size as the image and containing only 0s and 1s, where 0 means that the pixel at that position has not found a matching point in the other image, and conversely, 1 means that the pixel at that position has found a matching point in the other image. This matrix is called a marker matrix. During initialization, set the values of all feature point locations to 0.
[0177] (c) Take the feature point with the highest ZNCC value from the priority queue and delete it from the queue. In this paper, the neighborhood window size is selected as 5×5 to determine whether the point is located in the area where the photographed object is located and whether the neighborhood of the seed point is a matchable neighborhood. If the conditions are met, there is a neighborhood window w.
[0178] (d) In the neighborhood window w, calculate the ZNCC value of the point to be matched and each pixel in the search range, and put each pixel in the search range into a temporary local queue in descending order of ZNCC value. If its ZNCC value exceeds the set threshold and has not been matched (the corresponding position in the marker matrix is 0), the point is considered to be a correct match for the point to be matched. If there are multiple points that are greater than the threshold and have not been matched, the point with the largest ZNCC value is taken as the correct match point. Then update the marker matrix and put it into the corresponding position in the priority queue according to the size of the ZNCC value, and continue to diffuse as a seed point. The seed point diffusion adopts the four-connected domain method.
[0179] (e) Repeat steps (c) to (d) until the priority queue is empty.
[0180] By executing the above step (1), the matching relationship between almost every pixel point in each image pair in the image sequence except the weak texture area has been found, that is, the above diffusion result. Next, we only need to use the matching relationship of the points and the projection matrix to restore the three-dimensional spatial coordinates of the points.
[0181] Specifically, in the above step (2), the incremental SFM reconstruction method provided by the embodiment of the present invention is continued to be used to obtain a dense point cloud. The specific process is shown in the figure. It can be seen that incremental reconstruction is an iterative process. It first uses the initial image pair and dense matching point pair determined in the previous text as the basis for the reconstruction stage, and then enters a loop process, which includes three steps: 1) Calculate the coordinates of the three-dimensional space point according to the triangulation principle and the corresponding projection matrix; 2) Back-project all generated three-dimensional points back to the image, and calculate the reprojection error of all three-dimensional points; 3) Delete abnormal points, that is, discard points whose reprojection error exceeds the threshold. When the reconstruction of all images is completed, the dense point cloud of the model can be obtained.
[0182] Optionally, in order to achieve a better three-dimensional reconstruction effect, after the dense point cloud of the photographed object is restored, outliers in the dense point cloud may be further deleted according to the principle of statistical filtering.
[0183] In order to verify the beneficial effects of the embodiments of the present invention, the embodiments of the present invention are described below in combination with experimental results:
[0184] Experiment 1, taking the David sculpture as the shooting object to shoot multi-viewpoint images. Then, the three-dimensional reconstruction is performed using the traditional incremental SFM method and the incremental SFM method provided by the embodiment of the present invention, respectively, and the reconstruction effect diagrams are shown in Figure 7 (a) and Figure 7 (b) respectively. Among them, Figure 7 (a) is the effect diagram of the traditional incremental SFM method, and Figure 7 (b) is the effect diagram of the incremental SFM method provided by the embodiment of the present invention.
[0185] By comparison, it can be seen that the point cloud generated by the incremental SFM method provided by the embodiment of the present invention has fewer outliers, and the point cloud density at David's chin is higher.
[0186] Experiment 2, taking a rabbit sculpture as the shooting object to shoot multi-viewpoint images. Then, the three-dimensional reconstruction is performed using the traditional incremental SFM method and the incremental SFM method provided by the embodiment of the present invention, respectively, and the reconstruction effect diagrams are shown in Figure 8 (a) and Figure 8 (b) respectively. Among them, Figure 8 (a) is the effect diagram of the traditional incremental SFM method, and Figure 8 (b) is the effect diagram of the incremental SFM method provided by the embodiment of the present invention.
[0187] By comparison, it can be seen that the incremental SFM method provided by the embodiment of the present invention has achieved a certain degree of optimization in the point cloud shape of the upper part of the rabbit ear compared with the traditional method.
[0188] Experiment 3, taking a box as the shooting object to shoot multi-viewpoint images. Then, three-dimensional reconstruction is performed using the traditional incremental SFM method and the incremental SFM method provided by the embodiment of the present invention, respectively, and the reconstruction effect diagrams are shown in Figure 9 (a) and Figure 9 (b) respectively. Among them, Figure 9 (a) is the effect diagram of the traditional incremental SFM method, and Figure 9 (b) is the effect diagram of the incremental SFM method provided by the embodiment of the present invention.
[0189] By comparison, it can be seen that the point cloud generated by the incremental SFM method provided by the embodiment of the present invention fills part of the hole in the lower left corner of the box, which is better than the traditional incremental SFM method.
[0190] Experiment 4, taking a pillow as the shooting object to shoot multi-viewpoint images. Then, three-dimensional reconstruction is performed using the traditional incremental SFM method and the incremental SFM method provided by the embodiment of the present invention, respectively, and the reconstruction effect diagrams are shown in Figure 10 (a) and Figure 10 (b) respectively. Among them, Figure 10 (a) is the effect diagram of the traditional incremental SFM method, and Figure 10 (b) is the effect diagram of the incremental SFM method provided by the embodiment of the present invention.
[0191] By comparison, it can be seen that the point cloud generated by the incremental SFM method provided by the embodiment of the present invention fills part of the hole under the pillow, which is also better than the traditional incremental SFM method.
[0192] Table 1 shows the detailed experimental data of the incremental SFM method provided by the embodiment of the present invention and the traditional incremental SFM method in the above experiments 1 to 4.
[0193] Table 1 Point cloud statistics
[0194]
[0195]
[0196] Based on Table 1, it can be seen that due to the different emphasis of the scenes in the four groups of images, the number of three-dimensional space points reconstructed by the two methods in different images varies. However, for the point cloud models reconstructed from the rabbit image, the box image, and the pillow image, the embodiment of the present invention reconstructs more three-dimensional space points than the traditional method. At the same time, the average reprojection error of the traditional incremental SFM method is 1.593 pixels, while the average reprojection error of the embodiment of the present invention is 1.3857 pixels, which proves that the point cloud generated by the incremental SFM method provided by the embodiment of the present invention has a smaller reprojection error.
[0197] The method provided in the embodiment of the present invention can be applied to an electronic device. Specifically, the electronic device can be: a desktop computer, a portable computer, an entertainment device or a server, etc. This is not limited here, and any electronic device that can implement the present invention belongs to the protection scope of the present invention.
[0198] It should be noted that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0199] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification.
[0200] Although the present invention is described herein in conjunction with various embodiments, in the process of implementing the claimed invention, a person skilled in the art may understand and implement other variations of the disclosed embodiments by viewing the drawings, the disclosure, and the appended claims.
[0201] The present invention is described with reference to the flowchart of the method of the embodiment of the present invention. It should be understood that each process and combination of processes in the flowchart can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified by one or more processes in the flowchart.
[0202] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A function specified in a process or multiple processes.
[0203] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 The steps of a specified function in a process or multiple processes.
[0204] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as falling within the protection scope of the present invention.
Claims
1. An incremental structure-from-motion method for optimizing the order of image addition, characterized in that: include: Acquire a multi-view image captured by a camera; the multi-view image includes a plurality of images; The SIFT algorithm is used to detect the feature points of each image, and every two images are taken as an image pair, and the matching points between each image pair are determined based on the detected feature points; For each image pair, the RANSAC algorithm is used to find the optimal basic matrix based on its matching points; wherein, among the pairs of matching points between the image pairs, the number of matching point pairs C that satisfy the constraints of the optimal basic matrix is the largest; The ratio of the number of matching point pairs C of the image pair to the total number of matching point pairs of the image pair is used as the matching score of the image pair; An incremental structure-from-motion (SFM) method is performed, wherein an image pair with the highest matching score is selected as an initial image pair, and an additional image is determined based on the matching score of the image pair; Wherein, determining the matching points between each image pair based on the detected feature points includes: calculating the Euclidean distance between every two feature points between the image pairs to obtain a calculation result; for each feature point, if the ratio of the minimum Euclidean distance and the second minimum Euclidean distance associated with the feature point in the calculation result is less than a preset first threshold, determining another feature point associated with the minimum Euclidean distance as an initial matching point for the feature point; and using each pair of feature points in the image pair that are initial matching points to each other as matching points between the image pairs; For each image pair, the RANSAC algorithm is used to find the optimal basic matrix based on its matching points, including: A. Initialize the number of iterations and set the upper limit of the number of iterations; B. Randomly select 8 pairs of matching points of the image pair as random samples, and calculate a basic matrix of the image pair based on the random samples; C. Based on the calculated basic matrix, calculate the distance from each pair of matching points of the image pair to the corresponding epipolar line; D. Compare each calculated distance with a preset second threshold value. If the calculated distance is less than the second threshold value, record the pair of matching points with the distance as an inlier. Otherwise, do not record them as inliers. Count the number of inliers in this iteration, then end this iteration and increase the number of iterations by 1. E. Determine whether the current number of iterations has reached the upper limit of the number of iterations; if not, return to step B; if it has reached, use the basic matrix calculated in the iteration with the largest number of internal points as the optimal basic matrix for the image pair.
2. The method according to claim 1, characterized in that The upper limit of the number of iterations is estimated by the following formula: Among them, w 8 It is expected that the probability that the 8 pairs of matching points selected in step B will be recorded as internal points in step D, and p represents the probability that the optimal basic matrix can be obtained after k iterations.
3. The method according to claim 1, characterized in that The method of performing incremental motion recovery structure SFM includes: The multi-view images are sorted to form an image sequence; in the image sequence, the initial image pair is the first two images, and the newly added image adjacent to the i-th image is the image with the highest matching score with the i-th image; 2≤i≤X, X is the total number of the multiple images included in the multi-view images; The image pairs formed by every two adjacent images in the image sequence are processed in turn, including: calculating the three-dimensional space coordinates of the object photographed by the camera according to the optimal basic matrix of the image pair, the homogeneous coordinates of the matching points, and the intrinsic parameter matrix of the camera; after calculating the three-dimensional space coordinates, if the processing object is not the initial image pair, performing cluster adjustment.
4. The method according to claim 3, characterized in that The method further comprises: After processing the last image pair in the image sequence, outliers whose reprojection errors exceed a preset third threshold are deleted from the finally obtained three-dimensional space coordinates.
5. The method according to claim 4, characterized in that After deleting the outliers whose reprojection errors exceed a preset third threshold, the method further includes: Using a matching point with known three-dimensional spatial coordinates as an initial seed point, and using a zero-mean normalized correlation coefficient of the image and an image continuity constraint as a matching criterion, performing matching point diffusion in the spatial region where the photographed object is located to obtain a diffusion result; Based on the diffusion result, the incremental structure from motion (SFM) method is executed again to restore a dense point cloud of the photographed object.
6. The method according to claim 5, characterized in that After recovering the dense point cloud, the method further comprises: Outlier points in the dense point cloud are deleted according to the principle of statistical filtering.
7. The method according to claim 2, characterized in that w=0.9, p=0.
97.
8. The method according to claim 1, characterized in that The first threshold is 0.7±0.1.
