Patent Publication Number: US-2023135674-A1

Title: 6d pose measurement method for mechanical parts based on virtual contour feature points

Description:
BACKGROUND OF THE INVENTION 
     1. Technical Field 
     The present invention relates to the field of computer vision, in particular to a 6D (six degree of freedom) pose measurement method for mechanical parts based on virtual contour feature points. 
     2. Description of Related Art 
     Accurate guide of robot arms has always been an important constituent part of industrial automation. However, most existing robots on assembly lines can only move and perform gripping along a preset path based on a preset program. In fact, the robots in such an operating mode can hardly adapt to the more and more complicated industrial application scenarios at present. In this operating mode, whether the robots can be accurately guided depends, to a great extent, on whether parts are accurately placed; and the robots can only grip one types of parts based on the preset path and program, and the robot arm has to be recalibrated and the path has to be re-planned when the objects to be gripped are changed. Therefore, both the working efficiency and accuracy of the robots in this operating mode need to be improved. In view of this, it appears to be particularly important to develop a reliable robot arm guiding method. 
     The common solution to the above problem in the present industrial field is to install a camera on the robot arm to acquire pose images of parts and then perform 6D pose recognition on the parts according to the images. There are two mainstream methods for 6D pose measurement of objects according to hardware facilities used during 6D pose measurement. According to one method, surface point clouds of an object are acquired by means of three-dimensional vision, and the pose of the object is calculated according to the surface point clouds. This method can acquire complete information of the object, and the accuracy of a pose calculation result is high. However, since the point clouds of the object are acquired by laser radiation, accurate surface point cloud information of the object cannot be acquired by a measuring instrument in case of serious light reflection of the surface of the object, thus, this method is not suitable for measuring reflective objects. Moreover, because a large amount of point cloud data needs to be processed, this method has the defects of high calculation cost and low speed. According to the other method, three-dimensional images are used for measurement, so this method has the advantages of low cost, small calculation amount and high speed. However, this method depends on texture information on the surface of a target object and requires remarkable feature points, but common industrial metal parts have little surface texture information, which makes this method inapplicable to metal parts. 
     In view of the defects of the existing methods, the present invention provides a novel 6D pose measurement method for mechanical parts. According to a novel 6D pose measurement method for mechanical parts, a part model is established first, a few of sparse template images are generated, edge feature lines and ellipses of a part in a real image and the template images are detected by a line detection algorithm and an ellipse detection algorithm; after that, the lines in the real image and the template images are matched, and then intersection point matching and center matching are performed according to matching lines; and finally, a real 6D pose of the part is resolved by means of a PnP function in OPENCV. 
     BRIEF SUMMARY OF THE INVENTION 
     To overcome the defects of the above-mentioned pose estimation methods, the present invention provides a 6D pose measurement method for mechanical parts based on virtual contour feature points, comprising the following steps: 
     Step 1: photographing a part twice under different light conditions to extract line features respectively, and fusing the line features; 
     Step 2: resolving intersection points of spatial lines corresponding to lines recognized from a template image; 
     Step 3: performing intersection point matching on planar lines in the template image and in a real image if the spatial lines corresponding to the lines in the template image has an intersection point therebetween; 
     Step 4: extracting ellipse features from the real image, and describing the ellipse features according to matching lines; 
     Step 5: extracting ellipse features from the template image, and describing the ellipse features according to the matching lines; 
     Step 6: matching the ellipse features in the real image with the ellipse features in the template image; 
     Step 7: matching a center in the real image with a in the template image to generate a 2D-2D matching point pair; and 
     Step 8: establishing a line intersection point and center 2D-3D point pair of “real image-CAD model” by means of a vertex coordinate file of a CAD model, and calculating a pose by a PnP algorithm. 
     Preferably, photographing a part twice under different light conditions to extract line features respectively and fusing the extracted line features in Step 1 specifically comprises: arranging lights and a camera; during the first time of photographing, turning on a light 1 and a light 3, and during the second time of photographing, turning on a light 2 and a light 4; extracting lines from two images, fusing two line recognition results, and processing repetitive results appearing during the result fusing process as follows: 
     1. Extracting an outer contour of the part, and deleting all lines except the outer contour; 
     2. Searching for lines with similar slopes and endpoint coordinates in the two results; and 
     3. Calculating a midpoint distance of a line pair obtained in Step 2; if the midpoint distance is greater than five pixels, deleting this line pair; or, if the midpoint distance is less than or equal to 5 pixels, calculating midpoints of endpoints corresponding to the two lines, using the midpoints as new endpoints, and saving the new endpoints in line recognition results. 
     Preferably, resolving intersection points of spatial lines corresponding to lines recognized from template image in Step 2 specifically comprises: traversing all the lines recognized from the template image with every two of the lines as a group. For each line, only 2D coordinates (a 1 ,b 1 ) of endpoints of this line in the template image, and coordinates (x 1 ,y 1 ,z 1 ) of a spatial line corresponding to this line are saved, two lines to be verified whether an intersection point exists therebetween are L1 and L2 respectively, 3D coordinates of initial and end points corresponding to L1 are (x 1 ,y 1 ,z 1 ) and (x 2 ,y 2 ,z 2 ) respectively and 3D coordinates of initial and end points corresponding to L2 are (x 3 ,y 3 ,z 3 ) and (x 4 ,y 4 ,z 4 ) respectively, so whether an intersection point exists between the two lines is determined by calculation according to the following formula: 
         P =( x   1   −x   3   ,y   1   −y   3   ,z   1   −z   3 )×( x   1   −x   4   ,y   1   −y   4   ,z   1   −z   4 )·( x   1   −x   2   ,y   1   −y   2   ,z   1   −z   2 )
 
     If P=0, the two lines are co-planar, and the next step is performed; or, if P≠0, the two lines are not co-planar and have no intersection point therebetween; or 
         Q =( x   1   −x   2   ,y   1   −y   32   ,z   1   −z   32 )×( x   3   −x   4   ,y   3   −y   4   ,z   3   −z   4 )
 
     If Q=0, the two lines are parallel and have no intersection point therebetween; if Q≠0, the two lines are not parallel, and an intersection point between the two lines is resolved. 
     Preferably, performing intersection point matching on planar lines in the template image and in a real image if the spatial lines corresponding to the lines in the template image has an intersection point therebetween in Step 3 specifically comprises: for a pair of lines having an intersection point therebetween in space, calculating an intersection point of the pair of lines in the real image and in the template image, matching the 2D point with the 3D point calculated in Step 2, and saving a matching result. 
     Preferably, extracting ellipse features from the real image and the template image and describing the ellipse features according to matching lines in Step 4 and Step 5 specifically comprise: extracting the ellipse features from the real image and the template image respectively, calculating distances between an ellipse center and a plurality of closest lines nearby, and saving the distances as an array. 
     Preferably, matching the ellipse features and centers in the real image and the template image in Step 6 and Step 7 specifically comprise: comparing ellipses recognized from the real image and the template image according to descriptions of the ellipses, and matching centers of two ellipses meeting the following formula: 
       diff=| a−b|   
     Wherein, a=[a 1 , a 2 , . . . , a n ], b=[b 1 , b 2 , . . . , b n ], wherein a i  and b i  are the distance from a midpoint of an ellipse a to lines nearby and the distance from a midpoint of an ellipse b to lines nearby, respectively. 
     Preferably, establishing a line intersection point and center 2D-3D point pair of “real image-CAD model” by means of a vertex coordinate file of a CAD model and calculating a pose by a PnP algorithm in Step 8 specifically comprise: performing 2D-3D point pair matching from the real image to the CAD model according to the vertex coordinate file (including a corresponding relationship between 2D points in the template image and 3D points in the CAD model) generated when the template image is generated, and calculating a pose result by a PnP function according to a matching result. 
     The present invention has the following beneficial effects: 
     1) The application range is wide, virtual geometric features on images are fully used, and more accurate geometric poses of parts can be calculated independent of texture features of the parts. 
     2) Only two-dimensional information of a scene needs to be acquired by a common grayscale camera, and the two-dimensional information occupies little space and capable of being processed rapidly. 
    
    
     
       BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS 
         FIG.  1    is a rendering picture of light arrangement; 
         FIG.  2    is a plan view of light arrangement; 
         FIG.  3    illustrates a matching result of virtual geometric points; 
         FIG.  4    illustrates an ellipse recognition result of a real image; 
         FIG.  5    illustrates an ellipse recognition result of a template image; 
         FIG.  6    illustrates a center matching result; and 
         FIG.  7    illustrates superposed rendering effect pictures. 
     
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     The present invention will be further described below in conjunction with the accompanying drawings and embodiments. 
     First, two images of a part are captured under different light conditions, wherein light arrangement is shown in  FIG.  1    and  FIG.  2   ; a light 1 and a light 3 are turned on to capture a first picture, a light 2 and a light 4 are turned on a capture a second image; 
     Then, line recognition and matching are performed on the two images by an existing method. 
     Next, two pairs of matching lines are randomly selected; whether an intersection point exists between spatial lines corresponding to the two pairs of matching lines is determined; if so, the intersection point between the two pairs of lines in a real image and a template image are calculated; or, if the two pairs of lines meet the following conditions: 
     1) The two lines are parallel to each other; 
     2) The intersection point between the two lines is outside of the images; 
     3) The distance between the two lines recognized according to the distance between intersection points is long; 
     Another two pairs of lines will be selected randomly to perform the above step until any one pair of lines is verified whether an intersection point exists therebetween. 
     If the intersection point of the two pairs of lines meets requirements, the intersection point is saved in the 2D-2D point pair, as shown in  FIG.  3   . 
     Next, ellipse detection is performed on the real image and the template image to recognize ellipses in the images, as shown in  FIG.  4    and  FIG.  5   . 
     Next, distances from each ellipse center recognized from the real image and the template image to lines nearby are calculated to form vectors, wherein each ellipse in the template image and the real image corresponds to one vector. Next, a group of vectors in the template image and the real image is randomly selected, and a difference between the two groups of vectors is calculated to obtain a modulus. When the modulus is smaller than a set threshold, 2D coordinates of this group of centers are matched, as shown in  FIG.  6   . 
         {right arrow over (a)} =[ x   1   x   2    . . . x   n ] 
         {right arrow over (b)} =[ y   1   y   2    . . . y   n ] 
     
       
      
       P=∥{right arrow over (a)}−{right arrow over (b)}∥ 
      
     
     Next, matching of 2D coordinates in the real image with 3D coordinates of a model is completed according to a 2D-3D coordinate corresponding relationship in a vertex file. 
     Finally, a 6D pose of the part is resolved according to the 2D coordinates in the real image and the 3D coordinates of the model by means of a PnP function in OPENCV to obtain a position vector and a rotation vector of the part, superposed rendering pictures of calculation results are shown in  FIG.  7   . Each picture in  FIG.  7    is formed by superposing two images, one of which is a captured real image and the other one is an image formed by rendering a CAD model according to calculation results, and it can be seen, from the rendering pictures, that the rendered images almost completely overlap with original images, which indicates that the calculation results are extremely accurate. 
     Although the preferred embodiments of the invention have been disclosed above, these embodiments are not intended to limit the invention. Different modifications and embellishments can be made by those skilled in the art without departing from the spirit and scope of the invention. Thus, the protection scope of the invention should be defined by the claims.