Three-dimensional reconstruction method and device based on multiple ArUco codes
By using the method of multiple ArUco codes in 3D reconstruction, combined with the geometric constraints of beam adjustment and ArUco codes, the problem of low computational efficiency and scale definition of 3D reconstruction is solved, achieving efficient and accurate 3D reconstruction and reducing equipment costs. .
Patent Information
- Application Number
- CN202410661661.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-09-06
AI Technical Summary
Existing 3D reconstruction methods have low computational efficiency, lack of real scale and world coordinate system definition, and traditional acquisition equipment is expensive and bulky, making it difficult to achieve efficient and low-cost 3D reconstruction.
A three-dimensional reconstruction method based on multiple ArUco codes is adopted. Multiple ArUco codes are placed around the object to be reconstructed, and continuous videos are captured using a camera calibrated with internal parameters. The initial camera pose and ArUco code pose are calculated, combined with beam adjustment. Sparse point cloud optimization enables dense reconstruction and maintains the true scale and world coordinate system definition through the geometric constraints of the ArUco code.
It greatly improves the computational efficiency and robustness of 3D reconstruction, automatically restores the true scale of objects, comes with its own world coordinate system definition, and the acquisition equipment is light and flexible, with low cost, avoiding the increase in calculation time of incremental sparse reconstruction in traditional methods. and manual labeling errors.
Smart Images

Figure CN118608686A
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of machine vision, and in particular relates to a three-dimensional reconstruction method and device based on multiple ArUco codes. Background Art
[0002] 3D reconstruction belongs to the classic research field of computer vision, which is applied to common fields such as 3D modeling, digital twins and AR / VR. 3D reconstruction generally includes two steps: sparse reconstruction and dense reconstruction. Sparse reconstruction refers to the calculation of the sparse point cloud and camera pose of the object through multi-view images as input. Dense reconstruction usually refers to dense point cloud computing or 3D mesh computing, which uses camera pose and sparse point cloud as input to output a denser 3D model. Sparse reconstruction directly determines the upper limit of the quality of dense reconstruction.
[0003] The mainstream sparse reconstruction methods are divided into global and incremental methods, both of which rely on matching image feature points for pose estimation. Among them, the core of the global reconstruction method is to solve the global rotation average. This method only needs to perform a bundle adjustment at the end, so it is more efficient, but not as robust as the incremental reconstruction method. The famous 3D reconstruction open source library COLMAP is implemented using the incremental sparse reconstruction method. It is often used in modern 3D reconstruction tasks and has almost become one of the essential tools in this field. Incremental reconstruction requires a bundle adjustment after each image is added, resulting in low computational efficiency. Especially when a large number of images are input, the computational time of incremental reconstruction will increase significantly. How to improve computational efficiency while ensuring robustness becomes a difficult problem. Moreover, when there are fewer texture features, the mainstream reconstruction method will produce large errors in camera pose estimation, and there will not even be enough matching features to support pose estimation.
[0004] In addition, if the image is used as input alone, the camera pose calculated from the image features does not have the scale of the real world, which means that the reconstructed 3D point cloud also does not have the scale of the real world and is not defined in a certain world coordinate system. The common approach is to find the control points in the image and know the 3D information of the control points in advance. In this way, the point cloud and camera pose with scale and specific coordinate system can be restored by using the mainstream sparse reconstruction algorithm. However, control points usually need to be manually marked, which not only consumes manpower, but also has inevitable human errors. There are also some cutting-edge algorithms that use specially designed markers for scale restoration, but they are usually used as a post-processing task for 3D reconstruction alone, and they still cannot deviate from the mainstream technical route.
[0005] Using a calibrated multi-camera system for image acquisition is an effective traditional solution, because the camera position can be calculated in advance through external parameter calibration and contains real-world scale information. In order to obtain images from different perspectives, it is necessary to build expensive acquisition equipment, which generally includes multiple industrial cameras and a high-precision controlled rotating turntable. The equipment is often inconvenient to carry or move. Once the camera position or shooting angle in the device changes, the external parameter calibration needs to be performed again, which brings various inconveniences.
[0006] In summary, it is necessary to develop a three-dimensional reconstruction method that has high computational efficiency, can restore the true scale of objects, has its own world coordinate system definition, and requires lightweight, flexible, and low-cost acquisition equipment. Summary of the invention
[0007] In view of the above, the purpose of the present invention is to provide a three-dimensional reconstruction method and device based on multiple ArUco codes, which, on the one hand, improves the computational efficiency and robustness of the three-dimensional reconstruction process, and on the other hand, can restore the true scale of the object and come with its own world coordinate system definition, and the required acquisition equipment is light, flexible and low-cost.
[0008] In order to achieve the above-mentioned invention object, the technical solution provided by the present invention is as follows:
[0009] An embodiment of the present invention provides a three-dimensional reconstruction method based on multiple ArUco codes, comprising the following steps:
[0010] Place multiple ArUco codes around the object to be reconstructed, use the camera calibrated with internal parameters to shoot continuous video around the object to be reconstructed and the ArUco code, and evenly sample the video to obtain multiple images;
[0011] Calculate the initial camera pose and ArUco code pose based on multiple images, and preliminarily optimize the initial camera pose and ArUco code pose by minimizing the reprojection error;
[0012] Extract and match feature points from multiple images, and calculate the sparse point cloud based on the camera’s calibrated internal parameters, the camera’s preliminarily optimized pose, and the matched feature points;
[0013] The sparse point cloud, the camera's calibrated internal parameters, the camera's preliminarily optimized pose, and the ArUco code's preliminarily optimized pose are globally optimized through bundle adjustment.
[0014] Dense reconstruction is performed using multiple images, globally optimized camera poses, and globally optimized sparse point clouds to obtain a 3D mesh model with a texture map as the 3D reconstruction result of the object.
[0015] Preferably, placing a plurality of ArUco codes around the object to be reconstructed includes:
[0016] Keep the object to be reconstructed still, and place multiple ArUco codes of the same size around it without overlapping each other.
[0017] Preferably, the camera calibrated with the intrinsic parameters shoots continuous video around the object to be reconstructed and the ArUco code, and uniformly samples the video to obtain multiple images, including:
[0018] First, the internal parameters of the monocular camera in video shooting mode are calibrated. The internal parameters include focal length, image principal point and lens distortion parameters. Then, the camera with internal parameter calibration is used to shoot at least one circle of continuous video around the object to be reconstructed to ensure that each frame in the video contains at least two complete ArUco codes. Then, multiple images are evenly sampled in the video according to the set sampling frequency.
[0019] Preferably, the initializing the camera pose and the initializing the ArUco code pose based on the calculation of the multiple images comprises:
[0020] Iterate over multiple images Among them I i For the i-th image among a total of N images, detect all ArUco codes in the image The coordinates of the corner points, where m j For the jth ArUco code among the M ArUco codes, the transformation matrix from the local coordinate system of the ArUco code to the camera coordinate system is calculated using the PnP algorithm according to the corner point coordinates Among them C i is the camera in the shooting state corresponding to the i-th image;
[0021] Define the local coordinate system of ArUco code m1 as the world coordinate system W, and calculate the initial camera pose for all images containing ArUco code m1: in From world coordinate system W to camera C i Transformation matrix of the coordinate system;
[0022] Traverse all ArUco codes until the calculation is completed to get all the initialized camera poses For the ArUco code m j A pair of images I among all images of a and I b , a and b∈{1,2,…,N}, we have obtained and If there is an image I that has been calculated a The initial camera pose is Then calculate image I b The initial camera pose is
[0023] Traverse all ArUco codes, for those containing ArUco code m j Any image I i , calculate its initialization ArUco code pose as in is the ArUcode m j The transformation matrix from the local coordinate system to the world coordinate system W.
[0024] Preferably, the formula for minimizing the reprojection error is:
[0025]
[0026] Among them, the total number of multiple images is N, and the total number of multiple ArUco codes is M; is the camera pose, W is the world coordinate system, C i is the camera in the shooting state corresponding to the i-th image; is the ArUco code pose, m j is the jth ArUco code; Y q Y1=(0,0,0,1),Y2=(w,0,0,1),Y3=(w,w,0,1),Y4=(0,w,0,1) are the homogeneous coordinates of the four corner points in the local coordinate system of the ArUco code, w is the side length of the ArUco code; π(·) is the projection function of the camera, and μ is the intrinsic parameter of the camera; is the jth ArUco code m j In the i-th image I i The coordinates of the qth corner point in the corresponding Y q , is a two-dimensional real matrix; if the ArUco code m j The four corner points can be found in image I i If detected in ij =1, otherwise v ij =0; ρ(·) is the robust kernel function;
[0027] During the initial optimization solution, the initial values of the camera pose and ArUco code pose come from the initialization camera pose and the initialization ArUco code pose, respectively.
[0028] Preferably, a scale-invariant feature conversion algorithm is used to extract and match feature points from multiple images, and a sparse point cloud is obtained through preliminary triangulation calculation.
[0029] Preferably, the global optimization of the sparse point cloud, the camera calibrated internal parameters, the camera pose after preliminary optimization and the ArUco code pose after preliminary optimization by bundle adjustment includes:
[0030] The bundle adjustment is to solve the following nonlinear global optimization problem:
[0031]
[0032] Among them, the total number of multiple images is N, and the total number of multiple ArUco codes is M; is the camera pose, W is the world coordinate system, C i is the camera in the shooting state corresponding to the i-th image; is the ArUco code pose, m j is the jth ArUco code; Y q Y1=(0,0,0,1),Y2=(w,0,0,1),Y3=(w,w,0,1),Y4=(0,w,0,1) are the homogeneous coordinates of the four corner points in the local coordinate system of the ArUco code, w is the side length of the ArUco code; π(·) is the projection function of the camera, and μ is the intrinsic parameter of the camera; is the jth ArUco code m j In the i-th image I i The coordinates of the qth corner point in the corresponding Y q , is a two-dimensional real matrix; if the ArUco code m j The four corner points can be found in image I i If detected in ij =1, otherwise v ij =0; ρ(·) is the robust kernel function; λ is a non-negative constant coefficient; x ip For sparse point clouds The pth 3D point X in p In the image I i The corresponding 2D coordinates in P are the 3D points X p The total number of; superscript T is transposed; if X p In the image I i It can be seen that t ip =1, otherwise t ip =0;
[0033] During global optimization solution, the initial value of the sparse point cloud comes from the sparse point cloud obtained by preliminary calculation, the initial value of the camera intrinsic parameter comes from the intrinsic parameter after camera calibration, the initial value of the camera pose comes from the camera pose after preliminary optimization, and the initial value of the ArUco code pose comes from the ArUco code pose after preliminary optimization.
[0034] Preferably, the dense reconstruction using multiple images, the globally optimized camera pose and the globally optimized sparse point cloud to obtain a three-dimensional mesh model with a texture map as a three-dimensional reconstruction result of the object includes:
[0035] Dense point cloud is obtained by computing multiple images, globally optimized camera poses and globally optimized sparse point cloud.
[0036] Compute its grid model based on dense point cloud;
[0037] Texture mapping is performed based on the mesh model and multiple images to obtain a three-dimensional mesh model with a texture map, thus completing the three-dimensional reconstruction of the object.
[0038] Preferably, after the dense point cloud is calculated, the dense point cloud is first filtered to remove redundant point clouds, and then its grid model is built based on the filtered dense point cloud. The filtering method includes:
[0039] Select a plane determined by the ArUco code or set a height value h based on the plane, and remove redundant point clouds below or above the plane or the plane determined based on the height h;
[0040] For images with complex backgrounds, the position of the local origin of the ArUco code in the world coordinate system is extracted from the ArUco code pose after preliminary optimization or global optimization. The x-axis and y-axis are determined by the plane where the ArUco code is located. The bounding box information is obtained from multiple ArUco codes. The bounding box is determined by the range value on the x-axis and the range value on the y-axis, thereby removing the redundant point cloud outside the bounding box.
[0041] For clean background images shot with a backdrop, the color brightness of the point cloud is calculated, and points with color brightness lower than a set threshold are determined to be background points. All background points are removed as redundant point clouds.
[0042] To achieve the above-mentioned purpose of the invention, an embodiment of the present invention further provides a three-dimensional reconstruction device based on multiple ArUco codes, comprising: an image acquisition module, a preliminary pose optimization module, a sparse point cloud computing module, a global optimization module and a dense reconstruction module;
[0043] The image acquisition module is used to place multiple ArUco codes around the object to be reconstructed, use a camera calibrated with internal parameters to shoot continuous video around the object to be reconstructed and the ArUco code, and uniformly sample the video to obtain multiple images;
[0044] The pose preliminary optimization module is used to calculate the initialization camera pose and the initialization ArUco code pose based on multiple images, and to perform preliminary optimization on the initialization camera pose and the initialization ArUco code pose by minimizing the reprojection error;
[0045] The sparse point cloud computing module is used to extract and match feature points from multiple images, and preliminarily calculate the sparse point cloud based on the internal parameters after camera calibration, the camera posture after preliminary optimization and the matched feature points;
[0046] The global optimization module is used to globally optimize the sparse point cloud, the internal parameters after camera calibration, the camera pose after preliminary optimization, and the ArUco code pose after preliminary optimization through bundle adjustment;
[0047] The dense reconstruction module is used to perform dense reconstruction using multiple images, globally optimized camera poses and globally optimized sparse point clouds to obtain a three-dimensional mesh model with a texture map as a three-dimensional reconstruction result of the object.
[0048] Compared with the prior art, the present invention has the following beneficial effects:
[0049] (1) The three-dimensional reconstruction method proposed in the present invention benefits from the geometric characteristics naturally possessed by the ArUco code (each ArUco code can define an independent local three-dimensional coordinate system with a specific scale), which can automatically restore the true scale of the object to be reconstructed, and can also come with a defined world coordinate system without the need for additional scale calibration or coordinate system alignment. Based on the known world coordinate system, accurate and effective point cloud filtering can be achieved, that is, redundant point clouds are eliminated through planes or bounding boxes. In the dense reconstruction process, point cloud filtering can avoid unnecessary mesh reconstruction or texture mapping, thereby effectively improving the overall reconstruction quality, reducing the amount of calculation and saving computing memory.
[0050] (2) The present invention has opened up a new sparse reconstruction idea, combining the camera pose calculation based on multiple ArUco codes and the sparse point cloud calculation based on feature point matching, successfully avoiding the incremental sparse reconstruction often used in traditional reconstruction methods, thereby greatly improving the computational efficiency. In its sparse reconstruction method, the present invention adds geometric constraints based on multiple ArUco codes to the traditional bundle adjustment method, while globally optimizing the point cloud and pose, it can also not lose the true scale or the known world coordinate system, and also promotes a more robust solution of the bundle adjustment method, outputting more accurate camera internal and external parameters and sparse point clouds.
[0051] (3) The present invention realizes a low-cost, lightweight and flexible data acquisition configuration. There is no need to build industrial camera equipment or a multi-camera system. Only a monocular camera and a set of ArUco codes are needed to complete the data acquisition required for three-dimensional reconstruction. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0053] Figure 1is a flow chart of a three-dimensional reconstruction method based on multiple ArUco codes provided in an embodiment of the present invention;
[0054] Figure 2 This is a schematic diagram of the top view of the ArUco code placement provided by an embodiment of the present invention;
[0055] Figure 3 exemplified images of real shots from three different viewing angles in the same video input provided by an embodiment of the present invention;
[0056] Figure 4 is a schematic diagram of a dense point cloud without filtering provided by an embodiment of the present invention;
[0057] Figure 5 It is a schematic diagram of a three-dimensional mesh model reconstructed from a filtered dense point cloud and a three-dimensional mesh model obtained after texture mapping provided by an embodiment of the present invention;
[0058] Figure 6 It is a structural schematic diagram of a three-dimensional reconstruction device based on multiple ArUco codes provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific implementation methods described herein are only used to explain the present invention and do not limit the scope of protection of the present invention. It should be noted that, in the absence of conflict, the features in the following embodiments and implementation methods can be combined with each other.
[0060] The inventive concept of the present invention is: in view of the problems of low computational efficiency, lack of real scale and world coordinate system definition, or the requirement to build expensive, bulky and high-precision image acquisition equipment in the prior art three-dimensional reconstruction method, the embodiment of the present invention provides a three-dimensional reconstruction method and device based on multiple ArUco codes, through the camera pose calculation based on multiple ArUco code poses and sparse point cloud calculation based on feature point matching, the computational efficiency is greatly improved; in the sparse reconstruction process, by adding geometric constraints based on multiple ArUco codes to the bundle adjustment method, while globally optimizing the point cloud and pose, the real scale and the known world coordinate system can also be maintained, which promotes a more robust solution of the bundle adjustment method, thereby outputting more accurate camera internal and external parameters and sparse point clouds; in the dense reconstruction process, unnecessary grid reconstruction or texture mapping can be avoided by filtering the point cloud, thereby effectively improving the overall reconstruction quality, reducing the amount of calculation and saving computing memory. The present invention only needs to prepare a monocular camera and a set of ArUco codes to complete the data acquisition required for three-dimensional reconstruction, and can achieve low-cost, lightweight and flexible data acquisition configuration.
[0061] Figure 1FIG. 1 is a flow chart of a 3D reconstruction method based on multiple ArUco codes provided in an embodiment of the present invention. Figure 1 As shown, the embodiment provides a three-dimensional reconstruction method based on multiple ArUco codes, comprising the following steps:
[0062] First, define ζ W→C is the transformation matrix from coordinate system W to coordinate system C: Where R is a 3×3 rotation matrix, t is a 3×1 translation matrix, and SE(3) is the three-dimensional special Euclidean group.
[0063] Take any point X in three-dimensional space as an example. If the point is defined in coordinate system C, then Defined in coordinate system W, ζ W→C The corresponding coordinate transformation can be constructed:
[0064]
[0065] In the camera extrinsic calibration problem of the embodiment of the present invention, W is the world coordinate system, C is the camera, m is the ArUco code, ζ W→C is the absolute position of camera C, i.e., the camera external parameter, ζ m→W is the absolute position of ArUcode m.
[0066] S1. Camera internal parameter calibration. In order to facilitate the camera pose estimation in the later stage, the internal parameters of the monocular camera in the video shooting mode are calibrated to obtain the camera's internal parameters: focal length, image principal point and lens distortion parameters. This step only needs to be performed once, and the camera can be used repeatedly for data collection.
[0067] Specifically, the calibration plate is moved back and forth, and a continuous video of at least 1 minute is shot with a camera, and then the video is uniformly sampled into multiple images. In the embodiment, sampling is performed at 1 frame per second, and then the findChessboardCorners function in the open source library OpenCV is used to detect the 2D corner coordinates of the calibration plate, and then the calibrateCamera function is used to obtain the camera intrinsic parameters.
[0068] After calibration, the camera internal parameters are obtained, and the internal parameter matrix is Where (f x ,f y ) is the focal length, (c x ,c y ) is the principal point of the image, and the distortion parameters of the camera are (k1, k2, k3). Define the camera model (i.e., camera projection function) to facilitate the subsequent pose calculation and bundle adjustment steps. The camera projection function π(·) is to project the three-dimensional coordinate point to the image coordinate system:
[0069] π([xyz 1] T ; μ) = [uv] T
[0070] Among them, the camera internal parameter μ=(f x ,f y ,c x ,c y ,k1,k2,k3), x, y and z are the values of the three directions of the coordinate axes in the three-dimensional coordinates, u and v are the values of the two directions of the coordinate axes in the two-dimensional coordinates, and T is the transpose.
[0071] If only radial distortion is considered, the above projection includes the following transformations:
[0072]
[0073] r = x ′2 +y ′2
[0074] r ′ =1+k1r+k2r 2 +k3r 3
[0075] u=f x r ′ x ′ +c x ,v=f y r ′ y ′ +c y .
[0076] S2. Place a group of ArUco codes. Keep the object to be reconstructed still, and place a group of ArUco codes of the same size around it, so that they do not overlap each other, for a total of M ArUco codes.
[0077] Specifically, the printed ArUco code has the same side length. If the side length is w (for example, 7 cm), the four corner points correspond to (0,0,0), (w,0,0), (w,w,0), (0,w,0) in clockwise order, thereby defining the local coordinate system and the real physical scale of the ArUco code. In the embodiment, the function aruco.generateImageMarker in OpenCV is used to generate the ArUco code pattern, in which the dictionary of the ArUco code needs to be defined, and aruco.getPredefinedDictionary(aruco.DICT_4×4_50) is used to create a dictionary, and 50 independent ArUco code patterns are generated in this way.
[0078] like Figure 2As shown, in one embodiment, four ArUco codes m1, m2, m3 and m4 are placed clockwise at the four corners of the object to be reconstructed so that their origins ( Figure 2 The red points in the image) form a rectangular bounding box ( Figure 2 ), ensure that the origin of m2 is on the x-axis of m1, and the origin of m4 is on the y-axis of m1, and ensure that the ArUco code m1 and the bottom of the object are placed on the same plane, define the local coordinate system of m1 as the world coordinate system W, and only reconstruct objects above the plane and within the bounding box. In addition, in other embodiments, the ArUco code can be placed arbitrarily according to the needs of the site, and the size of the bounding box can be adjusted.
[0079] S3, obtaining image data. The continuous video obtained by shooting is uniformly sampled into multiple images.
[0080] Specifically, after adjusting the fill light conditions and camera exposure parameters, use a monocular camera to shoot at least one continuous video around the object to be reconstructed, and adjust the camera angle such as height, distance, etc. during the shooting. Figure 3 (a), (b) and (c) are three real shooting examples from different perspectives, ensuring that each frame in the video contains at least two complete ArUco codes. Then N images are uniformly sampled from the video. In the embodiment, the sampling frequency is at least 2 frames per second, and N images containing ArUco codes are accumulated.
[0081] In the embodiment, by arranging a background curtain at the shooting scene to generate a mask image, it is helpful to remove the background and improve the calculation efficiency.
[0082] S4. Initialize the camera and ArUco code poses. Calculate the initial camera pose and ArUco code pose based on multiple images.
[0083] Specifically, traverse all images Detect all ArUco codes in the image And perform ID recognition. In the embodiment, aruco.ArucoDetector in OpenCV is used to obtain the 2D coordinates of the four corner points of each ArUco code in each image, arranged clockwise. According to the known 2D coordinates of the corner points of the ArUco code and its corresponding 3D coordinates in the local coordinate system, the PnP algorithm (Perspective-n-Point, perspective n-point algorithm) is used to calculate the transformation matrix from the local coordinate system of the ArUco code to the camera coordinate system Among them, for the i-th image image I i Corresponding to the camera in a specific shooting state at a certain moment or in a specific posture, it is recorded as camera C i .
[0084] Define the local coordinate system of ArUco code m1 as the world coordinate system W, and calculate the initial camera pose for all images containing ArUco code m1 as:
[0085]
[0086] in, From world coordinate system W to camera C i The transformation matrix of the coordinate system.
[0087] Traverse all ArUco codes until the calculation is completed to get all the initialized camera poses For the ArUco code m j A pair of images I among all images of a and I b , a and b∈{1,2,…,N}, have been obtained by the above PnP algorithm and If there is an image I that has been calculated a The initial camera pose is Then calculate image I b The initial camera pose is:
[0088]
[0089] And so on.
[0090] Traverse all ArUco codes, for those containing ArUco code m j Any image I i , calculate its initialization ArUco code pose as:
[0091]
[0092] in, is the ArUcode m j The transformation matrix from the local coordinate system to the world coordinate system W.
[0093] S5. Preliminary optimization of all poses. After obtaining the initial estimate of the poses of the camera and the ArUco code, all poses are preliminarily optimized by minimizing the reprojection error.
[0094] Specifically, the formula for minimizing the reprojection error is expressed as follows:
[0095]
[0096] Among them, Y qY1=(0,0,0,1), Y2=(w,0,0,1), Y3=(w,w,0,1), Y4=(0,w,0,1) are the homogeneous coordinates of the four corner points in the local coordinate system of the ArUco code; π(·) is the projection function of the camera, and μ is the intrinsic parameter of the camera (obtained from step S1); is the ArUcode m j In the image I i The coordinates of the qth corner point in the corresponding Y q , is a two-dimensional real matrix; if the ArUco code m j The four corner points can be found in image I i If it is detected, then v ij =1, otherwise v ij =0; ρ(·) is a robust kernel function that can effectively reduce the impact of outliers. In the embodiment, the Cauchy loss function is used: where z is the residual of the reprojected coordinates.
[0097] To solve the above nonlinear least squares problem (minimizing the reprojection error), the Levenberg-Marquardt algorithm is used. After clearly defining the reprojection error function, the open source least squares solver is called for solution. In the embodiment, optimize.least_squares in SciPy is used. When solving, the initial value (i.e., the initial solution) needs to be defined in advance: camera pose And ArUco code pose The initial value of comes from the initialization camera pose and initialization ArUco code pose obtained in step S4, where the fixed For I 4×4 .
[0098] The core of step S5 is to use the geometric information of the ArUco code to make the camera pose have real physical meaning, such as 3D corner point coordinates The real physical scale is clarified, and the fixed For I 4×4 Compared with the traditional method which lacks scale and clear definition of coordinate system, the camera pose calculated by the method provided by the embodiment of the present invention is defined in a known world coordinate system and has a real physical scale.
[0099] Based on the above steps, the camera pose can be calculated without relying on texture features, and only the nonlinear least squares problem needs to be solved once, thereby greatly improving the calculation efficiency. In contrast, the incremental sparse reconstruction commonly used in traditional reconstruction methods requires repeated solutions to nonlinear least squares problems and gradually increases the complexity of the problem. During the implementation of the present invention, it was found that if more than 400 images are input, the method provided by the embodiment of the present invention saves at least half an hour in calculation time compared to the traditional method.
[0100] In the following steps, texture features will be used to further optimize the camera pose.
[0101] S6, extracting and matching feature points. Extract feature points from all images and match the feature points among them.
[0102] Specifically, the scale-invariant feature transform (SIFT) is used to extract feature points from all images, and the feature points are matched with each other. In the embodiment, the open source library COLMAP is used to implement this step, and the feature extraction is performed by using the feature_extractor in COLMAP, and the feature point matching is performed by using the exhaustive_matcher in COLMAP. Among them, exhaustive_matcher generally has a large amount of calculation and can produce a denser sparse point cloud. For a series of continuous images, using sequential_matcher instead of exhaustive_matcher is sufficient to ensure a certain accuracy.
[0103] S7. Preliminary calculation of sparse point cloud. According to the camera calibration internal parameters, the camera pose after preliminary optimization and the matched feature points, the sparse point cloud is calculated by triangulation. in
[0104] Specifically, the intrinsic parameter μ obtained by camera calibration and the camera pose after preliminary optimization are first entered into the COLMAP database. After completing the feature point matching, the sparse point cloud is calculated through the point_triangulator in COLMAP.
[0105] S8, global optimization of bundle adjustment. Global optimization of sparse point cloud, camera pose, camera intrinsic parameters and ArUco code pose is performed through bundle adjustment.
[0106] Specifically, the bundle adjustment method solves the following nonlinear global optimization problem:
[0107]
[0108] Among them, λ is a non-negative constant coefficient used to control the weight of the geometric constraint based on multiple ArUco codes; x ip For sparse point clouds The pth 3D point X in p In the image I i The corresponding 2D coordinates in P are the 3D points X p The total number of; superscript T is transposed; if the ArUco code m j The four corner points can be found in image I i If it is detected, then v ij =1, otherwise v ij =0; if X p In the image I i It can be seen that t ip =1, otherwise t ip =0.
[0109] The Levenberg-Marquardt algorithm is used to solve the above nonlinear least squares problem (nonlinear global optimization problem). The initial value (i.e. initial solution) needs to be defined in advance: sparse point cloud The initial value of comes from step S7, the camera internal parameter μ comes from step S1, and the camera pose And ArUco code pose The initial value of comes from the pose after preliminary optimization in step S5.
[0110] If only a simple implementation is considered, λ = 0 is selected, that is, the geometric constraints based on multiple ArUco codes are removed. At this time, the camera intrinsic parameter μ should be fixed, otherwise it will indirectly affect the scale information, which is equivalent to solving the conventional bundle adjustment method:
[0111]
[0112] The solution to this problem is to directly call bundle_adjuster in COLMAP, because the camera parameters need to be fixed, where BundleAdjustment.refine_focal_length and BundleAdjustment.refine_extra_params both need to be set to 0.
[0113] If complex implementation is considered, that is, the case of λ>0, solving the original nonlinear global optimization problem will obtain more accurate camera intrinsic parameters and camera pose, and at the same time obtain a more accurate sparse point cloud, which is more in line with the actual physical scale. When solving, refer to bundle_adjuster in COLMAP, and mainly modify the defined residual function: add the geometric constraints based on multiple ArUco codes to the original reprojection error function. For solving such large nonlinear least squares problems, refer to the Ceres solver used in bundle_adjuster.
[0114] S9, dense reconstruction. Including calculation of dense point cloud, filtering of dense point cloud, mesh reconstruction and texture mapping.
[0115] Specifically, input all images After global optimization of the camera pose and the sparse point cloud, we calculate the dense point cloud. This step is achieved by using DensifyPointCloud in the open source library OpenMVS. The result is as follows Figure 4 As shown, the blue line with a downward arrow represents the z-axis.
[0116] Specifically, the dense point cloud is filtered, and a plane is first selected to remove the point cloud below it. In the embodiment, the plane determined by the ArUco code is selected and the redundant point cloud with coordinate z greater than 0 is removed, or the height value h is set based on the plane determined by the ArUco code and then the redundant point cloud with coordinate z greater than -h is removed.
[0117] For images with complex backgrounds such as outdoor scenes, the ArUco code pose after preliminary optimization or global optimization is Extract the position of the local origin of the ArUco code in the world coordinate system, such as Figure 2 As shown, the bounding box information, namely the range value on the x-axis and the range value on the y-axis, can be obtained from the ArUco codes m1, m2, m3 and m4, thereby removing the redundant point cloud outside the bounding box.
[0118] For indoor scenes, if a background curtain is used for shooting, such as a pure black background curtain, the color brightness of the point cloud (Value in the HSV color space) is calculated, and the points with color brightness lower than the set threshold are judged as background points, and then all background points are removed as redundant point clouds.
[0119] Filtering the dense point cloud before mesh reconstruction can improve computational efficiency, improve overall reconstruction quality, and save computational memory. These benefits are not achieved if vertex culling is performed on the entire mesh after dense reconstruction.
[0120] Specifically, based on the filtered dense point cloud, its mesh model is further calculated. In the embodiment, ReconstructMesh in OpenMVS is used to perform rough reconstruction to generate a mesh model. Then, the mesh is refined, and RefineMesh in OpenMVS is used to obtain a refined mesh model, such as Figure 5 As shown in (a).
[0121] Specifically, the last step is texture mapping. In the embodiment, the refined mesh model and all images are input. Use TextureMesh in OpenMVS for texture mapping and output a 3D mesh model with a texture map, such as Figure 5 As shown in (b).
[0122] It should be noted that the dense reconstruction in the embodiment of the present invention is not limited to the use of the open source library OpenMVS. The 3D reconstruction method provided in the embodiment of the present invention focuses on sparse reconstruction, that is, calculating the camera pose and sparse point cloud. In addition to dense reconstruction, it can also be flexibly grafted into other application tasks, such as 3D visualization, which can replace the dense reconstruction in the 3D reconstruction method provided in the embodiment of the present invention with the Neural Radiance Field, thereby achieving realistic and high-precision 3D rendering.
[0123] It should also be noted that the 3D reconstruction method provided in the embodiment of the present invention is not limited to the use of ArUco codes. Any two-dimensional code that can be accurately detected and from which corner points can be extracted, such as AprilTag, can replace the ArUco code in the present invention.
[0124] In summary, a 3D reconstruction method based on multiple ArUco codes can restore the true scale of the object and has its own world coordinate system definition. Its computational efficiency far exceeds that of traditional methods, and the required acquisition equipment is light, flexible and low-cost.
[0125] Based on the same inventive concept, Figure 6 As shown, an embodiment of the present invention also provides a three-dimensional reconstruction device 600 based on multiple ArUco codes, including: an image acquisition module 610, a preliminary pose optimization module 620, a sparse point cloud computing module 630, a global optimization module 640 and a dense reconstruction module 650.
[0126] The image acquisition module 610 is used to place multiple ArUco codes around the object to be reconstructed, use the camera calibrated with internal parameters to shoot continuous video around the object to be reconstructed and the ArUco code, and evenly sample the video to obtain multiple images;
[0127] The pose preliminary optimization module 620 is used to calculate the initialization camera pose and the initialization ArUco code pose based on multiple images, and to perform preliminary optimization on the initialization camera pose and the initialization ArUco code pose by minimizing the reprojection error;
[0128] The sparse point cloud computing module 630 is used to extract and match feature points from multiple images, and preliminarily calculate the sparse point cloud based on the internal parameters after camera calibration, the camera pose after preliminary optimization, and the matched feature points;
[0129] The global optimization module 640 is used to perform global optimization on the sparse point cloud, the internal parameters after camera calibration, the camera pose after preliminary optimization, and the ArUco code pose after preliminary optimization through bundle adjustment;
[0130] The dense reconstruction module 650 is used to perform dense reconstruction using multiple images, globally optimized camera poses, and globally optimized sparse point clouds to obtain a three-dimensional mesh model with a texture map as a three-dimensional reconstruction result of the object.
[0131] It should be noted that the three-dimensional reconstruction device based on multiple ArUco codes and the three-dimensional reconstruction method based on multiple ArUco codes provided in the above embodiment belong to the same inventive concept. The specific implementation process is detailed in the embodiment of the three-dimensional reconstruction method based on multiple ArUco codes, which will not be repeated here.
[0132] The specific implementation methods described above have described in detail the technical solutions and beneficial effects of the present invention. It should be understood that the above is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A three-dimensional reconstruction method based on multiple ArUco codes, characterized in that: The following steps are involved: Place multiple ArUco codes around the object to be reconstructed, use the camera calibrated with internal parameters to shoot continuous video around the object to be reconstructed and the ArUco code, and evenly sample the video to obtain multiple images; Calculate the initial camera pose and ArUco code pose based on multiple images, and preliminarily optimize the initial camera pose and ArUco code pose by minimizing the reprojection error; Extract and match feature points from multiple images, and calculate the sparse point cloud based on the camera’s calibrated internal parameters, the camera’s preliminarily optimized pose, and the matched feature points; The sparse point cloud, the camera's calibrated internal parameters, the camera's preliminarily optimized pose, and the ArUco code's preliminarily optimized pose are globally optimized through bundle adjustment. Dense reconstruction is performed using multiple images, globally optimized camera poses, and globally optimized sparse point clouds to obtain a 3D mesh model with a texture map as the 3D reconstruction result of the object.
2. The three-dimensional reconstruction method based on multiple ArUco codes according to claim 1, characterized in that: Placing multiple ArUco codes around the object to be reconstructed includes: Keep the object to be reconstructed still, and place multiple ArUco codes of the same size around it without overlapping each other.
3. The three-dimensional reconstruction method based on multiple ArUco codes according to claim 1, characterized in that: The camera calibrated with the internal reference shoots continuous video around the object to be reconstructed and the ArUco code, and uniformly samples the video to obtain multiple images, including: First, the internal parameters of the monocular camera in video shooting mode are calibrated. The internal parameters include focal length, image principal point and lens distortion parameters. Then, the camera with internal parameter calibration is used to shoot at least one circle of continuous video around the object to be reconstructed to ensure that each frame in the video contains at least two complete ArUco codes. Then, multiple images are evenly sampled in the video according to the set sampling frequency.
4. The three-dimensional reconstruction method based on multiple ArUco codes according to claim 1, characterized in that: The initialization of the camera pose and the initialization of the ArUco code pose based on the calculation of multiple images includes: Iterate over multiple images Among them I i For the i-th image among a total of N images, detect all ArUco codes in the image The coordinates of the corner points, where m j For the jth ArUco code among the M ArUco codes, the transformation matrix from the local coordinate system of the ArUco code to the camera coordinate system is calculated using the PnP algorithm according to the corner point coordinates Among them C i is the camera in the shooting state corresponding to the i-th image; Define the local coordinate system of ArUco code m1 as the world coordinate system W, and calculate the initial camera pose for all images containing ArUco code m1: in From world coordinate system W to camera C i Transformation matrix of the coordinate system; Traverse all ArUco codes until the calculation is completed to get all the initialized camera poses For the ArUco code m j A pair of images I among all images of a and I b , a and b∈{1,2,…,N}, we have obtained and If there is an image I that has been calculated a The initial camera pose is Then calculate image I b The initial camera pose is Traverse all ArUco codes, for those containing ArUco code m j Any image I i , calculate its initialization ArUco code pose as in is the ArUcode m j The transformation matrix from the local coordinate system to the world coordinate system W.
5. The three-dimensional reconstruction method based on multiple ArUco codes according to claim 1, characterized in that: The formula for minimizing the reprojection error is: Among them, the total number of multiple images is N, and the total number of multiple ArUco codes is M; is the camera pose, W is the world coordinate system, C i is the camera in the shooting state corresponding to the i-th image; is the ArUco code pose, m j is the jth ArUco code; Y q Y1=(0,0,0,1),Y2=(w,0,0,1),Y3=(w,w,0,1),Y4=(0,w,0,1) are the homogeneous coordinates of the four corner points in the local coordinate system of the ArUco code, w is the side length of the ArUco code; π(·) is the projection function of the camera, and μ is the intrinsic parameter of the camera; is the jth ArUco code m j In the i-th image I i The coordinates of the qth corner point in the corresponding Y q , is a two-dimensional real matrix; if the ArUco code m j The four corner points can be found in image I i If detected in ij =1, otherwise v ij =0; ρ(·) is the robust kernel function; During the initial optimization solution, the initial values of the camera pose and ArUco code pose come from the initialization camera pose and the initialization ArUco code pose, respectively.
6. The three-dimensional reconstruction method based on multiple ArUco codes according to claim 1, characterized in that: The scale-invariant feature transformation algorithm is used to extract and match feature points from multiple images, and a sparse point cloud is obtained through preliminary triangulation calculation.
7. The three-dimensional reconstruction method based on multiple ArUco codes according to claim 1, characterized in that: The method of globally optimizing the sparse point cloud, the camera calibrated internal parameters, the camera pose after preliminary optimization, and the ArUco code pose after preliminary optimization by bundle adjustment includes: The bundle adjustment is to solve the following nonlinear global optimization problem: Among them, the total number of multiple images is N, and the total number of multiple ArUco codes is M; is the camera pose, W is the world coordinate system, C i is the camera in the shooting state corresponding to the i-th image; is the ArUco code pose, m j is the jth ArUco code; Y q Y1=(0,0,0,1),Y2=(w,0,0,1),Y3=(w,w,0,1),Y4=(0,w,0,1) are the homogeneous coordinates of the four corner points in the local coordinate system of the ArUco code, w is the side length of the ArUco code; π(·) is the projection function of the camera, and μ is the intrinsic parameter of the camera; is the jth ArUco code m j In the i-th image I i The coordinates of the qth corner point in the corresponding Y q , is a two-dimensional real matrix; if the ArUco code m j The four corner points can be found in image I i If detected in ij =1, otherwise v ij =0; ρ(·) is the robust kernel function; λ is a non-negative constant coefficient; x ip For sparse point clouds The pth 3D point X in p In the image I i The corresponding 2D coordinates in P are the 3D points X p The total number of; superscript T is transposed; if X p In the image I i It can be seen that t ip =1, otherwise t ip =0; During global optimization solution, the initial value of the sparse point cloud comes from the sparse point cloud obtained by preliminary calculation, the initial value of the camera intrinsic parameter comes from the intrinsic parameter after camera calibration, the initial value of the camera pose comes from the camera pose after preliminary optimization, and the initial value of the ArUco code pose comes from the ArUco code pose after preliminary optimization.
8. The three-dimensional reconstruction method based on multiple ArUco codes according to claim 1, characterized in that: The method uses multiple images, globally optimized camera poses, and globally optimized sparse point clouds to perform dense reconstruction to obtain a three-dimensional mesh model with a texture map as a three-dimensional reconstruction result of the object, including: Dense point cloud is obtained by computing multiple images, globally optimized camera poses and globally optimized sparse point cloud. Compute its grid model based on dense point cloud; Texture mapping is performed based on the mesh model and multiple images to obtain a three-dimensional mesh model with a texture map, thus completing the three-dimensional reconstruction of the object.
9. The three-dimensional reconstruction method based on multiple ArUco codes according to claim 8, characterized in that: After the dense point cloud is calculated, the dense point cloud is first filtered to remove redundant point clouds, and then its grid model is constructed based on the filtered dense point cloud. The filtering methods include: Select a plane determined by the ArUco code or set a height value h based on the plane, and remove redundant point clouds below or above the plane or the plane determined based on the height h; For images with complex backgrounds, the position of the local origin of the ArUco code in the world coordinate system is extracted from the ArUco code pose after preliminary optimization or global optimization. The x-axis and y-axis are determined by the plane where the ArUco code is located. The bounding box information is obtained from multiple ArUco codes. The bounding box is determined by the range value on the x-axis and the range value on the y-axis, thereby removing the redundant point cloud outside the bounding box. For clean background images shot with a backdrop, the color brightness of the point cloud is calculated, and points with color brightness lower than a set threshold are determined to be background points. All background points are removed as redundant point clouds.
10. A three-dimensional reconstruction device based on multiple ArUco codes, characterized in that: include: Image acquisition module, pose preliminary optimization module, sparse point cloud computing module, global optimization module and dense reconstruction module; The image acquisition module is used to place multiple ArUco codes around the object to be reconstructed, use a camera calibrated with internal parameters to shoot continuous video around the object to be reconstructed and the ArUco code, and uniformly sample the video to obtain multiple images; The pose preliminary optimization module is used to calculate the initialization camera pose and the initialization ArUco code pose based on multiple images, and to perform preliminary optimization on the initialization camera pose and the initialization ArUco code pose by minimizing the reprojection error; The sparse point cloud computing module is used to extract and match feature points from multiple images, and preliminarily calculate the sparse point cloud based on the internal parameters after camera calibration, the camera posture after preliminary optimization and the matched feature points; The global optimization module is used to globally optimize the sparse point cloud, the internal parameters after camera calibration, the camera pose after preliminary optimization, and the ArUco code pose after preliminary optimization through bundle adjustment; The dense reconstruction module is used to perform dense reconstruction using multiple images, globally optimized camera poses and globally optimized sparse point clouds to obtain a three-dimensional mesh model with a texture map as a three-dimensional reconstruction result of the object.
