Machining workpiece automatic alignment method and system based on image measurement
By calculating the normal gradient field of the workpiece image and reconstructing the micro-topography features, analyzing the command response deviation trajectory, and generating adaptive alignment driving commands, the accuracy and efficiency problems of traditional workpiece alignment methods on workpieces with complex topography are solved, and high-precision attitude adjustment and stability control are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-23
- Publication Date
- 2026-03-10
AI Technical Summary
Traditional automatic workpiece alignment methods are insufficient to meet the precision and efficiency requirements of high-end machining when dealing with workpieces with complex shapes or low-contrast image scenes. Moreover, most systems lack closed-loop control and real-time feedback capabilities, relying on manual intervention to adjust parameters.
By calculating the normal gradient field of the workpiece image, the surface micro-topography features are reconstructed. Combined with the boundary curvature continuity of the region with equal optical density, the command response deviation trajectory is analyzed. The least squares method is used to fit the error correction table and generate adaptive alignment drive commands to achieve dynamic compensation and real-time convergence control of attitude adjustment.
It improves the alignment accuracy and efficiency of workpieces under complex morphological conditions, enhances attitude stability, and realizes dynamic compensation and real-time convergence control throughout the entire process.
Smart Images

Figure CN121639804A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of workpiece alignment technology, and in particular to an automatic alignment method and system for machined workpieces based on image measurement. Background Technology
[0002] The field of workpiece alignment technology involves detecting and correcting parameters such as position and orientation of workpieces during the manufacturing process. This ensures that the workpiece's mounting posture on the processing equipment matches the predetermined processing path, thereby avoiding processing errors and improving process stability. Core aspects of this technology include: methods for detecting the spatial orientation of the workpiece, means of extracting alignment reference points or features, methods for calculating alignment errors, and alignment control strategies. This technology is widely used in industrial scenarios such as semiconductor manufacturing, CNC machining, electronic packaging, and precision assembly. Common implementation methods include using laser measurement, mechanical positioning, and image recognition to complete the spatial alignment process between the workpiece and the processing equipment. In these scenarios, to ensure processing accuracy, high-precision sensors and control mechanisms are typically used to measure the workpiece's offset and rotation angle in real time, and a feedback mechanism is used to automatically adjust the workpiece's position.
[0003] Traditional automatic workpiece alignment methods refer to placing the workpiece in a designated processing position using preset physical reference points or mechanical limits. These methods typically rely on fixed structures such as mechanical fixtures or alignment pins for initial positioning. Then, the operator visually observes, uses mechanical gauges for contact detection, or employs laser displacement sensors to obtain the workpiece's translational and rotational deviations. Based on the detection results, the workpiece position is manually or semi-automatically adjusted to complete the alignment process. Some automated equipment uses 2D image recognition to obtain the coordinates of workpiece feature points and estimates its pose based on the matching difference between the actual workpiece features and the template image. However, most systems lack closed-loop control and real-time feedback capabilities and rely on manual intervention to adjust parameters. Furthermore, traditional methods struggle to meet the alignment accuracy and efficiency requirements of high-end processing when dealing with workpieces with complex shapes or low-contrast image scenes. Summary of the Invention
[0004] The purpose of this invention is to overcome the shortcomings of the existing technology and to propose an automatic alignment method and system for machined workpieces based on image measurement.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: an automatic alignment method for machined workpieces based on image measurement, comprising the following steps: S1: Acquire images of the workpiece surface, calculate the normal gradient field of the workpiece image, analyze the local curvature change rate within the normal gradient field, adjust the sampling point density based on the local curvature change rate, reconstruct surface features, and generate workpiece surface micromorphology restoration data. S2: Extract gradient boundaries based on the workpiece surface micro-morphology restoration data, construct an equal optical density region, calculate the morphological stability score, determine whether the score is within the preset convergence range, and output the attitude correction stability judgment parameters. S3: Based on the attitude correction stability judgment parameters, start timing deviation tracking, obtain the timestamps of continuous image acquisition frames and the timestamps of the actuator action completion, perform timing interpolation on the feature point drift vector, and derive the unit time command response deviation trajectory. S4: Fit the unit time instruction response deviation trajectory using the least squares method, construct the response offset curve, calculate the difference between the current step position and the historical instruction position, perform inverse mapping of the response delay duration, and generate a dynamic execution error correction table. S5: Map the dynamic execution error correction table to the control signal, adjust the step direction and amplitude according to the delay inversion value of the dynamic execution error correction table, and generate an adaptive alignment drive command.
[0006] The present invention is improved in that the workpiece surface micro-morphology restoration data includes a point cloud coordinate set, a reconstructed surface normal texture map, and a feature depth matrix; the attitude correction stability judgment parameters include the continuity of the equal optical density domain boundary, the convergence value of the region area compactness, and the illumination distortion tolerance factor; the unit time command response deviation trajectory includes the inter-frame response timing drift vector, the command execution lag path node, and the dynamic deviation interpolation sequence; the dynamic execution error correction table includes the response delay time inversion mapping value, the mechanical transmission error compensation coefficient, and the actuator dead zone correction amount; and the adaptive alignment drive command includes the phase advance trigger pulse, the inertial suppression braking level, and the micro-step amplitude gain signal.
[0007] The present invention is improved in that the step of obtaining the workpiece surface micro-morphology restoration data is specifically as follows: S111: Acquire images of the workpiece surface, traverse the two-dimensional coordinates of each pixel in the image matrix, calculate the gray-level difference between the current pixel and its neighboring pixels in the horizontal and vertical axes, synthesize the normal gradient vector of the corresponding coordinate point based on the difference values, map the gradient vectors of all pixels to the two-dimensional plane coordinate system, construct the vector distribution field, and generate the pixel gray-level normal gradient vector matrix. S112: Call the pixel grayscale normal gradient vector matrix, perform differential operation on the vector elements in the matrix to obtain the directional deflection rate between adjacent vectors, use the deflection rate as the local curvature change rate and match it with the preset gradient change threshold, configure high-density sampling points for regions with a change rate greater than the threshold according to the matching result, and configure sparse sampling points for regions with a change rate less than or equal to the threshold, establish the index logic of sampling frequency and spatial position, and obtain the curvature adaptive sampling density mapping map; S113: Based on the curvature adaptive sampling density mapping, the sampler is activated to extract discrete height feature points in the workpiece surface coordinate system according to the density distribution logic set in the figure. Non-uniform rational B-spline interpolation is performed on the extracted feature point set to calculate the fitted surface coordinates of the sampling gap area. Based on the fitting result, the three-dimensional geometric shape of the surface micro-texture is reconstructed to generate workpiece surface micro-morphology restoration data.
[0008] The present invention is improved in that the step of obtaining the attitude correction stability determination parameter is specifically as follows: S211: Call the workpiece surface micro-morphology restoration data, perform gradient operator convolution on the reconstructed three-dimensional geometric shape, extract the connected pixel set whose gray level change rate difference is within the preset tolerance range, perform contour tracking and vector fitting along the edge of the set, and obtain the boundary coordinate sequence of the equal optical density domain. S212: Based on the boundary coordinate sequence of the equal optical density domain, traverse the boundary nodes to calculate the local curvature and the geometric properties of the enclosed area, calculate the morphological stability score, and obtain the regional morphological stability measurement information. S213: For the values in the region morphological stability measurement information, compare them with the preset morphological convergence threshold, count the proportion of regions within the convergence interval, perform binarized logic judgment on the current alignment state of the workpiece based on the proportion result, and output the posture correction stability judgment parameter.
[0009] The present invention is improved in that the formula for obtaining the morphological stability score by calculation is specifically as follows: ; in, A score representing the morphological stability of a single boundary region. The normalized value representing the area of regions with equal optical density. Represents the boundary of the first The normalized value of the gray-level gradient vector of each node. The total statistical value representing the boundary nodes. The normalized value of the closed perimeter representing the region boundary. Represents the boundary of the first The normalized curvature value of each node. The arithmetic mean normalized value representing the curvature of the entire boundary. This represents a non-zero infinitesimal constant.
[0010] The present invention is improved in that the step of obtaining the command response deviation trajectory per unit time is specifically as follows: S311: Based on the posture correction stability determination parameters, read continuous multi-frame grayscale images of the workpiece surface from the vision sensor and record the image acquisition frame timestamps. Poll the status register of the servo driver through the fieldbus to record the execution mechanism's action completion timestamp. Calculate the hysteresis difference between the two sets of timestamps, encapsulate the image data and time difference, and generate a multi-dimensional time-series image sampling data packet. S312: Analyze the image matrix in the multi-dimensional temporal image sampling data packet, use the Gaussian Laplacian operator to detect local extreme value regions, determine key feature points, use the pyramid optical flow algorithm to track the pixel coordinate migration path of key feature points between consecutive frames, calculate the magnitude and direction of the feature point displacement vector, and generate a multi-frame continuous feature drift vector sequence. S313: Call the time lag difference and multi-frame continuous feature drift vector sequence in the multi-dimensional time-series image sampling data packet, use the time difference as a non-uniform sampling interval, perform piecewise cubic Hermit interpolation on the displacement vector, construct a functional relationship describing the evolution of the deviation over time, derive the response position drift per unit time, and generate the command response deviation trajectory per unit time.
[0011] The present invention is improved in that the step of obtaining the dynamic execution error correction table is specifically as follows: S411: Call the unit time instruction response deviation trajectory, construct a high-order polynomial regression equation as a fitting benchmark, traverse the discrete data points in the trajectory sequence, construct an error matrix including the observed deviation value and the equation prediction value, solve the normal equation system, determine the polynomial coefficients that minimize the sum of squared residuals, establish a mathematical model describing the continuous evolution of the actuator response drift over time, and generate a nonlinear response offset fitting model. S412: Based on the nonlinear response offset fitting model, input the execution step index at the current moment, calculate the theoretical unbiased response coordinates, retrieve historical instruction position data from the log, perform vector difference operation on the two, obtain the actual spatial execution lag, perform multi-dimensional spatial correlation mapping between the lag and the corresponding timestamp delay, establish the quantitative correspondence between spatial error and time delay, and obtain the position time lag correlation mapping set. S413: Analyze the position time-series lag correlation mapping set, perform inversion operation on the lag mapping relationship, derive the preload time compensation value required to eliminate the target spatial error, quantize and segment the compensation value according to the preset instruction step size resolution, construct a lookup logic structure with step size and direction as index keys and time compensation value as data value, and generate a dynamic execution error correction table.
[0012] The present invention is improved in that the step of obtaining the adaptive alignment driving command is specifically as follows: S511: Call the dynamic execution error correction table, intercept the standard displacement control signal queue to be sent by the servo control device in real time, parse the target coordinate position and preset feed speed vector in the signal frame, use them as multi-dimensional index key values to retrieve the corresponding response delay time inversion mapping value and mechanical transmission error compensation coefficient in the dynamic execution error correction table, bind the retrieved error correction data with the sequence number of the original signal frame to the execution logic, construct the mapping relationship between signal physical characteristics and correction data, and generate the command mapping vector set to be corrected; S512: Based on the instruction mapping vector set to be corrected, extract the delay inversion mapping value, calculate the phase advance trigger time offset of the control pulse, call the error compensation coefficient to perform weighted scaling operation on the step amplitude of the original instruction, calculate the new step vector direction based on the adjusted amplitude and the motion state of the current mechanism, reconstruct the waveform envelope data of the drive signal using the vector synthesis rule, establish the parameter combination including timing correction, amplitude gain and direction adjustment, and generate spatiotemporal domain compensation modulation parameters; S513: For the aforementioned spatiotemporal domain compensation modulation parameters, perform binary encoding on the parameter combination according to the communication protocol format of the servo driver, write the phase advance trigger time offset into the timing control register field, convert the amplitude gain data into current drive instruction code, combine the direction control bit to encapsulate the cyclic redundancy check code and the synchronization frame header, construct a complete control data packet, and generate an adaptive alignment drive instruction.
[0013] An image-based automatic alignment system for machined workpieces, the image-based automatic alignment system for machined workpieces is used to implement the above-mentioned image-based automatic alignment method for machined workpieces, the system comprising: The surface restoration processing module acquires images of the workpiece surface, calculates the normal gradient field of the workpiece image, analyzes the local curvature change rate within the normal gradient field, adjusts the sampling point density based on the local curvature change rate, reconstructs surface features, and generates workpiece surface micromorphology restoration data. The attitude correction analysis module extracts gradient boundaries based on the workpiece surface micro-morphology restoration data, constructs an iso-optical density region, calculates the morphological stability score, determines whether the score is within a preset convergence range, and outputs attitude correction stability judgment parameters. The instruction deviation identification module starts timing deviation tracking based on the attitude correction stability judgment parameters, obtains the timestamps of continuous image acquisition frames and the timestamps of the actuator's action completion, performs timing interpolation on the feature point drift vector, and derives the instruction response deviation trajectory per unit time. The execution error correction module uses the least squares method to fit the unit time instruction response deviation trajectory, constructs the response offset curve, calculates the difference between the current step position and the historical instruction position, inversely maps the response delay time, and generates a dynamic execution error correction table. The alignment instruction construction module maps the dynamic execution error correction table to the control signal, adjusts the step direction and magnitude according to the delay inversion value of the dynamic execution error correction table, and generates an adaptive alignment drive instruction.
[0014] Compared with the prior art, the advantages and positive effects of the present invention are as follows: In this invention, by calculating the normal gradient field of the workpiece image and dynamically adjusting the sampling density based on the local curvature change rate, micro-topographic features with complete details can be reconstructed. Combining the boundary curvature continuity and area compactness ratio of the iso-density region, a morphological stability score is calculated, enabling accurate determination of the boundary contour under different image conditions. By analyzing the command response deviation trajectory in continuous images through temporal interpolation, a response offset function is constructed using the least squares method and mapped to an execution error correction table, completing the dynamic correction of command delay, improving the response accuracy and execution consistency of alignment commands, realizing full-process dynamic compensation and real-time convergence control of the attitude adjustment process, and enhancing the alignment efficiency and attitude stability of the workpiece under complex topographic conditions. Attached Figure Description
[0015] Figure 1 This is a flowchart of the method of the present invention; Figure 2 This is a flowchart illustrating the process of obtaining workpiece surface micro-morphology restoration data according to the present invention; Figure 3 This is a flowchart illustrating the process of obtaining attitude correction stability determination parameters according to the present invention. Figure 4 This is a flowchart illustrating the process of obtaining the command response deviation trajectory per unit time according to the present invention; Figure 5 This is a flowchart illustrating how the present invention obtains a dynamic execution error correction table; Figure 6 This is a flowchart illustrating the process of obtaining adaptive alignment driving instructions according to the present invention. Detailed Implementation
[0016] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0017] In the description of this invention, it should be understood that the terms "length," "width," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships, are based on the orientation or positional relationships shown in the accompanying drawings and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, in the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0018] Please see Figure 1 This invention provides a technical solution: an automatic alignment method for machined workpieces based on image measurement, comprising the following steps: S1: Acquire images of the workpiece surface and calculate the normal gradient field of pixel grayscale distribution. Analyze the local curvature change rate within the normal gradient field. Based on the local curvature change rate, dynamically adjust the sampling point density to reconstruct surface features and generate workpiece surface micromorphology restoration data. S2: Extract the grayscale gradient change boundary from the workpiece surface micro-morphology restoration data to construct an equal optical density region. Calculate the morphological stability score based on the boundary curvature continuity value and area compactness ratio of the equal optical density region, determine whether the score is within the preset convergence range, and output the attitude correction stability judgment parameter. S3: Start timing deviation tracking based on attitude correction stability judgment parameters, obtain the image acquisition frame timestamp and the execution mechanism action completion timestamp of multiple consecutive frames of images, perform timing interpolation operation on the feature point drift vector in multiple consecutive frames of images, and derive the command response deviation trajectory per unit time. S4: The least squares method is used to fit the unit time instruction response deviation trajectory to construct the response offset function curve, calculate the difference between the current execution step position and the historical instruction position, perform inverse mapping on the response delay duration, and generate a dynamic execution error correction table. S5: Map the dynamic execution error correction table to the control signal to be sent, adjust the step direction and amplitude of the command according to the delay inversion value in the dynamic execution error correction table, and generate an adaptive alignment drive command. The workpiece surface micro-morphology restoration data includes point cloud coordinate set, reconstructed surface normal texture map and feature depth matrix. The attitude correction stability judgment parameters include the continuity of the equal optical density domain boundary, the convergence value of the region area compactness and the illumination distortion tolerance factor. The unit time command response deviation trajectory includes the inter-frame response time drift vector, the command execution lag path node and the dynamic deviation interpolation sequence. The dynamic execution error correction table includes the response delay time inversion mapping value, the mechanical transmission error compensation coefficient and the actuator dead zone correction amount. The adaptive alignment drive command includes the phase advance trigger pulse, the inertial suppression braking level and the micro-step amplitude gain signal.
[0019] Please see Figure 2 The specific steps for obtaining the workpiece surface micro-morphology restoration data are as follows: S111: Acquire images of the workpiece surface, traverse the two-dimensional coordinates of each pixel in the image matrix, calculate the gray-level difference values between the current pixel and its neighboring pixels in the horizontal and vertical axes, synthesize the normal gradient vector of the corresponding coordinate point based on the difference values, map the gradient vectors of all pixels to the two-dimensional plane coordinate system, construct a vector distribution field describing the light reflection characteristics of the workpiece surface, and generate a pixel gray-level normal gradient vector matrix. Initialize the industrial camera to capture a grayscale bitmap with a resolution of 5120×3840 pixels, and iterate through the two-dimensional coordinates of each pixel in the image matrix. This retrieves the grayscale values of adjacent pixels along the horizontal axis at that coordinate. and Perform a difference operation to obtain the horizontal gradient component, and then call the gray values of adjacent pixels along the vertical axis. and The vertical gradient component is obtained by performing a difference operation, and the normal gradient vector at the corresponding coordinate point is synthesized based on the numerical values of the two components. By mapping the gradient vectors of all 19.66 million pixels to a two-dimensional plane coordinate system, a vector field distribution model is established. If a certain region in the image represents a tiny scratch or protrusion on the surface of a workpiece, the magnitude and direction of its corresponding normal gradient vector will exhibit distribution characteristics significantly different from those of the flat background region. For example, in coordinate... The gradient vector detected at a position has a magnitude of 150 and a direction angle of 45 degrees, while the magnitude at the neighborhood background is only 5. This is used to construct a vector distribution field describing the light reflection characteristics of the workpiece surface and generate a pixel grayscale normal gradient vector matrix.
[0020] S112: Call the pixel grayscale normal gradient vector matrix, perform differential operation on the vector elements in the matrix to obtain the direction deflection rate between adjacent vectors, use the deflection rate as the local curvature change rate and match it with the preset gradient change threshold. Based on the matching result, configure high-density sampling points for areas with a change rate greater than the threshold and configure sparse sampling points for areas with a change rate less than or equal to the threshold. Establish the index logic of sampling frequency and spatial position to obtain the curvature adaptive sampling density mapping map. The specific method for setting the gradient change threshold is as follows: statistically analyze the set of local curvature change rates in the pixel grayscale normal gradient vector matrix, calculate the probability density distribution function and global standard deviation of the set of values, identify the inflection point values in the probability density distribution curve that transition from flat areas to textured areas, and perform linear superposition of the inflection point values with the global standard deviation of multiple magnifications, and use the multiple graded values obtained from the calculation as the gradient change threshold. Calculate the ratio of the change in the angle between the normal gradient vectors of adjacent coordinate points to the spatial distance to obtain the directional deflection rate between adjacent vectors. Use the deflection rate as the local curvature change rate. As shown in Table 1, sample data from feature region A and flat region B in the image were selected. The mean rate of curvature change at each point in region A was calculated to be 0.85, and the mean rate in region B was 0.02. Subsequently, the gradient change threshold setting process was executed, and the numerical set of local curvature change rates in the entire matrix was statistically analyzed. The probability density distribution function of this set was then calculated. Identify The inflection point value of the curve transitioning from a high-frequency distribution in flat regions to a long-tailed distribution in textured regions. For example, measuring the inflection point Calculate the global standard deviation Set the linear superposition multiplier coefficient Then the gradient change threshold To store all points in the matrix Value and Perform interval matching, when a certain point When a region is identified as having a rate of change greater than a threshold, high-density sampling points with a step size of 1 pixel are configured. At that time, sparse sampling points with a step size of 10 pixels are configured, and indexing logic between sampling frequency and spatial position is established to obtain a curvature adaptive sampling density mapping map.
[0021] Table 1. Local Curvature Change Rate and Sampling Configuration Sampling Table; S113: Based on the curvature adaptive sampling density mapping, the sampler is activated to extract discrete height feature points in the workpiece surface coordinate system according to the density distribution logic set in the figure. Non-uniform rational B-spline interpolation is performed on the extracted feature point set to calculate the fitted surface coordinates of the sampling gap area. Based on the fitting results, the three-dimensional geometric shape of the surface micro-texture is reconstructed to generate workpiece surface micro-morphology restoration data. 2500 feature points are extracted from region A, which is identified as having a high rate of change, and 100 feature points are extracted from region B, which has a low rate of change. Non-uniform rational B-spline (NURBS) interpolation is performed on the extracted feature point set. The order of the B-spline is set to 3. A system of linear equations is constructed using the least squares method to solve for the control vertices. For regions with sampling gaps, the tangent vector constraints of adjacent feature points are used to solve for the fitted surface coordinates, for example, in unsampled coordinates. The height value is calculated based on the surface equation of the surrounding sampling points. Based on all fitting and sampling results, the three-dimensional geometry of the surface micro-texture is reconstructed to generate workpiece surface micro-morphology restoration data.
[0022] Please see Figure 3 The specific steps for obtaining the attitude correction stability determination parameters are as follows: S211: Call the workpiece surface micro-morphology restoration data, perform gradient operator convolution on the reconstructed three-dimensional geometric shape, extract the connected pixel set whose gray level change rate difference is within the preset tolerance range, perform contour tracking and vector fitting along the edge of the set, and obtain the boundary coordinate sequence of the equal optical density domain. A 3×3 Sobel operator is used to convolve the depth matrix of the restored data. The gradient magnitude response threshold is set to 50. Connected pixel sets with gray-level change rate differences within a preset tolerance range are extracted. Contour tracking is performed along the edge of the set, and the coordinates of all pixels on the tracking path are recorded. Vectorized fitting is then performed to transform discrete edge pixels into continuous closed polygon vector data. For example, an approximately circular micropore structure is identified in the dataset, and the coordinate sequence of 120 nodes on its edge is obtained, as well as the coordinate sequence of the iso-density domain boundary.
[0023] S212: Based on the boundary coordinate sequence of the iso-density domain, the local curvature and geometric properties of the enclosed region are calculated by traversing the boundary nodes, using the following formula: ; The morphological stability score is obtained through calculation, and the regional morphological stability measurement information is obtained. in, A score representing the morphological stability of a single boundary region. The normalized area value representing regions of equal optical density is obtained by dividing the total number of pixels contained in the region by the total number of pixels in the image. Represents the boundary of the first The normalized value of the gray-level gradient vector of each node is obtained by calculating the gradient magnitude at that node using the Sobel operator and mapping it to the interval between 0 and 1. The index identifier represents the discrete node of the boundary, which is obtained by numbering the boundary sequence in a clockwise direction, corresponding to the [number of nodes]. 1 node The total statistical value representing the boundary nodes is obtained by counting the extracted boundary coordinate sequences of the iso-intensity domain. The normalized value of the closed perimeter representing the region boundary is obtained by summing the Euclidean distances between adjacent nodes of the boundary and dividing by the length of the image diagonal. Represents the boundary of the first The normalized curvature value of each node is obtained by calculating the differential of the tangent direction angle at that node and then performing dimensionless processing. The arithmetic mean normalized value representing the curvature of the entire boundary is obtained by summing the normalized curvature values of all nodes and dividing by the total number of nodes. The value represents a non-zero infinitesimal constant. It is obtained by setting an extremely small dimensionless value to prevent the denominator from being zero based on the system's calculation accuracy. The morphological convergence threshold is obtained by selecting a workpiece image sample under standard alignment, calculating the normalized value of the morphological stability score of each region with equal optical density in the sample, and taking the lower quartile of its statistical distribution as the benchmark judgment value. The local curvature and geometric properties of the enclosed region are calculated by traversing the boundary nodes. A morphological stability score is then calculated for a specific region, "micropore R". Assuming this region contains 1500 pixels and the total image pixels are 1 million, the area normalized value is... On the boundary The process iterates through each node, calculates and normalizes the gradient magnitude of each node using the Sobel operator, and measures the sum of the normalized gradient vector values. Given a boundary closure perimeter of 200 pixels and an image diagonal of 2000 pixels, the normalized perimeter value is... Calculate the normalized curvature value of each node and measure the variance term. Set a small constant Substitute into the formula to calculate: ; The advantage of this formula is that its numerator combines the area of the region with the gradient energy, while the denominator combines the square of the perimeter with the variance of curvature. This results in regions with more regular shapes, clearer edge gradients, and moderate areas receiving higher scores, while regions with blurred edges or distorted shapes receive sharply lower scores. By selecting workpiece image samples under standard alignment conditions, the lower quartile of the sample statistical distribution is calculated as the morphological convergence threshold, for example, a threshold of 35.0. The morphological stability score is then obtained, yielding the region's morphological stability measurement information.
[0024] S213: For the values in the region morphological stability measurement information, compare them with the preset morphological convergence threshold, count the proportion of regions within the convergence interval, perform binary logic judgment on the current alignment state of the workpiece based on the proportion result, and output the attitude correction stability judgment parameter. Taking the calculated "micropore R" score as an example, its value of 40.25 is greater than the set morphological convergence threshold of 35.0, and the difference is +5.25. It is determined that the region is in the convergence interval. The proportion of regions in the convergence interval in the current whole image is counted. If a total of 10 feature regions are identified in the whole image, and the scores of 8 regions are higher than their respective convergence thresholds, the proportion is 80%. The system alignment ready percentage threshold is set to 75%. Based on the comparison result of 80%>75%, the current alignment status of the workpiece is binarized logically judged, the "stable" flag is set, and the posture correction stability judgment parameters are output.
[0025] Please see Figure 4 The specific steps for obtaining the command response deviation trajectory per unit time are as follows: S311: Based on the attitude correction stability judgment parameters, reads continuous multi-frame grayscale images of the workpiece surface from the vision sensor and records the image acquisition frame timestamp. Polls the status register of the servo driver through the fieldbus to record the execution mechanism's action completion timestamp, calculates the hysteresis difference between the two sets of timestamps, encapsulates the image data and time difference, and generates a multi-dimensional time-series image sampling data packet. When the determination result is "stable", timing deviation tracking is initiated, and multiple consecutive frames of grayscale images of the workpiece surface (frame A, frame B, frame C) are read from the vision sensor. The timestamps of the image acquisition frames are recorded as follows: , , By polling the status register of the servo driver via the fieldbus, the timestamps of the actuator's actions at corresponding times are recorded. , , Calculate the lag difference between the two sets of timestamps to obtain... , , The three sets of image matrix data and their corresponding time lag differences are encapsulated in binary form to generate a multidimensional time-series image sampling data packet.
[0026] S312: Analyze the image matrix in the multi-dimensional temporal image sampling data packet, use the Gaussian Laplacian operator to detect local extreme value regions, determine key feature points, use the pyramid optical flow algorithm to track the pixel coordinate migration path of key feature points between consecutive frames, calculate the magnitude and direction of the feature point displacement vector, and generate a multi-frame continuous feature drift vector sequence. The Laplacian of Gaussian (LoG) operator is used to perform convolution on frames A, B, and C to detect local extrema and identify key feature points. For example, the coordinates of feature point P extracted in frame A are... The pyramid optical flow algorithm is used to track the position of feature point P in subsequent frames, and the coordinates are located in frame B. Locate the coordinates in frame C. Calculate the displacement vector of the feature point from frame A to frame B. The modulus is 2.236 pixels, and the displacement vector is from frame B to frame C. With a modulus of 3.605 pixels, a multi-frame continuous feature drift vector sequence is generated.
[0027] S313: Call the time lag difference and multi-frame continuous feature drift vector sequence in the multi-dimensional time-series image sampling data packet, use the time difference as the non-uniform sampling interval, perform piecewise cubic Hermit interpolation on the displacement vector, construct the functional relationship describing the evolution of the deviation with time, derive the response position drift per unit time, and generate the command response deviation trajectory per unit time. Using the time difference (e.g., 15ms) as a non-uniform sampling interval, piecewise cubic Hermitian interpolation is performed on the displacement vector to construct a functional relationship describing the evolution of the deviation over time. Discrete displacement vectors and As an interpolation node, it derives the response position drift within a unit time (e.g., 1 ms), for example, by calculating the position shift within a given time. The interpolation drift at time is Pixels generate the deviation trajectory of the instruction response per unit time.
[0028] Please see Figure 5 The specific steps for obtaining the dynamic execution error correction table are as follows: S411: Call the unit time instruction response deviation trajectory, construct a high-order polynomial regression equation as the fitting benchmark, traverse the discrete data points in the trajectory sequence, construct an error matrix including the observed deviation value and the equation prediction value, solve the normal equation system, determine the polynomial coefficients that minimize the sum of squared residuals, establish a mathematical model describing the continuous evolution of the actuator response drift over time, and generate a nonlinear response offset fitting model. Constructing higher-order polynomial regression equations As a fitting benchmark, 50 discrete data points in the trajectory sequence are traversed to construct an error matrix including observation deviations and equation predictions. The normal equations are then solved using the least squares method. Determine the polynomial coefficients that minimize the sum of squared residuals, for example, by solving for... A mathematical model describing the continuous evolution of actuator response drift over time is established, and a nonlinear response offset fitting model is generated.
[0029] S412: Based on the nonlinear response offset fitting model, input the execution step index at the current moment, calculate the theoretical unbiased response coordinates, retrieve historical instruction position data from the log, perform vector difference operation on the two, obtain the actual spatial execution lag, perform multi-dimensional spatial correlation mapping between the lag and the corresponding timestamp delay, establish the quantitative correspondence between spatial error and time delay, and obtain the position time lag correlation mapping set. Enter the current time The execution step index (e.g., step 100) is used to determine the theoretical unbiased response coordinates of the model output. Retrieve historical command location data from the logs at that specific moment. Performing a vector difference operation on both yields the actual spatial execution lag as follows: Mapping this spatial lag back to the time domain, if the current feed rate is... The corresponding time delay is By associating spatial errors with time delays, a location-time lag correlation mapping set can be obtained.
[0030] S413: Analyze the position-time lag correlation mapping set, perform inversion operation on the lag mapping relationship, derive the preload time compensation value required to eliminate the target space error, quantize and segment the compensation value according to the preset instruction step size resolution, construct a lookup logic structure with step size and direction as index keys and time compensation value as data value, and generate a dynamic execution error correction table. As shown in Table 2, an inversion operation is performed on the hysteresis mapping relationship to derive the preload time compensation value required to eliminate the target spatial error, for example, for... The lag error needs to be addressed in advance. Trigger commands according to a preset command step size resolution (e.g., ...). The compensation value is quantified and segmented, and a lookup logic structure is constructed with step size and direction as index keys and time compensation value as data value. For example, the index key "step size 50um_direction X+" corresponds to the value "compensation 5ms", and a dynamic execution error correction table is generated.
[0031] Table 2. Example table of dynamic execution error correction parameters; Please see Figure 6 The specific steps for obtaining adaptive alignment drive instructions are as follows: S511: Call the dynamic execution error correction table, intercept the queue of standard displacement control signals to be sent by the servo control device in real time, parse the target coordinate position and preset feed speed vector in the signal frame, use them as multi-dimensional index key values to retrieve the corresponding response delay time inversion mapping value and mechanical transmission error compensation coefficient in the dynamic execution error correction table, bind the retrieved error correction data with the sequence number of the original signal frame to the execution logic, construct the mapping relationship between signal physical characteristics and correction data, and generate the command mapping vector set to be corrected; Real-time interception of the standard displacement control signal queue to be sent by the servo control device, and parsing of the target coordinate position in the current signal frame. The preset feed rate vector is The current instruction step size is calculated to be... The direction is the positive X-axis, which is used as the multidimensional index key to retrieve the corresponding response latency inversion mapping value. And set the mechanical transmission error compensation coefficient as The retrieved error correction data is bound to the original signal frame sequence number ID:1024 using execution logic to construct a mapping relationship between the signal physical characteristics and the correction data, and to generate a set of instruction mapping vectors to be corrected.
[0032] S512: Based on the instruction mapping vector set to be corrected, extract the delay inversion mapping value, calculate the phase advance trigger time offset of the control pulse, call the error compensation coefficient to perform weighted scaling operation on the step amplitude of the original instruction, calculate the new step vector direction based on the adjusted amplitude and the motion state of the current mechanism, reconstruct the waveform envelope data of the drive signal using the vector synthesis rule, establish the parameter combination including timing correction, amplitude gain and direction adjustment, and generate spatiotemporal domain compensation modulation parameters; Extracting delayed inversion mapping values Calculate the phase advance of the control pulse by the trigger time offset, i.e., at the originally scheduled trigger time... forward Send pulse, call error compensation coefficient Step size of the original instruction Perform weighted scaling to obtain the corrected amplitude. Based on the adjusted amplitude and the current motion state of the mechanism, the new step vector direction is calculated. The waveform envelope data of the driving signal is reconstructed using the vector synthesis rule. The parameter combination including timing correction (-5ms), amplitude gain (+2%) and direction adjustment (no change) is established to generate the spatiotemporal compensation modulation parameters.
[0033] S513: For the spatiotemporal domain compensation modulation parameters, the parameter combination is binary encoded according to the communication protocol format of the servo driver, the phase advance trigger time offset is written into the timing control register field, the amplitude gain data is converted into current drive instruction code, and the cyclic redundancy check code and synchronization frame header are encapsulated in the direction control bit to construct a complete control data packet and generate adaptive alignment drive instructions. The parameter combination is binary encoded according to the EtherCAT communication protocol format of the servo driver, and the phase advance trigger time offset is calculated. Write the Offset register field of the DistributedClock to convert the amplitude gain data into hexadecimal current drive instruction code. Combine the 32-bit Cyclic Redundancy Check (CRC) code and the synchronization frame header (SOF) encapsulated by the direction control bits to construct a complete control data packet and generate adaptive alignment drive instructions.
[0034] An image-based automatic workpiece alignment system is provided. This system implements the aforementioned image-based automatic workpiece alignment method. The system includes: The surface restoration processing module acquires images of the workpiece surface, calculates the normal gradient field of the workpiece image, analyzes the local curvature change rate within the normal gradient field, adjusts the sampling point density based on the local curvature change rate, reconstructs surface features, and generates workpiece surface micromorphology restoration data. The attitude correction analysis module extracts gradient boundaries based on the workpiece surface micro-morphology restoration data, constructs an iso-optical density region, calculates the morphological stability score, determines whether the score is within the preset convergence range, and outputs attitude correction stability judgment parameters. The instruction deviation identification module starts timing deviation tracking based on attitude correction stability judgment parameters, obtains the timestamps of continuous image acquisition frames and the timestamps of the actuator's action completion, performs timing interpolation on the feature point drift vector, and derives the instruction response deviation trajectory per unit time. The execution error correction module uses the least squares method to fit the unit time instruction response deviation trajectory, constructs the response offset curve, calculates the difference between the current step position and the historical instruction position, inverts the mapping of the response delay time, and generates a dynamic execution error correction table. The alignment instruction construction module maps the dynamic execution error correction table to the control signal, adjusts the step direction and magnitude according to the delay inversion value of the dynamic execution error correction table, and generates adaptive alignment drive instructions.
[0035] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments that can be applied to other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.
Claims
1. A method for automatic alignment of a workpiece based on image measurement, characterized by, The method comprises the following steps: S1: collecting a workpiece surface image, calculating a normal gradient field of the workpiece image, analyzing a local curvature change rate in the normal gradient field, adjusting a sampling point density according to the local curvature change rate, reconstructing a surface feature, and generating workpiece surface micro-topography restoration data; S2: extracting a gradient boundary based on the workpiece surface micro-topography restoration data, constructing an equal optical density region, calculating a morphology stability score, determining whether the score is within a preset convergence range, and outputting a pose correction stability judgment parameter; S3: starting a time sequence deviation tracking based on the pose correction stability judgment parameter, obtaining a continuous image acquisition frame timestamp and an actuator action completion timestamp, performing a time sequence interpolation operation on a feature point drift vector, and deducing a unit time instruction response deviation trajectory; S4: fitting the unit time instruction response deviation trajectory using a least squares method, constructing a response offset curve, calculating a current step position and a historical instruction position difference value, inversely mapping a response delay time length, and generating a dynamic execution error correction table; S5: mapping the dynamic execution error correction table to a control signal, adjusting a step direction and amplitude according to a delay inversion value of the dynamic execution error correction table, and generating an adaptive alignment driving instruction.
2. The image measurement based automatic alignment method of a processed workpiece according to claim 1, characterized by, The workpiece surface micro-topography restoration data includes a point cloud coordinate set, a reconstructed surface normal texture map, and a feature depth matrix. The pose correction stability judgment parameter includes an equal optical density domain boundary continuity, a region area compactness convergence value, and a light distortion tolerance factor. The unit time instruction response deviation trajectory includes an inter-frame response time sequence drift vector, an instruction execution lag path node, and a dynamic deviation interpolation sequence. The dynamic execution error correction table includes a response delay time inversion mapping value, a mechanical transmission error compensation coefficient, and an actuator dead zone correction amount. The adaptive alignment driving instruction includes a phase advance trigger pulse, an inertia suppression braking level, and a micro-step amplitude gain signal.
3. The method of claim 2, wherein, The acquisition step of the workpiece surface micro-topography restoration data is specifically as follows: S111: collecting a workpiece surface image, traversing two-dimensional coordinates of each pixel point in the image matrix, respectively calculating gray difference values of the current pixel point and the neighborhood pixel points in the horizontal and vertical axes, synthesizing the normal gradient vector of the corresponding coordinate point according to the difference value, mapping the gradient vectors of all pixel points to a two-dimensional plane coordinate system, constructing a vector distribution field, and generating a pixel gray normal gradient vector matrix; S112: calling the pixel gray normal gradient vector matrix, performing a differential operation on the vector elements in the matrix to obtain a direction deflection rate between adjacent vectors, taking the deflection rate as a local curvature change rate and performing interval matching with a preset gradient change threshold, configuring high-density sampling points for regions with a change rate greater than the threshold, configuring sparse sampling points for regions with a change rate less than or equal to the threshold, establishing an index logic of sampling frequency and spatial position, and obtaining a curvature adaptive sampling density mapping graph. S113: Based on the curvature adaptive sampling density map, the sampler activates the density distribution logic set in the map to extract discrete height feature points in the workpiece surface coordinate system, performs non-uniform rational B-spline interpolation operation on the extracted feature point set, calculates the fitting surface coordinates of the sampling vacancy area, reorganizes the three-dimensional geometric morphology of the surface micro-texture according to the fitting result, and generates the workpiece surface micro-topography restoration data.
4. The method of claim 3, wherein, The acquisition step of the posture correction stability determination parameter is specifically: S211: Call the workpiece surface micro-topography restoration data, perform gradient operator convolution on the reconstructed three-dimensional geometric morphology, extract the connected pixel set with a gray change rate difference within a preset tolerance range, perform contour tracking and vector fitting along the edge of the set, and obtain an equal optical density domain boundary coordinate sequence; S212: Based on the equal optical density domain boundary coordinate sequence, traverse the boundary nodes to calculate the local curvature and the geometric properties of the enclosed area, and obtain the morphology stability score by operation, to obtain the area morphology stability measurement information; S213: For the numerical values in the area morphology stability measurement information, respectively, difference comparison is performed with the preset morphology convergence threshold value, the area ratio in the convergence interval is counted, the current alignment state of the workpiece is judged by binary logic according to the ratio result, and the posture correction stability determination parameter is output.
5. The method of claim 4, wherein, The formula for calculating the morphology stability score is specifically: ; wherein, a shape stability score representative of a single boundary region, an area normalization value representative of an equal optical density region, a gray level gradient vector normalization value representative of a first node on the boundary, a total quantity statistical value representative of the boundary nodes, a closed perimeter normalization value representative of the region boundary, a curvature normalization value representative of a first node on the boundary, an arithmetic mean normalization value representative of the entire boundary curvature, representative of a non-zero infinitesimal constant.
6. The method of claim 5, wherein, The acquisition step of the unit time instruction response deviation trajectory is specifically: S311: Based on the posture correction stability determination parameter, read continuous multiple frames of workpiece surface gray scale images from the visual sensor and record the image acquisition frame time stamp, poll the state register of the servo driver through the field bus to record the execution mechanism action completion time stamp, calculate the lag difference value between the two groups of time stamps, package the image data and time difference value, and generate a multi-dimensional time sequence image sampling data packet; S312: Analyze the image matrix in the multi-dimensional time sequence image sampling data packet, detect local extreme regions using a Gaussian Laplacian operator, determine key feature points, track the pixel coordinate migration path of the key feature points between consecutive frames using a pyramid optical flow algorithm, calculate the length and direction of the feature point displacement vector, and generate a multi-frame continuous feature drift vector sequence; S313: Call the time lag difference value and the multi-frame continuous feature drift vector sequence in the multi-dimensional time sequence image sampling data packet, use the time difference value as a non-uniform sampling interval, perform piecewise cubic Hermite interpolation operation on the displacement vector, construct a function relationship describing the evolution of the deviation over time, derive the response position drift amount in unit time, and generate a unit time instruction response deviation trajectory.
7. The method of claim 6, wherein, The acquisition step of the dynamic execution error correction table is specifically: S411: Call the unit time instruction response deviation trajectory, construct a high-order polynomial regression equation as a fitting reference, traverse the discrete data points in the trajectory sequence, construct an error matrix including the observed deviation value and the equation predicted value, solve the normal equation set, determine the polynomial coefficients that minimize the residual sum of squares, establish a mathematical model describing the continuous evolution of the execution mechanism response drift over time, and generate a non-linear response offset fitting model; S412: According to the nonlinear response offset fitting model, input the current time execution step index, calculate the theoretical unbiased response coordinates, retrieve the historical command position data from the log, perform vector difference operation on both, obtain the actual spatial execution lag, map the lag and the corresponding time stamp delay in multidimensional space, establish the quantitative corresponding relationship between spatial error and time delay, obtain the position time lag correlation mapping set; S413: Analyze the position time lag correlation mapping set, perform inverse operation on the lag mapping relationship, deduce the preloading time compensation value required to eliminate the target spatial error, quantize the compensation value according to the preset command step resolution, construct a lookup logic structure with step amplitude and direction as index keys and time compensation value as data value, and generate a dynamic execution error correction table.
8. The method of claim 7, wherein, The acquisition step of the adaptive alignment driving instruction is specifically: S511: Call the dynamic execution error correction table, real-time intercept the standard displacement control signal queue to be sent by the servo control device, analyze the target coordinate position and preset feed speed vector in the signal frame as multidimensional index key values in the dynamic execution error correction table to retrieve the corresponding response delay time inverse mapping value and mechanical transmission error compensation coefficient, perform logical binding on the error correction data obtained by retrieval and the sequence number of the original signal frame, construct the mapping relationship between signal physical characteristics and correction data, and generate a to-be-corrected instruction mapping vector set; S512: Based on the to-be-corrected instruction mapping vector set, extract the delay inverse mapping value, calculate the phase advance trigger time offset of the control pulse, call the error compensation coefficient to perform weighted scaling operation on the step amplitude of the original instruction, calculate the new step vector direction according to the adjusted amplitude and the motion state of the current mechanism, reconstruct the waveform envelope data of the driving signal using the vector synthesis rule, establish the parameter combination including time correction, amplitude gain and direction adjustment, and generate the space-time domain compensation modulation parameter; S513: For the space-time domain compensation modulation parameter, perform binary encoding on the parameter combination according to the communication protocol format of the servo driver, write the phase advance trigger time offset into the time sequence control register field, convert the amplitude gain data into current driving instruction code, encapsulate the cyclic redundancy check code and synchronization frame header combined with the direction control bit, construct a complete control data packet, and generate an adaptive alignment driving instruction.
9. An image measurement based automatic alignment system for a workpiece being processed, characterized by, The system is used to implement the image measurement-based automatic alignment method of the machining workpiece according to any one of claims 1-8, and the system comprises: A surface restoration processing module that collects a machining workpiece surface image, calculates a normal gradient field of the workpiece image, analyzes a local curvature change rate in the normal gradient field, adjusts a sampling point density according to the local curvature change rate, reconstructs a surface feature, and generates workpiece surface micro-topography restoration data; A posture correction analysis module that extracts a gradient boundary based on the workpiece surface micro-topography restoration data, constructs an equal optical density area, calculates a morphology stability score, determines whether the score is within a preset convergence range, and outputs a posture correction stability determination parameter; An instruction deviation identification module starts time sequence deviation tracking based on the posture correction stability determination parameter, acquires continuous image acquisition frame time stamps and execution mechanism action completion time stamps, performs time sequence interpolation operation on a feature point drift vector, and deduces a unit time instruction response deviation trajectory; An execution error correction module adopts a least square method to fit the unit time instruction response deviation trajectory, constructs a response deviation curve, calculates a current step length position and a historical instruction position difference value, inversely maps a response delay time length, and generates a dynamic execution error correction table; An alignment instruction construction module maps the dynamic execution error correction table to a control signal, adjusts a step length direction and amplitude according to a delay inverse value of the dynamic execution error correction table, and generates an adaptive alignment driving instruction.
Citation Information
Cited By
Workpiece in-place state identification method and system based on multi-source heterogeneous data fusion
CN121904705A