A fully automatic detection system and method for precision turning workpieces based on machine vision

Through the fully automatic detection system for precision turned workpieces based on machine vision, the Pratt algebra fitting and binary tree decomposition algorithm are used to solve the problem of low efficiency of precision turned workpiece detection in the existing technology, and realize efficient and automatic multi-feature detection.

CN116625270BActive Publication Date: 2025-09-19TIANJIN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310530324.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-11
Publication Date
2025-09-19
Estimated Expiration
2043-05-11

AI Technical Summary

Technical Problem

Existing technologies lack efficient automatic detection methods in precision turning processing, especially for the multi-feature characteristics of rotating workpieces, which cannot achieve fast and accurate detection.

Method used

A fully automatic inspection system for precision turned workpieces based on machine vision is adopted, including hardware and software units. A voltage controller, a parallel light source, a bilateral telecentric lens and a CCD camera are used for image acquisition. Image processing and feature recognition are performed through Pratt algebra fitting and binary tree decomposition algorithms. A three-level feature tree system is established to realize automatic measurement of multiple features.

Benefits of technology

It improves detection efficiency and accuracy, reduces waste of human resources, realizes efficient automatic detection of multi-feature workpieces, and is suitable for multi-feature automatic measurement of various types of workpieces.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116625270B_ABST
    Figure CN116625270B_ABST
Patent Text Reader

Abstract

The present invention discloses a fully automatic detection system and method for precision turning workpieces based on machine vision. The detection system includes a hardware unit and a software unit; the hardware unit includes a lighting unit, an acquisition unit, a workpiece placement table, and a computer; the software unit is integrated into the computer; the system uses backlight measurement to acquire images with high edge contrast, which are then converted into digital images for processing in the computer. First, the image is preprocessed by Gaussian filtering, morphological closing operations to remove burrs, and then the image edges are filled to obtain floating-point contour edge vectors. The contour features corresponding to each area of ​​the workpiece are confirmed. Based on the type of contour feature, the calculation method of the geometric features in the database is indexed to complete various geometric measurement tasks, and the data is analyzed, displayed, and stored. The present invention is suitable for large-scale and rapid detection of workpieces in fully automatic production scenarios, saving manpower and improving efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of turning workpiece detection, which mainly adopts machine vision technology, and in particular to a fully automatic detection system and method for precision turning workpieces based on machine vision. Background Art

[0002] During precision turning, the dimensions and form and position tolerances of the workpiece after machining must be strictly controlled to ensure that product quality meets requirements. Rotating workpieces generally have multiple features, such as the diameter and taper of the outer circle, the radius of the transition fillet, the height of the countersunk head, the length of the bolt, and so on. Although contact measurement technology is very mature and has high precision, it is mostly a point-by-point measurement method, resulting in relatively slow measurement speeds. Non-contact measurement methods often require manual determination of the position of various features before measurement, which also consumes excessive manpower and time. Therefore, a more accurate and efficient automatic detection method is needed to meet the quality inspection requirements of precision turned parts. Summary of the Invention

[0003] The purpose of the present invention is to overcome the deficiencies in the prior art and, based on conventional machine vision inspection systems, to provide a fully automatic inspection system and method for precision turning workpieces based on machine vision, targeting the multi-feature characteristics of the precision turning process.

[0004] The purpose of the present invention is achieved through the following technical solutions:

[0005] A fully automatic detection system for precision turning workpieces based on machine vision, including a hardware unit and a software unit;

[0006] The hardware unit includes a lighting unit, a collection unit, a workpiece placement table, and a computer; the lighting unit is composed of a voltage controller and a parallel light source, and the collection unit is composed of a double-sided telecentric lens and a CCD camera. The voltage controller, parallel light source, workpiece placement table, double-sided telecentric lens, CCD camera, and computer are sequentially connected to each other;

[0007] The hardware unit is placed on a detection platform, and the software unit is integrated into a computer;

[0008] The software unit includes a device control module, a template formulation module, an acquisition module, an image processing module, a contour type recognition module, a feature calculation module, a result display module and a storage module; the device control module and the template formulation module are respectively connected to the acquisition module, and the acquisition module is sequentially connected to the image processing module, the contour type recognition module, the feature calculation module, the result display module and the storage module;

[0009] The device control module is used to search and select the CCD camera connected to the current PC through the network port, and control the opening and closing of the CCD camera;

[0010] The template setting module is used to set the features that need to be measured and their corresponding tolerance range information. After completing the template setting, you can start collecting;

[0011] The acquisition module is used to realize automatic detection of the workpiece and determine whether the workpiece is placed stably;

[0012] The image processing module is used to receive the backlit digital image acquired by the acquisition unit, firstly perform noise reduction processing on the backlit digital image; secondly, use a closing operation method to perform a closing operation along the edge of the workpiece in the backlit digital image to determine the path, thereby removing dust, flaws and burrs on the surface of the workpiece in the backlit digital image; and finally, perform image boundary filling on the backlit digital image of the workpiece;

[0013] The contour type recognition module is used to determine the contour features corresponding to the contours of various areas of the workpiece to be measured;

[0014] The feature calculation module defines the calculation method of various workpiece geometric features. Based on the results of the contour type recognition module (), for each identified contour feature, it automatically indexes the geometric features required to be measured in the template formulation module and completes the calculation of the geometric features.

[0015] The result display module is used to compare the calculation results of the feature calculation module with the tolerance range and other information in the template formulation module, analyze the status of the workpiece, and display and record the results;

[0016] The storage module saves the original workpiece image and the measured annotated display image in JPG and BMP formats, and saves the measurement information.

[0017] Furthermore, after selecting the automatic detection mode in the acquisition module, the automatic detection process of the workpiece is started; in this process, automatic detection of the workpiece placement is realized. When it is detected that a workpiece is placed at the specified position of the workpiece placement table, the subsequent calculation thread is automatically started; when the workpiece moves or leaves the field of view of the CCD camera, the calculation thread is closed.

[0018] Furthermore, the image processing module first receives the backlit digital image captured by the CCD camera, and uses the Gaussian filtering method to perform noise reduction processing on the backlit digital image to remove noise interference; then uses the morphological closing operation method to perform a closing operation to determine the path along the edge of the workpiece in the backlit digital image, and removes dust, defects and burrs on the surface of the workpiece in the backlit digital image; finally, the backlit digital image boundary is filled, specifically using the Canny edge extraction method, and based on the gradient relationship at the edge, the coarse edge of the backlit digital image is obtained; the sub-pixel edge of the backlit digital image is obtained using a method based on the Zernike orthogonal moment, and the point set vector of the floating-point coordinates is obtained.

[0019] Furthermore, the steps of the contour type recognition module determining the contour features corresponding to the contours of each area of ​​the workpiece to be measured are as follows:

[0020] (1) Using the Pratt-based binary tree decomposition algorithm, the point set vector of the complete edge contour is divided into two types of contours: a single straight line or a single arc, and saved in the format of a binary tree node;

[0021] (2) Since the previous step uses binary segmentation, segmentation may occur in the middle of a straight line or arc contour, resulting in abnormal contour disconnection. Therefore, it is necessary to perform a pre-order traversal of the entire binary tree, splicing the contours that meet the splicing conditions together, and the spliced ​​result is referred to as a segmented independent contour;

[0022] (3) Establish a three-level feature tree system, in which the first level is the segmented independent contour, which represents the small segment contour edge after the complete contour is segmented; the second level represents the contour feature, which represents the type of each area of ​​the workpiece to be measured; the third level represents the geometric feature, which represents the geometric quantity or dimensional index that needs to be measured of the workpiece to be measured;

[0023] (4) The arrangement and arrangement of the independent contours of each segment are predefined to achieve the correspondence from contour to feature, and the features corresponding to the contours of each area of ​​the workpiece to be measured are determined.

[0024] Furthermore, the Pratt-based binary tree decomposition algorithm unified the positioning methods of straight lines and arcs by introducing Pratt algebra fitting; then, in the Pratt algebra fitting solution process, the third largest eigenvalue represents the characteristics of the fitting error, and a contour segmentation algorithm is constructed based on the eigenvalue. Combined with the characteristic that all point sets participate in the operation simultaneously in the data matrix calculation, a binary tree segmentation algorithm that adapts to the fitting characteristics is designed. Based on the pre-order traversal, the splicing of interrupted contours in the binary tree decomposition is completed, and contour segmentation by type is realized.

[0025] Furthermore, the software unit is designed as four threads, namely the human-computer interaction thread, the CCD camera acquisition thread, the workpiece entry and exit judgment thread, and the calculation thread; in the workpiece entry and exit judgment thread, the judgment criterion for the workpiece entry is: the workpiece enters the field of view and is placed on the workpiece placement table and remains stationary, that is, placed steadily in the specified position; the judgment criterion for the workpiece exit is: the workpiece moves.

[0026] The present invention also provides a fully automatic detection method for precision turning workpieces based on machine vision, comprising the following steps:

[0027] S1. Use the template setting module to set the features to be measured and their corresponding tolerance range information. After the template setting is completed, start the acquisition;

[0028] S2. Select the automatic detection mode in the acquisition module to start the automatic detection process of the workpiece. When a workpiece is detected and placed at the designated position of the workpiece placement table, the subsequent calculation thread will automatically start. If the workpiece moves or leaves the field of view of the CCD camera, the calculation thread will be closed.

[0029] S3. The image processing module receives the backlit digital image captured by the CCD camera and performs noise reduction processing using a Gaussian filter to remove noise interference;

[0030] S4. The image processing module uses a closing operation method to perform a closing operation along the edge of the workpiece in the backlit digital image to determine the path, thereby removing dust, blemishes, and burrs on the workpiece surface in the backlit digital image;

[0031] S5. Fill the borders of the backlit digital image using the image processing module and extract the rough edges of the backlit digital image using the Canny edge extraction method based on the gradient relationship at the edges. Finally, use the Zernike orthogonal moment method to extract the sub-pixel edges of the backlit digital image and obtain a floating-point point set vector.

[0032] S6. In the contour type recognition module, a binary tree decomposition algorithm based on Pratt algebra fitting is used to segment the point set vectors of the complete edge contour into single line or single arc contours and save them in the binary tree node format;

[0033] S7. Perform a pre-order traversal of the entire binary tree, and join the contours that meet the joining conditions together. The contours segmented in step S6 and joined in this step are referred to as segmented independent contours.

[0034] S8. Establish a three-level feature tree system, where the first level represents segmented independent contours, representing the contour edges after the complete contour is segmented; the second level represents contour features, indicating the types of each area of ​​the workpiece to be measured; and the third level represents geometric features, indicating the geometric quantities or dimensional indicators that need to be measured on the workpiece to be measured.

[0035] S9. predefine the arrangement and arrangement of the independent contours of each segment to achieve the correspondence between contours and features, and determine the features corresponding to the contours of each area of ​​the workpiece to be measured;

[0036] S10. For each identified contour feature, automatically index the geometric features required to be measured in the template formulation module and complete the calculation of the geometric features;

[0037] S11. Compare the calculated value of the feature calculation module with the tolerance range in the template formulation module, analyze the state of the workpiece, and mark and record the results;

[0038] S12. Save the original workpiece image and the measured annotated display image.

[0039] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:

[0040] 1. By introducing Pratt algebraic fitting, the positioning methods of straight lines and circular arcs are unified, avoiding the problem of positioning straight lines and circular arcs separately in Hough transform or ordinary fitting methods, effectively improving positioning efficiency;

[0041] 2. Based on the properties of the Pratt algebra fitting eigenvalues, a reasonable contour segmentation threshold is set. Combined with the fact that all point sets participate in the calculation simultaneously during the data matrix calculation process, a binary tree segmentation algorithm that adapts to the fitting characteristics is designed, which reduces the relationship between the algorithm's time complexity and the contour length, and effectively improves the segmentation efficiency.

[0042] 3. The method based on pre-order traversal of the binary tree solves the contour interruption problem caused by binary division, and expresses all contour interruption situations with fewer conditions. The program can be quickly implemented through recursion.

[0043] 4. A three-level feature tree system is constructed based on the results of contour segmentation by type, which can effectively characterize most rotating workpieces without advanced curves, thereby realizing automatic measurement of multiple features of multiple types of workpieces and improving the automation and systematicness of the detection system. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1a It is a functional block diagram of the hardware units in the detection system of the present invention.

[0045] Figure 1b It is a functional block diagram of the software unit in the detection system of the present invention.

[0046] Figure 2 It is the outline binary tree decomposition flow chart;

[0047] Figure 3This is a flow chart of the splicing algorithm based on pre-order traversal.

[0048] Figure 4 This is an illustration of a three-level feature tree. DETAILED DESCRIPTION

[0049] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0050] In the visual inspection hardware system, the most critical part is the lighting system. The design of the lighting system can often determine the success or failure of the visual inspection system. Illuminating the object to be measured is only one aspect of the lighting system. A good lighting system can achieve the best separation of the target feature area and the background area, improve the change between the target area and the background area, make the edge features obvious, thereby reducing the complexity of the image processing algorithm and effectively improving the system measurement accuracy. At the same time, the reliability and stability of the visual inspection system can be guaranteed.

[0051] For this purpose, this embodiment mainly designs a fully automatic detection system for precision turning workpieces based on machine vision. Figure 1a and Figure 1b The detection system includes a hardware unit and a software unit; the hardware unit includes a lighting unit, a collection unit, a workpiece placement table 103 and a computer 106; the lighting unit is composed of a voltage controller 101 and a parallel light source 102, and the collection unit is composed of a double-sided telecentric lens 104 and a CCD camera 105. The voltage controller 101, the parallel light source 102, the workpiece placement table 103, the double-sided telecentric lens 104, the CCD camera 105 and the computer 106 are connected to each other in sequence; the hardware unit is placed on the detection platform, and the software unit is integrated in the computer 106.

[0052] The software unit includes a device control module 201, a template formulation module 202, an acquisition module 203, an image processing module 204, a contour type recognition module 205, a feature calculation module 206, a result display module 207 and a storage module 208; the device control module 201 and the template formulation module 202 are respectively connected to the acquisition module 203, and the acquisition module 203 is connected to the image processing module 204, the contour type recognition module 205, the feature calculation module 206, the result display module 207 and the storage module 208 in turn.

[0053] The detection method based on the above-mentioned fully automatic detection system for precision turning workpieces is as follows:

[0054] Hardware: Turn on the power of the CCD camera and light source, and connect the CCD camera to the computer via the GIGE interface. Ensure that the light source and lens are coaxial as much as possible, and adjust the workpiece placement table 103 so that its center is on the focal plane of the imaging system, and then fix it.

[0055] The implementation process of the software unit is as follows:

[0056] S1: The device control module 201 searches and selects the camera device connected to the current PC through the network port, and controls the opening of the camera device. The template setting module 202 can set the characteristics that need to be measured and their corresponding tolerance ranges. After the template setting is completed, the acquisition can begin.

[0057] S2: After selecting the automatic detection mode in the acquisition module 203, the automatic detection process for the rotating workpiece is initiated. This process automatically detects the placement of the workpiece. When a workpiece is detected at the designated position on the workpiece placement table, the subsequent calculation thread automatically begins. If the workpiece moves or leaves the CCD camera's field of view, the calculation thread is terminated.

[0058] In this embodiment, the software unit is designed as four threads: a human-computer interaction thread, a camera acquisition thread, a workpiece entry and exit determination thread, and a calculation thread. In the entry and exit determination thread, the criteria for a workpiece entry is that the workpiece enters the field of view and remains stationary on the platform, i.e., securely positioned in the designated location. The criteria for a workpiece exit is that the workpiece moves.

[0059] S3: The image processing module 204 first receives the backlit digital image captured by the CCD camera. The backlit image has a very high edge contrast, and then uses a Gaussian filter method to perform noise reduction processing to remove noise interference.

[0060] S4: The image processing module 204 then uses a morphological closing method multiple times to perform path-specific closing operations along the edges of the workpiece in the backlit digital image, thereby removing dust, blemishes, and large burrs from the workpiece surface in the backlit digital image. Because the workpiece edge in a backlit digital image typically only occupies a small portion of the image, the computational complexity of the path-specific closing operation is far less than that of the global closing operation, significantly improving the computational speed.

[0061] Since there may be uncleaned dust, burrs and tiny surface unevenness on the workpiece surface, the extraction of edge contours will be greatly affected. Performing multiple global closing operations can simply and effectively remove most of the above effects. However, in order to meet high-precision requirements, the selected CCD cameras generally have very high resolutions, and there are a large number of background blank pixels and workpiece internal pixels in the backlit image, that is, pixels that are useless for edge extraction. Therefore, simply using a global closing operation will greatly waste computing power and reduce the efficiency of the entire algorithm. Therefore, this embodiment adopts an improved closing operation to traverse the structural element along the pixels near the edge, which can achieve an effect similar to the global closing operation, and the operation speed is increased by hundreds of times.

[0062] S5: The image processing module 204 fills the backlit digital image border and then uses the Canny edge extraction method to obtain the rough edge of the backlit digital image based on the gradient relationship at the edge. Then, a method based on Zernike orthogonal moments is used to obtain the sub-pixel edge of the backlit digital image, and a point set vector of floating-point coordinates is obtained.

[0063] This step first involves filling the image's borders. This ensures that even if an object is too large and extends beyond one or more edges, edge derivatives can still be calculated, allowing for edge detection. Because backlit images typically have a bright 255-pixel background and low-pixel values ​​around the object, the filled borders are all 255 pixels long.

[0064] S6: The contour type recognition module 205 first performs a binary decomposition on the point set vector according to the independent contour algorithm based on Pratt algebra fitting until the point set vector is divided into independent contours such as a single straight line or a single arc, and saves them in the format of a binary tree node, that is, the independent contours are the nodes of the binary tree.

[0065] The cross-sections of most rotating workpieces are composed of two basic geometric elements: straight lines and circular arcs. These two geometric elements can be combined in different directions, positions, orders, quantities, and other factors to form various features such as external circles and countersunk heads. The Pratt algebraic fitting expression can simultaneously represent two two-dimensional geometric shapes: circular arcs and straight lines. In the Pratt calculation process, the eigenvector corresponding to the smallest positive eigenvalue is the best fitting parameter, and its corresponding eigenvalue can represent the total error of the fitting process. The eigenvector can be used as the initial value of the geometric fitting process in the subsequent characteristic value calculation. The eigenvalue can set a threshold as an independent contour criterion to determine whether the current point set vector is an independent straight line or an independent arc.

[0066] See Figure 2 , S6 specifically includes the following processing procedures and principles:

[0067] S6.1: In the Pratt algebraic fitting method, assume that the equation of the circle is:

[0068] A(x 2 +y 2 )+Bx+Cy+D=0 (1-1)

[0069] Compared with the most commonly used general least squares fitting, that is In the equation in Fit, Equation 1-1 adds the parameter A before the quadratic term. This avoids singular points when fitting a straight line, and allows the value of A to be used to set an appropriate threshold to distinguish between a straight line and an arc.

[0070] In geometric fitting, the error d at each data point is i is the geometric distance from each data point to the circle, that is:

[0071]

[0072] Among them, (a, b) is the center of the circle, R is the radius of the circle, r i is the distance from the data point to the center of the circle. Compared with geometric fitting, algebraic fitting generally uses some easy-to-calculate quantities f i Instead of d i , then the total error equation of algebraic fitting can be expressed as:

[0073]

[0074] Among them, f i It is usually defined as some simple algebraic equations without square roots.

[0075] In common use -In Fit, the error f of a single point i for:

[0076] f i =r i 2 -R 2 =(r i +R)(r i -R)=d i (2R+d i )≈2Rd i (1-4)

[0077] The reason why is that in the fitting calculation, except for a few points that deviate seriously from the sample, the deviation d of each point is i <<R, that is, is a minimum value, otherwise a reasonable fitting result cannot be obtained. Therefore, the main influencing factor of the fitting error is Rd iObviously, in the fitting process, in order to make the error tend to a smaller value, it will tend to fit a circle with a smaller radius R, and the error value multiplied by the coefficient R will be significantly amplified, causing the algorithm to be more sensitive to errors and lose stability.

[0078] Therefore, in Pratt-Fit, to solve the above problem, the error equation is set as:

[0079]

[0080] in Formula 1-5 is obtained by dividing by R 2 , which effectively suppresses the influence of the radius in Equation 1-4 and ensures the accuracy of the error estimation in the algebraic fitting.

[0081] However, if equation 1-5 is solved using regular equations, the resulting system of homogeneous linear equations will have only zero and infinite solutions, which obviously does not meet the requirements. Considering that the proportional changes in the coefficients of equation 1-1 do not affect the actual shape of the circle, we can set the constraint equation:

[0082] R(H)=B 2 +C 2 -4AD=1 (1-6)

[0083] Where H is (A, B, C, D). Combining equations 1-5, we can get:

[0084] F P =∑[Az i +Bx i +Cy i +D] 2 (1-7)

[0085] At this time, the Lagrange multiplier method can be used to solve the minimum value of the error equation under the constraint equations 1-7 to solve the problem. That is:

[0086] L(H,η)=F P (H)-η(R(H)-1) (1-8)

[0087] Among them, F P (H) is the error equation of Pratt-Fit, R(H) is the constraint equation, and η is the Lagrange multiplier.

[0088] In summary, Pratt-Fit has -Fit has two important advantages. On the one hand, its equation expression has coefficient A, which can simultaneously represent the main components (arcs and straight lines) of the segmented independent contour; on the other hand, it optimizes the error equation, making its calculation results relatively accurate.

[0089] S6.2: First convert Equation 1-8 into matrix form.

[0090] Let the parameter vector be:

[0091] H=[ABCD] T (1-9)

[0092] Let the data matrix be represented as:

[0093]

[0094] Where (x i ,y i ) are the coordinates of each point in the fitting data set. The coefficient matrix can be defined as:

[0095]

[0096] Therefore, Equation 1-7 can be converted to:

[0097] F P (H)=H T MH (1-12)

[0098] For the constraint matrix, let:

[0099]

[0100] Then the constraint equation of Equation 1-6 can be converted to:

[0101] R(H)=H T NH (1-14)

[0102] Combining equations 1-8, 1-12, and 1-14, the Lagrange equation can be transformed into:

[0103] L(H,η)=H T MH-η(H T NH-1) (1-15)

[0104] From Equation 1-15, taking partial derivatives of H and η, we can get the characteristic equation:

[0105]

[0106] H T NH=1 (1-17)

[0107] The matrix N in Equation 1-16 must be reversible, so the arrow holds. Obviously, H is a matrix of eigenvectors, and η is a one-dimensional vector of eigenvalues.

[0108] S6.3: Since M is a symmetric matrix, it can be orthogonally diagonalized.

[0109] Right now

[0110]

[0111] You can find the square root.

[0112] Let YY=M, and Y=Y T , for formula N -1 MH=ηH multiplied by Y on the left, we get

[0113] YN -1 Y(YH)=ηYH (1-19)

[0114] Easy to know YN -1 Y and N -1 M has the same eigenvalue, and from Sylvester's law of inertia we know that Y T N -1 Y and N -1 Same, with three positive eigenvalues ​​and one negative eigenvalue, so N -1 M also has three positive eigenvalues ​​and one negative eigenvalue.

[0115] S6.4: Left multiplication by H T Then, we get H T MH=ηH T NH=η. It can be seen that

[0116] 1) Let matrix A be any m*n matrix and x be an n*1 vector;

[0117] but,

[0118] x T A T Ax=(Ax) T (Ax)≥0 (1-20)

[0119] So A T A must be a positive semidefinite matrix.

[0120] but is a semi-positive definite matrix, so η ≥ 0. (In actual measurement, when fitting a perfect straight line, it may be a very small negative value), the characteristic equation N -1 The eigenvector corresponding to the smallest positive eigenvalue of MH=ηH is the best fitting parameter.

[0121] 2) Due to

[0122] F P (H)=H T MH=η (1-21)

[0123] Therefore, the eigenvalue η can represent the total fitting error, and the smaller its value is, the better the fitting effect of this parameter is.

[0124] S6.5: As described in S6.1-S6.4, combined with the basic properties of geometric elements, we can obtain two criteria:

[0125] 1) The eigenvalue η represents the size of the fitting error, and the entire image should be under the same noise level. The larger the η value, the less likely it is that the point sequence is an independent contour.

[0126] 2) For the actual two-dimensional workpiece contour image, it is difficult to form a stable and resolvable functional relationship between the position coordinates x and y. Now assume that the curve can be represented by the parametric equation {(x(c), y(c))|c∈[a,b]}, then its curvature calculation formula can be expressed as

[0127] for:

[0128]

[0129] In this form, the first-order and second-order derivatives of x(c) and y(c) in Equation 3-35 can be calculated by difference, that is:

[0130]

[0131] Where y(i) is the y coordinate of the i-th point, and x is calculated in the same way as in Equation 1-23. In a two-dimensional image with integer coordinates, the step size h = 1.

[0132] S6.6: See as Figure 2 In the contour decomposition process, the contour point sequence is first subjected to Pratt fitting, and then the third eigenvalue is judged to be less than the set threshold. If not, it is divided into two segments and Pratt fitting is continued; if it is satisfied, the fitting eigenvalues ​​of the left and right segments are calculated respectively. If they are much smaller than the fitting eigenvalues ​​before the bisection, they can be regarded as independent contour segments. If they are not much smaller than the fitting eigenvalues ​​before the bisection, curvature calculation is performed point by point to obtain more accurate contour segmentation.

[0133] S7: The contour type identification module 205 then performs a pre-order traversal on the entire binary tree, and splices the independent contours that meet the splicing conditions into one piece, that is, splices the same contour segment that was split by the binary method back together as a more complete independent contour segment. The calculation method of algebraic fitting is that all points in the point set participate in the calculation at the same time, rather than calculating point by point. Therefore, the complete point set composed of all contours can be continuously divided into two using the binary method until it is guaranteed that each contour segment meets the independent contour criterion. In this process, there may be a situation where a complete independent contour segment is divided into multiple small independent contours, so these small independent contours need to be spliced ​​together. To facilitate subsequent splicing processing, this method first uses the complete contour as the root of the binary tree, then uses each contour segment separated by the binary method as a node of the tree, and finally uses each independent contour segment as the terminal node (leaf) of the tree, thereby forming a full binary tree.

[0134] See as Figure 3 , specifically including the following processing procedures and principles:

[0135] S7.1: First, take the complete outline as the root of the binary tree, then take each segment of the outline obtained by the binary division as the node of the tree, and finally take each independent outline as the terminal node (leaf) of the tree, thus forming a full binary tree.

[0136] S7.2: Perform a pre-order traversal of the binary tree until a node without children is encountered, i.e., a terminal node. Then, after temporarily storing the terminal node, continue traversing until the next terminal node is found. After obtaining two terminal nodes in the temporary storage area, determine whether the two terminal nodes are brothers. If so, the left node is considered an independent contour, and the right node is placed in the temporary storage area, waiting for the next terminal node. If not, after splicing, perform Pratt algebra fitting to determine whether the eigenvalue is less than the threshold; if it is, the spliced ​​contour is placed in the temporary storage area, waiting for the next terminal node; if not, the left node is considered an independent contour, and the right node is placed in the temporary storage area, waiting for the next terminal node.

[0137] In summary, from the structure of the full binary tree, we can see that 1. Only the terminal nodes of the binary tree are independent contours and can be spliced. 2. All terminal nodes combined together form the initial complete contour. 3. Starting from the left side of the binary tree, splicing can only occur between the two closest terminal nodes; because only adjacent independent contours can be spliced, it is impossible to cross an independent contour and still meet the calculation of the independent contour criterion. 4. It is impossible to splice between brothers, because brother nodes are divided into two parts because they do not meet the independent contour criterion. Therefore, when this embodiment adopts pre-order traversal, as long as non-brothers and no children (terminal nodes) are used as conditions, all independent contours that can be spliced ​​can be traversed. Then, a more stringent threshold is used as a judgment, and the contours that can be spliced ​​together can be spliced ​​together. When the pre-order traversal ends, the entire splicing process is completed. The whole process is fast to operate, the code structure is simple, and it can well meet the splicing requirements.

[0138] S8: Figure 4 As shown, in order to elevate the result of contour segmentation to the feature recognition level, the contour type recognition module 205 establishes a three-level feature tree system, wherein the first level is the segmented independent contour, which represents the small segment contour edge after the complete contour segmentation; the second level represents the contour feature, which represents the type of each area of ​​the workpiece to be measured, such as countersunk and fillet; the third level represents the geometric feature, which represents the geometric quantity or dimensional index that needs to be measured of the workpiece to be measured, such as the radius of the fillet and the height of the countersunk.

[0139] S9: The contour type recognition module 205 finally predefines the arrangement, combination and orientation arrangement of each segmented independent contour, thereby achieving the correspondence from contour to feature and determining the features corresponding to the contours of each area of ​​the workpiece to be measured.

[0140] This embodiment establishes a method for constructing various workpiece contour features from basic straight lines or arcs. First, the axis of symmetry of the workpiece is determined. Based on this, the independent contours are divided into groups of symmetrical contour pairs. These pairs are then compared with a feature library to determine the features represented by the contours at each position. For example, the countersunk head of a bolt is composed of two symmetrical straight lines with different slopes and one line that is not symmetrical about the axis; the fillet of a bolt is composed of two symmetrical arcs.

[0141] S10: The feature calculation module 206 defines the calculation methods for various geometric features. Based on the results of the contour type identification module 205, the geometric features required to be measured in the template creation module 202 are automatically indexed for each identified contour feature and the geometric features are calculated. For example, the radius of the fillet area is calculated using an arc approximation algorithm under tangency constraints; the diameter of the shaft segment is obtained by calculating the distance between two straight lines.

[0142] S11: The result display module 207 compares the calculated value of the feature calculation module 206 with the tolerance range in the template formulation module 202, analyzes the state of the workpiece, and annotates, displays and records the results.

[0143] S12: The storage module 208 can save the original workpiece image and the measured annotated display image into formats such as JPG and BMP, and can save the measurement information into data formats such as Excel1.

[0144] The present invention is not limited to the embodiments described above. The above description of the specific embodiments is intended to describe and illustrate the technical solutions of the present invention. The above specific embodiments are merely illustrative and not restrictive. Without departing from the scope of the present invention and the scope of protection of the claims, those skilled in the art may make various specific modifications based on the teachings of the present invention, all of which fall within the scope of protection of the present invention.

Claims

1. A fully automatic detection system for precision turning workpieces based on machine vision, characterized in that: Includes hardware units and software units; The hardware unit includes a lighting unit, a collection unit, a workpiece placement table, and a computer; the lighting unit is composed of a voltage controller and a parallel light source, and the collection unit is composed of a double-sided telecentric lens and a CCD camera. The voltage controller, parallel light source, workpiece placement table, double-sided telecentric lens, CCD camera, and computer are sequentially connected to each other; The hardware unit is placed on a detection platform, and the software unit is integrated into a computer; The software unit comprises a device control module (201), a template formulation module (202), an acquisition module (203), an image processing module (204), a contour type recognition module (205), a feature calculation module (206), a result display module (207) and a storage module (208); the device control module (201) and the template formulation module (202) are respectively connected to the acquisition module (203), and the acquisition module (203) is sequentially connected to the image processing module (204), the contour type recognition module (205), the feature calculation module (206), the result display module (207) and the storage module (208); The device control module (201) is used to search for and select a CCD camera connected to the current PC via a network port, and to control the opening and closing of the CCD camera; The template setting module (202) is used to set the features currently required to be measured and their corresponding tolerance range information, and the acquisition starts after the setting of the template setting module (202) is completed; The acquisition module (203) is used to realize automatic detection of the workpiece and to determine whether the workpiece is stably placed; The image processing module (204) is used to receive the backlight digital image collected by the collection unit, and first perform noise reduction processing on the backlight digital image; Secondly, a closing operation method is used to perform a closing operation along the edge of the workpiece in the backlit digital image to determine the path, thereby removing dust, flaws and burrs on the surface of the workpiece in the backlit digital image; finally, the image boundary of the backlit digital image of the workpiece is filled; The contour type recognition module (205) is used to determine the contour features corresponding to the contours of various areas of the workpiece to be measured; the steps are as follows: (1) Through the Pratt-based binary tree decomposition algorithm, the point set vector of the complete edge contour is divided into two types of contours: a single straight line or a single arc, and saved in the format of a binary tree node; (2) Perform a pre-order traversal of the entire binary tree, and splice the contours that meet the splicing conditions together. The spliced ​​result is referred to as a segmented independent contour. (3) Establish a three-level feature tree system, in which the first level is the segmented independent contour, which represents the small segment contour edge after the complete contour is segmented; the second level represents the contour feature, which represents the type of each area of ​​the workpiece to be measured; the third level represents the geometric feature, which represents the geometric quantity or dimensional index that needs to be measured of the workpiece to be measured; (4) Predefine the arrangement and arrangement of the independent contours of each segment to achieve the correspondence from contour to feature, and determine the features corresponding to the contours of each area of ​​the workpiece to be measured; The feature calculation module (206) defines the calculation method of various workpiece geometric features, and based on the results in the contour type recognition module (205), automatically indexes the geometric features required to be measured in the template formulation module (202) for each identified contour feature, and completes the calculation of the geometric features; The result display module (207) is used to compare the calculation result of the feature calculation module (206) with the tolerance range information in the template formulation module (202), analyze the state of the workpiece, and display and record the result; The storage module (208) saves the original workpiece image and the measured marked display image into JPG and BMP formats, and saves the measurement information.

2. The fully automatic detection system for precision turning workpieces based on machine vision according to claim 1, characterized in that: After the automatic detection mode is selected in the acquisition module (203), the automatic detection process of the workpiece is started; in this process, the automatic detection of the workpiece placement is realized, and when it is detected that a workpiece is placed at a designated position on the workpiece placement table, the subsequent calculation thread is automatically started; when the workpiece moves or leaves the field of view of the CCD camera, the calculation thread is closed.

3. The fully automatic detection system for precision turning workpieces based on machine vision according to claim 1, characterized in that: The image processing module (204) first receives the backlit digital image captured by the CCD camera, and uses a Gaussian filter method to perform noise reduction processing on the backlit digital image to remove noise interference; Then, a morphological closing operation method is used to perform a closing operation along the edge of the workpiece in the backlit digital image to determine the path, and dust, defects and burrs on the surface of the workpiece in the backlit digital image are removed; finally, the boundary of the backlit digital image is filled, and the Canny edge extraction method is used to obtain the coarse edge of the backlit digital image based on the gradient relationship at the edge; the sub-pixel edge of the backlit digital image is obtained using a method based on Zernike orthogonal moments, and the point set vector of floating-point coordinates is obtained.

4. The fully automatic detection system for precision turning workpieces based on machine vision according to claim 1, characterized in that: The Pratt-based binary tree decomposition algorithm unifies the positioning methods of lines and arcs by introducing Pratt algebra fitting. Then, in the Pratt algebra fitting solution process, the third largest eigenvalue represents the characteristics of the fitting error. The contour segmentation algorithm is constructed based on the eigenvalue. Combined with the characteristic that all point sets participate in the operation simultaneously in the data matrix calculation, a binary tree segmentation algorithm that adapts to the fitting characteristics is designed. The interrupted contours in the binary tree decomposition are spliced ​​based on the pre-order traversal, realizing contour segmentation by type.

5. The fully automatic detection system for precision turning workpieces based on machine vision according to claim 1, characterized in that: The software unit is designed as four threads: the human-computer interaction thread, the CCD camera acquisition thread, the workpiece entry and exit judgment thread, and the calculation thread. In the workpiece entry and exit judgment thread, the judgment criteria for the workpiece entry are: the workpiece enters the field of view and is placed on the workpiece placement table and remains stationary, that is, placed steadily in the specified position; the judgment criteria for the workpiece exit is: the workpiece moves.

6. A fully automatic detection method for precision turning workpieces based on machine vision, based on the fully automatic detection system for precision turning workpieces according to any one of claims 1 to 5, characterized in that: The following steps are involved: S1. Use the template setting module to set the features to be measured and their corresponding tolerance range information. After the template setting is completed, start the acquisition; S2. Select the automatic detection mode in the acquisition module to start the automatic detection process of the workpiece. When a workpiece is detected and placed at the designated position of the workpiece placement table, the subsequent calculation thread will automatically start. If the workpiece moves or leaves the field of view of the CCD camera, the calculation thread will be closed. S3. The image processing module receives the backlit digital image captured by the CCD camera and performs noise reduction processing using a Gaussian filter to remove noise interference; S4. The image processing module uses a closing operation method to perform a closing operation along the edge of the workpiece in the backlit digital image to determine the path, thereby removing dust, blemishes, and burrs on the workpiece surface in the backlit digital image; S5. Fill the borders of the backlit digital image using the image processing module and extract the rough edges of the backlit digital image using the Canny edge extraction method based on the gradient relationship at the edges. Finally, use the Zernike orthogonal moment method to extract the sub-pixel edges of the backlit digital image and obtain a point set vector of floating-point coordinates. S6. In the contour type recognition module, a binary tree decomposition algorithm based on Pratt algebra fitting is used to segment the point set vectors of the complete edge contour into single line or single arc contours and save them in the binary tree node format; S7. Perform a pre-order traversal of the entire binary tree, and join the contours that meet the joining conditions together. The contours segmented in step S6 and joined in this step are referred to as segmented independent contours. S8. Establish a three-level feature tree system, where the first level represents segmented independent contours, representing the contour edges after segmentation and splicing of the complete contour; the second level represents contour features, indicating the types of each area of ​​the workpiece to be measured; and the third level represents geometric features, indicating the geometric quantities or dimensional indicators that need to be measured on the workpiece to be measured. S9. predefine the arrangement and arrangement of the independent contours of each segment to achieve the correspondence between contours and features, and determine the features corresponding to the contours of each area of ​​the workpiece to be measured; S10. For each identified contour feature, automatically index the geometric features required to be measured in the template formulation module and complete the calculation of the geometric features; S11. Compare the calculated value of the feature calculation module with the tolerance range in the template formulation module, analyze the state of the workpiece, and mark and record the results; S12. Save the original workpiece image and the measured annotated display image.

Citation Information

Patent Citations

  • Multi-type workpieces batch visual measuring system and method

    CN109357630A

  • Arc workpiece matching and positioning method based on high-precision geometric primitive extraction

    CN111311618A