Pipeline 3D reconstruction method, device and storage medium based on multi-view optimization
Through multi-view optimization technology, it solves the problems of three-dimensional information loss and feature mismatching in pipeline disease detection, achieves delicate three-dimensional pipeline reconstruction, and generates a more realistic and observable model.
Patent Information
- Application Number
- CN202210578640.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-25
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2042-05-25
AI Technical Summary
The existing technology loses three-dimensional information in pipeline disease detection, resulting in feature mismatching and excessive noise, making texture mapping difficult, and making it impossible to obtain a highly observable three-dimensional pipeline model.
A pipeline 3D reconstruction method based on multi-view optimization is adopted to obtain multi-angle images, detect feature points, use twin networks and optical flow to optimize feature matching, perform sparse and dense reconstruction, and combine geometric estimation and texture reconstruction to generate a delicate 3D pipeline model.
It reduces feature point drift, reduces noise, and improves the effect of texture mapping, making the three-dimensional pipeline model more realistic and observable.
Smart Images

Figure CN115082617B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of scene three-dimensional reconstruction, and in particular to a pipeline three-dimensional reconstruction method, device and storage medium based on multi-view optimization. Background Art
[0002] Pipelines are widely used in water conservancy, military, chemical industry, urban drainage and other industries, and are an important transportation device. Pipeline quality problems will seriously affect the functions of related systems. Therefore, professionals must regularly inspect pipelines for defects. In recent years, how to use machine vision technology to assist staff in pipeline defect detection has become one of the research hotspots in colleges and universities and research institutes.
[0003] At present, there are many studies based on deep learning to directly replace humans in pipeline disease detection. However, such methods will lose the three-dimensional information of the pipeline. In addition, the internal images of the pipeline are highly repeatable, simple in structure, and have unobtrusive features. For humans, such images can be distinguished by combining experience, the environment around the image, and subtle visual differences; but computers do not have this ability.
[0004] The traditional 3D reconstruction method consists of five steps: image acquisition, feature extraction and matching, sparse reconstruction, dense reconstruction, and texture mapping. For the internal image of the pipeline, due to the above features, directly using the traditional 3D reconstruction method will mismatch a large number of features as similar features, resulting in a large number of noise points in the models obtained by sparse reconstruction and texture reconstruction, making it difficult to successfully map the texture, and the well-mapped model surface will also have too many "wrinkles" and cannot be observed. Summary of the invention
[0005] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a pipeline 3D reconstruction method based on multi-view optimization with fine texture and good 3D scene restoration effect.
[0006] The purpose of the present invention can be achieved by the following technical solutions:
[0007] A pipeline 3D reconstruction method based on multi-view optimization includes the following steps:
[0008] Step 1) obtaining a multi-angle template image of a checkerboard template attached to a plane taken by a camera, detecting feature points in the template image, and solving the camera's intrinsic parameter matrix;
[0009] Step 2) obtaining an image of the interior of the pipeline;
[0010] Step 3) extracting image features and performing preliminary matching on the internal image of the pipeline;
[0011] Step 4) Perform multi-view optimization on image feature extraction and initial matching results based on the twin network and optical flow;
[0012] Step 5) performing sparse reconstruction and dense reconstruction on the pipeline model based on the multi-view optimization results;
[0013] Step 6) performing point cloud segmentation and geometry estimation on the pipeline model based on the reconstruction result;
[0014] Step 7) Reconstruct the texture of the pipeline model based on the geometric estimation results.
[0015] The internal image of the pipeline in step 2) is obtained by shooting inside the pipeline with a high-resolution SLR camera. The camera adopts manual exposure, keeps the focal length of the lens unchanged during the shooting process, and fully fills the internal surface of the pipeline with light, and shoots 360 degrees uniformly, while ensuring that there is a large overlapping area between adjacent images and that each part of the pipeline surface is shot from multiple perspectives. The shooting pixel of the high-resolution SLR camera is not less than 5 million.
[0016] The step 3) comprises:
[0017] Step 3-1) Establish a Gaussian difference pyramid for the image inside the pipeline, detect and locate the scale-invariant key points of the image, determine the direction of the key points of the image, and generate feature descriptors;
[0018] Step 3-2) Determine the similarity between feature points of different images based on the Euclidean distance, and perform preliminary matching of the images based on the similarity.
[0019] The step 4) comprises:
[0020] Step 4-1) Build a twin network, input images two by two, and calculate the optical flow between the feature points of the two images;
[0021] Step 4-2) Use the optical flow as the edge connecting the feature points on different images and the feature points as points to build a graph model, minimize the optical flow and similarity, and adjust the position of the feature points on each image.
[0022] The step 5) comprises:
[0023] Step 5-1) Based on the multi-view optimization result in step 4), combined with the camera intrinsic parameter matrix obtained in step 1), triangulation, posture estimation and BA optimization are performed to extract the sparse point cloud of the pipeline scene and estimate the camera pose corresponding to each image;
[0024] Step 5-2) perform depth map estimation, fuse the depth maps using the depth map registration principle, and obtain a dense point cloud model of the pipeline scene;
[0025] Step 5-3) Delaunay triangulation is performed on the dense point cloud model to obtain a mesh map of the pipeline model.
[0026] The step 6) comprises:
[0027] Step 6-1) Use RANSAC to segment the point cloud model and obtain the parameters of all cylindrical surfaces inside the pipeline model, including the radius r, the axis direction vector v, and a point p on the axis. c ;
[0028] Step 6-2) Use the parameters of all cylindrical surfaces to fit the equation of the three-dimensional plane where the central axis of the pipeline is located:
[0029] a p x+b p y+c p z+d p =0
[0030] Among them, a p , b p , c p , d p is the fitting parameter;
[0031] Using the mesh map of the pipeline model obtained in step 5) of the plane cutting method to obtain a dense point cloud map, wherein all points in the dense point cloud map are on the plane;
[0032] The plane is taken as the xOy plane, and the three-dimensional point coordinates in the dense point cloud image are converted to the coordinate system where the xOy plane is located, so that the z value in the three-dimensional point coordinates (x, y, z) is 0;
[0033] Step 6-3) The torus is mapped on the xOy plane to obtain a torus, which is composed of two arcs, and the arcs are determined by the coordinates of the center point (x c ,y c ), starting and ending arc θ s ,θ e And the radius r is uniquely determined. For any point (x, y) on the arc, the loss function is used as the optimization target, and the loss function is minimized to obtain the center coordinates and radius of the arc parameters. Among them, the loss function L 2 for:
[0034]
[0035] Among them, d 2 =(xx c ) 2 +(yy c ) 2 , m is the number of points on the arc;
[0036] The center and inner and outer radii of the ring are obtained according to the arc parameters, and the starting and ending arcs of the ring are obtained by combining the tangent relationship between the center arc of the ring and the central axis of the cylinder. The central axis of the pipeline is obtained by combining the parameters of the cylindrical surface obtained in step 6-1).
[0037] The mesh diagram of the plane cutting pipeline model in step 6-2) is specifically:
[0038] For each triangle in the mesh diagram of the pipeline model, calculate whether there is an intersection between the plane and the three line segments of the triangle. If there is no intersection or only one intersection, delete the triangular face; if there are two intersections, calculate the three-dimensional coordinates of the two intersections, then delete the triangular face and retain the two intersections in the ply file.
[0039] The step 7) comprises:
[0040] Step 7-1) obtaining a three-dimensional mesh model of the pipeline according to the pipeline centerline and the arc radius, wherein the three-dimensional mesh model does not contain color information;
[0041] Step 7-2) Based on the three-dimensional grid model, texture mapping is performed on the model in combination with the camera's intrinsic parameter matrix and the camera pose corresponding to each image obtained in step 5) to obtain a three-dimensional model of the pipeline.
[0042] A pipeline three-dimensional reconstruction device based on multi-view optimization includes a memory, a processor, and a program stored in the memory, characterized in that the processor implements the method described above when executing the program.
[0043] A storage medium stores a program thereon, wherein the program implements the method described above when executed.
[0044] Compared with the prior art, the present invention has the following beneficial effects:
[0045] (1) The present invention adopts a multi-view optimization method to reduce the drift of the same feature point on different images, avoid mismatching a large number of features as similar features, reduce the noise points in the model obtained by sparse reconstruction and texture reconstruction, and achieve good texture mapping results with strong observability;
[0046] (2) The present invention combines the actual geometric information of the pipeline with the traditional three-dimensional reconstruction to calculate the three-dimensional mesh map of the pipeline, which is more realistic than the results of the traditional method. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 It is a schematic diagram of the method flow of the present invention;
[0048] Figure 2 This is a schematic diagram of a sample shot of a camera inside a pipeline according to an embodiment of the present invention;
[0049] Figure 3 Schematic diagram of sparse point cloud for three-dimensional reconstruction of pipeline in an embodiment of the present invention;
[0050] Figure 4 Schematic diagram of dense point cloud of pipeline 3D reconstruction in an embodiment of the present invention;
[0051] Figure 5 Schematic diagram of Delaunay triangulation mesh for three-dimensional reconstruction of pipeline in an embodiment of the present invention;
[0052] Figure 6 This is a schematic diagram of the central axis of a pipeline in an embodiment of the present invention;
[0053] Figure 7 is a schematic diagram of a pipeline three-dimensional grid model in an embodiment of the present invention;
[0054] Figure 8 Schematic diagram of a three-dimensional pipeline model after texture reconstruction in an embodiment of the present invention. DETAILED DESCRIPTION
[0055] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0056] This embodiment proposes a pipeline 3D reconstruction method based on multi-view optimization for a pipeline with a diameter that allows a person to pass through and a length of not less than 10 meters, to achieve internal information reconstruction of the pipeline, including the following steps:
[0057] Step 1) obtain a multi-angle template image of a checkerboard template attached to a plane taken by a camera, detect feature points in the template image, and solve the camera's intrinsic parameter matrix.
[0058] In this embodiment, the Zhang Zhengyou calibration method is used to calibrate the camera intrinsic parameters to obtain the camera intrinsic parameter matrix K.
[0059] Step 2) Obtain the internal image of the pipeline.
[0060] The internal image of the pipeline is obtained by taking pictures inside the pipeline with a 5-megapixel high-resolution SLR camera. The camera adopts manual exposure, keeps the focal length of the lens unchanged during the shooting process, and fully fills the internal surface of the pipeline with light, and takes 360-degree uniform pictures. At the same time, it ensures that there is a large overlap area between adjacent images and that each part of the pipeline surface is photographed from multiple perspectives. The internal image of the pipeline obtained in this embodiment is as follows: Figure 2 shown.
[0061] Step 3) Extract image features and perform preliminary matching on the image inside the pipeline.
[0062] Step 3-1) Introduce the Gaussian kernel function and convolve it with the input image.
[0063] The Gaussian kernel function is:
[0064]
[0065] Among them, x, y are image coordinates, σ 2 is the variance of the setting.
[0066] The convolution function is:
[0067] L(x,y,σ)=I(x,y)*G(x,y,σ)
[0068] Among them, I(x,y) is the input function.
[0069] For the same image, different Gaussian kernel functions are selected for downsampling to achieve scale invariance; then key points are selected in the DoG image, a circle is drawn with the key point coordinates as the center, all gradient directions in the circle are superimposed on 8 directions, the 8 directions are 0°, 45°, 90°, 135°, 180°, 225°, 270°, 315°, and the maximum value is selected as the main direction of the key point to achieve direction invariance; then a box is selected, the box is divided into 4×4 small grids, the gradient direction of each small grid is calculated, and it is added to the 8 directions to determine a vector of 4×4×8 size, thereby determining the feature descriptor.
[0070] Step 3-2) Use the Euclidean distance of the feature vector As a metric to calculate the similarity of key points in two images: taking two images A and B as an example, for a feature point in the target image A, find the Euclidean distance between the feature vectors of this point and all feature points in image B, and find the ratio of the minimum to the second minimum Euclidean distance. If it is less than the threshold, it is selected as a matching point.
[0071] Step 4) Perform multi-view optimization on image feature extraction and initial matching results based on the twin network and optical flow.
[0072] The image features extracted in step 3) are based on a single view. When the feature points obtained based on a single view are used for feature matching in multiple views, the quality of feature point matching will inevitably be affected because the same feature points may be offset in different viewing angles, thereby affecting the subsequent 3D reconstruction work, causing the final reconstruction result to have more noise points and be unobservable.
[0073] Therefore, the feature extraction results are optimized based on multiple views:
[0074] Step 4-1) Two-view optimization based on the twin network: Build a twin network, pair the pictures with matching feature points, then input the blocks where the key points on the two pictures are located into the twin network, do the inner product of the results of the two blocks, and get the optical flow of the two images through the regression layer;
[0075] Step 4-2) Multi-view optimization based on graph model: Use key points on different images as points of the graph model, initial matching relationship and optical flow as edges of the graph model, minimize optical flow and similarity, and thus adjust the position of key points.
[0076] Step 5) Perform sparse reconstruction and dense reconstruction of the pipeline model based on the multi-view optimization results.
[0077] Step 5-1) Based on the image feature matching results after multi-view optimization, for the pairing point x in the camera coordinate system of the two images 1 and x 2 , using the formula Solve the essential matrix E and separate T(R|y) from E; then combine the intrinsic parameter matrix K of the camera in step 1) and use the following formula to perform triangulation to estimate the depth s of the point 1 and 2 :
[0078] K -1 s 2 x 2 =s 1 K -1 Rx 1 +t
[0079] Among them, x 1 and x 2 are the pixel coordinates of the two sets of feature points in the image coordinate system, K is the intrinsic parameter matrix of the camera, and T is the camera posture;
[0080] Then the Levenberg-Marquardt method is used to minimize the reprojection error, thereby optimizing the camera's 3D point coordinates and camera pose, so that the optimized camera pose is:
[0081]
[0082] After obtaining the optimized 3D point coordinates, you can construct a ply file and input the 3D points and colors into the ply file, such as Figure 3 shown.
[0083] Step 5-2) Based on step 5-1), the depth map is estimated, and the depth map is fused using the depth map registration principle to restore the dense point cloud. The dense point cloud is as follows: Figure 4 As shown;
[0084] Step 5-3) Delaunay triangulation is performed on the dense point cloud obtained in step 5-2). Specifically, the color information in the dense point cloud is removed, and only the three-dimensional point information is retained. The Bowyer-Watson algorithm is used to construct a Delaunay triangulation of the three-dimensional points. The mesh after triangulation is as follows: Figure 5 shown.
[0085] Step 6) Perform point cloud segmentation and geometry estimation on the pipeline model based on the reconstruction results.
[0086] Step 6-1) The pipeline is composed of two basic elements: a torus and a cylinder. For the cylinder, the RANSAC algorithm can be used for point cloud segmentation: randomly sample points inside the model, fit the cylindrical model, count the number of points inside the model at other points, repeat multiple times, and obtain the parameters of all cylindrical surfaces inside the pipeline model: radius r, axis direction vector v, a point p on the axis c .
[0087] Step 6-2) Using all cylinder parameters (v,p c ) Fitting the equation of the three-dimensional plane P where the central axis of the pipeline is located a p x+b p y+c p z+d p =0, where a p , b p , c p , d p is the fitting parameter; specifically, a plane parallel to the central axis of the cylinder and equidistant from the central axis of the cylinder is taken as plane P.
[0088] Use plane P to cut the mesh obtained in step 5-3). Specifically, for each triangle in the mesh, calculate whether P and the three line segments of the triangle have intersections. If there is no intersection or only one intersection, delete the triangle face from the ply file; if there are two intersections, calculate the three-dimensional coordinates of the two intersections, then delete the triangle face, and only keep the two intersections in the ply file. After processing, a dense point cloud can be obtained, and all the points in the point cloud are on P.
[0089] Taking P as the xOy plane, the three-dimensional point coordinates in the point cloud image are converted to this coordinate system, so that the z value in the three-dimensional coordinates (x, y, z) is 0, thereby optimizing the estimation of the parameters of the pipeline ring part on the two-dimensional plane.
[0090] Step 6-3) The torus is mapped on the xOy plane to obtain a torus, which is composed of two arcs, and the arcs are determined by the coordinates of the center point (x c ,y c ), starting and ending arc θ s ,θ eAnd the radius r is uniquely determined. For any point (x, y) on the arc, the loss function is used as the optimization target, and the loss function is minimized to obtain the center coordinates and radius of the arc parameters. Among them, the loss function L 2 for:
[0091]
[0092] Among them, d 2 =(xx c ) 2 +(yy c ) 2 , m is the number of points on the arc;
[0093] The above formula is optimized using the Adam algorithm. The center and inner and outer radii of the ring are obtained based on the two-dimensional arc parameters. The starting and ending arcs of the ring are obtained by combining the tangent relationship between the center arc of the ring and the center axis of the cylinder. The center axis of the pipeline is obtained by combining the parameters of the cylinder obtained in step 6-1). Figure 6 shown.
[0094] Step 7) Reconstruct the texture of the pipeline model based on the geometric estimation results.
[0095] Step 7-1) Get Figure 6 After the central axis shown in the figure (actually a uniform and dense point), for each point on the line, its direction vector n along the central axis can be calculated, and a uniform point on the circle is generated with the point as the center and the radius r of the annular surface and the cylindrical surface as the radius on the plane with n as the normal vector, thereby obtaining a dense, uniform, noise-free pipeline model point cloud map. Then, the points in the point cloud map can be connected according to a regular pattern to obtain a uniform grid map. Then, the inverse transformation of the coordinate transformation in step 6-2) is applied to the grid map, and finally a uniform grid map of the pipeline without color information in the three-dimensional reconstruction coordinate system can be obtained, as shown in FIG. Figure 7 As shown;
[0096] Step 7-2) Based on step 7-1), combined with the camera's intrinsic parameter matrix and the camera pose corresponding to each image obtained in step 5), select the viewing angle for the triangular surface of the pipeline mesh, perform texture mapping on the model, generate a fused texture map, and obtain the pipeline 3D model as shown in Figure 8 shown.
[0097] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program code.
Claims
1. A pipeline 3D reconstruction method based on multi-view optimization, characterized in that: The following steps are involved: Step 1) obtaining a multi-angle template image of a checkerboard template attached to a plane taken by a camera, detecting feature points in the template image, and solving the camera's intrinsic parameter matrix; Step 2) obtaining an image of the interior of the pipeline; Step 3) extracting image features and performing preliminary matching on the internal image of the pipeline; Step 4) Perform multi-view optimization on image feature extraction and initial matching results based on the twin network and optical flow; Step 5) performing sparse reconstruction and dense reconstruction on the pipeline model based on the multi-view optimization results; Step 6) performing point cloud segmentation and geometry estimation on the pipeline model based on the reconstruction result; Step 7) reconstructing the texture of the pipeline model based on the geometric estimation result; The step 4) comprises: Step 4-1) Build a twin network, input images two by two, and calculate the optical flow between the feature points of the two images; Step 4-2) Use the optical flow as the edge connecting the feature points on different images and the feature points as points to establish a graph model, minimize the optical flow and similarity, and adjust the position of the feature points on each image; The step 5) comprises: Step 5-1) Based on the multi-view optimization result in step 4), combined with the camera intrinsic parameter matrix obtained in step 1), triangulation, posture estimation and BA optimization are performed to extract the sparse point cloud of the pipeline scene and estimate the camera pose corresponding to each image; Step 5-2) perform depth map estimation, fuse the depth maps using the depth map registration principle, and obtain a dense point cloud model of the pipeline scene; Step 5-3) performing Delaunay triangulation on the dense point cloud model to obtain a mesh map of the pipeline model; The step 6) comprises: Step 6-1) Use RANSAC to segment the point cloud model and obtain the parameters of all cylindrical surfaces inside the pipeline model, including the radius r, the axis direction vector v, and a point p on the axis. c ; Step 6-2) Use the parameters of all cylindrical surfaces to fit the equation of the three-dimensional plane where the central axis of the pipeline is located: a p x+b p y+c p z+d p =0 Among them, a p , b p , c p , d p is the fitting parameter; Using the grid map of the pipeline model obtained in step 5), a dense point cloud map is obtained, and all points in the dense point cloud map are on the plane; The plane is taken as the xOy plane, and the three-dimensional point coordinates in the dense point cloud image are converted to the coordinate system where the xOy plane is located, so that the z value in the three-dimensional point coordinates (x, y, z) is 0; Step 6-3) The torus is mapped on the xOy plane to obtain a torus, which is composed of two arcs, and the arcs are determined by the coordinates of the center point (x c ,y c ), starting and ending arc θ s ,θ e And the radius r is uniquely determined. For any point (x, y) on the arc, the loss function is used as the optimization target, and the loss function is minimized to obtain the center coordinates and radius of the arc parameters. The loss function L2 is: Among them, d 2 =(xx c ) 2 +(yy c ) 2 , m is the number of points on the arc; The center and inner and outer radii of the ring are obtained according to the arc parameters, and the starting and ending arcs of the ring are obtained by combining the tangent relationship between the center arc of the ring and the central axis of the cylinder. The central axis of the pipeline is obtained by combining the parameters of the cylindrical surface obtained in step 6-1).
2. The pipeline 3D reconstruction method based on multi-view optimization according to claim 1, characterized in that: The internal image of the pipeline in step 2) is obtained by photographing the inside of the pipeline with a high-resolution SLR camera. The camera adopts manual exposure, and the focal length of the lens is kept unchanged during the shooting process. The internal surface of the pipeline is fully supplemented with light, and 360-degree uniform shooting is performed. At the same time, a large overlapping area is ensured between adjacent images, and each part of the pipeline surface is photographed from multiple perspectives.
3. The pipeline 3D reconstruction method based on multi-view optimization according to claim 1, characterized in that: The step 3) comprises: Step 3-1) Establish a Gaussian difference pyramid for the image inside the pipeline, detect and locate the scale-invariant key points of the image, determine the direction of the key points of the image, and generate feature descriptors; Step 3-2) Determine the similarity between feature points of different images based on the Euclidean distance, and perform preliminary matching of the images based on the similarity.
4. The pipeline 3D reconstruction method based on multi-view optimization according to claim 1, characterized in that: The mesh diagram of the plane cutting pipeline model in step 6-2) is specifically: For each triangle in the mesh diagram of the pipeline model, calculate whether there is an intersection between the plane and the three line segments of the triangle. If there is no intersection or only one intersection, delete the triangular face; if there are two intersections, calculate the three-dimensional coordinates of the two intersections, then delete the triangular face and retain the two intersections in the ply file.
5. The pipeline 3D reconstruction method based on multi-view optimization according to claim 1, characterized in that: The step 7) comprises: Step 7-1) obtaining a three-dimensional mesh model of the pipeline according to the pipeline centerline and the arc radius, wherein the three-dimensional mesh model does not contain color information; Step 7-2) Based on the three-dimensional grid model, texture mapping is performed on the model in combination with the camera's intrinsic parameter matrix and the camera pose corresponding to each image obtained in step 5) to obtain a three-dimensional model image of the pipeline.
6. A pipeline three-dimensional reconstruction device based on multi-view optimization, comprising a memory, a processor, and a program stored in the memory, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 5 is implemented.
7. A storage medium having a program stored thereon, characterized in that: When the program is executed, the method according to any one of claims 1 to 5 is implemented.
