Shaft part measuring method based on motion scanning and image acquisition

Through the measurement method of shaft parts based on motion scanning and image acquisition, combined with the gripper and vision system, the automatic detection of shaft parts and the automatic detection of multi-size types are realized, solving the problems of low efficiency and complex operation of existing detection methods. , improving detection efficiency and simplifying the operation process.

CN118729944APending Publication Date: 2024-10-01RES INST OF ZHEJIANG UNIV TAIZHOU
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411031995.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

The existing inspection methods for shaft parts are inefficient and cannot detect multiple sizes at the same time. The operation is cumbersome, requires high operator skills and is complex to maintain.

Method used

The measurement method of shaft parts based on motion scanning and image acquisition is adopted. The upper computer controls the lower computer to perform data acquisition and image processing to achieve automatic detection and automatic detection of multiple sizes and types. The clamping device and vision system are combined to clamp the product. and position correction, using template libraries and decision trees for quality classification and blanking processing.

Benefits of technology

It realizes automatic detection of shaft parts and automatic detection of multiple size types, improves detection efficiency, simplifies operating procedures, reduces maintenance complexity, and can automatically cut materials according to quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118729944A_ABST
    Figure CN118729944A_ABST
Patent Text Reader

Abstract

The invention discloses a shaft part measuring method based on motion scanning and image acquisition, and the method is based on a shaft part measuring system which comprises an upper computer, a lower computer, a feeding device, a transmission device, a jacking device, a visual system, a clamping jaw device and a discharging device. The upper computer controls the feeding device, the conveying device, the jacking device, the visual system, the clamping jaw device and the discharging device to execute actions through the lower computer, and the upper computer comprises a database, a data acquisition module, a system state monitoring module and a man-machine interaction module. According to the invention, automatic detection of the size of the part and automatic detection of various size types of the part are realized through the shaft part measuring device, meanwhile, the quality of the part is automatically distinguished, a full-automatic detection process of automatic blanking according to the quality is realized, and compared with an existing detection mode, the part detection efficiency is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of parts detection, and relates to a shaft parts measuring method based on motion scanning and image acquisition. Background Art

[0002] Shaft parts are one of the most common parts in the machinery industry. The evaluation of the size and form tolerance of shaft parts, especially precision shaft parts, is an important means to measure the processing quality of shaft parts. At present, shaft parts are mainly tested by general measuring tools or special shaft measuring instruments: general measuring tools have strong applicability but relatively low detection efficiency and accuracy, while special shaft measuring instruments require high operator skills and are cumbersome to maintain.

[0003] At present, the dimensional inspection of shaft parts is not limited to the inspection of one dimension, but usually includes the inspection of length, height, coaxiality, etc. However, the above-mentioned inspection method can only inspect one dimension at a time. When other dimensions need to be inspected, other inspection equipment needs to be replaced, which is not only cumbersome but also inefficient. Summary of the invention

[0004] In order to overcome at least one deficiency of the prior art, the present invention provides a shaft parts measuring method based on motion scanning and image acquisition.

[0005] In order to achieve the above-mentioned purpose, the present invention adopts the following technical scheme: a method for measuring shaft parts based on motion scanning and image acquisition, the method is based on a shaft part measurement system, the system includes a host computer, a slave computer, a feeding device, a transmission device, a lifting device, a visual system, a clamping device, and a feeding device. The host computer controls the feeding device, the transmission device, the lifting device, the visual system, the clamping device, and the feeding device through the slave computer to perform actions. The host computer includes a database, a data acquisition module, a system status monitoring module, and a human-computer interaction module. The method includes the following steps:

[0006] Step 1: After the system is powered on, it will enter the self-test process. If the self-test passes, it will proceed to step 2. If the self-test fails, it will wait for the user to perform maintenance and then re-perform self-test;

[0007] Step 2: Read the system status file, the data acquisition module executes the data acquisition process, obtains a single product outer contour data processing object, performs preliminary processing on the single product outer contour data processing object, and obtains the product outer contour size data;

[0008] Step 3: Import the product outer contour dimension data into the template decision tree to determine whether the decision tree is empty. If so, the display interface shows that there is no corresponding template and execute step 4. If not, execute the product quality classification process.

[0009] Obtain product quality classification data, and the number of product inspections will increase by 1;

[0010] Step 4: Enter the template library to search for a template. If the template library has a corresponding template, the decision tree is written into the template and step 3 is executed. If the template library does not have a corresponding template, a button for creating a template is displayed on the display interface.

[0011] Step 5: Input the product quality classification data into the host computer to determine whether the product quality classification data is abnormal. If so, read the product corner point features and execute the template matching process. If not, execute step 4.

[0012] Step 6: The system executes the material unloading process according to the product classification data to move the product from the set position to the corresponding material unloading classification frame 72;

[0013] Step 7: Determine whether all product contours have been inspected. If yes, the system stops. If no, proceed to step 2.

[0014] Step 8: End.

[0015] Furthermore, the loading device and the unloading device are respectively docked with the transmission device, the loading device includes a loading frame, a loading robot and a loading position sensor, the loading position sensor is installed on the transmission device, the transmission device is provided with a detection position sensor and a carrying device for carrying the product, the detection position sensor is located at a set detection position, the detection position sensor is used to detect whether the product reaches the detection position, the lifting device includes a lifting cylinder and a lifting plate, the lifting plate is fixedly connected to the output shaft of the lifting cylinder, the lifting plate is used to lift the product, the visual system includes a visual moving mechanism and a measuring head, the visual moving mechanism is connected to the measuring head, the clamping device includes a first clamping mechanism and a second clamping mechanism, the first clamping mechanism includes a first cylinder, a first clamping jaw and a first clamping jaw detection sensor, the second clamping mechanism includes a second cylinder, a second clamping jaw and a second clamping jaw detection sensor, the unloading device includes a unloading robot, an unloading classification frame and and an unloading sensor.

[0016] Furthermore, the data collection process is used to collect product contour data processing objects, which are graphs.

[0017] Like, this object is used for subsequent size calculations, which include the following steps:

[0018] Step 21: The host computer waits for the loading signal from the loading robot and the unloading signal from the unloading robot;

[0019] The loading manipulator transmits the loading result and the unloading robot transmits the unloading result to the PLC. The PLC sets the loading completion and unloading completion flag registers to 1. The host computer reads the loading and unloading status by scanning the PLC registers to obtain the loading completion signal of the loading manipulator and the unloading completion signal of the unloading robot.

[0020] Step 22: Write motion parameters to PLC;

[0021] Step 23: Execute the single product measurement motion process;

[0022] Step 24: The host computer receives a motion completion signal sent back by the PLC and reads the sensor data once;

[0023] Step 25: Complete product outline data collection.

[0024] Furthermore, before the measurement starts, the overall measurement area of ​​a single product is divided into multiple measurement areas according to the template setting requirements. After the measuring head completes the data collection of a single measurement area, the lower computer controls the motion mechanism to move the measuring head to the next measurement area, and repeats the above steps to complete the surface profile data collection of the entire shaft. The single product measurement motion process is used for the data collection of the outer contour of a single product, and specifically includes the following steps:

[0025] Step A1: Wait for the PLC signal, execute the loading process to move the product from the loading frame to the set position and clamp it;

[0026] Step A2: The measuring head moves to the qth shooting position to shoot the image of the inspection area where the product cq is located, saves the cq image, transmits the cq image to the host computer, and the number of shots P is counted + 1;

[0027] The product is divided into several detection areas along its axial direction, namely c1...cq...cp. The 1st...q...pth shooting positions are set. The first shooting position corresponds to the c1 detection area...the pth shooting position corresponds to the cp detection area. q is the serial number of the current detection area, and p is the total number of the divided detection areas.

[0028] Step A3: Determine whether P is less than p. If so, it is considered that the product scanning is not completed, and a motion instruction is sent to the PLC. The measuring head moves to the q+1th shooting position, and the sequence number q=q+1 is reset. Step A2 is executed. If not, it is considered that the product scanning is completed, and step A4 is executed.

[0029] Step A4: the host computer performs preliminary processing on the c1...cq...cp images to obtain pre-processed images;

[0030] The c1...cq...cp images contain all the outer contour dimension data of the product. The pre-processed images of each inspection area are obtained by pre-processing the images.

[0031] Step A5: Read the template detection area information to obtain the product outer contour dimension data contained in the pre-processed image.

[0032] Furthermore, the product loading process in step A1 includes the following steps:

[0033] Step A11: The loading position sensor detects whether there is material on the current carrying device. If so, execute step A12; if not, the loading robot 11 places the product from the loading frame on the carrying device;

[0034] Step A12: The transmission device transports the product to the inspection position;

[0035] Step A13: The lifting device lifts the product to the set position. When the proximity switch receives the in-position signal, it is considered that the product has been lifted to the set position. After waiting for the set time, if there is no in-position signal within the set time, the system stops and an alarm is issued, indicating that the lifting cylinder is wrong.

[0036] Step A14: the visual moving mechanism moves the measuring head to a set first position to scan a first image of the product, moves the measuring head to a set second position to scan a second image of the product, and processes and integrates the first image and the second image to obtain an initial image;

[0037] The first image scanned by the measuring head at the first position is an image of one end of the product, and the second image scanned by the measuring head at the second position is an image of the other end of the product;

[0038] Step A15: Compare the initial image with the target position image in the template to determine whether the initial image matches the target position image. If so, it is considered that the current product is in the set center position, and step A17 is executed; if not, it is considered that the current product deviates from the set position, and step A16 is executed;

[0039] The source of the target position image in the template is: when the product is located at the set center position, the measuring head is located at the first position and scans the standard first image of the product; the measuring head is located at the second position and scans the standard second image of the product; the standard first image and the standard second image are processed and integrated to obtain the target position image, and the coordinates of the two ends of the product in the target position image can be obtained, and then the distances a1 and a2 between the two ends of the product and the boundary can be known. When the product is in the center position, a1=a2, and a1 and a2 are known values;

[0040] The method for judging whether the initial image matches the target position image is: obtaining the coordinates of the two ends of the product in the initial image, and then obtaining the distances a3 and a4 between the two ends of the product and the boundary, where a=|a1-a3|, and a is the deviation value of a1 and a3. If a is not greater than the preset deviation value threshold, it is considered that the initial image matches the target position image, and the current product is in the set center position. If a is greater than the preset deviation value threshold, it is considered that the initial image does not match the target position image, and the current product deviates from the set position.

[0041] Step A16: The first clamping mechanism or the second clamping mechanism pushes the product to a central position;

[0042] Before starting, the first clamp mechanism and the second clamp mechanism are located at the set positions respectively. The distances between the first clamp mechanism and the second clamp mechanism and the center of the product located at the center are preset values, namely b1 and b2 respectively. In the initial image, the coordinates of the center of the product are obtained according to the length L of the product, and the actual distance values ​​b3 and b4 between the first clamp mechanism and the second clamp mechanism and the center of the current product are obtained, and the deviation between the preset value and the actual distance value is calculated;

[0043] b5=|b1-b3|,

[0044] b6=|b2-b4|;

[0045] Determine whether b5 is greater than b6. If so, drive the second clamping mechanism to move X in the product direction, X=b3-L / 2+b1--b3=b1-L / 2; if not, drive the first clamping mechanism to move y in the product direction, y=b4-L / 2+b2--b4=b2-L / 2;

[0046] Step A17: The first clamping mechanism or the second clamping mechanism is reset, the first clamping mechanism moves toward the product, the first clamping mechanism performs a clamping action, and the first clamping sensor detects whether the product is clamped. If so, step A18 is executed. If not, an alarm is issued to indicate that the product has fallen.

[0047] Step A18: The measuring head scans and obtains the current product clamping image, matches the current product clamping image with the standard product clamping image of the template, and compares the similarity between the two. If the similarity reaches a preset threshold, it is considered that the first clamping jaw has clamped the product in place; if the similarity does not reach the preset threshold, it is considered that the first clamping jaw has not clamped the product in place, and an alarm is issued to indicate that the product is not clamped;

[0048] The standard product clamping image is an image taken when the first clamping jaw clamps the product normally;

[0049] Step A19: The second clamping jaw mechanism moves toward the product, and the second clamping jaw performs a clamping action. The second clamping jaw detection sensor detects whether the product is clamped. If so, step A110 is executed. If not, an alarm is issued to indicate that the product has fallen.

[0050] Step A110: The measuring head scans and obtains the current product clamping image, matches the current product clamping image with the standard product clamping image of the template, and compares the similarity between the two. If the similarity reaches a preset threshold, it is considered that the second clamping jaw has clamped the product in place; if the similarity does not reach the preset threshold, it is considered that the second clamping jaw has not clamped the product in place, and an alarm is issued to indicate that the product is not clamped;

[0051] Step A111: Loading is completed.

[0052] Furthermore, the image pre-processing in step A4 specifically includes the following steps:

[0053] Step A41: stitching the c1...cq...cp images;

[0054] According to the detection area and corner point information set by the template, when there is an overlapping area, the two images are spliced;

[0055] Image stitching is performed using a phase correlation algorithm, which specifically includes the following steps:

[0056] Step A41-1: Perform Fourier transform on the image to be stitched to obtain its frequency domain representation;

[0057] Step A41-2: Convert the frequency domain representation into a phase representation, and calculate the phase difference between different images;

[0058] Step A41-3: Calculating phase correlation according to the phase difference;

[0059] By normalizing the phase difference, the phase correlation value is obtained, which is used to evaluate the similarity between different images;

[0060] Step A41-4: determining the registration parameter according to the maximum phase correlation value;

[0061] Find the registration parameter corresponding to the maximum phase correlation value, and use the parameter to perform image registration and stitching;

[0062] Step A42: cropping the spliced ​​image according to the detection area drawn when the template is made to obtain a cropped image;

[0063] Step A43: Perform bilateral filtering and least squares interpolation on the cropped image to obtain a preprocessed image.

[0064] Furthermore, in the step 3, the product quality classification process classifies the product quality based on the template and the product outer contour dimension data. The preprocessed images of different inspection areas belong to different measurement types of products, and the dimension calculation methods of different measurement types of products are different.

[0065] When the measurement type is outer diameter and height, the outer diameter and height measurement is the line-to-line spacing calculation. The calculation process includes the following steps:

[0066] Step C1: extracting edge points of the corresponding pre-processed image according to the measurement type set by the template;

[0067] Step C2: Fitting edge points to two straight lines based on the least squares method;

[0068] Step C3: Calculate the distance D between the two straight lines;

[0069] Step C4: Compare the distance D with the standard value set by the template and each tolerance range to obtain the product quality classification of the measurement type;

[0070] The steps for calculating the spacing D in step C3 are:

[0071] Step C31: The line with more edge points among the two lines is taken as the target line L2, and the line with less edge points is taken as the original line L1;

[0072] Step C32: Assume that the starting point P1 and the end point P2 of the original straight line L1, the starting point P3 and the end point P4 of the target straight line L2, the coordinates of P1, P2, P3, and P4 are known, which are P1 (X1, Y1), P2 (X2, Y2), P3 (X3, Y3), and P4 (X4, Y4), respectively. The target straight line is translated to the starting point P1, so that the end point P4 of the target straight line coincides with P1, and is set as L3. The target straight line is translated to the starting point P1, so that the starting point P3 of the target straight line coincides with P1, and is set as L4.

[0073] Step C33: Calculate the translation offset Lm1 between L3 and L2 and the translation offset Lm2 between L4 and L2;

[0074] Lm1(X1-X4, Y1-Y4), Lm2(X1-X3, Y1-Y3);

[0075] Step C34: Calculate the distance between the end point P3O of L3 away from P1, the end point P4O of L4 away from P1 and the end point P2 of L1 according to the translation offset, and select the standard line according to the distance;

[0076] Coordinates of the two endpoints of L3:

[0077] ([(X1, Y1), (P3OX, P3OY)]) = ([(X1, Y1), (X3+X1-X4, Y3+Y1-Y4)]);

[0078] The distance d3O between P3O and the end point P2 of L1 is:

[0079]

[0080] Coordinates of the two end points of L4:

[0081] ([(X1, Y1), (P4OX, P4OY)])===([(X1, Y1), (X4+X1-X3, Y4+Y1-Y3)]);

[0082]

[0083] Determine the size of d3O and d40. If d3O is less than d40, determine that the angle between L3 and L2 is an acute angle. If d3O is greater than d40, determine that the angle between L4 and L2 is an acute angle. Select the straight line with an acute angle with L2 as the standard line for subsequent calculations. In this embodiment, Figure 7 b and 7c, the angle between L4 and L2 is acute, and L4 is the standard line;

[0084] Step C35: Select the midpoint of the line connecting P40 of L4 and P2 of L1, connect P1 and the midpoint, and obtain a parallel constraint line;

[0085] The coordinates of the two end points of the parallel constraint line are [(X1, Y1), (P4OX+X2) / 2, (P4OY+Y2) / 2];

[0086] Step C36: Calculate the slope k of the parallel constraint line;

[0087] K=((P4OX+X2) / 2-X1) / ((P4OY+Y2) / 2-Y1)

[0088] =(P4OX+X2-2X1) / (P4OY+Y2-2Y1);

[0089] Step C37: translating the parallel constraint line so that the endpoint of the parallel constraint line coincides with the midpoint of L1, thereby obtaining the target parallel constraint line L5;

[0090] The L5 slope formula is y = kx + b, where k is the slope of the parallel constraint line;

[0091] The coordinates of the midpoint of L1 are ((X1+X2) / 2), (Y1+Y2) / 2));

[0092] Therefore, b = (Y1 + Y2) / 2 - k(X1 + X2) / 2;

[0093] Step C38: Calculate the distance D;

[0094] The spacing D is the distance from the point to the line, that is, the distance from the midpoint of L2 to the target parallel constraint line L5;

[0095]

[0096] A=k,B=-1,C=b,(x0,y0) are the coordinates of the midpoint of L2,(x0,y0)=((X3+X4) / 2),(Y3+Y4) / 2)),

[0097] have to:

[0098]

[0099] Furthermore, when the measurement type is spherical diameter, according to the template settings, there are 4 modes for spherical diameter calculation:

[0100] 1. Direct fitting to find the diameter without circle search;

[0101] 2. Find the maximum distance without circle search and use it as the diameter;

[0102] 3. Contour extraction with circle search and diameter calculation of circle fitting;

[0103] 4. Contour extraction with circle search, find the maximum distance as the diameter;

[0104] The specific steps of Mode 1 are:

[0105] Step D1-1: extracting contour data of the corresponding pre-processed image according to the measurement type set in the template;

[0106] When editing the template, the spherical diameter detection area set by the template is drawn in an area smaller than the spherical range, that is, it does not include the non-spherical contour and there will still be no non-spherical contour range after the sample has a small offset;

[0107] Step D1-2: Fit the circle based on the least squares method, find the standard equation of the circle, get the radius of the circle, and multiply it by 2 to get the diameter;

[0108] The specific steps of Mode 2 are:

[0109] Step D2-1: extracting the contour data of the corresponding pre-processed image according to the measurement type set by the template;

[0110] When editing the template, the spherical diameter detection area set by the template is drawn in an area smaller than the spherical range, that is, it does not include the non-spherical contour and there will still be no non-spherical contour range after the sample has a small offset;

[0111] Step D2-2: Fit the circle based on the least squares method, calculate the maximum distance between the point on the left contour and the point on the right contour, take the middle 80% range data, remove the maximum and minimum values, and take the average as the diameter;

[0112] The specific steps of Mode 3 are:

[0113] Step D3-1: according to the measurement type set in the template, extract the corresponding pre-processed image, perform circle search position correction on it and extract contour data, and use Hough transform to locate the circle position;

[0114] When editing the template, the spherical diameter detection area set by the template is drawn in an area smaller than the spherical range, that is, it does not include the non-spherical contour and there will still be no non-spherical contour range after the sample has a small offset;

[0115] Step D3-2: Fit the circle based on the least squares method, find the standard equation of the circle, get the radius of the circle, and multiply it by 2 to get the diameter;

[0116] The specific steps of Mode 4 are:

[0117] Step D4-1: according to the measurement type set by the template, extract the corresponding pre-processed image, perform circle search position correction on it and extract contour data, and use Hough transform to locate the circle position;

[0118] When editing the template, the spherical diameter detection area set by the template is drawn in an area smaller than the spherical range, that is, it does not include the non-spherical contour and there will still be no non-spherical contour range after the sample has a small offset;

[0119] Step D4-2: Fit the circle based on the least squares method, calculate the maximum distance from the point on the left contour to the point on the right contour, take the middle 80% range of data, remove the maximum and minimum values, and take the average as the diameter.

[0120] Furthermore, when the measurement type is thread diameter and pitch, the calculation steps are as follows:

[0121] Step G1: extracting edge point data of the corresponding pre-processed image according to the measurement type set by the template;

[0122] Step G2: perform mean filtering on the edge point data (determine the thread peak-valley according to the change of the curve slope, and use fuzzy processing to reduce the extraction of thread area by small fluctuations);

[0123] Step G3: Segment the edge points into several small segments according to the set detection accuracy;

[0124] Set the detection accuracy to 10 times, that is, 10 data form a small segment to calculate the slope;

[0125] Step G4: Calculate the slope of each segment and extract the zero-crossing point of the slope;

[0126] The zero crossing point is the point where the positive changes to negative or negative changes to positive, and the zero crossing point is the peak point or valley point;

[0127] Step G5: accurately locate the peak and valley positions, using the maximum and minimum values ​​before mean filtering in step 2 and combining the zero crossing points to determine the peak and valley points;

[0128] Step G6: taking the average of all adjacent peak-to-peak distances and valley-to-valley distances as the pitch result;

[0129] Step G7: Fitting straight lines to all peak points of the contour and calculating the distance between the straight lines to the peak points of another contour as the major diameter;

[0130] Step G8: Fitting straight lines to all valley points of the contour and the distance between the straight lines fitting to valley points of another contour is used as the path;

[0131] Step G9: calculation;

[0132] Step G10: Fitting a straight line and calculating the diameter;

[0133] Taking all points within the range of ±0.002 of the peak and valley points, increasing the amount of data improves the accuracy of straight line fitting.

[0134] Furthermore, the step G9 includes the following steps:

[0135] Step G9-1: Calculate the distance D between the left contour and the right contour, and calculate each outer diameter value every 0.1 mm in the y-axis direction to obtain a distance set D = {D1, D2, ..., Dn};

[0136] The spacing D is the distance between the left contour point (x1 n, y1 n) and the right contour point (x2n, y2n), where the difference between y1 n and y2n is less than 0.1 mm. If the difference is greater than 0.1 mm, the next set of D is calculated;

[0137] Step G9-2: Perform median filtering and mean smoothing filtering on the data of set D to obtain set D';

[0138] Step G9-3: Take all values ​​with odd numbers in D' to obtain D'={D1, D3, D5...Dn}. By eliminating half of the adjacent values, the influence of interference data on the number of zero-crossing points can be prevented;

[0139] Step G9-4: Perform differential processing on D' to obtain DD, DD = {D3-D1, D5-D3, ...Dn-Dn-2};

[0140] Step G9-5: Binarize the data of DD, set the value greater than 0 to 1, and the value less than 0 to 0, and obtain DD';

[0141] Step G9-6: perform differential processing on the data of DD', and extract the index peak y coordinate set Max with a value of -1 and the index trough y coordinate set Min with a value of 1;

[0142] Step G9-7: Accurately locate the peak and valley coordinates of the contour data;

[0143] Left contour (peak point): Taking the first peak in Max as an example, take the set P of all contour points in the Max[0] neighborhood (Max[0]-0.1, Max[0]+0.1), and take the point with the minimum x coordinate in P as the peak point;

[0144] Right contour (peak point): Taking the first peak in Max as an example, take the set P of all contour points in the Max[0] neighborhood (Max[0]-0.1, Max[0]+0.1), and take the point with the maximum x coordinate in P as the peak point.

[0145] Left contour (trough point): Taking the first peak in Max as an example, take the set P of all contour points in the Max[0] neighborhood (Max[0]-0.1, Max[0]+0.1), and take the point with the maximum x coordinate in P as the trough point.

[0146] Right contour (trough point): Taking the first peak in Max as an example, take the set P of all contour points in the neighborhood of Max[0] (Max[0]-0.1, Max[0]+0.1), and take the point with the smallest x coordinate in P as the trough point.

[0147] In summary, the present invention is beneficial in that:

[0148] The present invention realizes automatic detection of part size and automatic detection of various size types of individual parts through a shaft part measuring device, and simultaneously automatically distinguishes the quality of parts and automatically unloads materials according to the quality. Compared with the existing detection methods, the present invention greatly improves the efficiency of part detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0149] Figure 1 It is a schematic diagram of the system control flow of the present invention.

[0150] Figure 2 It is a schematic diagram of the feeding process of the present invention.

[0151] Figure 3 It is a schematic diagram of the material cutting process of the present invention.

[0152] Figure 4 It is a schematic diagram of the shaft parts measuring system of the present invention.

[0153] Figure 5 It is a schematic diagram of the jacking device of the present invention.

[0154] Figure 6 It is a schematic diagram of the visual system and the gripper device of the present invention.

[0155] Figure 7 a- Figure 7 e is a schematic diagram of the structure of the line-to-line spacing calculation of the present invention.

[0156] Figure 8 a- Figure 8 d is a schematic diagram of the structure of the ball diameter calculation of the present invention. DETAILED DESCRIPTION

[0157] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.

[0158] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0159] All directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, horizontal, vertical...) are only used to explain the relative position relationship, movement status, etc. between the components in a certain specific posture. If the specific posture changes, the directional indication will also change accordingly.

[0160] Due to installation errors and other reasons, the parallel relationship referred to in the embodiments of the present invention may actually be an approximately parallel relationship, and the vertical relationship may actually be an approximately vertical relationship.

[0161] Embodiment 1:

[0162] like Figure 1-Figure 8 As shown, a method for measuring shaft parts based on motion scanning and image acquisition is based on a shaft part measurement system. The system includes an upper computer, a lower computer, a feeding device 1, a transmission device 2, a lifting device 3, a visual system 4, a clamping device 5, and a feeding device 7. The upper computer controls the feeding device 1, the transmission device 2, the lifting device 3, the visual system 4, the clamping device 5, and the feeding device 7 through the lower computer to perform actions. The upper computer includes a database, a data acquisition module, a system status monitoring module, and a human-computer interaction module.

[0163] The method comprises the following steps:

[0164] Step 1: After the system is powered on, it will enter the self-test process. If the self-test passes, it will proceed to step 2. If the self-test fails, it will wait for the user to perform maintenance and then re-perform self-test;

[0165] Step 2: Read the system status file, the data acquisition module executes the data acquisition process, obtains a single product outer contour data processing object, performs preliminary processing on the single product outer contour data processing object, and obtains the product outer contour size data;

[0166] Step 3: Import the product outer contour dimension data into the template decision tree to determine whether the decision tree is empty. If so, the display interface shows that there is no corresponding template and executes step 4. If not, execute the product quality classification process to obtain product quality classification data, and the number of product inspections increases by 1.

[0167] Measure and label the product according to the parameters set by the decision tree;

[0168] Product quality classification is specifically divided into excellent products, defective products, etc.

[0169] Step 4: Enter the template library to search for a template. If the template library has a corresponding template, the decision tree is written into the template and step 3 is executed. If the template library does not have a corresponding template, a button for creating a template is displayed on the display interface.

[0170] Step 5: Input the product quality classification data into the host computer to determine whether the product quality classification data is abnormal. If so, read the product corner point features and execute the template matching process. If not, execute step 4.

[0171] Abnormal product quality classification data means that the product is not a good product, but a defective product or other abnormal situation;

[0172] Step 6: The system executes the material unloading process according to the product classification data to move the product from the set position to the corresponding material unloading classification frame 72;

[0173] Step 7: Determine whether all product contours have been inspected. If yes, the system stops. If no, proceed to step 2.

[0174] Step 8: End.

[0175] The loading device 1 and the unloading device 7 are respectively connected to the transmission device 2, the loading device 1 moves the product (parts to be tested) to the transmission device 2 for loading, the transmission device 2 drives the product to move to the detection position, the lifting device 3 lifts the product moved to the detection position to the set position, the clamping device 5 clamps the product, and the visual system 4 collects the image of the product.

[0176] For the convenience of orientation description, this embodiment establishes an xyz coordinate system, where the x-axis is the left-right direction, which is also the transmission direction of the transmission device 2, the y-axis is the front-back direction, which is also the width direction of the transmission device 2, and the z-axis is the height direction.

[0177] The loading device 1 includes a loading frame 10, a loading robot 11 and a loading position sensor 12. The loading position sensor 12 is installed on the transmission device 2. The loading position sensor 12 is used to detect whether the product is placed on the transmission device 2. The loading frame 10 has several products built in. The loading robot 11 clamps the product and places it on the transmission device 2. After the loading position sensor 12 detects the product, the transmission device 2 starts to move the product to the detection position.

[0178] The transmission device 2 is configured as a motor-driven assembly line structure, specifically including a transmission motor, a transmission frame 21, a transmission belt 22 and a plurality of carrying devices 23. The transmission motor and the transmission belt 22 are respectively connected to the transmission frame 21, and a plurality of carrying devices 23 are distributed in an array on the transmission belt 22 along the transmission direction of the transmission device 2. The carrying device 23 is used to carry products. The transmission motor drives the transmission belt 22 to transmit, thereby driving the carrying device 23 and the products it carries to move synchronously.

[0179] The conveyor belt 22 is provided with a plurality of lifting openings 221, which are connected up and down, and are arranged in an array along the transmission direction of the transmission device 2. During the movement of the conveyor belt 22, the plurality of lifting openings 221 are sequentially opposite to the lifting device 3. The number of the lifting openings 221 corresponds to the number of the carrying devices 23, and the two are arranged in a one-to-one correspondence.

[0180] The carrying device 23 includes two groups of carrying blocks 231, which are symmetrically distributed on both sides of the lifting port 221. The two groups of carrying blocks 231 respectively carry the two ends of the product, and the middle end of the product is located above the lifting port 221. When the conveyor belt 22 drives the product to move to the detection position, that is, the product is located above the lifting device 3, the lifting device 3 starts to lift the product to the specified position.

[0181] Preferably, the bearing block 231 is provided with a bearing opening (not shown in the figure), and the bearing opening is a V-shaped structure. The product is placed in the bearing opening, and the V-shaped bearing opening can limit the product.

[0182] The transmission frame 21 is also provided with a detection position sensor 24. The detection position sensor 24 is located at a set detection position. The detection position sensor 24 is used to detect whether the product reaches the detection position.

[0183] The lifting device 3 includes a lifting cylinder 31 and a lifting plate 32. The lifting plate 32 is fixedly connected to the output shaft of the lifting cylinder 31. The lifting plate 32 is used to lift the product. The lifting cylinder 31 starts and controls the lifting plate 32 to drive the product to move up and down. The lifting cylinder 31 is provided with a proximity switch, and the proximity switch can be used to determine whether the product is lifted into place.

[0184] The visual system 4 includes a visual moving mechanism 41 and a measuring head 42. The visual moving mechanism 41 is connected to the frame 6. The visual moving mechanism 41 is connected to the measuring head 42. The visual moving mechanism 41 is configured as a power drive mechanism. The measuring head 42 is controlled to move along the y-axis direction by the visual moving mechanism 41. The power drive mechanism can be configured as a cylinder drive, a ball screw drive, a synchronous belt drive or other structures, which is not limited in the present application.

[0185] There are two groups of measuring heads 42, and the two groups of measuring heads 42 are symmetrically arranged along the x direction, so as to facilitate comprehensive scanning and detection of the product.

[0186] The clamping device 5 includes a first clamping mechanism 51 and a second clamping mechanism 52. The first clamping mechanism 51 and the second clamping mechanism 52 are located in the front-to-back direction to clamp two ends of the product respectively.

[0187] The first clamping mechanism 51 includes a first cylinder 511, a first clamping jaw 512 and a first clamping jaw detection sensor 513. The first cylinder 511 is fixedly connected to the frame 6. The first cylinder 511 is connected to the first clamping jaw 512. The first cylinder 511 drives the first clamping jaw 512 to move. The first clamping jaw 512 is used to clamp the detection part. The first clamping jaw detection sensor 513 is connected to the first clamping jaw 512. The first clamping jaw detection sensor 513 is used to detect whether the first clamping jaw 512 clamps the detection part. The second clamping mechanism 52 includes a second cylinder 521, a second clamping jaw 522 and a second clamping jaw detection sensor 523. The second cylinder 521 is fixedly connected to the frame 6. The second cylinder 521 is connected to the second clamping jaw 522. The second cylinder 521 drives the second clamping jaw 522 to move. The second clamping jaw 522 is used to clamp the detection part. The second clamping jaw detection sensor 523 is connected to the second clamping jaw 522. The second clamping jaw detection sensor 523 is used to detect whether the second clamping jaw 522 clamps the detection part.

[0188] The unloading device 7 includes an unloading robot 71, an unloading classification frame 72 and an unloading sensor (not shown). The unloading sensor is used to detect whether the measured parts have reached the unloading position. The unloading classification frame 72 is divided into a finished product frame and a defective frame. The unloading robot 71 places the measured parts in the finished product frame or the defective frame according to the measurement results of the product.

[0189] The upper computer has built-in upper computer software, and the upper computer communicates with the lower computer (PLC) to obtain real-time data and process, monitor, control and manage and calculate product dimensions. The product dimensions include ball diameter, roundness, outer diameter, height, and thread pitch.

[0190] The database is used to store the data of the host computer software, including user data, instruction data and related logs;

[0191] Data acquisition module, used to obtain product surface profile data;

[0192] System status monitoring module, which is used to monitor the equipment operation status in real time by reading the status bit of the lower computer in real time, and automatically issue an alarm or prompt information when an abnormal situation occurs;

[0193] The human-computer interaction module is used by operators to manage the human-computer interaction function of the upper computer software to realize information exchange and operation control between humans and machines. The human-computer interaction function includes display interface, control function, data management, and user authority management.

[0194] The display interface is used by actual operators to facilitate data observation and operation. The equipment status and measurement information are displayed in charts. The measurement information is product production information and single-piece production quality. The display interface also includes a login button and a motion setting button. Click the login button to enter the login interface. The login interface includes a user login mode and a visitor mode. When the actual operator cannot enter through the user login mode, he can enter through the visitor mode; click the motion parameter setting button to enter the motion parameter setting interface. The motion parameters are written to the PLC through the motion parameter setting interface. The motion parameters include the detection position and the motion speed of the transmission device 2.

[0195] Control function: used by actual operators to control the equipment through the host computer, such as starting, stopping, changing products (changing measurement templates), manually controlling equipment, etc.

[0196] Data management: used by management personnel to manage measurement template data and product size quality production data;

[0197] User authority management: used by management personnel to manage and control the operating authority of users in the system to ensure the security and confidentiality of data.

[0198] The self-check process in step 1 includes the following steps:

[0199] Step 11: Is the system connected to the database? If so, enter the login interface and execute step 12. If not, execute step 13 in guest mode.

[0200] Step 12: Check whether the actual operator has logged in successfully. If so, proceed to step 13;

[0201] Step 13: Determine whether the status of the lower computer is normal. If so, execute step 14. If not, determine that the self-test has failed.

[0202] Step 14: Determine whether the state of the measuring head 42 is normal. If so, determine that the self-test has passed. If not, determine that the self-test has not passed.

[0203] The data collection process is used to collect product contour data processing objects, which are images. The objects are used for subsequent size calculations and specifically include the following steps:

[0204] Step 21: The host computer waits for the loading completion signal from the loading manipulator 11 and the unloading completion signal from the unloading robot 71;

[0205] The loading robot 11 transmits the loading and unloading results to the PLC, and the PLC sets the loading completion and unloading completion flag registers to 1. The host computer reads the loading and unloading conditions by scanning the PLC registers, thereby obtaining the loading completion signals of the loading robot 11 and the unloading completion signals of the unloading robot 71.

[0206] Step 22: Write motion parameters to PLC;

[0207] Step 23: Execute the single product measurement motion process;

[0208] Step 24: The host computer receives a motion completion signal sent back by the PLC and reads the sensor data once;

[0209] Step 25: Complete product outline data collection.

[0210] Before measuring, the whole measuring area of ​​a single product is divided into multiple measuring areas according to the template setting requirements. After the measuring head completes the data collection of a single measuring area, the lower computer controls the motion mechanism to move the measuring head to the next measuring area, and repeats the above steps to complete the surface profile data collection of the entire shaft. The single product measurement motion process is used for the data collection of the outer contour of a single product, which specifically includes the following steps:

[0211] Step A1: Wait for the PLC signal, execute the loading process to move the product from the loading frame 10 to the set position and clamp it;

[0212] Step A2: the measuring head 42 moves to the qth shooting position to shoot an image of the inspection area where the product cq is located, saves the cq image, transmits the cq image to the host computer, and the number of shots P is counted +1;

[0213] The product is divided into several detection areas along its axial direction, namely c1...cq...cp. The 1st...q...pth shooting positions are set. The first shooting position corresponds to the c1 detection area...the pth shooting position corresponds to the cp detection area. q is the serial number of the current detection area, and p is the total number of the divided detection areas.

[0214] Step A3: Determine whether P is less than p. If so, it is considered that the product scanning is not completed, and a motion instruction is sent to the PLC. The measuring head 42 moves to the q+1th shooting position, and the sequence number q=q+1 is reset. Step A2 is executed. If not, it is considered that the product scanning is completed, and step A4 is executed.

[0215] Step A4: the host computer performs preliminary processing on the c1...cq...cp images to obtain pre-processed images;

[0216] The c1...cq...cp images contain all the outer contour dimension data of the product. The pre-processed images of each inspection area are obtained by pre-processing the images.

[0217] Step A5: Read the template detection area information to obtain the product outer contour dimension data contained in the pre-processed image.

[0218] The product loading process in step A1 includes the following steps:

[0219] Step A11: The loading position sensor 12 detects whether there is material on the current carrying block 231. If so, step A12 is executed; if not, the loading robot 11 places the product from the loading frame 10 on the carrying block 231;

[0220] Step A12: The transmission device 2 transports the product to the detection position;

[0221] Step A13: The lifting device 3 lifts the product to the set position. When the proximity switch receives the in-position signal, it is considered that the product has been lifted to the set position. After waiting for the set time, if there is no in-position signal within the set time, the system is stopped and an alarm is issued, indicating that the lifting cylinder 31 is wrong.

[0222] Step A14: the visual moving mechanism 41 moves the measuring head 42 to a set first position to scan a first image of the product, moves the measuring head 42 to a set second position to scan a second image of the product, and processes and integrates the first image and the second image to obtain an initial image;

[0223] The first image scanned by the measuring head 42 at the first position is an image of one end of the product, and the second image scanned by the measuring head 42 at the second position is an image of the other end of the product;

[0224] Step A15: Compare the initial image with the target position image in the template to determine whether the initial image matches the target position image. If so, it is considered that the current product is in the set center position, and step A17 is executed; if not, it is considered that the current product deviates from the set position, and step A16 is executed;

[0225] The source of the target position image in the template is: when the product is located at the set center position, the measuring head 42 is located at the first position and scans the standard first image of the product; the measuring head 42 is located at the second position and scans the standard second image of the product; the standard first image and the standard second image are processed and integrated to obtain the target position image, and the coordinates of the two ends of the product in the target position image can be obtained, and then the distances a1 and a2 between the two ends of the product and the boundary can be known. When the product is in the center position, a1=a2, and a1 and a2 are known values;

[0226] The method for determining whether the initial image matches the target position image is: obtain the coordinates of the two ends of the product in the initial image, and then obtain the distances a3 and a4 between the two ends of the product and the boundary, where a=|a1-a3|, and a is the deviation value of a1 and a3. If a is not greater than the preset deviation value threshold, it is considered that the initial image matches the target position image, and the current product is in the set center position. If a is greater than the preset deviation value threshold, it is considered that the initial image does not match the target position image, and the current product is considered to deviate from the set position.

[0227] The target position image is used to compensate for the position deviation of the product due to the loading, which causes the clamping device 5 to not fully engage with the workpiece, resulting in a position deviation of the product in space and causing a deviation in the measurement data.

[0228] Step A16: The first clamping mechanism 51 or the second clamping mechanism 52 pushes the product to a central position;

[0229] Before starting, the first clamping jaw mechanism 51 and the second clamping jaw mechanism 52 are located at the set positions respectively, and the distances between the first clamping jaw 512 and the second clamping jaw 522 and the center of the product located at the center are preset values, namely b1 and b2 respectively. In the initial image, the coordinates of the product center are obtained according to the product length L, and then the actual distance values ​​b3 and b4 between the first clamping jaw mechanism 51 and the second clamping jaw mechanism 52 and the center of the current product can be obtained, and the deviation between the preset value and the actual distance value can be calculated;

[0230] b5=|b1-b3|,

[0231] b6=|b2-b4|;

[0232] Determine whether b5 is greater than b6. If so, drive the second clamping mechanism 52 to move in the product direction by X, X=b3-L / 2+b1--b3=b1-L / 2; if not, drive the first clamping mechanism 51 to move in the product direction by y, y=b4-L / 2+b2--b4=b2-L / 2;

[0233] The calculation of coordinates and distances, and the calculation of two-dimensional distances and three-dimensional space distances involved in this embodiment are all conventional calculation methods, which will not be described in detail here.

[0234] Step A17: The first clamping mechanism 51 or the second clamping mechanism 52 is reset, the first clamping mechanism 51 moves toward the product, the first clamping jaw 512 performs a clamping action, and the first clamping jaw detection sensor 513 detects whether the product is clamped. If so, step A18 is executed. If not, an alarm is issued to indicate that the product has fallen.

[0235] Step A18: The measuring head 42 scans and obtains the current product clamping image, matches the current product clamping image with the standard product clamping image of the template, and compares the similarity between the two. If the similarity reaches a preset threshold, it is considered that the first clamping jaw 512 has clamped the product in place; if the similarity does not reach the preset threshold, it is considered that the first clamping jaw 512 has not clamped the product in place, and an alarm is issued to indicate that the product is not clamped.

[0236] The standard product clamping image is an image taken when the first clamping jaw 512 normally clamps the product;

[0237] Step A19: The second clamping jaw mechanism 52 moves toward the product, the second clamping jaw 522 performs a clamping action, and the second clamping jaw detection sensor 523 detects whether the product is clamped. If so, step A110 is executed. If not, an alarm is issued to indicate that the product has fallen.

[0238] Step A110: the measuring head 42 scans and obtains the current product clamping image, matches the current product clamping image with the standard product clamping image of the template, and compares the similarity between the two. If the similarity reaches a preset threshold, it is considered that the second clamping jaw 522 has clamped the product in place; if the similarity does not reach the preset threshold, it is considered that the second clamping jaw 522 has not clamped the product in place, and an alarm is issued to indicate that the product is not clamped.

[0239] Step A111: Loading is completed.

[0240] The image pre-processing in step A4 specifically includes the following steps:

[0241] Step A41: stitching the c1...cq...cp images;

[0242] According to the detection area and corner point information set by the template, when there is an overlapping area, the two images are spliced;

[0243] This embodiment uses a phase correlation algorithm to perform image stitching, which specifically includes the following steps:

[0244] Step A41-1: Perform Fourier transform on the image to be stitched to obtain its frequency domain representation;

[0245] Step A41-2: Convert the frequency domain representation into a phase representation, and calculate the phase difference between different images;

[0246] Step A41-3: Calculating phase correlation according to the phase difference;

[0247] By normalizing the phase difference, the phase correlation value is obtained, which is used to evaluate the similarity between different images;

[0248] Step A41-4: determining the registration parameter according to the maximum phase correlation value;

[0249] Find the registration parameter corresponding to the maximum phase correlation value, and use the parameter to perform image registration and stitching;

[0250] Step A42: cropping the spliced ​​image according to the detection area drawn when the template is made to obtain a cropped image;

[0251] Step A43: Perform bilateral filtering and least squares interpolation on the cropped image to obtain a preprocessed image.

[0252] The specific production process of the above template includes the following steps:

[0253] Step B1: Obtain the outer contour data of the real-time product, and the historical template directly reads the outer contour data of the product;

[0254] The product's outer contour data is obtained according to step 2, which will not be described here;

[0255] Step B2: Whether to generate a decision tree process. If so, calculate the size result according to the outer contour data of the product, and mark the size result. The decision tree process adds 1 and executes step B4. If not, set the inspection area of ​​the product and execute step B3.

[0256] Step B3: Determine whether to generate a decision tree. If yes, load the motion parameters and measurement parameters, calculate the size results according to the product's outer contour data, and mark the size results. Add 1 to the decision tree process and execute step B4. If no, execute step B5.

[0257] The dimension results are marked to classify the product quality according to the dimension results;

[0258] Step B4: Determine whether the number of decision tree processes is greater than the total number of decision tree processes. If so, iterate to generate a decision tree and write the decision tree into a template.

[0259] Step B5: Extract the corner point features of the current data, write the corner point features of the data into the template, and save the template.

[0260] The specific steps to set the detection area of ​​the product are:

[0261] Step B21: Add the measurement items of the product and select the measurement type;

[0262] Measurement types include ball diameter, sphericity, outer diameter, height, coaxiality, thread pitch, etc.

[0263] Step B22: Draw a measurement area corresponding to the measurement type, and accurately determine the starting point and the end point of the measurement area;

[0264] Step B23: Setting the standard value and tolerance range of the measurement type, and setting the product quality classification within each tolerance range;

[0265] For example, if the standard value of the ball diameter of a product is z, the tolerance range of the good product is set to (z1, z2), the tolerance range of the defective product is set to (z3, z4), and so on;

[0266] Step B24: Check whether all measurement items have been set. If so, generate motion parameters according to the measurement area, save the measurement parameters and motion parameters, and save the template. If not, execute step B21.

[0267] In step 3, the product quality classification process classifies product quality based on the template and product outer contour dimension data. The preprocessed images of different inspection areas belong to different measurement types of products. Different measurement types of products have different dimension calculation methods. Specifically:

[0268] like Figure 7 a- Figure 7 As shown in Figure 5, when the measurement type is outer diameter and height, the outer diameter and height measurement is the line-to-line spacing calculation, and the calculation process includes:

[0269] Step C1: extracting edge points (Canny) of the corresponding preprocessed image according to the measurement type set by the template;

[0270] Step C2: Fitting edge points to two straight lines based on the least squares method;

[0271] Step C3: Calculate the distance D between the two straight lines;

[0272] Step C4: Compare the distance D with the standard value set by the template and each tolerance range to obtain the product quality classification of the measurement type;

[0273] The steps for calculating the spacing D in step C3 are:

[0274] Step C31: The line with more edge points among the two lines is taken as the target line L2, and the line with less edge points is taken as the original line L1;

[0275] Step C32: Assume that the starting point P1 and the end point P2 of the original line L1, the starting point P3 and the end point P4 of the target line L2, the coordinates of P1, P2, P3, and P4 are known, which are P1 (X1, Y1), P2 (X2, Y2), P3 (X3, Y3), and P4 (X4, Y4), respectively. The target line is translated to the starting point P1, so that the end point P4 of the target line coincides with P1. Figure 7 b, and set it as L3, translate the target straight line to the starting point P1, so that the starting point P3 of the target straight line coincides with P1. Figure 7 c, and set to L4;

[0276] Step C33: Calculate the translation offset Lm1 between L3 and L2 and the translation offset Lm2 between L4 and L2;

[0277] Lm1(X1-X4, Y1-Y4), Lm2(X1-X3, Y1-Y3);

[0278] Step C34: Calculate the distance between the end point P3O of L3 away from P1, the end point P4O of L4 away from P1 and the end point P2 of L1 according to the translation offset, and select the standard line according to the distance;

[0279] Coordinates of the two endpoints of L3:

[0280] ([(X1, Y1), (P3OX, P3OY)]) = ([(X1, Y1), (X3+X1-X4, Y3+Y1-Y4)]);

[0281] The distance d3O between P3O and the end point P2 of L1 is:

[0282]

[0283] Coordinates of the two end points of L4:

[0284] ([(X1, Y1), (P4OX, P4OY)])===([(X1, Y1), (X4+X1-X3, Y4+Y1-Y3)]);

[0285]

[0286] Determine the size of d3O and d40. If d3O is less than d40, determine that the angle between L3 and L2 is an acute angle. If d3O is greater than d40, determine that the angle between L4 and L2 is an acute angle. Select the straight line with an acute angle with L2 as the standard line for subsequent calculations. In this embodiment, Figure 7 b and 7c, the angle between L4 and L2 is acute, and L4 is the standard line;

[0287] Step C35: Select the midpoint of the line connecting P40 of L4 and P2 of L1, connect P1 and the midpoint, and obtain a parallel constraint line;

[0288] The coordinates of the two end points of the parallel constraint line are [(X1, Y1), (P4OX+X2) / 2, (P4OY+Y2) / 2];

[0289] Step C36: Calculate the slope k of the parallel constraint line;

[0290] K=((P4OX+X2) / 2-X1) / ((P4OY+Y2) / 2-Y1)

[0291] =(P4OX+X2-2X1) / (P4OY+Y2-2Y1);

[0292] Step C37: translating the parallel constraint line so that the endpoint of the parallel constraint line coincides with the midpoint of L1, thereby obtaining the target parallel constraint line L5;

[0293] The L5 slope formula is y = kx + b, where k is the slope of the parallel constraint line;

[0294] The coordinates of the midpoint of L1 are ((X1+X2) / 2), (Y1+Y2) / 2));

[0295] Therefore, b = (Y1 + Y2) / 2 - k(X1 + X2) / 2;

[0296] Step C38: Calculate the distance D;

[0297] The spacing D is the distance from the point to the line, that is, the distance from the midpoint of L2 to the target parallel constraint line L5;

[0298]

[0299] Where A=k, B=-1, C=b, (x0, y0) are the coordinates of the midpoint of L2, and (x0, y0)=((X3+X4) / 2), (Y3+Y4) / 2)).

[0300] We can get:

[0301]

[0302] like Figure 8 a- Figure 8 As shown in d, when the measurement type is ball diameter,

[0303] According to the template settings, there are 4 modes for ball diameter calculation:

[0304] 1. Direct fitting to find the diameter without circle search;

[0305] 2. Find the maximum distance without circle search and use it as the diameter;

[0306] 3. Contour extraction with circle search and diameter calculation of circle fitting;

[0307] 4. Contour extraction with circle search, find the maximum distance as the diameter;

[0308] The specific steps of Mode 1 are:

[0309] Step D1-1: According to the measurement type set by the template, extract the contour data of the corresponding pre-processed image, such as Figure 8 As shown in a;

[0310] When editing the template, the spherical diameter detection area set by the template is drawn in an area smaller than the spherical range, that is, it does not include the non-spherical contour and there will still be no non-spherical contour range after the sample has a small offset;

[0311] Step D1-2: Fit the circle based on the least squares method, find the standard equation of the circle, get the radius of the circle, and multiply it by 2 to get the diameter;

[0312] The specific steps of Mode 2 are:

[0313] Step D2-1: According to the measurement type set by the template, extract the contour data of the corresponding pre-processed image, such as Figure 8 As shown in a;

[0314] When editing the template, the spherical diameter detection area set by the template is drawn in an area smaller than the spherical range, that is, it does not include the non-spherical contour and there will still be no non-spherical contour range after the sample has a small offset;

[0315] Step D2-2: Fit the circle based on the least squares method, calculate the maximum distance between the point on the left contour and the point on the right contour, take the middle 80% range data, remove the maximum and minimum values, and take the average as the diameter;

[0316] The specific steps of Mode 3 are:

[0317] Step D3-1: According to the measurement type set by the template, extract the corresponding pre-processed image, perform circle search position correction on it and extract contour data, and use Hough transform to locate the circle position, such as Figure 8 As shown in b;

[0318] When editing the template, the spherical diameter detection area set by the template is drawn in an area smaller than the spherical range, that is, it does not include the non-spherical contour and there will still be no non-spherical contour range after the sample has a small offset;

[0319] Step D3-2: Fit the circle based on the least squares method, find the standard equation of the circle, get the radius of the circle, and multiply it by 2 to get the diameter;

[0320] The specific steps of Mode 4 are:

[0321] Step D4-1: According to the measurement type set by the template, extract the corresponding pre-processed image, perform circle search position correction on it and extract contour data, and use Hough transform to locate the circle position, such as Figure 8 As shown in b;

[0322] When editing the template, the spherical diameter detection area set by the template is drawn in an area smaller than the spherical range, that is, it does not include the non-spherical contour and there will still be no non-spherical contour range after the sample has a small offset;

[0323] Step D4-2: Fit the circle based on the least squares method, calculate the maximum distance from the point on the left contour to the point on the right contour, take the middle 80% range of data, remove the maximum and minimum values, and take the average as the diameter.

[0324] The specific steps of the Hough transform to locate the circle position are as follows:

[0325] Step E1: Set the parameters of the circle: the horizontal coordinate a0 of the center of the circle, the vertical coordinate b0 of the center of the circle and the radius r of the circle;

[0326] Step E2: Hough transform space, calculate the range of a0, b0 and r according to the contour point data;

[0327] a0 (x-axis coordinate of the center of the circle) range: the midline position of the two contours expands to both ends (2mm);

[0328] b0 (circle center y-axis coordinate) range: template editing selection range (image height range);

[0329] r (circle radius) range: the minimum distance from any point on the left contour to all points on the right contour divided by 2 - the image width divided by 2;

[0330] Step E3: accumulator array of Hough transform;

[0331] Create an accumulator array (three-dimensional array) whose dimensions correspond to the value range of a0, b0 and r in the parameter space (the precision of a0, b0 and r are all 0.1, and the Hough circle finding is only used as the approximate position of the positioning circle. The specific result is calculated based on the contour data. Here, the step size is 0.1 to reduce the amount of calculation). Initially, the values ​​of all elements are zero.

[0332] Step E4: Perform Hough transform on each edge point;

[0333] For each contour point in the image, traverse the possible range of r and theta values ​​from the center of the circle to the contour point, then calculate the corresponding a0 and b0 values, and increase the count at the corresponding position in the accumulator array, theta (90°-270° for the left contour, 0°-90° and 270° to 360° for the right contour each increase by 1°).

[0334] a0=xr\cos*theta

[0335] b0=yr\sin*theta

[0336] x and y are the coordinates of the contour point, r is the radius, and theta is the angle from the center of the circle to the contour point;

[0337] Step E5: Find the peak value in the accumulator array;

[0338] Find the maximum value in the accumulator array, the position of which gives the estimated values ​​of the center a0, b0 and radius r of the circle, and perform threshold processing on the values ​​in the accumulator array, retaining only values ​​greater than a certain threshold to filter out insignificant peaks;

[0339] Step E6: contour extraction;

[0340] First, use the found center a0, b0 and radius r to obtain the circle shown by the double-dash line (in order to improve the calculation efficiency, the traversal step size is set to 0.1mm, so that the center coordinates of the circle found by Hough have a deviation of about 0.1mm in the x and y directions, and the radius also has a deviation of 0.1). Then, keep the center unchanged, add 0.2mm to the radius r (such as the dotted circle), calculate the intersection of the left and right contours and the circle with the increased radius (as shown in the figure, the points form a square), and finally, according to the intersection of the circle and the contour, reduce it inward (10% to 20%) to obtain the contour extraction range (as shown in the contour range formed by the straight lines in the figure).

[0341] When the measurement type is sphericity, sphericity = average spherical diameter / maximum spherical diameter. The closer the sphericity value is to 1, the closer the surface is to a sphere.

[0342] When measuring sphericity, the ball diameter calculation is performed multiple times. After each calculation, the mechanism rotates a certain angle and calculates the ball diameter again to obtain a set of diameter data. The ratio of the average diameter to the maximum diameter is used as the sphericity evaluation standard.

[0343] When the measurement type is coaxiality, the calculation method is:

[0344] Step F1: extract the corresponding pre-processed image according to the measurement type set in the template, and evenly divide the pre-processed image into 5 segments;

[0345] Step F2: take the 1st and 4th sections as the coaxiality calculation data;

[0346] Step F3: extract edge point data to obtain four groups of contour point data: L1_1, L1_2, L2_1, and L2_2;

[0347] Step F4: Fitting the four sets of contour point data to straight lines according to the standard straight line equation to obtain L1(x), L2(x), L3(x), and L4(x);

[0348] Step F5: Find the equations of the two axes (segment 1 and segment 2) f1(x) and f2(x), and make the distances between axis-L1 and axis-L2 equal. Given the expressions of L1 and L2, solve for axis F1. Similarly, calculate F2.

[0349] The distance between the two straight lines of the axes F1 and F2 represents the coaxiality in the pre-processed image.

[0350] When the measurement type is thread diameter and pitch, the calculation method is:

[0351] Step G1: extracting edge point data of the corresponding pre-processed image according to the measurement type set by the template;

[0352] Step G2: perform mean filtering on the edge point data (determine the thread peak-valley according to the change of the curve slope, and use fuzzy processing to reduce the extraction of thread area by small fluctuations);

[0353] Step G3: Segment the edge points into several small segments according to the set detection accuracy;

[0354] Set the detection accuracy to 10 times, that is, 10 data form a small segment to calculate the slope;

[0355] Step G4: Calculate the slope of each segment and extract the zero-crossing point of the slope;

[0356] The zero crossing point is the point where the positive changes to negative or negative changes to positive, and the zero crossing point is the peak point or valley point;

[0357] Step G5: accurately locate the peak and valley positions, using the maximum and minimum values ​​before mean filtering in step 2 and combining the zero crossing points to determine the peak and valley points;

[0358] Step G6: taking the average of all adjacent peak-to-peak distances and valley-to-valley distances as the pitch result;

[0359] Step G7: Fitting straight lines to all peak points of the contour and calculating the distance between the straight lines to the peak points of another contour as the major diameter;

[0360] Step G8: Fitting straight lines to all valley points of the contour and the distance between the straight lines fitting to valley points of another contour is used as the path;

[0361] Step G9: calculation;

[0362] Step G10: Fitting a straight line and calculating the diameter;

[0363] Taking all points within the range of ±0.002 of the peak and valley points, increasing the amount of data improves the accuracy of straight line fitting.

[0364] Step G9 includes the following steps:

[0365] Step G9-1: Calculate the distance D between the left contour and the right contour, and calculate each outer diameter value every 0.1 mm in the y-axis direction to obtain a distance set D = {D1, D2, ..., Dn};

[0366] The spacing D is the distance between the left contour point (x1 n, y1 n) and the right contour point (x2n, y2n), where the difference between y1 n and y2n is less than 0.1 mm. If the difference is greater than 0.1 mm, the next set of D is calculated;

[0367] Step G9-2: Perform median filtering and mean smoothing filtering on the data of set D to obtain set D';

[0368] Step G9-3: Take all values ​​with odd numbers in D' to obtain D'={D1, D3, D5...Dn}. By eliminating half of the adjacent values, the influence of interference data on the number of zero-crossing points can be prevented;

[0369] Step G9-4: Perform differential processing on D' to obtain DD, DD = {D3-D1, D5-D3, ...Dn-Dn-2};

[0370] Step G9-5: Binarize the data of DD, set the value greater than 0 to 1, and the value less than 0 to 0, and obtain DD';

[0371] Step G9-6: perform differential processing on the data of DD', and extract the index peak y coordinate set Max with a value of -1 and the index trough y coordinate set Min with a value of 1;

[0372] Step G9-7: Accurately locate the peak and valley coordinates of the contour data;

[0373] Left contour (peak point): Taking the first peak in Max as an example, take the set P of all contour points in the Max[0] neighborhood (Max[0]-0.1, Max[0]+0.1). The point with the minimum x coordinate in P is the peak point;

[0374] Right contour (peak point): Taking the first peak in Max as an example, take the set P of all contour points in the neighborhood of Max[0] (Max[0]-0.1, Max[0]+0.1), and take the point with the maximum x coordinate in P as the peak point.

[0375] Left contour (trough point): Taking the first peak in Max as an example, take the set P of all contour points in the Max[0] neighborhood (Max[0]-0.1, Max[0]+0.1). The point with the maximum x coordinate in P is the trough point.

[0376] Right contour (trough point): Taking the first peak in Max as an example, take the set P of all contour points in the Max[0] neighborhood (Max[0]-0.1, Max[0]+0.1). The point with the minimum x coordinate in P is the trough point.

[0377] The template matching process in step five uses the current template and the current product contour data to compare and determine whether the product-template matches. The matching algorithm draws on the FAST feature point detection algorithm to calculate the corner point features of the current product image and compare them with the corner point features in the template (generated when the template is made).

[0378] The decision tree is used to classify product quality based on probability. There may be abnormal results when the correct template is used due to unreasonable sample data and labeling (abnormal conditions are more likely to occur during labeling, and the decision tree only classifies similar results as abnormalities, while abnormalities during the measurement process are considered to be incorrect template use or hardware problems). By comparing corner point features to eliminate interference, it can be determined whether the abnormal result is a template mismatch or a product size failure. The specific steps include:

[0379] Step H1: Extract the outer contour data of the abnormal product: extract the contour point data set PX1 of the left contour of the product and the contour point data set PX2 of the right contour, and traverse all points in PX1 and PX2;

[0380] Step H2: Corner point determination: Calculate the distance between the current point and the previous point in PX1. If it is less than 1mm, delete it to obtain the filtered contour point data PX1'. Every three adjacent points form a triangle. Slide and calculate the area of ​​the triangle to obtain the area set SX1. Do the same with PX2 to obtain the area set SX2.

[0381] Area calculation formula: When the coordinates of the three points A, B, and C are A(x1, y1), B(x2, y2), and C(x3, y3), the area of ​​the triangle is calculated as:

[0382] SX1=(x1y2-x1y3+x2y3-x2y1+x3y1-x2y2).

[0383] Before area calculation, determine that the length of the three sides does not exceed 2.5mm. Normally, a data point is taken every 1mm, and the longest side length is 2mm. If it exceeds 2.5mm, it is considered that the contour has a fault, and the area of ​​the point is directly set to 0;

[0384] Step H3: All areas in the sets SX1 and SX2 are judged, and those larger than the threshold are regarded as corner points, and the corner point set F = {(x1, y1), ..., ((xn, yn))} is obtained;

[0385] The threshold was set to 0.25, 30°;

[0386] Step H4: read the corner point information in the template file, where the corner point set in the template file is M;

[0387] Step H5: Calculate the Jaccard distance (J) to determine the FM similarity ((F∩M) / (F∪M)); Note: The intersection of elements (corner point coordinates) in FM is determined based on: the Euclidean distance is less than the threshold;

[0388] Step H6: Compare the similarity J with the set threshold to determine the current product measurement result;

[0389] When J (range 0-1, the closer to 1, the higher the similarity) is greater than the threshold, the current product matches the measurement template, the measurement result is valid, and the product size is unqualified;

[0390] If J is less than the threshold, the product does not match the measurement template, and step 4 is executed.

[0391] The process of creating a decision tree in this embodiment includes the following steps:

[0392] Step J1: Create a measurement template Q, which includes measurement position information, corner point information, no decision tree node information and no decision tree data;

[0393] Step J2: Enter the classification results to form a classification set R;

[0394] The classification of the classification set R can be set as needed, for example, the simple one includes only qualified products / unqualified products, and the complex one includes high-quality products, good products, qualified products, defective products (which can be reprocessed into good products), waste products, abnormal data, etc.

[0395] The classification result is related to the standard value of each detection area of ​​the template and the setting of each tolerance range;

[0396] Step J3: Load template Q, start the product automatic measurement process, and obtain the measurement result set D of each product;

[0397] Step J4: manually label the obtained result set D, and annotate each group of results in R according to the classification results set in step J2 to obtain the data set J;

[0398] Manually mark what category the product belongs to. For example, if the measurement result of a diameter of a product is greater than the set tolerance range but other dimensions are qualified, a category of "repair category" can be defined, which can be reprocessed to meet the requirements; for example, if a non-critical dimension of a product is unqualified, it is defined as a qualified product;

[0399] Step J5: Generate an ID3 decision tree by iterative calculation based on the data set J and the classification set R;

[0400] As can be seen from steps J1-J4, the decision tree is a model generated based on sample data and annotation results. The steps for generating an ID3 decision tree include:

[0401] Step J5-1: Calculate the information entropy of the entire data set J, that is, the sum of the information entropy of each category (measurement items in set D);

[0402] Step J5-2: Measurement information in template Q, one measurement task is one feature, and for each feature, its information gain is calculated;

[0403] Information gain is the degree to which the information entropy of the entire data set is reduced after the feature is used to divide the data set;

[0404] Step J5-3: Recursively calculate the information entropy of the unfeatured features, remove the selected features, select the feature with the largest information gain as the partition feature of the current node, and partition the data set according to the value of the feature;

[0405] Step J5-4: recursively perform the above steps for each child node until all data are completely classified or the pre-set stop condition is reached;

[0406] Step J5-5: The information entropy is calculated as follows: E = -∑P(xi)*Log2(P(xi)){i = 1, 2, ... n}

[0407] P(xi) represents the probability of being classified as the i-th category when the feature is x;

[0408] The probability is the sample data and the annotation result;

[0409] When the uncertainty of the data is greater, the information entropy is also greater. When all samples belong to the same category, the information entropy is the smallest, which is 0. This means that the data set has the highest purity and the lowest degree of disorder. When the data set contains samples of different categories and the distribution is relatively uniform, the information entropy is higher and the degree of disorder of the data set is also higher.

[0410] Step J5-6: Write the decision tree node-branch information into template Q, write the data set J into the template to complete the decision tree data creation process (for subsequent sample addition and modification of decision tree nodes-branches).

[0411] The blanking process of step six includes the following steps:

[0412] Step 61: lift the lifting device to the set position, determine whether it is in place, if so, release the first clamp and the second clamp, return to the original position, if not, wait for a set time, if there is no in-place signal within the set time, stop the system and report a lifting cylinder error;

[0413] Step 62: The first clamping jaw sensor detects whether the first clamping jaw is fully released, and the second clamping jaw sensor detects whether the second clamping jaw is fully released. If both are released, the lifting device is started to drive the product to move downward. If either is released, an alarm is triggered to indicate that the first clamping jaw and / or the second clamping jaw is faulty.

[0414] Step 63: The detection position sensor detects whether the product reaches the detection position. If so, the transmission device starts to transmit the product to the down-feeding device. If not, an alarm is issued to indicate that the lifting device is faulty.

[0415] Step 64: The material feeding sensor detects whether there is a product. If so, execute step 65. If not, execute step 63:

[0416] Step 65: The unloading robot receives the product quality classification data and unloads the product into the corresponding unloading classification box.

[0417] Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

Claims

1. A method for measuring shaft parts based on motion scanning and image acquisition, characterized in that: The method is based on a shaft parts measurement system. The system includes a host computer, a slave computer, a feeding device, a transmission device, a lifting device, a visual system, a clamping device, and a feeding device. The host computer controls the feeding device, the transmission device, the lifting device, the visual system, the clamping device, and the feeding device through the slave computer to perform actions. The host computer includes a database, a data acquisition module, a system status monitoring module, and a human-computer interaction module. The method includes the following steps: Step 1: After the system is powered on, it will enter the self-test process. If the self-test passes, it will proceed to step 2. If the self-test fails, it will wait for the user to perform maintenance and then re-perform self-test; Step 2: Read the system status file, the data acquisition module executes the data acquisition process, obtains a single product outer contour data processing object, performs preliminary processing on the single product outer contour data processing object, and obtains the product outer contour size data; Step 3: Import the product outer contour dimension data into the template decision tree to determine whether the decision tree is empty. If so, the display interface shows that there is no corresponding template and executes step 4. If not, execute the product quality classification process to obtain product quality classification data, and the number of product inspections increases by 1. Step 4: Enter the template library to search for a template. If the template library has a corresponding template, the decision tree is written into the template and step 3 is executed. If the template library does not have a corresponding template, a button for creating a template is displayed on the display interface. Step 5: Input the product quality classification data into the host computer to determine whether the product quality classification data is abnormal. If so, read the product corner point features and execute the template matching process. If not, execute step 4. Step 6: The system executes the material unloading process according to the product classification data to move the product from the set position to the corresponding material unloading classification frame 72; Step 7: Determine whether all product contours have been inspected. If yes, the system stops. If no, proceed to step 2. Step 8: End.

2. The method for measuring shaft parts based on motion scanning and image acquisition according to claim 1, characterized in that: The loading device and the unloading device are respectively docked with the transmission device. The loading device includes a loading frame, a loading manipulator and a loading position sensor. The loading position sensor is installed on the transmission device. The transmission device is provided with a detection position sensor and a carrying device for carrying products. The detection position sensor is located at a set detection position. The detection position sensor is used to detect whether the product reaches the detection position. The jacking device includes a jacking cylinder and a jacking plate. The jacking plate is fixedly connected to the output shaft of the jacking cylinder. The jacking plate is used to jack the product. The visual system includes a visual moving mechanism and a measuring head. The visual moving mechanism is connected to the measuring head. The clamping device includes a first clamping mechanism and a second clamping mechanism. The first clamping mechanism includes a first cylinder, a first clamping jaw and a first clamping jaw detection sensor. The second clamping mechanism includes a second cylinder, a second clamping jaw and a second clamping jaw detection sensor. The unloading device includes an unloading robot, an unloading classification frame and an unloading sensor.

3. The method for measuring shaft parts based on motion scanning and image acquisition according to claim 2, characterized in that: The data acquisition process is used to acquire a product contour data processing object, which is an image, and the object is used for subsequent size calculation, and specifically includes the following steps: Step 21: The host computer waits for the loading signal from the loading robot and the unloading signal from the unloading robot; The loading manipulator transmits the loading result and the unloading robot transmits the unloading result to the PLC. The PLC sets the loading completion and unloading completion flag registers to 1. The host computer reads the loading and unloading status by scanning the PLC registers to obtain the loading completion signal of the loading manipulator and the unloading completion signal of the unloading robot. Step 22: Write motion parameters to PLC; Step 23: Execute the single product measurement motion process; Step 24: The host computer receives a motion completion signal sent back by the PLC and reads the sensor data once; Step 25: Complete product outline data collection.

4. The method for measuring shaft parts based on motion scanning and image acquisition according to claim 3 is characterized in that: Before the measurement of a single product, the whole measurement area is divided into multiple measurement areas according to the template setting requirements. After the measuring head completes the data collection of a single measurement area, the lower computer controls the motion mechanism to move the measuring head to the next measurement area, and repeats the above steps to complete the surface profile data collection of the entire shaft. The single product measurement motion process is used for the data collection of the outer contour of a single product, and specifically includes the following steps: Step A1: Wait for the PLC signal, execute the loading process to move the product from the loading frame to the set position and clamp it; Step A2: The measuring head moves to the qth shooting position to shoot the image of the inspection area where the product cq is located, saves the cq image, transmits the cq image to the host computer, and the number of shots P is counted + 1; The product is divided into several detection areas along its axial direction, namely c1...cq...cp. The 1st...q...pth shooting positions are set. The first shooting position corresponds to the c1 detection area...the pth shooting position corresponds to the cp detection area. q is the serial number of the current detection area, and p is the total number of the divided detection areas. Step A3: Determine whether P is less than p. If so, it is considered that the product scanning is not completed, and a motion instruction is sent to the PLC. The measuring head moves to the q+1th shooting position, and the sequence number q=q+1 is reset. Step A2 is executed. If not, it is considered that the product scanning is completed, and step A4 is executed. Step A4: the host computer performs preliminary processing on the c1...cq...cp images to obtain pre-processed images; The c1...cq...cp images contain all the outer contour dimension data of the product. The pre-processed images of each inspection area are obtained by pre-processing the images. Step A5: Read the template detection area information to obtain the product outer contour dimension data contained in the pre-processed image.

5. The method for measuring shaft parts based on motion scanning and image acquisition according to claim 4 is characterized in that: The product loading process in step A1 includes the following steps: Step A11: The loading position sensor detects whether there is material on the current carrying device. If so, execute step A12; if not, the loading robot 11 places the product from the loading frame on the carrying device; Step A12: The transmission device transports the product to the inspection position; Step A13: The lifting device lifts the product to the set position. When the proximity switch receives the in-position signal, it is considered that the product has been lifted to the set position. After waiting for the set time, if there is no in-position signal within the set time, the system stops and an alarm is issued, indicating that the lifting cylinder is wrong. Step A14: the visual moving mechanism moves the measuring head to a set first position to scan a first image of the product, moves the measuring head to a set second position to scan a second image of the product, and processes and integrates the first image and the second image to obtain an initial image; The first image scanned by the measuring head at the first position is an image of one end of the product, and the second image scanned by the measuring head at the second position is an image of the other end of the product; Step A15: Compare the initial image with the target position image in the template to determine whether the initial image matches the target position image. If so, it is considered that the current product is in the set center position, and step A17 is executed; if not, it is considered that the current product deviates from the set position, and step A16 is executed; The source of the target position image in the template is: when the product is located at the set center position, the measuring head is located at the first position and scans the standard first image of the product; the measuring head is located at the second position and scans the standard second image of the product; the standard first image and the standard second image are processed and integrated to obtain the target position image, and the coordinates of the two ends of the product in the target position image can be obtained, and then the distances a1 and a2 between the two ends of the product and the boundary can be known. When the product is in the center position, a1=a2, and a1 and a2 are known values; The method for judging whether the initial image matches the target position image is: obtaining the coordinates of the two ends of the product in the initial image, and then obtaining the distances a3 and a4 between the two ends of the product and the boundary, where a=|a1-a3|, and a is the deviation value of a1 and a3. If a is not greater than the preset deviation value threshold, it is considered that the initial image matches the target position image, and the current product is in the set center position. If a is greater than the preset deviation value threshold, it is considered that the initial image does not match the target position image, and the current product deviates from the set position. Step A16: The first clamping mechanism or the second clamping mechanism pushes the product to a central position; Before starting, the first clamp mechanism and the second clamp mechanism are located at the set positions respectively. The distances between the first clamp mechanism and the second clamp mechanism and the center of the product located at the center are preset values, namely b1 and b2 respectively. In the initial image, the coordinates of the center of the product are obtained according to the length L of the product, and the actual distance values ​​b3 and b4 between the first clamp mechanism and the second clamp mechanism and the center of the current product are obtained, and the deviation between the preset value and the actual distance value is calculated; b5=|b1-b3|, b6=|b2-b4|; Determine whether b5 is greater than b6. If so, drive the second clamping mechanism to move X in the product direction, X=b3-L / 2+b1--b3=b1-L / 2; if not, drive the first clamping mechanism to move y in the product direction, y=b4-L / 2+b2--b4=b2-L / 2; Step A17: The first clamping mechanism or the second clamping mechanism is reset, the first clamping mechanism moves toward the product, the first clamping mechanism performs a clamping action, and the first clamping sensor detects whether the product is clamped. If so, step A18 is executed. If not, an alarm is issued to indicate that the product has fallen. Step A18: The measuring head scans and obtains the current product clamping image, matches the current product clamping image with the standard product clamping image of the template, and compares the similarity between the two. If the similarity reaches a preset threshold, it is considered that the first clamping jaw has clamped the product in place; if the similarity does not reach the preset threshold, it is considered that the first clamping jaw has not clamped the product in place, and an alarm is issued to indicate that the product is not clamped; The standard product clamping image is an image taken when the first clamping jaw clamps the product normally; Step A19: The second clamping jaw mechanism moves toward the product, and the second clamping jaw performs a clamping action. The second clamping jaw detection sensor detects whether the product is clamped. If so, step A110 is executed. If not, an alarm is issued to indicate that the product has fallen. Step A110: The measuring head scans and obtains the current product clamping image, matches the current product clamping image with the standard product clamping image of the template, and compares the similarity between the two. If the similarity reaches a preset threshold, it is considered that the second clamping jaw has clamped the product in place; if the similarity does not reach the preset threshold, it is considered that the second clamping jaw has not clamped the product in place, and an alarm is issued to indicate that the product is not clamped; Step A111: Loading is completed.

6. The method for measuring shaft parts based on motion scanning and image acquisition according to claim 4 is characterized in that: The image pre-processing in step A4 specifically includes the following steps: Step A41: stitching the c1...cq...cp images; According to the detection area and corner point information set by the template, when there is an overlapping area, the two images are spliced; Image stitching is performed using a phase correlation algorithm, which specifically includes the following steps: Step A41-1: Perform Fourier transform on the image to be stitched to obtain its frequency domain representation; Step A41-2: Convert the frequency domain representation into a phase representation, and calculate the phase difference between different images; Step A41-3: Calculating phase correlation according to the phase difference; By normalizing the phase difference, the phase correlation value is obtained, which is used to evaluate the similarity between different images; Step A41-4: determining the registration parameter according to the maximum phase correlation value; Find the registration parameter corresponding to the maximum phase correlation value, and use the parameter to perform image registration and stitching; Step A42: cropping the spliced ​​image according to the detection area drawn when the template is made to obtain a cropped image; Step A43: Perform bilateral filtering and least squares interpolation on the cropped image to obtain a preprocessed image.

7. The method for measuring shaft parts based on motion scanning and image acquisition according to claim 1, characterized in that: The product quality classification process in step 3 classifies product quality based on the template and product outer contour dimension data. Preprocessed images of different inspection areas belong to different measurement types of products, and different measurement types of product size calculation methods different, When the measurement type is outer diameter and height, the outer diameter and height measurement is the line-to-line spacing calculation. The calculation process includes the following steps: Step C1: extracting edge points of the corresponding pre-processed image according to the measurement type set by the template; Step C2: Fitting edge points to two straight lines based on the least squares method; Step C3: Calculate the distance D between the two straight lines; Step C4: Compare the distance D with the standard value set by the template and each tolerance range to obtain the product quality classification of the measurement type; The steps for calculating the spacing D in step C3 are: Step C31: The line with more edge points among the two lines is taken as the target line L2, and the line with less edge points is taken as the original line L1; Step C32: Assume that the starting point P1 and the end point P2 of the original straight line L1, the starting point P3 and the end point P4 of the target straight line L2, the coordinates of P1, P2, P3, and P4 are known, which are P1 (X1, Y1), P2 (X2, Y2), P3 (X3, Y3), and P4 (X4, Y4), respectively. The target straight line is translated to the starting point P1, so that the end point P4 of the target straight line coincides with P1, and is set as L3. The target straight line is translated to the starting point P1, so that the starting point P3 of the target straight line coincides with P1, and is set as L4. Step C33: Calculate the translation offset Lm1 between L3 and L2 and the translation offset Lm2 between L4 and L2; Lm1(X1-X4, Y1-Y4), Lm2(X1-X3, Y1-Y3); Step C34: Calculate the distance between the end point P3O of L3 away from P1, the end point P4O of L4 away from P1 and the end point P2 of L1 according to the translation offset, and select the standard line according to the distance; Coordinates of the two endpoints of L3: ([(X1, Y1), (P3OX, P3OY)]) = ([(X1, Y1), (X3+X1-X4, Y3+Y1-Y4)]); The distance d3O between P3O and the end point P2 of L1 is: Coordinates of the two end points of L4: ([(X1, Y1), (P4OX, P4OY)])===([(X1, Y1), (X4+X1-X3, Y4+Y1-Y3)]); Determine the size of d3O and d40. If d3O is less than d40, determine that the angle between L3 and L2 is an acute angle. If d3O is greater than d40, determine that the angle between L4 and L2 is an acute angle. Select a straight line with an acute angle with L2 as the standard line for subsequent calculations. In this embodiment, as shown in FIGS. 7b and 7c, the angle between L4 and L2 is an acute angle, and L4 is the standard line. Step C35: Select the midpoint of the line connecting P40 of L4 and P2 of L1, connect P1 and the midpoint, and obtain a parallel constraint line; The coordinates of the two end points of the parallel constraint line are [(X1, Y1), (P4OX+X2) / 2, (P4OY+Y2) / 2]; Step C36: Calculate the slope k of the parallel constraint line; K=((P4OX+X2) / 2-X1) / ((P4OY+Y2) / 2-Y1) =(P4OX+X2-2X1) / (P4OY+Y2-2Y1); Step C37: translating the parallel constraint line so that the endpoint of the parallel constraint line coincides with the midpoint of L1, thereby obtaining the target parallel constraint line L5; The L5 slope formula is y = kx + b, where k is the slope of the parallel constraint line; The coordinates of the midpoint of L1 are ((X1+X2) / 2), (Y1+Y2) / 2)); Therefore, b = (Y1 + Y2) / 2 - k(X1 + X2) / 2; Step C38: Calculate the distance D; The spacing D is the distance from the point to the line, that is, the distance from the midpoint of L2 to the target parallel constraint line L5; Where A=k,B=-1,C=b,(x0,y0) are the coordinates of the midpoint of L2,(x0,y0)=((X3+X4) / 2),(Y3+Y4) / 2)),we get:

8. The method for measuring shaft parts based on motion scanning and image acquisition according to claim 7 is characterized in that: When the measurement type is spherical diameter, there are 4 modes for spherical diameter calculation according to the template settings:

1. Direct fitting to find the diameter without circle search; 2. Find the maximum distance without circle search and use it as the diameter; 3. Contour extraction with circle search and diameter calculation of circle fitting; 4. Contour extraction with circle search, find the maximum distance as the diameter; The specific steps of Mode 1 are: Step D1-1: extracting contour data of the corresponding pre-processed image according to the measurement type set by the template; When editing the template, the spherical diameter detection area set by the template is drawn in an area smaller than the spherical range, that is, it does not include the non-spherical contour and there will still be no non-spherical contour range after the sample has a small offset; Step D1-2: Fit the circle based on the least squares method, find the standard equation of the circle, get the radius of the circle, and multiply it by 2 to get the diameter; The specific steps of Mode 2 are: Step D2-1: extracting the contour data of the corresponding pre-processed image according to the measurement type set by the template; When editing the template, the spherical diameter detection area set by the template is drawn in an area smaller than the spherical range, that is, it does not include the non-spherical contour and there will still be no non-spherical contour range after the sample has a small offset; Step D2-2: Fit the circle based on the least squares method, calculate the maximum distance between the point on the left contour and the point on the right contour, take the middle 80% range data, remove the maximum and minimum values, and take the average as the diameter; The specific steps of Mode 3 are: Step D3-1: according to the measurement type set by the template, extract the corresponding pre-processed image, perform circle search position correction on it and extract contour data, and use Hough transform to locate the circle position; When editing the template, the spherical diameter detection area set by the template is drawn in an area smaller than the spherical range, that is, it does not include the non-spherical contour and there will still be no non-spherical contour range after the sample has a small offset; Step D3-2: Fit the circle based on the least squares method, find the standard equation of the circle, get the radius of the circle, and multiply it by 2 to get the diameter; The specific steps of Mode 4 are: Step D4-1: according to the measurement type set by the template, extract the corresponding pre-processed image, perform circle search position correction on it and extract contour data, and use Hough transform to locate the circle position; When editing the template, the spherical diameter detection area set by the template is drawn in an area smaller than the spherical range, that is, it does not include the non-spherical contour and there will still be no non-spherical contour range after the sample has a small offset; Step D4-2: Fit the circle based on the least squares method, calculate the maximum distance from the point on the left contour to the point on the right contour, take the middle 80% range of data, remove the maximum and minimum values, and take the average as the diameter.

9. The method for measuring shaft parts based on motion scanning and image acquisition according to claim 7, characterized in that: When the measurement type is thread diameter and pitch, the calculation steps are as follows: Step G1: extracting edge point data of the corresponding pre-processed image according to the measurement type set by the template; Step G2: perform mean filtering on the edge point data (determine the thread peak-valley according to the change of the curve slope, and use fuzzy processing to reduce the extraction of thread area by small fluctuations); Step G3: Segment the edge points into several small segments according to the set detection accuracy; Set the detection accuracy to 10 times, that is, 10 data form a small segment to calculate the slope; Step G4: Calculate the slope of each segment and extract the zero-crossing point of the slope; The zero crossing point is the point where the positive changes to negative or negative changes to positive, and the zero crossing point is the peak point or valley point; Step G5: accurately locate the peak and valley positions, use the maximum and minimum values ​​before the mean filtering in step 2, and combine the zero crossing point to determine the peak and valley points; Step G6: take the average value of all adjacent peak-to-peak distances and valley-to-valley distances as the pitch result; Step G7: Fitting straight lines to all peak points of the contour and calculating the distance between the straight lines to the peak points of another contour as the major diameter; Step G8: Fitting straight lines to all valley points of the contour and the distance between the straight lines fitting to valley points of another contour is used as the path; Step G9: calculation; Step G10: Fitting a straight line and calculating the diameter; Taking all points within the range of ±0.002 of the peak and valley points, increasing the amount of data improves the accuracy of straight line fitting.

10. The method for measuring shaft parts based on motion scanning and image acquisition according to claim 9, characterized in that: The step G9 comprises the following steps: Step G9-1: Calculate the distance D between the left contour and the right contour, and calculate each outer diameter value every 0.1 mm in the y-axis direction to obtain a distance set D = {D1, D2, ..., Dn}; The spacing D is the distance between the left contour point (x1 n, y1 n) and the right contour point (x2n, y2n), where the difference between y1 n and y2n is less than 0.1 mm. If the difference is greater than 0.1 mm, the next set of D is calculated; Step G9-2: Perform median filtering and mean smoothing filtering on the data of set D to obtain set D'; Step G9-3: Take all values ​​with odd numbers in D' to obtain D'={D1, D3, D5...Dn}. By eliminating half of the adjacent values, the influence of interference data on the number of zero-crossing points can be prevented; Step G9-4: Perform differential processing on D' to obtain DD, DD = {D3-D1, D5-D3, ...Dn-Dn-2}; Step G9-5: Binarize the data of DD, set the value greater than 0 to 1, and the value less than 0 to 0, and obtain DD'; Step G9-6: perform differential processing on the data of DD', and extract the index peak y coordinate set Max with a value of -1 and the index trough y coordinate set Min with a value of 1; Step G9-7: Accurately locate the peak and valley coordinates of the contour data; Left contour (peak point): Taking the first peak in Max as an example, take the set P of all contour points in the Max[0] neighborhood (Max[0]-0.1, Max[0]+0.1), and take the point with the minimum x coordinate in P as the peak point; Right contour (peak point): Taking the first peak in Max as an example, take the set P of all contour points in the Max[0] neighborhood (Max[0]-0.1, Max[0]+0.1), and take the point with the maximum x coordinate in P as the peak point. Left contour (trough point): Taking the first peak in Max as an example, take the set P of all contour points in the Max[0] neighborhood (Max[0]-0.1, Max[0]+0.1), and take the point with the maximum x coordinate in P as the trough point. Right contour (trough point): Taking the first peak in Max as an example, take the set P of all contour points in the neighborhood of Max[0] (Max[0]-0.1, Max[0]+0.1), and take the point with the smallest x coordinate in P as the trough point.