Method for positioning poses of screw holes based on three-dimensional point cloud
Through 3D camera module shooting and point cloud processing, the circumference and plane of the screw hole are detected and fitted, and template matching is performed based on the screw hole model, which solves the problem of inaccurate collection of screw hole pose information and achieves more accurate and efficient 3D modeling.
Patent Information
- Application Number
- CN202410800209.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-09-10
AI Technical Summary
The existing technology has hidden dangers of inaccurate collection of pose information and failure of three-dimensional modeling when faced with objects such as screw holes whose features are not obvious.
Use a 3D camera module to shoot objects, generate 2D images and 3D point clouds, detect screw holes through detection algorithms, perform cutting and grid segmentation, fit the circumference and plane of the screw holes, and perform template matching based on the screw hole model to determine the position. posture.
It improves the accuracy and simplicity of screw hole positioning, reduces dependence on the quality of captured images, and enhances the stability and efficiency of three-dimensional modeling.
Smart Images

Figure CN118628569A
Abstract
Description
Technical Field
[0001] The present invention relates to the relevant fields of machine vision, and in particular to a method for locating screw hole posture based on three-dimensional point cloud. Background Art
[0002] The intelligent industry represented by robotics technology has flourished and has become an important symbol of modern scientific and technological innovation. As one of the key technologies, machine vision realizes industrial production through measurement and has derived many application fields. Among them, the use of optical instruments to measure object features and postures and realize object posture estimation has become a hot topic in the field of vision in actual production. This technology is widely used, for example, it plays a key role in fields such as automated assembly, picking and quality inspection. Through the high-precision image processing and pattern recognition algorithms of the machine vision system, it can accurately identify and locate workpieces, and realize intelligent and automated control of industrial production processes. The development of this technology has brought huge benefits to industrial production, improved production efficiency, reduced costs, and ensured the consistency and stability of product quality. With the continuous advancement of science and technology, the application prospects of machine vision in the intelligent industry are broader, which will bring more convenience and innovation to people's lives and work.
[0003] In the prior art, as shown in the patent document (application number CN107038753B), only technical solutions such as visual measurement, camera posture relationship, feature matching, and image stitching are provided. The reconstruction of the three-dimensional model is based on the posture relationship and the features of the captured image. Although the hand-eye calibration link is bypassed, the captured image is large. If it is applied to objects such as screw holes where the features of the measured object are not obvious, there is a risk of modeling failure. Summary of the invention
[0004] The purpose of an embodiment of the present invention is to provide a method for locating the position and posture of a screw hole based on a three-dimensional point cloud, so as to alleviate the technical problem existing in the prior art that when faced with objects with unclear features such as screw holes, the prior art is inaccurate in collecting their position and posture information, resulting in the risk of modeling failure.
[0005] To solve the above technical problems, the embodiments of the present invention provide the following technical solutions:
[0006] A first aspect of the present invention provides a method for positioning a screw hole based on a three-dimensional point cloud, the method comprising the steps of:
[0007] S10. photographing the object with a three-dimensional camera module, generating a two-dimensional image and a three-dimensional point cloud, and performing an inverse transformation of the camera rotation matrix on the three-dimensional point cloud;
[0008] S20. Detect the screw holes on the two-dimensional image using a detection algorithm, detect all the screw holes, and set them as a screw hole bounding box set; then expand all elements in the screw hole bounding box set to obtain a screw hole expanded bounding box set, and use the screw hole expanded bounding box set to cut the point cloud corresponding to the two-dimensional image to obtain a point cloud set around all the screw holes after cutting; perform plane fitting on the point cloud corresponding to the two-dimensional image, and the fitting result is used to remove the screw hole interference point cloud in the point cloud set around all the screw holes after cutting, and project the expanded edge onto the corresponding three-dimensional point cloud to cut out the corresponding projected point cloud;
[0009] S30. Perform 3D mesh segmentation on the point cloud model obtained by cutting, and divide each mesh into several blocks according to the XYZ direction. Each block is a cube, and the segmentation is performed with equal lengths, and the segmentation length is L. Then, the number of 3D small cubes is determined according to the XYZ length of the model point cloud.
[0010] S40. Fit the circumference of the screw hole according to the normal vector and coordinates of the gridded point cloud in step S30, and then fit the circular plane according to the grid of the circumference in space, and calculate the point cloud in the grid for the fitted circular plane. The coordinates of all point clouds in the grid are the center of the grid, and the normal vector is the right-hand rule rotation direction with the circumference as the circle;
[0011] S50. Match the fitted point cloud with the screw hole screw model through the screw end template to determine the screw hole position.
[0012] In some modified implementations of the first aspect of the present invention, the expression in step S30 is:
[0013] X=INT((xp-min_x) / Lvoxel)
[0014] Y=INT((yp-min_y) / Lvoxel)
[0015] Z = INT ((zp-min_z) / Lvoxel)
[0016] Voexl(p) = voxel[X][Y][Z];
[0017] Among them, x p ,y p ,z p Indicates the coordinate values of a point P in the point cloud in the X, Y, and Z directions;
[0018] min x ,min y ,min z Respectively represent the minimum coordinate values of the point cloud in the X, Y, and Z directions;
[0019] L voxelRepresents the side length of a three-dimensional grid (voxel). All three-dimensional grids (voxels) are cubes with equal side lengths.
[0020] INT: indicates the rounding function, which converts the calculation result into the maximum integer not greater than this value;
[0021] X, Y, Z: represents the index of the voxel corresponding to point P in the X, Y, and Z directions;
[0022] Voxel(p) represents the voxel where point P is located;
[0023] voxel[X][Y][Z] represents the voxel at index [X][Y][Z] in the 3D voxel grid.
[0024] In some modified implementations of the first aspect of the present invention, in step S10, the following steps are included:
[0025] S11. Use two 3D camera modules of the same model to perform binocular positioning on the object, calibrate the parameters of the 3D camera module, use a dot target for calibration, establish the z plane of the world coordinate system on the target plane, and obtain a homography transformation from the target plane to the image plane;
[0026] S12. Determine the cycle according to the number of images of the Gray code, and encode the sub-regions by multi-frequency heterodyning to obtain sub-region level information;
[0027] S13. After the unfolded phase obtained in step 12 has been corrected by the epipolar line, the search for corresponding points is performed along the horizontal scan line of the image; the disparity corresponding to each point in the left and right unfolded phases is obtained by matching through the stereo matching algorithm. The phase difference value of a specific window transformation is combined with the transformation of the pixel grayscale into a bit string to measure the similarity of the corresponding points in the left and right views; the matching costs of the target point and the surrounding nearby points are superimposed through cross-window aggregation to enhance reliability, and the matching cost aggregation is completed; and the point with the best aggregated matching cost is directly selected as the corresponding matching point through the scan line optimization parameters. For discrete matching points that include mismatched points in the matching points calculated in the previous step, the initial disparity is refined through left and right consistency detection and adjustment of the disparity of the edge pixels to obtain a more accurate disparity result;
[0028] S14. Combine the parameters of the three-dimensional camera module in step S11, and obtain the depth information of the object to be measured by the depth conversion formula through the principle of triangulation, where f is the focal length of the camera, b is the distance between the optical centers of the two cameras, d is the obtained disparity, and z is the required depth information; the disparity value obtained by the depth conversion formula obtained through the principle of triangulation is converted into the depth information of the object to be measured, and the coordinates (x, y, z) of each point in the world coordinate system are obtained according to the coordinates (x, y), and the dense point cloud information of the object is reconstructed to complete the three-dimensional reconstruction of the object;
[0029] The camera external parameter matrix R1 includes the rotation matrix and the translation vector, and its expression is:
[0030]
[0031] Where: R is a 3x3 rotation matrix used to describe the rotation of the camera coordinate system relative to the world coordinate system; t is a 3x1 translation vector used to describe the translation of the camera coordinate system relative to the world coordinate system; the last row [0 1] is an additional row for homogeneous coordinate representation.
[0032] In some modified implementations of the first aspect of the present invention, step S20 includes the following steps:
[0033] S21. Read the two-dimensional image containing the screw holes and then perform image preprocessing: convert the image into a grayscale image, then perform binarization processing, use the contour detection algorithm to find the contours of all screw holes; extract the bounding box of the screw hole: for each detected contour, calculate its bounding box, and store these bounding boxes in the screw hole bounding box set;
[0034] Traverse the screw hole bounding box set, subtract 10 from the upper left corner coordinate of each bounding box in the screw hole bounding box set, and increase the width and height by 20 to obtain an extended bounding box; store the extended bounding box in the screw hole extended bounding box set;
[0035] S22. For each bounding box in the set of screw hole extended bounding boxes, filter out the point cloud points within the bounding box, and store these points in the point cloud set around all screw holes after cutting; calculate the distance from each point to the fitting plane; set a threshold, retain the point cloud points with a distance greater than the threshold, and remove the interference points with a distance less than the threshold;
[0036] Step S40 includes the following steps:
[0037] S41. Using the three-dimensional grid segmentation result in step S30, the point cloud data of the point cloud set around all screw holes after cutting are segmented into small cubic grids. The coordinates and normal vectors of the point cloud in each grid are merged to traverse each grid; the coordinates of the point cloud in each grid are merged; the normal vectors of all the point clouds in the grid are averaged to obtain the normal vector of the grid;
[0038] S42. Fit the circumference of the screw hole, use the gridded point cloud data to perform circumference fitting on each grid; and further fit a circular plane based on the grid of the circumference in the space.
[0039] In some modified implementations of the first aspect of the present invention, in step S50, the following steps are included:
[0040] S51. Setting a circular template to represent the shape of the end of the screw hole, and matching the three-dimensional point cloud around the screw hole using the predefined template; to find the point cloud area that best matches the template shape, and determine its position and posture;
[0041] S52. Obtaining a set of screw hole poses and a set of screw hole poses, and determining whether the matching is successful: when the template matches successfully, obtaining the pose information of the screw hole;
[0042] S53. Convert to the world coordinate system, using the camera extrinsic matrix R1: multiply each pose in the pose set of the screw hole by the camera extrinsic matrix R1 to obtain the coordinates of the screw in the world coordinate system;
[0043] Use the pre-performed hand-eye calibration matrix to transform the pose in the world coordinate system to the pose in the robot coordinate system.
[0044] The present invention designs a method for locating screw holes based on object surface calculation; the method first performs two-dimensional and three-dimensional measurements on the object, locates the screw holes in a two-dimensional image, cuts a three-dimensional point cloud according to the two-dimensionally located screw holes, then grids the cut point cloud, fits a circle around the circular hole according to the grid, fits a circular plane according to the fitted circle, fits the point cloud according to the plane, and then performs template matching on the screw hole fitting point cloud according to the screw hole model to determine the screw hole posture; that is, the present invention calculates the hole posture by fitting the hole plane according to the edge of the point cloud. Compared with the prior art of realizing three-dimensional object reconstruction through posture relationship and captured image features, the influence of captured image quality on three-dimensional modeling is reduced, and the operation is simpler, faster and more accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required to be used in the embodiments are briefly introduced below.
[0046] Figure 1 An overall flow chart of a screw hole pose estimation method based on three-dimensional point cloud provided by an embodiment of the present invention;
[0047] Figure 2 A two-dimensional image and a three-dimensional point cloud image of a workpiece captured in a method for estimating a screw hole posture based on a three-dimensional point cloud provided in an embodiment of the present invention;
[0048] Figure 3 In a method for estimating a screw hole posture based on a three-dimensional point cloud provided in an embodiment of the present invention, the detected screw hole edge is expanded and then projected to a corresponding three-dimensional point cloud image and a corresponding projected point cloud image is cut out;
[0049] Figure 4 In a screw hole pose estimation method based on three-dimensional point cloud provided in an embodiment of the present invention, the circumference of the screw hole and the fitted circular plane are fitted according to the normal vector and coordinates of the gridded point cloud;
[0050] Figure 5 In a screw hole pose estimation method based on three-dimensional point cloud provided in an embodiment of the present invention, a screw end template matching diagram is performed between the fitted point cloud and the screw hole screw model. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0052] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0053] Embodiment 1
[0054] like Figure 1 As shown, this embodiment provides a method for locating the screw hole posture based on a three-dimensional point cloud. The method first performs two-dimensional and three-dimensional measurements on the object, locates the screw hole in the two-dimensional image, cuts the three-dimensional point cloud according to the two-dimensionally located screw hole, and then grids the cut point cloud, fits a circle around the circular hole according to the grid, fits a circular plane according to the fitted circle, fits the point cloud according to the plane, and then performs template matching on the screw hole fitting point cloud according to the screw hole model to determine the screw hole posture.
[0055] Two-dimensional and three-dimensional measurements include generating two-dimensional images and three-dimensional point cloud images respectively, and performing inverse transformation of the camera rotation matrix on the three-dimensional point cloud. This includes the calibration of the three-dimensional camera module to obtain the internal and external parameters of the camera.
[0056] The method of edge detection is used to identify the positioning screw holes in the two-dimensional image, and the segmentation of the screw holes in the three-dimensional point cloud includes multiple operation steps such as point cloud denoising, point cloud meshing, and point cloud fitting. Finally, template matching is performed according to the screw model to determine the screw hole position. The steps are:
[0057] S10. Shooting to generate a two-dimensional image and a three-dimensional point cloud, and performing an inverse transformation of the camera rotation matrix on the three-dimensional point cloud;
[0058] S20. Detect the screw holes on the two-dimensional image using a detection algorithm, detect all the screw holes, and set them as the screw hole bounding box set. Then expand all elements in the screw hole bounding box set by 10 pixels to obtain the screw hole expanded bounding box set, and use the screw hole expanded bounding box set to cut the point cloud corresponding to the two-dimensional image to obtain the point cloud set around all the screw holes after cutting. Perform plane fitting on the point cloud corresponding to the two-dimensional image, and the fitting result is used to remove the screw hole interference point cloud in the point cloud set around all the screw holes after cutting, and project the expanded edge onto the corresponding three-dimensional point cloud to cut out the corresponding projected point cloud;
[0059] S30. Perform 3D mesh segmentation on the point cloud model obtained by cutting, and divide each mesh into several blocks according to the XYZ direction. Each block is a cube, and the segmentation is performed with equal lengths, and the segmentation length is L. Then, the number of 3D small cubes is determined according to the XYZ length of the model point cloud.
[0060] S40. Fit the circumference of the screw hole according to the normal vector and coordinates of the gridded point cloud, and then fit the circular plane according to the grid of the circumference in space, and obtain the point cloud in the grid for the fitted circular plane. The coordinates of all point clouds in the grid are the center of the grid, and the normal vector is the right-hand rule rotation direction with the circumference as the center;
[0061] S50. Match the fitted point cloud with the screw hole screw model to the screw end template to determine the screw hole position;
[0062] The principle is: perform three-dimensional grid segmentation on each element of the point cloud set around all screw holes after cutting, divide each grid into several blocks according to the XYZ direction, each block is a cube, and take equal lengths for segmentation, the segmentation length is L. Then determine the number of three-dimensional small cubes according to the XYZ length of the model point cloud, as shown below:
[0063] X=INT((xp-min_x) / Lvoxel)
[0064] Y=INT((yp-min_y) / Lvoxel)
[0065] Z = INT ((zp-min_z) / Lvoxel)
[0066] Voexl(p)=voxel[X][Y][Z]
[0067] x p ,y p ,z p Indicates the coordinate values of a point P in the point cloud in the X, Y, and Z directions.
[0068] min x ,min y ,min z Respectively represent the minimum coordinate values of the point cloud in the X, Y, and Z directions.
[0069] L voxel Represents the side length of a three-dimensional grid (voxel). All three-dimensional grids (voxels) are cubes with equal side lengths.
[0070] INT: represents the rounding function, which converts the calculation result into the maximum integer not greater than this value.
[0071] X, Y, Z: represents the index of the voxel corresponding to point P in the X, Y, and Z directions.
[0072] Voxel(p) represents the voxel where point P is located.
[0073] voxel[X][Y][Z] represents the voxel at index [X][Y][Z] in the 3D voxel grid.
[0074] Determine the segmentation length L, which is the side length of each cube (voxel). It determines how fine a grid we divide the point cloud into. Choosing an appropriate L value requires considering the resolution and processing requirements of the point cloud. In order to perform network segmentation, you need to know the range of the point cloud in each direction, which involves finding the minimum and maximum values of the point cloud in the X, Y, and Z directions. Calculate the index of the small cube where each point cloud point is located For each point in the point cloud, calculate the index of the small cube (X, Y, Z) where it is located based on its coordinates in the X, Y, and Z directions and the segmentation length L.
[0075] It should be noted that, in this embodiment, the expanded pixel size 10 of the screw hole in the two-dimensional image is set relatively, wherein the expanded pixel size is set according to the size of the screw in the actual situation to be faced. And for obtaining the point cloud attached to the screw hole and performing grid processing, the required segmentation length L is also set relatively.
[0076] The present invention can be used to assemble the system by positioning the screw hole posture, which can be used to improve the posture information required before the assembly starts, and can also be combined with the three-dimensional point cloud to find the accurate hole posture of the screw in the system. In this structure, the light source can use monocular structured light or binocular structured light, and the industrial camera can work in a visible light environment. It is further explained in conjunction with the following embodiments.
[0077] Embodiment 2
[0078] like Figure 2 As shown, a 3D camera module is used to shoot an object to generate a 2D image Pic and a corresponding 3D original point cloud. The generated 2D image is a grayscale image, which can avoid interference from external ambient light. The 3D point cloud is generated based on the Gray phase shift method of structured light, and has high point cloud flatness and accuracy. The 2D image Pic shot by the 3D camera module is in the camera coordinate system, while the corresponding 3D original point cloud is in the world coordinate system. Therefore, in order to make each coordinate of the 2D image and the 3D point cloud correspond one-to-one, it is necessary to convert the point cloud coordinates into the camera coordinate system, which requires the camera extrinsic parameter matrix R1. The 3D original point cloud is multiplied by the inverse matrix of R1 to obtain the image corresponding point cloud. The 3D points of the point cloud correspond one-to-one to each pixel (X, Y) in the 2D image.
[0079] In step S10, the following steps are included:
[0080] S11. Use Zhang Zhengyou calibration method to calibrate the two cameras separately to obtain the internal and external parameters of the left and right cameras (internal parameters include camera focal length, distortion, etc.; external parameters include the position relationship between the camera and the world coordinate system, which can be used to calculate the camera coordinate system). The purpose of dual-target calibration is to obtain the relative transformation relationship between the left and right cameras, that is, to determine the rigid body transformation matrix between the two cameras.
[0081] Since the left and right cameras use the same camera model, we first calibrate the internal parameters of a single camera. We use Zhang Zhengyou's two-dimensional target plane calibration method, use a dot target for calibration, establish the z plane of the world coordinate system on the target plane, and obtain a homography transformation from the target plane to the image plane. That is, we combine the internal and external parameters into a single transformation matrix, and then use pure mathematical derivation to separate the internal and external parameters from the single transformation matrix;
[0082] S12. Phase shift technology is to project a series of sinusoidal periodic gratings onto the surface of the object to be measured. Four-step phase shift encoding is to determine the period (that is, the frequency) according to the number of Gray code images. Six Gray code images can divide the image into 64 sub-areas. Therefore, the period is T and the frequency f is 1 / 64. The phase shift is introduced to solve the unknowns. Because there are three unknowns A(x, y), B(x, y), and φ(x, y), at least three phase shifts are required. Finally, the wrapped phase φ(x, y) is obtained by the formula. (truncated at -π, +π). However, it is necessary to know which level the truncated phase in each period belongs to in order to solve the phase and make it continuous. Therefore, Gray code and multi-frequency heterodyne are introduced to encode the sub-areas, so as to decode the sub-area level information;
[0083] Multi-frequency heterodyne structured light measurement principle: Multi-frequency heterodyne is based on the time phase unwrapping algorithm. This method uses fringe gratings of different frequencies to be projected onto the surface of the object being measured, and each frequency fringe projection process will perform a corresponding phase shift transformation. This algorithm based on time phase unwrapping calculates the phase information of each pixel independently, which is conducive to suppressing interference;
[0084] S13. After the unfolded phase is obtained by the S32 phase shift method and the epipolar line correction is performed, the search for corresponding points only needs to be performed along the horizontal scan line of the image. The disparity corresponding to each point in the left and right unfolded phases is obtained by matching through the stereo matching algorithm. The similarity of corresponding points in the left and right views is measured using the absolute phase difference value of a specific window combined with the transformation of pixel grayscale into a bit string; the matching costs of the target point and the surrounding nearby points are superimposed through cross-window aggregation to enhance reliability and complete the matching cost aggregation; and the point with the best aggregated matching cost is directly selected as the corresponding matching point through the scan line optimization parameters. For discrete matching points that contain mismatched points in the matching points calculated in the previous step, the initial disparity is refined through left and right consistency detection and adjustment of the disparity of edge pixels to obtain a more accurate disparity result.
[0085] S14. Combine the internal and external parameters of the camera obtained in S11, and obtain the depth conversion formula through the principle of triangulation to obtain the depth information of the object being measured, where f is the focal length of the camera, b is the distance between the optical centers of the two cameras, d is the obtained disparity, and z is the required depth information. The disparity value obtained by the depth conversion formula obtained through the principle of triangulation can be converted into the depth information of the object being measured, and the coordinates (x, y, z) of each point in the world coordinate system are obtained according to the coordinates (x, y), thereby reconstructing the dense point cloud information of the object and completing the three-dimensional reconstruction of the object.
[0086] Inverted pose: represents the transformation from the camera coordinate system to the world coordinate system. By inverting the pose, we can get the position and orientation of the camera in the world coordinate system, which is very important for the subsequent 3D reconstruction and matching process. To further explain, we can look at the structure of the pose matrix and the calculation of its inverse matrix:
[0087] The camera external parameter matrix R1 is a 4x4 homogeneous transformation matrix, which contains the rotation matrix and the translation vector, as shown below:
[0088]
[0089] Where: R is a 3x3 rotation matrix used to describe the rotation of the camera coordinate system relative to the world coordinate system. t is a 3x1 translation vector used to describe the translation of the camera coordinate system relative to the world coordinate system. The last row [0 1] is an additional row for homogeneous coordinate representation. Inverse transformation matrix, to transform the point cloud from the world coordinate system to the camera coordinate system, you need to use the inverse matrix of the extrinsic matrix.
[0090] Embodiment 3
[0091] like Figure 3 As shown, for any workpiece placed, the target point cloud (green) is generated by the device, and the coordinate system is the base coordinate system of the robot arm. The template (red) is used for template matching in the base coordinate system to obtain the precise position (coordinates and orientation) of the screw hole in the base coordinate system. After the model is meshed, the coordinates and normal vectors of the point cloud in each grid are merged. No matter how many point clouds are in the grid, the center of the grid is uniformly taken as the grid coordinate. The normal vector of the grid is taken as the average of the normal vectors of all the point clouds in the grid. The circumference of the screw hole is fitted according to the normal vector and coordinates of the gridded point cloud, and then the circular plane is fitted according to the grid of the circumference in space. The point cloud in the grid is calculated for the fitted circular plane. The coordinates of all point clouds in the grid are the center of the grid, and the normal vector is the right-hand-rule rotation direction with the circumference as the circle. The gridded point cloud is used to fit the circumference and circular plane of the screw hole surface and generate a plane point cloud. The fitted plane is as follows Figure 3 and Figure 4 In steps S20 and S40, the following steps are included:
[0092] S21. Read the two-dimensional image containing the screw holes and then perform image preprocessing: convert the image into a grayscale image and then perform binarization processing to make it easier to detect the contours of the screw holes. Use the contour detection algorithm to find the contours of all screw holes. Extract the bounding box of the screw holes: For each detected contour, calculate its bounding box and store these bounding boxes in the screw hole bounding box set;
[0093] Traverse the screw hole bounding box set: process each bounding box in the set. Expand the bounding box: subtract 10 from the upper left corner coordinate of each bounding box, and increase the width and height by 20 to obtain the expanded bounding box. Store the expanded bounding box: store the expanded bounding box in the point cloud set around all screw holes after cutting;
[0094] S22. Process each bounding box in the point cloud set around all screw holes after cutting to cut the point cloud: for each bounding box, filter out the point cloud points within the bounding box and store these points in the point cloud set around all screw holes after cutting. Calculate the distance from each point to the fitting plane. Set a threshold, retain the point cloud points with a distance greater than the threshold, and remove the interference points with a distance less than the threshold;
[0095] S41. Mesh the model. Use the three-dimensional mesh segmentation result in S30 to segment the point cloud data of the point cloud set around all screw holes after cutting into small cubic meshes. Merge the coordinates and normal vectors of the point cloud in each mesh and traverse each mesh. Merge the coordinates of the point cloud in each mesh. Regardless of the number of point clouds in the mesh, take the center of the mesh as the mesh coordinate. Average the normal vectors of all point clouds in the mesh to obtain the normal vector of the mesh. The normal vector is a vector that indicates the orientation of the mesh in space.
[0096] S42. Fit the circumference of the screw hole. Use the gridded point cloud data to fit the circumference of each grid. The circumference here refers to the outline of the screw hole. The fitting result should be a center and radius, which describes the shape of the screw hole. Fit the circular plane. According to the grid of the circumference in the space, further fit the circular plane.
[0097] The circular plane describes the basic geometric features of the entire screw hole. Solve the point cloud in the circular plane, and select the point cloud in the grid belonging to the plane according to the fitted circular plane. Set the coordinates of all point clouds in the grid to the center of the circular plane. The normal vector is determined according to the right-hand rule, that is, the circumferential direction is used as the rotation direction.
[0098] The overall purpose of these steps is to extract information that matches the screw holes from complex 3D point cloud data, and describe and process it in a structured manner to provide accurate spatial position and orientation information for subsequent applications such as robot vision positioning and assembly.
[0099] Embodiment 4
[0100] like Figure 5As shown, the fitted circular point cloud is matched with the screw end at the screw hole by a three-dimensional surface template. The thickness of the matching template is 1mm. After a successful match, the pose set of the screw space and the pose set of the screw hole are obtained. The pose set of the screw hole is multiplied by the matrix R to obtain the pose in the world coordinate system, and then the coordinates of the screw in the world coordinate system are obtained. Then, according to the hand-eye calibration matrix, the pose in the world coordinate system is converted to the pose in the robot arm coordinate system, which is the pose of the screw hole in the robot arm coordinate system.
[0101] In step S50, the following steps are included:
[0102] S51. Prepare template: Set a circular template to represent the shape of the end of the screw hole. Usually, the thickness of the template is 1mm; match each screw hole position, and use the pre-defined template to match the 3D point cloud around the screw hole. The matching goal is to find the point cloud area that best matches the template shape and determine its position and posture;
[0103] S52. Obtaining the pose set of the screw hole. Determining whether the matching is successful: when the template matches successfully, obtaining the pose information of the screw hole. Obtaining the pose set of the screw hole: the pose set includes multiple pose hypotheses of the screw hole in the camera coordinate system;
[0104] S53. Convert to the world coordinate system and use the camera extrinsic matrix R1: multiply each pose in the pose set of the screw hole by the camera extrinsic matrix R1 to obtain the coordinates of the screw in the world coordinate system.
[0105] Application of hand-eye calibration matrix: Use the pre-performed hand-eye calibration matrix to convert the pose in the world coordinate system to the pose in the robot coordinate system.
[0106] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for positioning screw hole positions based on three-dimensional point clouds, characterized in that: The steps of this method are: S10. photographing the object with a three-dimensional camera module, generating a two-dimensional image and a three-dimensional point cloud, and performing an inverse transformation of the camera rotation matrix on the three-dimensional point cloud; S20. Detect the screw holes on the two-dimensional image using a detection algorithm, detect all the screw holes, and set them as a screw hole bounding box set; then expand all elements in the screw hole bounding box set to obtain a screw hole expanded bounding box set, and use the screw hole expanded bounding box set to cut the point cloud corresponding to the two-dimensional image to obtain a point cloud set around all the screw holes after cutting; perform plane fitting on the point cloud corresponding to the two-dimensional image, and the fitting result is used to remove the screw hole interference point cloud in the point cloud set around all the screw holes after cutting, and project the expanded edge onto the corresponding three-dimensional point cloud to cut out the corresponding projected point cloud; S30. Perform 3D mesh segmentation on the point cloud model obtained by cutting, and divide each mesh into several blocks according to the XYZ direction. Each block is a cube, and the segmentation is performed with equal lengths, and the segmentation length is L. Then, the number of 3D small cubes is determined according to the XYZ length of the model point cloud. S40. Fit the circumference of the screw hole according to the normal vector and coordinates of the gridded point cloud in step S30, and then fit the circular plane according to the grid of the circumference in space, and calculate the point cloud in the grid for the fitted circular plane. The coordinates of all point clouds in the grid are the center of the grid, and the normal vector is the right-hand rule rotation direction with the circumference as the circle; S50. Match the fitted point cloud with the screw hole screw model through the screw end template to determine the screw hole position.
2. The method for positioning screw hole positions based on three-dimensional point cloud according to claim 1, characterized in that: The expression in step S30 is: X=INT((xp-min_x) / Lvoxel) Y=INT((yp-min_y) / Lvoxel) Z = INT ((zp-min_z) / Lvoxel) Voexl(p) = voxel[X][Y][Z]; Among them, x p ,y p ,z p Indicates the coordinate values of a point P in the point cloud in the X, Y, and Z directions; min x ,min y ,min z Respectively represent the minimum coordinate values of the point cloud in the X, Y, and Z directions; L voxel Represents the side length of a three-dimensional grid (voxel). All three-dimensional grids (voxels) are cubes with equal side lengths. INT : represents the rounding function, that is, converting the calculation result into the maximum integer not greater than this value; X, Y, Z: represents the index of the voxel corresponding to point P in the X, Y, and Z directions; V oxel(p) represents the voxel where point P is located; v oxel[X][Y][Z] represents the voxel at index [X][Y][Z] in the 3D voxel grid.
3. The method for positioning screw hole positions based on three-dimensional point clouds according to claim 1 is characterized in that: In step S10, the following steps are included: S11. Use two 3D camera modules of the same model to perform binocular positioning on the object, calibrate the parameters of the 3D camera module, use a dot target for calibration, establish the z plane of the world coordinate system on the target plane, and obtain a homography transformation from the target plane to the image plane; S12. Determine the cycle according to the number of images of the Gray code, and encode the sub-regions by multi-frequency heterodyning to obtain sub-region level information; S13. After the unfolded phase obtained in step 12 is corrected by the epipolar line, the search for corresponding points is performed along the horizontal scan line of the image; the disparity corresponding to each point in the left and right unfolded phases is obtained by matching through a stereo matching algorithm; the similarity of the corresponding points in the left and right views is measured by using the phase difference value of a specific window transformation combined with the transformation of the pixel grayscale into a bit string; the matching costs of the target point and the surrounding nearby points are superimposed through cross-window aggregation to enhance reliability, and the matching cost aggregation is completed; and the point with the best aggregated matching cost is directly selected as the corresponding matching point through the scan line optimization parameter; for the discrete matching points including the mismatched points among the matching points calculated in the previous step, the initial disparity is refined through left and right consistency detection and adjustment of the disparity of the edge pixels to obtain a more accurate disparity result; S14. Combine the parameters of the three-dimensional camera module in step S11, and obtain the depth information of the object to be measured by the depth conversion formula through the principle of triangulation, where f is the focal length of the camera, b is the distance between the optical centers of the two cameras, d is the obtained disparity, and z is the required depth information; the disparity value obtained by the depth conversion formula obtained through the principle of triangulation is converted into the depth information of the object to be measured, and the coordinates (x, y, z) of each point in the world coordinate system are obtained according to the coordinates (x, y), and the dense point cloud information of the object is reconstructed to complete the three-dimensional reconstruction of the object; The camera external parameter matrix R1 includes the rotation matrix and the translation vector, and its expression is: Where: R is a 3x3 rotation matrix used to describe the rotation of the camera coordinate system relative to the world coordinate system; t is a 3x1 translation vector used to describe the translation of the camera coordinate system relative to the world coordinate system; the last row [0 1] is an additional row for homogeneous coordinate representation.
4. The method for positioning screw hole positions based on three-dimensional point cloud according to claim 3, characterized in that: Step S20 includes the following steps: S21. Read the two-dimensional image containing the screw holes and then perform image preprocessing: convert the image into a grayscale image, then perform binarization processing, use the contour detection algorithm to find the contours of all screw holes; extract the bounding box of the screw hole: for each detected contour, calculate its bounding box, and store these bounding boxes in the screw hole bounding box set; Traverse the screw hole bounding box set, subtract 10 from the upper left corner coordinate of each bounding box in the screw hole bounding box set, and increase the width and height by 20 to obtain the expanded bounding box; The expanded bounding box is stored in the screw hole expanded bounding box collection; S22. For each bounding box in the set of screw hole expansion bounding boxes, filter out the point cloud points within the bounding box, and store these points in the point cloud set around all screw holes after cutting; Calculate the distance from each point to the fitting plane; set a threshold, retain the point cloud points whose distance is greater than the threshold, and remove the interference points whose distance is less than the threshold; Step S40 includes the following steps: S41. Using the three-dimensional grid segmentation result in step S30, the point cloud data of the point cloud set around all screw holes after cutting are segmented into small cubic grids. The coordinates and normal vectors of the point cloud in each grid are merged, and each grid is traversed; the coordinates of the point cloud in each grid are merged; Average the normal vectors of all point clouds in the grid to get the normal vector of the grid; S42. Fit the circumference of the screw hole, use the gridded point cloud data to perform circumference fitting on each grid; and further fit a circular plane based on the grid of the circumference in the space.
5. The method for positioning screw hole positions based on three-dimensional point cloud according to claim 4, characterized in that: In step S50, the following steps are included: S51. Setting a circular template to represent the shape of the end of the screw hole, and matching the three-dimensional point cloud around the screw hole using the predefined template; to find the point cloud area that best matches the template shape, and determine its position and posture; S52. Obtaining a set of screw hole poses and a set of screw hole poses, and determining whether the matching is successful: when the template matches successfully, obtaining the pose information of the screw hole; S53. Convert to the world coordinate system, using the camera extrinsic matrix R1: multiply each pose in the pose set of the screw hole by the camera extrinsic matrix R1 to obtain the coordinates of the screw in the world coordinate system; Use the pre-performed hand-eye calibration matrix to transform the pose in the world coordinate system to the pose in the robot coordinate system.
Citation Information
Patent Citations
Method for acquiring position of mounting hole, method for mounting license plate and corresponding device
CN112045681A
Method and system for measuring circle center three-dimensional coordinates of positioning hole of automobile cylinder body workpiece
CN114087989A
Visual identification and positioning method for bolt hole of rolling mill
CN114792312A
Method and device for characterizing and calculating distribution position parameters of film holes
CN115661235A
Bolt hole positioning and pose estimation method based on three-dimensional vision
CN116958264A
Cited By
Method and device for acquiring normal vector of photovoltaic panel, medium and screw locking robot
CN119952454A
Nut tightening method, storage medium and tightening device
CN120133957A
Cannula pose recognition method and system based on binocular vision
CN120182360A
Substation screen cabinet screw identification and positioning method and system based on three-dimensional vision
CN120707633A
