A machine vision-based fine carving machine machining track control method
By generating dynamic feature masks and calculating Gaussian difference gradients, the problems of brittle fracture warning and visual interference in optical glass processing are solved, achieving precise trajectory control and a safe processing procedure.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-27
- Publication Date
- 2026-03-31
AI Technical Summary
Existing technologies cannot effectively predict brittle fracture in optical glass processing. The control strategy lacks a real-time synchronization mechanism, which leads to saturation or instability of the servo driver output. Furthermore, visual interference and feature extraction distortion cause trajectory positioning errors.
By receiving instructions from the CNC system, the system generates source data packets using a vision acquisition unit and an infrared sensor. Combined with a preset homography matrix and frictional thermal response coefficient, it generates a dynamic feature mask, performs Gaussian difference gradient calculation and least squares ellipse fitting, outputs tool tip feedback coordinates, and drives the feed axis motor to perform displacement compensation.
It effectively distinguishes between real tool tip hotspots and optical virtual images, improves the uniqueness and accuracy of trajectory recognition, prevents machining edge chipping, and ensures the safety and robustness of the machining process.
Smart Images

Figure CN121578743B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of numerical control technology, specifically to a method for controlling the machining trajectory of a precision engraving machine based on machine vision. Background Technology
[0002] In the field of precision CNC machining, achieving accurate tracking and real-time correction of machining trajectories for complex curved surfaces is a core technical challenge. Existing technologies generally employ a closed-loop feedback strategy of "machine vision + motion control." For example, by acquiring images of the machining area, extracting the actual trajectory through binarization and coordinate mapping, and calculating its displacement deviation from the standard G-code trajectory, compensation commands are generated and fed back to the CNC system. This control logic based on static geometric mapping is currently the mainstream technical approach.
[0003] However, existing technologies have significant shortcomings in the processing control of transparent, hard, and brittle materials such as optical glass. The control strategies only focus on the displacement deviation of the geometric position and lack consideration for the brittle fracture mechanism, making it impossible to provide effective early warning before edge breakage occurs. In terms of deviation correction, existing technologies attempt to introduce auxiliary adjustment variables (such as local intervention for environmental field parameters) or superimpose excitation signals of specific frequency bands outside the main control loop. Such strategies are often designed in an open-loop or decoupled manner in terms of program logic, and lack a real-time synchronization mechanism with the spindle motion command. Superimposing a compensation signal with a preset frequency on the position command, without adaptive filtering, can easily excite higher-order unmodeled dynamics of the system, leading to saturation or instability of the servo drive output. Existing offline error compensation methods (i.e., surface correction performed after control) change the initial state parameters of the controlled object, rendering the original model parameters of the control system invalid, resulting in a lack of repeatability and safety in subsequent program control processes. In addition, there are problems of visual interference and feature extraction distortion in trajectory recognition. Due to the high reflectivity of optical glass, dynamic refraction parallax is easily caused during processing, and the internal reflection phantom generated by high light transmittance can also interfere with trajectory positioning, making it impossible to distinguish between real tool tip hotspots and optical virtual images, resulting in the inability to obtain the real physical processing trajectory.
[0004] To address this, a machine vision-based method for controlling the machining trajectory of a precision engraving machine is proposed. Summary of the Invention
[0005] The purpose of this invention is to provide a machine vision-based method for controlling the machining trajectory of a precision engraving machine, so as to solve the problems mentioned in the background art.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a machine vision-based method for controlling the machining trajectory of a precision engraving machine, comprising:
[0007] The system receives a work task instruction containing the workpiece ID from the CNC system, triggers the vision acquisition unit to acquire the reflected light intensity matrix, and the infrared sensor to acquire the processing thermal field data, generating a source data packet containing the workpiece ID.
[0008] The processing thermal field data is mapped to the reflected light intensity matrix using a preset homography matrix to obtain the fused thermal distribution matrix; the workpiece ID is used to query the preset workpiece database to obtain the frictional thermal response coefficient; based on the frictional thermal response coefficient, the area in the fused thermal distribution matrix that exceeds the preset working condition intensity threshold is determined as the physical tool tip contact area, and a dynamic feature mask is generated.
[0009] Perform a logical AND operation between the dynamic feature mask and the reflected light intensity matrix to output the monitoring area; perform edge gradient analysis and least squares ellipse fitting on the monitoring area to output the coordinates of the execution end.
[0010] Read the current tool axis depth data, and use the pre-stored sensor calibration parameters to inversely transform the end coordinates into tool tip feedback coordinates; read the current interpolation command coordinates, calculate the difference vector with the tool tip feedback coordinates, and drive the feed axis motor to perform displacement compensation through the servo adder register.
[0011] Preferably, the specific generation process of the source data packet includes:
[0012] The system receives the work task instruction from the CNC system and extracts the workpiece ID using a protocol parser. It then sends rising edge trigger pulses in parallel to the vision acquisition unit and the infrared sensor. In response to the trigger pulses, the vision acquisition unit acquires the reflected light intensity matrix and writes it into the first direct memory access buffer, while the infrared sensor acquires the machining thermal field data and writes it into the second direct memory access buffer. The system iterates through the first and second direct memory access buffers, locking matrix pairs whose timestamp difference is less than a preset clock cycle tolerance. Finally, it performs a data splicing operation, encapsulating the locked reflected light intensity matrix, the machining thermal field data, and the workpiece ID into the source data packet.
[0013] Preferably, the specific process for generating the fused heat distribution matrix includes:
[0014] Parse the source data packet to separate the processing thermal field data; retrieve the pre-calibrated homography transformation matrix, perform matrix multiplication and perspective division operations on the original row and column coordinate vectors of each element in the processing thermal field data, and calculate the target floating-point coordinates mapped to the coordinate system of the reflected light intensity matrix; read the raster values of the processing thermal field data adjacent to the target floating-point coordinates, perform bilinear interpolation processing, and calculate the corrected radiation value; fill the corrected radiation value into an empty matrix with the same resolution as the reflected light intensity matrix according to the integer part of the target floating-point coordinates, and output the fused thermal distribution matrix.
[0015] Preferably, the specific construction process of the dynamic feature mask includes:
[0016] The source data packet is parsed to extract the workpiece ID; the workpiece ID is used as an index key to input into the workpiece database, and the corresponding frictional heat response coefficient is retrieved; based on the inverse function of Planck's law, combined with the frictional heat response coefficient, the grayscale data of each pixel in the fused heat distribution matrix is transformed from radiation value to temperature value to generate an absolute temperature matrix of the workpiece surface; a preset working condition intensity threshold is retrieved and compared with the absolute temperature matrix of the workpiece surface; the coordinate set with temperature values higher than the working condition intensity threshold is defined as the thermally effective area, and the coordinate set with temperature values lower than the working condition intensity threshold is defined as the cold background area, generating a binary thermal image; an erosion algorithm is used to remove isolated noise points from the binary thermal image, and an expansion algorithm is used to fill the holes inside the hot spots, outputting the dynamic feature mask.
[0017] Preferably, the specific process for generating the execution end coordinates includes:
[0018] The process involves: retrieving the dynamic feature mask and the reflected light intensity matrix; performing a bitwise AND operation on the pixel values at corresponding positions to force the reflected light intensity data corresponding to regions with a logical value of zero in the dynamic feature mask to zero, retaining the data for regions with a logical value of 1, and generating a monitoring region; constructing two Gaussian convolution kernels with different scale standard deviations; applying convolution filtering to the monitoring region using the Gaussian convolution kernels to generate two blurred images; constructing a Gaussian difference response map based on the two blurred images; traversing the Gaussian difference response map and extracting the zero-crossing points of the response values as the edge feature point set; constructing an algebraic distance objective function describing the geometric equation of an ellipse; substituting the coordinate data of the edge feature point set into the algebraic distance objective function to obtain an overdetermined linear equation system; solving the least squares solution of the overdetermined linear equation system using singular value decomposition to determine the geometric parameters of the fitted ellipse; and extracting the geometric floating-point coordinates of the center of the fitted ellipse as the coordinates of the execution endpoint.
[0019] Preferably, the specific process for generating the tool tip feedback coordinates includes:
[0020] The system reads the current tool axis depth value fed back by the encoder of the CNC system; retrieves the sensor calibration parameters including the intrinsic parameter matrix, distortion coefficient, and hand-eye transformation matrix; performs a distortion correction operation on the execution end coordinates using the distortion coefficient to eliminate radial and tangential nonlinear errors, obtaining distorted coordinates; performs a linear transformation on the distorted coordinates using the inverse matrix of the intrinsic parameter matrix to obtain a unit line-of-sight vector; performs a scalar multiplication between the unit line-of-sight vector and the tool axis depth value to reconstruct the three-dimensional spatial coordinates; performs a rotational and translational rigid body transformation on the three-dimensional spatial coordinates using the hand-eye transformation matrix, and outputs the tool tip feedback coordinates in the workpiece coordinate system.
[0021] Preferably, the specific process of the drive feed axis motor performing micro-displacement compensation includes:
[0022] Within the current servo control cycle, the theoretical interpolation command coordinate data and the original interpolation pulse generated by the interpolator are locked and extracted; the tool tip feedback coordinates are called as a non-contact external feedback signal; the position deviation vector between the theoretical interpolation command coordinates and the tool tip feedback coordinates is calculated through three-dimensional spatial vector subtraction; the position deviation vector is decomposed into independent scalar error components corresponding to each feed axis using the machine tool inverse kinematics formula; each of the independent scalar error components is written into the position loop controller; when the position loop controller performs position closed-loop calculation, it digitally superimposes the independent scalar error components with the original interpolation pulse to generate a composite motion command containing dynamic correction, which is converted into a pulse width modulation voltage by the servo driver to excite the feed axis servo motor for displacement compensation.
[0023] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0024] 1. Based on the workpiece ID, a preset workpiece database is queried to obtain the frictional thermal response coefficient. Based on this coefficient, areas exceeding a preset cutting temperature threshold in the registered thermal radiation distribution matrix are identified as physical tool tip contact areas. A dynamic thermal mask is generated, utilizing the physical blocking properties of optical glass—transparent in the visible light band but with near-zero transmittance in the long-wave infrared band. The high-radiation areas captured by the infrared sensor are more likely to be actual cutting hotspots on the workpiece surface, rather than cold optical virtual images formed by multiple refractions and reflections within the glass. By performing a logical AND operation between the dynamic thermal mask and the reflected light intensity matrix, the visual algorithm is forced to focus only on areas with thermodynamic truth. This method directly eliminates interference using the spectral physical properties of materials, effectively distinguishing between real tool tip hotspots and optical virtual images, ensuring the uniqueness and authenticity of trajectory recognition.
[0025] 2. By performing Gaussian difference gradient calculation and least-squares ellipse fitting on the monitored area, the coordinates of the execution endpoint are output, improving the accuracy when relying solely on infrared images. In optical glass processing, high reflectivity easily causes dynamic refraction parallax, resulting in high-frequency noise and false edges in the visible light image. This invention adopts an infrared localization and visible light point positioning strategy. It utilizes a dynamic thermal mask generated by infrared to strictly limit the search range to the actual physical contact area. Within this extremely small monitoring area, the advantages of the short wavelength and high resolution of visible light are used for sub-pixel-level edge extraction. This avoids the low positioning accuracy caused by blurred edges in infrared images and prevents the Gaussian difference operator from being mistakenly attracted by bright noise points from specular reflections during full-image search. This ensures that the acquired processing trajectory data has both semantic authenticity and higher geometric accuracy.
[0026] 3. By reading the current tool axis depth data and using pre-stored camera calibration parameters, the tool tip observation coordinates are reconstructed into the measured feedback coordinates of the tool tip. Finally, the feed axis motor is driven to perform micro-displacement compensation, converting the visual observation data into effective physical control commands. By introducing the Z-axis encoder data of the CNC system as a strong geometric constraint, combined with the camera calibration parameters, the pixel coordinates on the two-dimensional image are restored to three-dimensional physical coordinates in the workpiece coordinate system. This allows the CNC system to dynamically correct visual positioning errors caused by optical virtual images and refraction, ensuring stable acquisition and execution of the true physical machining trajectory, effectively preventing machining chipping or overcutting caused by visual errors.
[0027] 4. By deeply spatiotemporally coupling the physical cutoff characteristics of the infrared spectrum, the high-frequency texture features of visible light, and the kinematic constraints of the CNC system, a closed-loop "perception-execution" system was constructed. Utilizing an infrared thermal mask as prior physical knowledge, the high-precision sub-pixel search of visible light is confined to the dynamic region of interest, reducing the computational overhead of image processing. Simultaneously, the Z-axis depth data of the CNC system provides absolute geometric constraints for visual computation, while the differential vector from visual feedback is used to inversely correct the feed commands of the CNC system through inverse kinematics computation, forming a mutually supportive dual verification mechanism. This deep cross-domain integration enables the system to maintain the ability to lock onto the true physical trajectory even when dealing with transparent, hard, and brittle materials such as optical glass, effectively preventing servo oscillations caused by false alarms or delays in the vision system, and improving the safety of precision machining processes and the robustness of trajectory control. Attached Figure Description
[0028] Figure 1 The flowchart illustrates a machine vision-based precision engraving machine trajectory control method proposed in an embodiment of this invention application.
[0029] Figure 2 This is a flowchart of the dynamic feature mask construction process proposed in an embodiment of this invention.
[0030] Figure 3 This is a flowchart of the execution end coordinate extraction sub-process proposed in an embodiment of the present invention. Detailed Implementation
[0031] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0032] Please see Figures 1-3The present invention provides a machine vision-based method for controlling the machining trajectory of a precision engraving machine, the specific steps of which are as follows:
[0033] The system receives a work task instruction containing the workpiece ID from the CNC system, triggers the vision acquisition unit to acquire the reflected light intensity matrix, and the infrared sensor to acquire the processing thermal field data. Through time alignment, it generates a source data packet containing the workpiece ID.
[0034] The processing thermal field data is mapped to the reflected light intensity matrix using a preset homography matrix to obtain the fused thermal distribution matrix; the workpiece ID is used to query the preset workpiece database to obtain the frictional thermal response coefficient; based on the frictional thermal response coefficient, the area in the fused thermal distribution matrix that exceeds the preset working condition intensity threshold is determined as the physical tool tip contact area, and a dynamic feature mask is generated.
[0035] Perform a logical AND operation between the dynamic feature mask and the reflected light intensity matrix to output the monitoring area; perform Gaussian difference gradient calculation and least squares ellipse fitting on the monitoring area to output the coordinates of the execution end;
[0036] Read the current tool axis depth data, and use the pre-stored sensor calibration parameters to inversely transform the end coordinates into tool tip feedback coordinates; read the current interpolation command coordinates, calculate the difference vector with the tool tip feedback coordinates, and drive the feed axis motor to perform displacement compensation through the servo adder register.
[0037] The technical solution of the present invention will be further described in detail below with reference to specific embodiments. Example
[0038] This application discloses a machine vision-based method for controlling the machining trajectory of a precision engraving machine. (See attached document.) Figure 1 The specific steps proposed in this invention include: S1. Receiving a work task instruction containing a workpiece ID from a CNC system, triggering a vision acquisition unit to acquire a reflected light intensity matrix, and an infrared sensor to acquire machining thermal field data, generating a source data packet containing the workpiece ID; S2. Mapping the machining thermal field data to the reflected light intensity matrix using a preset homography matrix to obtain a fused thermal distribution matrix; S3. Querying a preset workpiece database based on the workpiece ID to obtain a frictional thermal response coefficient; based on the frictional thermal response coefficient, determining the area in the fused thermal distribution matrix that exceeds a preset working condition intensity threshold as a physical tool tip contact area, and generating a dynamic feature mask; S4. Performing a logical AND operation between the dynamic feature mask and the reflected light intensity matrix to output the monitoring area; performing Gaussian difference gradient calculation and least squares ellipse fitting on the monitoring area to output the execution end coordinates; S5. Reading the current tool axis depth data, and inversely transforming the execution end coordinates to tool tip feedback coordinates using pre-stored sensor calibration parameters; S6. Reading the current interpolation instruction coordinates, calculating the difference vector with the tool tip feedback coordinates, and driving the feed axis motor to perform displacement compensation through a servo adder register.
[0039] Furthermore, the system receives a work task instruction containing the workpiece ID from the CNC system, triggering the vision acquisition unit to acquire the reflected light intensity matrix and the infrared sensor to acquire the machining thermal field data. Through time alignment, a source data packet containing the workpiece ID is generated; this corresponds to step S1 above. The specific implementation process includes:
[0040] The system receives the work task instruction from the CNC system and extracts the workpiece ID using a protocol parser. It then sends rising edge trigger pulses in parallel to the vision acquisition unit and the infrared sensor. In response to the trigger pulses, the vision acquisition unit acquires the reflected light intensity matrix and writes it into the first direct memory access buffer, while the infrared sensor acquires the machining thermal field data and writes it into the second direct memory access buffer. The system iterates through the first and second direct memory access buffers, locking matrix pairs whose timestamp difference is less than a preset clock cycle tolerance. Finally, it performs a data splicing operation, encapsulating the locked reflected light intensity matrix, the machining thermal field data, and the workpiece ID into the source data packet.
[0041] Specifically, the system receives the work task instruction from the CNC system and extracts the workpiece ID using a protocol parser. Rising-edge trigger pulses are sent in parallel to the vision acquisition unit and the infrared sensor. In this embodiment, communication with the CNC system is established via an industrial Ethernet interface, and the macro variable register (e.g., addresses #500 to #510) is periodically polled. When the status bit at address #500 changes from 0 to 1, it is determined to be a work task start signal, and a work task instruction is issued. At this time, the protocol parser reads the ASCII encoded data stored at address #501 and decodes it into a workpiece ID string (e.g., "N-BK7-Prism-Optic04"). The input to this process is the register status value of the CNC system, and the output is a unique workpiece index key. Next, the FPGA sends synchronous trigger signals to the vision acquisition unit and the infrared sensor (i.e., the visible light camera and the infrared sensor) through two independent physical channels. This trigger signal is configured as a TTL standard rising-edge pulse with a pulse width of 50μs and an amplitude of 5V. To eliminate the transmission delay difference caused by optical isolation, the delay compensation parameters of the two trigger lines were calibrated in advance using an oscilloscope to ensure that the physical time deviation of the optical signal arriving at the two sensor photosensitive chips is strictly controlled within 1μs.
[0042] Specifically, in response to the trigger pulse, the visual acquisition unit acquires the reflected light intensity matrix and writes it into the first direct memory access buffer, while the infrared sensor acquires the processing thermal field data and writes it into the second direct memory access buffer. In this embodiment, in response to the trigger pulse, the visual acquisition unit exposes and outputs an 8-bit grayscale image stream with a resolution of 2448×2048; the infrared sensor (using a vanadium oxide microbolometer) outputs 14-bit processing thermal field data with a resolution of 640×512. Two circular buffers, namely the first direct memory access buffer and the second direct memory access buffer, are opened in the kernel space, with each region having a depth of 32 frames. Image data is written to physical memory directly via DMA operation through the PCIe bus. The input to this process is the raw LVDS or differential signal output by the sensor, and the output is two-dimensional matrix data residing in memory, resulting in the reflected light intensity matrix.
[0043] In this embodiment, when acquiring the reflected light intensity matrix, the original light intensity information under four polarization dimensions is acquired simultaneously. The polarization degree component of the object is calculated using Stokes vectors. Utilizing the physical difference in polarization states between diffuse reflection and specular reflection, strong light noise generated by specular reflection is reconstructed and removed. In the strong reflection environment of optical glass processing, the original image often suffers from pixel saturation due to specular reflection. Specifically, the visual acquisition unit incorporates a polarization filter array. First, based on the acquired original light intensity values under the four polarization dimensions, the Stokes vectors of three components are calculated. The first component represents the total light intensity, the second component is the difference between horizontal and vertical polarization, and the third component is the difference between diagonal polarization. The degree of polarization is further calculated, its value being equal to the square root of the sum of the squares of the second and third components divided by the total light intensity. The total light intensity consists of diffuse reflection and specular reflection components. Because the internal reflection virtual image and surface specular highlights of optical glass have extremely high linear polarization characteristics, with a polarization degree close to 1, while the polarization state of the diffuse reflection signal generated by cutting at the tool tip is random and its polarization degree is relatively low, a preset polarization degree threshold of 0.75 is set. The reflection intensity matrix coordinates are iterated, and when the polarization degree at a point is higher than the threshold, the Fresnel reflection coefficient is used to inversely estimate and subtract the specular reflection component to obtain the preprocessed reflection intensity matrix. Through the physical optics decoupling process, the flickering specular highlights that originally obscured the tool tip texture are effectively suppressed, and the true geometric details of the tool are preserved in the reflection intensity matrix. This solves the feature loss problem caused by light intensity saturation and prevents distortion in tool tip feature extraction caused by pixel saturation.
[0044] Specifically, the first and second direct memory access buffers are traversed to lock matrix pairs whose timestamp difference is less than a preset clock cycle tolerance. In this embodiment, the first and second buffer queues each contain an image matrix and a timestamp. First, the time bases of the two sensors are calibrated to ensure clock synchronization accuracy is better than 1μs. During the traversal, the latest frame in the first buffer queue is selected, its timestamp is read, and then a binary search is performed to find the corresponding frame whose timestamp absolute difference is less than a preset parameter. The parameter is set to a preset clock cycle tolerance of 50μs, calculated based on the maximum feed speed of the engraving machine of 6000mm / min (i.e., 100mm / s). A time deviation of 50μs corresponds to a spatial displacement error of 0.005mm, which is less than the preset machining accuracy tolerance, thus ensuring the physical validity at the same moment. If the condition is met, the two frames of data, i.e., a matrix pair of data, are marked as locked and dequeued from the queue; if the traversal fails, older isolated frames are discarded according to the order of their timestamps to maintain the real-time performance of the queue.
[0045] Specifically, a data splicing operation is performed, encapsulating the locked reflected light intensity matrix, the processing thermal field data, and the workpiece ID into the source data packet. In this embodiment, the data splicing operation is performed once a valid data pair is locked. The source data packet is defined as a compact structure in memory, with its header containing 64 bytes of metadata, including the workpiece ID (32-byte character array), an aligned unified timestamp (8-byte double-precision floating-point number), and the size parameters of the two images. The payload portion is then filled with the visible light reflected light intensity matrix and the infrared processing thermal field data sequentially via memory copy instructions.
[0046] The protocol parser extracts the workpiece ID and directly drives the hardware to generate rising edge trigger pulses, triggering dual sensors in parallel. Combined with DMA direct memory access and microsecond-level timestamp alignment technology, it locks the light intensity and radiation data at the same physical moment, avoiding random jitter. Furthermore, by encapsulating the source data packet, it binds the workpiece material properties with the real-time sensing data, ensuring that the data stream can still reflect the processing status under high-speed feeding conditions, providing a reliable time reference for eliminating dynamic parallax.
[0047] Furthermore, the processing thermal field data is mapped to the reflected light intensity matrix using a preset homography matrix to obtain the fused thermal distribution matrix; this corresponds to step S2 above; the specific implementation process includes:
[0048] Parse the source data packet to separate the processing thermal field data; retrieve the pre-calibrated homography transformation matrix, perform matrix multiplication and perspective division operations on the original row and column coordinate vectors of each element in the processing thermal field data, and calculate the target floating-point coordinates mapped to the coordinate system of the reflected light intensity matrix; read the raster values of the processing thermal field data adjacent to the target floating-point coordinates, perform bilinear interpolation processing, and calculate the corrected radiation value; fill the corrected radiation value into an empty matrix with the same resolution as the reflected light intensity matrix according to the integer part of the target floating-point coordinates, and output the fused thermal distribution matrix.
[0049] Specifically, the source data packet is parsed to separate the processing thermal field data. A pre-calibrated homography transformation matrix is retrieved, and matrix multiplication and perspective division operations are performed on the original row and column coordinate vectors of each element in the processing thermal field data to calculate the target floating-point coordinates mapped to the coordinate system of the reflected light intensity matrix. In this embodiment, the source data packet is parsed, and the output is independent processing thermal field data and a reflected light intensity matrix. At this time, the values in the processing thermal field data still represent the thermal radiation intensity received by the sensor detection unit in the form of digital quantization values. The pre-calibrated infrared lens distortion coefficient is retrieved, and distortion correction processing is performed on the processing thermal field data to generate corrected thermal field data. Then, a pre-calibrated 3x3 homography transformation matrix is called. The homography transformation matrix contains the rotation, translation, and intrinsic parameter scaling relationships between the two sensors. To ensure that the output matrix and the reflected light intensity matrix are strictly aligned in space, a reverse mapping strategy is adopted. Each pixel coordinate of the reflected light intensity matrix is traversed and constructed into a homogeneous coordinate vector. Subsequently, matrix multiplication is performed on the aligned sub-coordinate vectors using the inverse of the homography transformation matrix, yielding a result vector containing three components, where the third component is defined as the normalization factor. Next, perspective division is performed: the target floating-point x-coordinate is equal to the projected value of the target x-coordinate divided by the normalization factor, and the target floating-point y-coordinate is equal to the projected value of the target y-coordinate divided by the normalization factor. This calculates the target floating-point coordinates of the visible light pixel in the processing thermal field data coordinate system. For example, the visible light coordinates (1224, 1024) might correspond to (320.5, 256.5) in the processing thermal field data coordinate system after calculation.
[0050] In this embodiment, the current tool axis depth and glass refractive index are obtained, and a dynamic refraction offset operator based on Snell's law is constructed. An online affine correction is performed on the preset basic homography matrix to compensate for the dynamic refraction parallax offset caused by changes in the optical glass thickness. During CNC machining, the line of sight passing through transparent optical glass will generate a refraction displacement, which dynamically changes with the machining depth and observation angle. In this embodiment, the real-time tool axis coordinates fed back by the CNC system are first read, combined with the refractive index constant of the glass material (e.g., 1.5168 for BK7 glass), and the preset camera mounting tilt angle parameter, i.e., the angle between the camera optical axis and the normal to the workpiece surface, is retrieved and defined as the incident angle. A refraction offset correction matrix is constructed. The specific construction process is as follows: First, the actual machining depth is determined based on the difference between the current real-time tool axis coordinates and the workpiece surface reference; second, based on Snell's law of refraction, the sine value of the refraction angle of light inside the glass is calculated using the refractive index of the glass medium, i.e., the sine value of the incident angle divided by the refractive index; then, the lateral position offset caused by refraction is calculated based on the principle of parallel plate refraction. The processing depth is set to the glass thickness, and the refraction angle is calculated using the refractive index. The calculation logic for the lateral position offset is as follows: calculate the sine value of the difference between the incident angle and the refraction angle, divide the sine value by the cosine value of the refraction angle, and then multiply the result by the processing depth. Based on the calculated lateral position offset, according to the camera's imaging model, obtain the pixel value corresponding to a unit physical distance (i.e., the imaging ratio), and convert the above lateral offset into a pixel offset in the image coordinate system. Obtain the projection angle of the current line of sight on the image plane, decompose the pixel offset into horizontal and vertical components, construct a translation transformation matrix containing these two components, and multiply the translation transformation matrix on the left by a preset basic homography matrix to generate a refraction correction dynamic homography matrix. When mapping infrared thermal field data to the reflected light intensity matrix, this dynamic matrix is used for coordinate transformation. By using affine correction, the physical misalignment between the actual position of the infrared hotspot and the apparent position of the visible light image in the coordinate system caused by the thickness of the glass is effectively solved. The static mapping is upgraded to dynamic precision matching that takes into account the optical properties of the medium, eliminating the positioning drift during deep processing and the dynamic refractive parallax caused by the thickness of the optical glass.
[0051] Specifically, the grid values adjacent to the target floating-point coordinates in the processing thermal field data are read, and bilinear interpolation is performed to calculate the corrected radiation value. The corrected radiation value is then filled into an empty matrix with the same resolution as the reflected light intensity matrix according to the integer part of the target floating-point coordinates, and the fused thermal distribution matrix is output. In this embodiment, since the calculated target floating-point coordinates are usually located at non-integer grid points in the infrared matrix, direct rounding will cause image jaggedness and information loss, so bilinear interpolation is required. For the above target floating-point coordinates, their integer and decimal parts are extracted first. Next, the pixel values of the four adjacent grid values in the processing thermal field data are read: the top left, top right, bottom left, and bottom right corner pixels. The interpolation calculation follows a weighted average principle: the corrected radiance value is equal to the sum of four products. The first product is (1 minus the horizontal decimal part) multiplied by (1 minus the vertical decimal part) multiplied by the top-left pixel value; the second product is the horizontal decimal part multiplied by (1 minus the vertical decimal part) multiplied by the top-right pixel value; the third product is (1 minus the horizontal decimal part) multiplied by the vertical decimal part multiplied by the bottom-left pixel value; and the fourth product is the horizontal decimal part multiplied by the vertical decimal part multiplied by the bottom-right pixel value. This process is equivalent to performing a weighted average of thermal radiation energy in two-dimensional space based on distance weights. The calculated corrected radiance value is filled into the corresponding position in an empty matrix with a resolution exactly the same as the reflected light intensity matrix (2448×2048). After traversing all pixels, the fused thermal distribution matrix is output.
[0052] By employing homography transformation and subpixel interpolation, the resulting spatial parallax was corrected. A perspective projection transformation was performed on the processing thermal field data using a pre-calibrated homography matrix, strictly mapping it to the reflected light intensity matrix coordinate system. Simultaneously, combined with bilinear interpolation processing, the jagged effect of low-resolution infrared images during the mapping process was smoothed, ensuring that the temperature field data could be covered on the texture image with subpixel-level accuracy. This enabled the determination of the physical properties of each pixel, effectively overcoming the positioning deviation caused by dynamic refraction parallax and ensuring the geometric accuracy of multispectral fusion.
[0053] Further, based on the workpiece ID, a preset workpiece database is queried to obtain the frictional thermal response coefficient; based on the frictional thermal response coefficient, the region in the fused heat distribution matrix exceeding the preset working condition intensity threshold is determined as the physical tool tip contact area, and a dynamic feature mask is generated; corresponding to step S3 above; see [link to relevant documentation]. Figure 2 The specific implementation process includes:
[0054] The source data packet is parsed to extract the workpiece ID; the workpiece ID is used as an index key to input into the workpiece database, and the corresponding frictional heat response coefficient is retrieved; based on the inverse function of Planck's law, combined with the frictional heat response coefficient, the grayscale data of each pixel in the fused heat distribution matrix is transformed from radiation value to temperature value to generate an absolute temperature matrix of the workpiece surface; a preset working condition intensity threshold is retrieved and compared with the absolute temperature matrix of the workpiece surface; the coordinate set with temperature values higher than the working condition intensity threshold is defined as the thermally effective area, and the coordinate set with temperature values lower than the working condition intensity threshold is defined as the cold background area, generating a binary thermal image; an erosion algorithm is used to remove isolated noise points from the binary thermal image, and an expansion algorithm is used to fill the holes inside the hot spots, outputting the dynamic feature mask.
[0055] Specifically, the source data packet is parsed to extract the workpiece ID. The workpiece ID is then used as an index key to input into the workpiece database, retrieving the corresponding frictional thermal response coefficient. In this embodiment, the source data packet is parsed, the workpiece identification code field in the header is locked, and a string, such as "N-BK7-Prism-Optic04", is read. This string is then used as the primary key index and passed to the query interface of the workpiece database. The workpiece database maintains a relational table that records in detail the thermal radiation physical properties of different optical glass materials in the long-wave infrared band (8 to 14 μm). By executing a standard query, the key physical parameter corresponding to the BK7 optical glass workpiece is retrieved: surface spectral emissivity (in this embodiment, under specific wet grinding conditions, this parameter is calibrated as the equivalent frictional thermal response coefficient considering the effect of cutting fluid attenuation). Optical glass is opaque and has high emissivity in the long-wave infrared range. Based on international standard data and actual measurement calibration, the emissivity of BK7 glass on the processed surface is typically set to 0.92. If the search fails, a default safety factor value of 0.90 will be triggered and an alarm will be triggered to prevent thermal control failure due to missing parameters. This workpiece database is a pre-built lookup table stored in the CNC system controller, which internally establishes an index relationship between different workpiece material IDs and corresponding physical parameters (including frictional thermal response coefficient, refractive index, and standard workpiece thickness parameters).
[0056] Specifically, based on the inverse function of Planck's law and combined with the frictional heat response coefficient, a radiation value to temperature value mapping transformation is performed on the grayscale data of each pixel in the fused heat distribution matrix to generate the absolute temperature matrix of the workpiece surface. In this embodiment, based on the inverse transformation form of Planck's blackbody radiation law, the input is the grayscale value of each pixel in the fused heat distribution matrix (representing thermal radiation intensity), and the output is the absolute temperature matrix of the workpiece surface. The calculation formula is: the absolute temperature equals the second radiation constant divided by the product of the infrared sensor center wavelength and the natural logarithm, where the argument of the natural logarithm is the product of the frictional heat response coefficient multiplied by the first radiation constant divided by the product of the thermal radiation intensity and the fifth power of the wavelength, plus one. The specific parameter settings follow international physical standards: the first radiation constant is set to 3.7427 × 10⁻⁶. 8 W·m -2 ·μm -1 The second radiation constant is set to 14388 μm·K. For optical glass grinding scenarios, the center wavelength parameter of the infrared sensor needs to be set to 10 μm (corresponding to the peak response of a conventional uncooled microbolometer). During the initialization phase, a mapping lookup table with a resolution of 16384 (corresponding to a 14-bit ADC depth) will be pre-calculated based on the above formula. During runtime, the conversion from radiance to temperature is completed directly through array indexing.
[0057] Specifically, in this embodiment, regarding the temperature field calibration and loss function design for optical glass grinding scenarios, a data-driven regression training method is used to determine the equivalent frictional thermal response coefficient (whose physical essence is an equivalent radiation parameter that integrates the material surface emissivity and the liquid film transmittance) to address the physical attenuation effect of the dynamic liquid film formed by the cutting fluid on the infrared radiation signal. The training data acquisition process involves attaching a contact thermocouple to the surface of a BK7 glass sample and simultaneously recording the actual temperature measured by the thermocouple and the radiance value collected by the infrared sensor under simulated conditions of coolant spraying. The optimization goal is to find the optimal effective frictional thermal response coefficient that minimizes the error between the calculated temperature and the actual temperature. The specific loss function is defined as a weighted mean square error function: within the temperature range of interest (e.g., 80°C to 300°C), for each sampling moment, the difference between the infrared calculated temperature obtained from the inversion of the equivalent frictional thermal response coefficient to be optimized and the thermocouple measured temperature is calculated; the square of this difference is calculated and multiplied by the corresponding temperature weighting coefficient; the weighted squared differences of all sampling points are summed and divided by the total number of sampling points to obtain the weighted mean square error value. Solving this value using the gradient descent method, the corrected radiation coefficient (e.g., a corrected 0.88) for the wet grinding scenario is finally determined as the final frictional thermal response coefficient and stored in the workpiece database to compensate for the measurement error caused by the coolant film. The weighting function in the weighted mean square error function adopts a piecewise linear mapping: when the sample temperature is below 100°C, the weight value is constant at 1.0; when the sample temperature is above 100°C, the weight value is equal to the square of the sample temperature divided by 100 (e.g., the weight is 4.0 at 200°C).
[0058] Specifically, a preset working condition intensity threshold is retrieved and compared with the absolute temperature matrix of the workpiece surface. The set of coordinates with temperatures higher than the working condition intensity threshold is defined as the thermally effective zone, and the set of coordinates with temperatures lower than the working condition intensity threshold is defined as the cold background zone, generating a binary thermal image. An erosion algorithm is used to remove isolated noise points from the binary thermal image, and an expansion algorithm is used to fill the voids inside hot spots, outputting the dynamic feature mask. In this embodiment, after obtaining the absolute temperature matrix of the workpiece surface, the preset working condition intensity threshold is retrieved. Considering the low thermal conductivity of optical glass, the cutting heat is highly concentrated at the tool contact point, and localized high temperatures are easily generated, leading to microcracks (flashover). Simultaneously, the background environment temperature is low (approximately 25°C) due to the presence of coolant. Therefore, the working condition intensity threshold is set to 120°C to capture instantaneous grinding hot spots while filtering out splashed warm coolant. The absolute temperature matrix of the workpiece surface is traversed, and a binary logic operation is performed: pixels with a temperature value greater than 120℃ are assigned a logic 1 (hot active area), and those with a temperature value less than 120℃ are assigned a logic 0 (cold background area). Subsequently, a morphological erosion algorithm (3 x 3 cores) is used to remove false noise caused by coolant refraction, and a dilation algorithm (5 x 5 cores) is used to fill the voids formed by wear debris within hot spots, resulting in a 2448×2048 pixel dynamic feature mask with closed contours and smooth edges.
[0059] By parsing the workpiece ID to obtain a specific frictional thermal response coefficient, and applying the inverse function of Planck's law, the original radiation value is inverted into the absolute temperature of the workpiece surface. This allows the threshold determination to be based on a clear physical phase transition temperature. Combined with morphological algorithms for corrosion and expansion, isolated thermal noise points caused by cutting fluid droplet splashing are effectively eliminated, and temperature voids inside the tool tip are filled. This delineates the effective thermal zone of the tool-workpiece contact area. Even in environments with severe optical virtual image interference, a high-contrast feature mask can still be generated, ensuring the uniqueness and authenticity of the trajectory extraction.
[0060] Further, a logical AND operation is performed between the dynamic feature mask and the reflected light intensity matrix to output the monitoring area; Gaussian difference gradient calculation and least squares ellipse fitting are performed on the monitoring area to output the coordinates of the execution end; this corresponds to step S4 above; see [link to relevant documentation]. Figure 3 The specific implementation process includes:
[0061] The process involves: retrieving the dynamic feature mask and the reflected light intensity matrix; performing a bitwise AND operation on the pixel values at corresponding positions to force the reflected light intensity data corresponding to regions with a logical value of zero in the dynamic feature mask to zero, retaining the data for regions with a logical value of 1, and generating a monitoring region; constructing two Gaussian convolution kernels with different scale standard deviations; applying convolution filtering to the monitoring region using the Gaussian convolution kernels to generate two blurred images; constructing a Gaussian difference response map based on the two blurred images; traversing the Gaussian difference response map and extracting the zero-crossing points of the response values as the edge feature point set; constructing an algebraic distance objective function describing the geometric equation of an ellipse; substituting the coordinate data of the edge feature point set into the algebraic distance objective function to obtain an overdetermined linear equation system; solving the least squares solution of the overdetermined linear equation system using singular value decomposition to determine the geometric parameters of the fitted ellipse; and extracting the geometric floating-point coordinates of the center of the fitted ellipse as the coordinates of the execution endpoint.
[0062] Specifically, the dynamic feature mask and the reflected light intensity matrix are retrieved; a bitwise AND operation is performed on the pixel values at the corresponding positions, forcing the reflected light intensity data corresponding to the regions with a logic value of zero in the dynamic feature mask to zero, retaining the data of the regions with a logic value of 1, and generating a monitoring area. In this embodiment, the dynamic feature mask and the reflected light intensity matrix are received. For the precision grinding process of optical glass (such as BK7), where the processing area is often covered by a high-pressure cutting fluid atomization layer and splashed glass micropowder, a pixel-by-pixel bitwise AND operation is first performed on two matrices, each with a resolution of 2448×2048 pixels. The operation rule is defined as follows: traverse each pixel in the image coordinate system. If the logical value of that position in the dynamic feature mask is 0, it indicates that the area is a cold background or non-processed area affected by coolant interference, and the gray value of the corresponding position in the reflected light intensity matrix is forced to be zero. If the logical value of that position in the mask is 1, it indicates that the area is an effective grinding heat zone with a temperature exceeding 120 degrees Celsius, and the original 8-bit gray value in the reflected light intensity matrix is retained. Finally, the output is a monitoring area matrix that only contains the texture details of the tool grinding contact area.
[0063] In this embodiment, a spatiotemporal phase consistency check is performed on candidate hotspots within the monitoring area. The geometric similarity between the motion vectors of feature points across consecutive frames and the feed commands of the CNC system is analyzed to eliminate nonlinear phantoms caused by internal reflection. Internal reflection phantoms in optical glass often exhibit rapid nonlinear drift with the movement of the main axis and fine-tuning of the viewing angle, while the motion trajectory of the actual tool tip hotspot must strictly conform to the displacement commands of the CNC system. This embodiment introduces a phantom identification filtering mechanism: after outputting the monitoring area data, instead of direct fitting, a sliding window feature sequence of preset length is maintained. The optical flow algorithm is used to calculate the instantaneous visual motion vector of the feature point group within the area, while simultaneously extracting the theoretical interpolation vector from the CNC system. A consistency scoring function is constructed, and the specific calculation rules of the consistency scoring function are as follows: First, calculate the cosine of the angle between the visual motion vector and the theoretical interpolation vector, and multiply it by a first weighting coefficient to obtain the directional consistency component; Second, calculate the magnitude of the visual motion vector and the magnitude of the theoretical interpolation vector, and define the absolute value of the difference between the two as the linear velocity magnitude deviation value; Third, multiply the linear velocity magnitude deviation value by a preset attenuation factor and take the negative number, use the natural constant e as the base and the negative number as the exponent to calculate the exponential function value, and then multiply the exponential function value by a second weighting coefficient to obtain the velocity consistency component; Fourth, the final consistency score is equal to the sum of the directional consistency component and the velocity consistency component. In this embodiment, the first weighting coefficient is set to 0.7, and the second weighting coefficient is set to 0.3. The attenuation factor is set to 2.0, and the weighting coefficients are pre-constructed historical sample datasets containing real knife tip trajectories and internal reflection phantom trajectories. The first weighting coefficient is used as the independent variable, and iterative steps are performed in the range of zero to one, while the second weighting coefficient is equal to one minus the first weighting coefficient. For each weight combination, the scores of all targets in the sample set are calculated, and the inter-class variance of the positive and negative sample score distribution is calculated using the Otsu method. Finally, the first weight coefficient that maximizes the inter-class variance is selected as the optimal solution. The motion vector of the real tool tip and the machine tool feed vector exhibit extremely high autocorrelation in direction and velocity, and their consistency score is usually higher than the preset high confidence threshold (e.g., 0.85). However, due to the nonlinear characteristics of light path refraction, the apparent motion speed of the phantom generated by internal reflection often appears to lead or lag behind the actual feed, and there is a slight deviation in the motion direction. By performing dynamic threshold judgment, low-scoring pseudo-feature points are forcibly removed, retaining only the true hot spots that conform to the machine tool kinematic constraints. This verification process utilizes the strong constraint characteristics of mechanical motion, logically shielding the control closed loop from the misleading influence of optical interference signals, achieving stable locking of the real physical trajectory, and improving the anti-interference capability of trajectory positioning in complex lighting environments.
[0064] Specifically, two Gaussian convolution kernels with different scale standard deviations are constructed. These kernels are then used to perform convolution filtering on the monitored area, generating two blurred images. Based on these two blurred images, a Gaussian difference response map is constructed. The Gaussian difference response map is traversed, and zero-crossing points of the response values are extracted as edge feature point sets. In this embodiment, two two-dimensional Gaussian convolution kernels with different scale standard deviations are first constructed. Based on the Malcolm-Hilderasse edge detection theory, the scale standard deviation of the first Gaussian convolution kernel is set to 1.0 pixels to capture fine edges; the scale standard deviation of the second Gaussian convolution kernel is set to 1.6 pixels to smooth noise. These two Gaussian convolution kernels are used to perform spatial convolution filtering on the monitored area, truncating it into 7×7 and 11×11 matrices respectively, generating two blurred images with different degrees of blur. Subsequently, a matrix subtraction operation is performed, subtracting the second blurred image from the first blurred image to obtain the Gaussian difference response map. In the Gaussian difference response map, edge locations where grayscale values change drastically are represented by zero-crossing points with alternating positive and negative values. Traverse the Gaussian difference response map to find the neighborhood where the pixel value sign is flipped, and calculate the floating-point coordinates of the response value to zero using bilinear interpolation. These zero-crossing points constitute the edge feature point set.
[0065] Specifically, an algebraic distance objective function describing the geometric equation of an ellipse is constructed; the coordinate data of the edge feature point set are substituted into the algebraic distance objective function to obtain an overdetermined linear equation system; the least squares solution of the overdetermined linear equation system is solved using singular value decomposition to determine the geometric parameters of the fitted ellipse; the geometric floating-point coordinates of the center of the fitted ellipse are extracted as the coordinates of the execution end point. In this embodiment, under high-speed rotation (e.g., 20,000 revolutions per minute) and grinding force, the projection of its end face onto the camera imaging plane is approximately an ellipse. To obtain robust center coordinates from a discrete set of edge feature points that may have local occlusion, a direct least squares fitting algorithm based on algebraic distance is used to construct an algebraic distance objective function. The edge feature point set is received, and the coefficient vector a of the general equation of the ellipse is first solved. The general equation of the ellipse is described as: coefficient A multiplied by the square of the abscissa, plus coefficient B multiplied by the product of the abscissa and ordinate, plus coefficient C multiplied by the square of the ordinate, plus coefficient D multiplied by the abscissa, plus coefficient E multiplied by the ordinate, plus coefficient F equal to zero. In constructing the algebraic distance objective function, the coordinates of all feature points are first substituted into the equation to construct the design matrix D, and then the scatter matrix is calculated. To force the fitted result to be an ellipse, constraints are introduced. This constraint is expressed in matrix form. The constraint matrix C is a 6×6 matrix, with elements of 2 only at positions (1,3) and (3,1), and -1 at position (2,2), with the rest being 0. The mathematical solution is transformed into a generalized eigenvalue problem. ,in Represents the generalized eigenvalues, where the coefficient vector is... Defined as This ultimately forms an overdetermined system of linear equations. The singular value decomposition method is used to solve this system, and the eigenvector corresponding to the unique positive eigenvalue is selected as the optimal solution 'a'. Finally, the geometric floating-point coordinates of the center are calculated based on the solved coefficients: the x-coordinate of the end point is then calculated. Execute the end ordinate This coordinate is the coordinate of the execution end.
[0066] By combining the difference of Gaussians (DG) and least-squares elliptic fitting algorithms, end-effector localization was achieved under strong noise conditions. The DoG operator, as a bandpass filter, further suppressed high-frequency electronic noise and low-frequency illumination unevenness, enhancing the gradient characteristics of the tool tip edge. Subsequently, singular value decomposition was used to solve the overdetermined linear equations, and elliptic fitting was performed on the edge point set to reconstruct the unique geometric center of the tool tip from partially occluded or optically distorted incomplete contours. This improved visual positioning accuracy to the sub-pixel level, ensuring that even with minute optical perturbations, accurate physical machining trajectory coordinates could still be obtained.
[0067] Further, the current tool axis depth data is read, and the end-effector coordinates are inversely transformed into tool tip feedback coordinates using pre-stored sensor calibration parameters; this corresponds to step S5 above; the specific implementation process includes:
[0068] The system reads the current tool axis depth value fed back by the encoder of the CNC system; retrieves the sensor calibration parameters including the intrinsic parameter matrix, distortion coefficient, and hand-eye transformation matrix; performs a distortion correction operation on the execution end coordinates using the distortion coefficient to eliminate radial and tangential nonlinear errors, obtaining distorted coordinates; performs a linear transformation on the distorted coordinates using the inverse matrix of the intrinsic parameter matrix to obtain a unit line-of-sight vector; performs a scalar multiplication between the unit line-of-sight vector and the tool axis depth value to reconstruct the three-dimensional spatial coordinates; performs a rotational and translational rigid body transformation on the three-dimensional spatial coordinates using the hand-eye transformation matrix, and outputs the tool tip feedback coordinates in the workpiece coordinate system.
[0069] Specifically, the current tool axis depth value fed back by the CNC system encoder is read. In this embodiment, the absolute mechanical coordinates of the spindle Z-axis are polled via an industrial fieldbus. At the same moment the pixel position of the execution end (i.e., the tool tip hotspot) in the image coordinate system is obtained, a position latching command is triggered. The pulse count value fed back by the servo motor encoder is read and converted into a double-precision floating-point physical depth value (e.g., -120.500mm) based on the leadscrew pitch (e.g., 10mm) and encoder resolution. To eliminate asynchronous errors caused by communication delays, a timestamp interpolation algorithm is used. Linear interpolation is performed based on the position data at the image acquisition trigger moment and the two preceding and following servo cycles to calculate the tool axis depth value that strictly corresponds to the exposure instant.
[0070] Specifically, the sensor calibration parameters, including the intrinsic parameter matrix, distortion coefficients, and hand-eye transformation matrix, are retrieved. In this embodiment, a calibration file is loaded during the initialization phase. This file contains the intrinsic parameter matrix, distortion coefficients, and hand-eye transformation matrix. The intrinsic parameter matrix is a 3x3 matrix describing the camera's focal length and optical center, in pixels. For example, the focal length might be 3500.5 pixels, and the principal point coordinates might be 1224.0 and 1024.5. The distortion coefficients include radial distortion parameters (k1, k2, k3) and tangential distortion parameters (p1, p2), used to mathematically describe the pincushion or barrel geometry distortion of the lens caused by the manufacturing process. The hand-eye transformation matrix is a 4x4 homogeneous transformation matrix describing the rigid body pose relationship of the camera coordinate system relative to the tool center point or spindle flange. The sensor calibration parameters are obtained using the Zhang Zhengyou calibration method, and their accuracy directly determines the reliability of the final measurement results.
[0071] Specifically, the distortion coefficients are used to perform distortion correction on the coordinates of the execution end, eliminating radial and tangential nonlinear errors to obtain distorted coordinates. In this embodiment, the pixel coordinates are first converted into normalized image plane coordinates, and then the Brown-Conrady model is applied for inverse correction. The specific formula for distortion correction is described as follows: the distorted abscissa equals the original abscissa multiplied by the radial distortion factor plus the tangential distortion correction term. The radial distortion factor equals 1 plus k1 multiplied by the square of the radius plus k2 multiplied by the fourth power of the radius plus k3 multiplied by the sixth power of the radius; the tangential distortion correction term involves coupling terms of p1 and p2 with the coordinate product. Newton's iteration method is typically used for fast lookup and interpolation, ultimately outputting distorted coordinates after eliminating optical errors, ensuring that the point mapping conforms to the ideal pinhole imaging model.
[0072] Specifically, the distortion-free coordinates are linearly transformed using the inverse of the intrinsic parameter matrix to obtain a unit line-of-sight vector. This unit line-of-sight vector is then multiplied by the tool axis depth value to reconstruct the three-dimensional spatial coordinates. In this embodiment, the inverse of the intrinsic parameter matrix is used to perform matrix multiplication on the distortion-free coordinates to obtain the unit line-of-sight vector (i.e., the component of this vector in the depth axis direction is normalized to 1). This vector physically represents the directional ray originating from the camera's optical center and pointing towards the physical point at the tool tip. Subsequently, combined with the read tool axis depth value, a scalar multiplication operation is performed based on the principle of similar triangles. The calculation formula is: the three-dimensional coordinates in the camera coordinate system equal the tool axis depth value multiplied by the unit line-of-sight vector. For example, if the normalized coordinates are (0.1, 0.05, 1) and the depth is 100mm, then the reconstructed coordinates are (10, 5, 100)mm. This process assumes that the tool tip hotspot is located on a physical machining depth plane perpendicular to the spindle axis.
[0073] Specifically, the hand-eye transformation matrix is used to perform a rotational-translational rigid body transformation on the three-dimensional spatial coordinates, outputting the tool tip feedback coordinates in the workpiece coordinate system. In this embodiment, a pre-stored hand-eye transformation matrix is used to perform a rotational-translational rigid body transformation on the point in the camera coordinate system. The specific calculation process is as follows: extract the 3x3 rotation submatrix and the 3x1 translation subvector from the hand-eye transformation matrix. The transformation formula is described as: the target coordinate vector equals the rotation submatrix (3x3) multiplied by the point in the camera coordinate system plus the translation subvector (3x1). This transformation compensates for the offset of the camera mounting position relative to the spindle center (e.g., the camera is mounted 50mm to the side of the spindle) and the slight tilt of the mounting angle. The final output is the actual physical feedback coordinates of the tool tip in the workpiece coordinate system. For example, the calculation result may show the tool tip feedback coordinates as (100.015, 50.005, -10.000) mm.
[0074] By constructing a complete spatial inverse transformation link, the influence of imaging distortion and depth uncertainty on trajectory positioning is eliminated. Distortion coefficients are used for correction to restore the true image geometry. Furthermore, by introducing tool axis depth data as a scale constraint, the unit line-of-sight vector on the two-dimensional image is reconstructed into three-dimensional spatial coordinates. A hand-eye transformation matrix is then used to unify these coordinates to the workpiece coordinate system, ensuring that the feedback coordinates are not merely a point on the image, but a three-dimensional coordinate point with clear physical meaning. This eliminates the spatial definition error between visual measurement and mechanical motion.
[0075] Further, the current interpolation command coordinates are read, the difference vector between the current coordinates and the tool tip feedback coordinates is calculated, and the feed axis motor is driven to perform displacement compensation via the servo adder register; this corresponds to step S6 above; the specific implementation process includes:
[0076] Within the current servo control cycle, the theoretical interpolation command coordinate data and the original interpolation pulse generated by the interpolator are locked and extracted; the tool tip feedback coordinates are called as a non-contact external feedback signal; the position deviation vector between the theoretical interpolation command coordinates and the tool tip feedback coordinates is calculated through three-dimensional spatial vector subtraction; the position deviation vector is decomposed into independent scalar error components corresponding to each feed axis using the machine tool inverse kinematics formula; each of the independent scalar error components is written into the position loop controller; when the position loop controller performs position closed-loop calculation, it digitally superimposes the independent scalar error components with the original interpolation pulse to generate a composite motion command containing dynamic correction, which is converted into a pulse width modulation voltage by the servo driver to excite the feed axis servo motor for displacement compensation.
[0077] Specifically, within the current servo control cycle, the theoretical interpolation command coordinate data and raw interpolation pulses generated by the interpolator are locked and extracted. In this embodiment, the interrupt period is set to 1 millisecond. At the beginning of each cycle, within a microsecond-level time slot, the theoretical interpolation command coordinate data for the current moment is locked by accessing the interpolator's shared memory address (e.g., memory offsets 0x0040 to 0x0060). This data is the ideal tooltip trajectory point generated by the G-code interpreter after velocity look-ahead and acceleration / deceleration planning. For example, at a certain moment, the theoretical coordinates are (120.500mm, -45.200mm, 10.100mm). Simultaneously, the corresponding raw interpolation pulses are extracted. These are pure commands without any compensation added to the position loop, representing the theoretical number of pulses each axis should move within the cycle. For example, if the system pulse equivalent is 0.1 micrometers and the X-axis feed component in the current cycle is 0.01mm, then the raw interpolation pulses are 100 units. The input for this step is the register state at the bottom layer of the CNC system, and the output is a digital instruction that is strictly aligned with physical time, ensuring the uniqueness and real-time performance of the subsequent comparison benchmark.
[0078] Specifically, the tool tip feedback coordinates are used as a non-contact external feedback signal. The position deviation vector between the theoretical interpolation command coordinates and the tool tip feedback coordinates is calculated using a three-dimensional spatial vector subtraction operation. In this embodiment, the tool tip feedback coordinates are used as the non-contact external feedback signal. This signal is based on the real physical position reconstructed by machine vision in the workpiece coordinate system, for example (120.512mm, -45.205mm, 10.098mm), recording the absolute timestamp of the visual image acquisition. When calculating the deviation, the historical interpolation command coordinates strictly corresponding to this timestamp are extracted by querying the historical position buffer of the CNC system and used as the theoretical interpolation command coordinates for calculation. A Kalman filter is used to perform a three-dimensional spatial vector subtraction operation to predict the estimated deviation at the current moment: the position deviation vector equals the theoretical interpolation command coordinates minus the tool tip feedback coordinates. In this embodiment, the X-axis deviation component equals 120.500 minus 120.512, which equals -0.012 mm; the Y-axis deviation component equals -45.200 minus -45.205, which equals +0.005 mm; and the Z-axis deviation component equals 10.100 minus 10.098, which equals +0.002 mm. This positional deviation vector characterizes the combined spatial error caused by thermal deformation, tool deflection, or mechanical transmission clearance.
[0079] Specifically, the position deviation vector is decomposed into independent scalar error components corresponding to each feed axis using the machine tool inverse kinematics formula. In this embodiment, since the tool tip spatial error is usually defined in the Cartesian workpiece coordinate system, and the actuator is the servo motor of each joint axis (feed axis), coordinate system mapping is necessary. For a standard three-axis orthogonal engraving machine, the inverse kinematics formula is relatively linear, meaning that the independent scalar error components of each axis directly correspond to the Cartesian deviation components. However, for a five-axis linkage engraving machine, the inverse kinematics formula must introduce the inverse Jacobian matrix containing the angle parameters of the rotation axes (A-axis, C-axis) for decoupling. The algorithm input is the aforementioned position deviation vector and the current encoder positions of each axis of the machine tool. Using pre-stored kinematic chain parameters (such as a swing length of 150mm and an offset of 20mm), the spatial error is projected onto the motion direction of each physical axis. Taking the X-axis as an example, the additional reverse feed distance required by the X-axis motor to compensate for a spatial error of -0.012mm is calculated. Subsequently, using the pulse equivalent parameters of each axis (e.g., 10,000 pulses per revolution, 5mm lead screw pitch, i.e., 0.5 micrometers / pulse), the distance error is converted into a pulse count error. For example, -0.012mm corresponds to -24 pulses. This step outputs an independent scalar error component (in pulses) for each feed axis.
[0080] Specifically, each of the independent scalar error components is written into the position loop controller. When performing position closed-loop calculations, the position loop controller digitally superimposes the independent scalar error components with the original interpolation pulses to generate a composite motion command containing dynamic corrections. In this embodiment, before the control window of the current servo cycle closes via a high-speed fieldbus (such as EtherCAT), the calculated independent scalar error components for each axis (e.g., the negative 24 pulses of the X-axis) are written into the corresponding compensation register (e.g., address Offset_Reg_X). A dual-rate control strategy is adopted: the vision acquisition and calculation unit updates the position deviation vector at a frequency of thirty frames per second, while the servo control position loop reads the latest deviation value from the shared memory at a frequency of 1000Hz. During the servo cycle between two vision frames, the controller uses a zero-order hold or linear extrapolation strategy to maintain the current compensation amount. When performing position closed-loop calculations, the internal logic of the position loop controller not only compares the command position with the encoder feedback position but also reads the value of the compensation register in parallel. The digital superposition follows the formula: the composite motion command pulse equals the original interpolation pulse plus the independent scalar error components. In the example, if the original interpolation pulse is positive 100 and the error component is negative 24, then the final composite command issued will be 76 pulses.
[0081] Specifically, the motion is converted into pulse-width modulation (PWM) voltage by a servo driver to excite the feed axis servo motor for displacement compensation. In this embodiment, the composite motion command output from the position loop is first processed by velocity feedforward and acceleration limiting, and then sent to the current loop of the servo driver. The inverter circuit inside the driver calculates the required three-phase current vector according to the command, and uses space vector pulse width modulation (SVM) technology to convert the digital command into a PWM voltage applied to the stator coil of the motor. The duty cycle and frequency of the voltage directly determine the magnitude and direction of the current flowing through the coil, thereby generating electromagnetic torque. Taking the X-axis as an example, after receiving the drive voltage corresponding to the corrected 76 pulses, the servo motor rotates the rotor by a corresponding small angle, driving the worktable to move by 0.038mm via the ball screw. This series of physical actions ultimately achieves displacement compensation for the tool tip trajectory, ensuring that the surface accuracy of the machined optical glass workpiece strictly meets the design requirements.
[0082] By calculating the position deviation vector between the interpolation command and visual feedback, and then decoupling through machine tool inverse kinematics, the deviation is converted into independent scalar error components for each axis, which are then superimposed onto the original interpolation pulse in the position loop controller. This control strategy, combining feedforward and feedback, counteracts trajectory drift caused by machine tool thermal expansion, tool deflection, and mechanical transmission backlash, automatically corrects the machining path, ensures that the final workpiece dimensions are highly consistent with the design model, and reduces the scrap rate.
[0083] This invention provides a machine vision-based method for controlling the machining trajectory of a CNC engraving machine. During high-speed machining, the internal reflection of the observation window often creates a false tool phantom, and dynamic refraction parallax interferes with visual positioning. This invention utilizes a "thermal-optical" dual-modal fusion mechanism, leveraging the physical characteristic of high temperatures generated by the cutting edge, and calculates the radiation distribution by querying the workpiece's specific frictional thermal response coefficient. A dynamic feature mask is generated, filtering out cold background reflections, glass phantoms, and cutting fluid splash noise that lack cutting thermal characteristics, retaining only the true physical tool tip contact area. By performing a logical AND operation between the thermal mask and the reflected light intensity matrix, a high-confidence monitoring area is constructed, distinguishing the true physical machining trajectory from the optical phantom. This ensures the anti-interference capability and robustness of trajectory recognition under complex lighting conditions, improving machining accuracy. Example
[0084] This embodiment focuses on using a machine vision-based engraving machine trajectory control method to lock and control the actual physical tool tip trajectory. Taking the grinding of an optical glass prism as an example, this material has extremely high transmittance in the visible light band (refractive index of approximately 1.5168), and the wet cutting fluid film on the surface during grinding forms a complex microlens effect. When the vision acquisition unit is aimed at the high-speed rotating diamond grinding rod (spindle speed set at 24,000 rpm) for imaging, due to the combined effects of total internal reflection within the glass and refraction by the cutting fluid, multiple high-brightness pseudo-tool tip feature points often appear in the original reflected light intensity matrix. For example, at a certain sampling moment, the vision system simultaneously detects three high-grayscale suspected target areas in an image with a resolution of 2448 x 2048: the actual grinding contact point A, the virtual image B formed by reflection from within the glass, and the highlight point C formed by mirror reflection from the liquid film. After receiving the operation instruction containing material ID information, visible light and infrared spectral data are simultaneously acquired through hard triggering. The workpiece database was analyzed to retrieve the frictional thermal response coefficient of N-BK7 glass in the 8-14 micrometer long-wave infrared band. Although the glass is transparent under visible light, it appears opaque in the long-wave infrared band and has a high surface emissivity (set to 0.92). The generated fused thermal distribution matrix reveals a physical reality quite different from the visible light image: the real grinding point A experiences instantaneous grinding flash due to the high-frequency, intense friction between the diamond abrasive grains and the glass substrate; calculated using the inverse function of Planck's law, its local temperature reading reaches as high as 420.5 degrees Celsius. Meanwhile, the coordinates of the virtual image B, although extremely bright under visible light, only reflect the background temperature of the glass surface after being covered by coolant, approximately 26.8 degrees Celsius. Similarly, the temperature of the liquid film highlight point C is only 28.2 degrees Celsius.
[0085] Based on temperature differences, the working condition intensity threshold is set to 150 degrees Celsius. This threshold is higher than the ambient temperature but lower than the softening point of the glass, effectively distinguishing processing hotspots from cold background areas. By comparing the registered temperature matrix with this threshold, a dynamic feature mask containing only region A is generated. A logical AND operation is performed, and this mask is overlaid on the original visible light reflection intensity matrix. The pixel grayscale values of coordinate regions B and C are cleared to zero, outputting an image of the monitoring area that retains only the true blade tip texture. Based on the monitoring area image, Gaussian difference gradient calculation is performed on region A, selecting a larger-scale second Gaussian kernel (standard deviation ratio of 1.6) to enhance the smoothing effect. After edge feature extraction, it is substituted into a constrained least squares elliptic fitting model, and the center coordinates of the execution end are calculated to be (1240.52, 1020.24).
[0086] The tool axis depth feedback value (e.g., -15.005 mm) of the current servo cycle is read and combined with the sensor calibration parameters for inverse projection transformation to reconstruct the true physical position of the tool tip in the workpiece coordinate system as (50.012, 30.005, -15.005) mm. This is compared with the theoretical interpolation command coordinates (50.000, 30.000, -15.000) mm, revealing a positive 12 micrometer deviation in the X-axis and a positive 5 micrometer deviation in the Y-axis. The corresponding independent scalar error components for each axis are calculated, with the X-axis requiring compensation of -120 pulses and the Y-axis requiring compensation of -50 pulses. These values are written to the servo adder register of the position loop controller via the high-speed PMC interface. The servo driver superimposes this compensation pulse in the next control cycle (within 1 millisecond) to drive the linear motor to make minor trajectory corrections. The experimental results show that after enabling the dual-light fusion anti-spoofing control, the contour error of the N-BK7 prism decreased from ±0.02mm to ±0.003mm.
[0087] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A machine vision-based control method for machining trajectory of a fine carving machine, characterized in that, The application relates to a method for monitoring the contact between a tool tip and a workpiece during machining. The method comprises the following steps: Receiving a work task instruction containing a workpiece ID issued by a numerical control system, triggering a visual acquisition unit to collect a reflection light intensity matrix, triggering an infrared sensor to collect machining thermal field data, and generating a source data packet containing the workpiece ID; Using a preset homography matrix to map the machining thermal field data into the reflection light intensity matrix to obtain a fusion thermal distribution matrix; According to the workpiece ID, querying a preset workpiece database to obtain a friction heat response coefficient; based on the friction heat response coefficient, determining a region exceeding a preset working condition intensity threshold in the fusion thermal distribution matrix as a physical tool tip contact area, and generating a dynamic feature mask; Performing a logical AND operation on the dynamic feature mask and the reflection light intensity matrix to output a monitoring area; Performing edge gradient analysis and least square ellipse fitting on the monitoring area to output an execution end coordinate; 2.The machine vision-based fine carving machine machining track control method according to claim 1, characterized in that, Reading current tool shaft depth data, inversely transforming the execution end coordinate into a tool tip feedback coordinate through pre-stored sensor calibration parameters, reading current interpolation instruction coordinates, calculating a difference vector of the tool tip feedback coordinate, and driving a feed shaft motor to perform displacement compensation through a servo adder register. The specific generation process of the source data packet comprises the following steps: 3.The machine vision-based fine carving machine machining track control method according to claim 1, characterized in that, Receiving a work task instruction issued by a numerical control system, extracting a workpiece ID by using a protocol parser; sending a rising edge trigger pulse to a visual acquisition unit and an infrared sensor in parallel; in response to the trigger pulse, the visual acquisition unit collects a reflection light intensity matrix and writes the reflection light intensity matrix into a first direct memory access cache area, and the infrared sensor collects machining thermal field data and writes the machining thermal field data into a second direct memory access cache area; traversing the first direct memory access cache area and the second direct memory access cache area, locking matrix pair data with a time stamp difference less than a preset clock cycle tolerance; performing a data splicing operation to encapsulate the locked reflection light intensity matrix, the machining thermal field data and the workpiece ID into the source data packet. The specific generation process of the fusion thermal distribution matrix comprises the following steps:
4. The machine vision-based fine carving machine machining track control method according to claim 1, characterized in that, Analyzing the source data packet to separate the machining thermal field data; calling a pre-calibrated homography transformation matrix, performing matrix multiplication and perspective division operation on the original row and column coordinate vectors of each element in the machining thermal field data to solve the target floating point coordinates mapped in the reflection light intensity matrix coordinate system; reading the grid values adjacent to the target floating point coordinates in the machining thermal field data, performing bilinear interpolation processing to calculate the corrected radiation value; filling the corrected radiation value into an empty matrix with the same resolution as the reflection light intensity matrix according to the integer part of the target floating point coordinates, and outputting the fusion thermal distribution matrix. The specific construction process of the dynamic feature mask comprises the following steps: The source data packet is parsed, and the workpiece ID is extracted; the workpiece ID is input as an index key into a workpiece database to call the corresponding friction heat response coefficient; based on an inverse function of Planck's law, the friction heat response coefficient is combined to perform mapping and transformation of each pixel gray data of the fusion heat distribution matrix from radiation value to temperature value, to generate a workpiece surface absolute temperature matrix; a preset working condition intensity threshold is called and compared with the workpiece surface absolute temperature matrix, a coordinate set with a temperature value higher than the working condition intensity threshold is defined as a thermal active area, and a coordinate set with a temperature value lower than the working condition intensity threshold is defined as a cold background area, to generate a binary thermal image; isolated noise points of the binary thermal image are removed by using an erosion algorithm, and internal cavities of hot spots are filled by using a dilation algorithm, and the dynamic feature mask is output.
5. The machine vision-based fine carving machine machining track control method according to claim 1, characterized in that, The specific generation process of the execution end coordinates includes: The dynamic feature mask and the reflected light intensity matrix are called; bitwise AND logic operation is performed on pixel values of corresponding positions, reflected light intensity data corresponding to a region with a logic value of 0 in the dynamic feature mask is forced to be 0, and region data with a logic value of 1 is retained, to generate a monitoring area; two Gaussian convolution kernels with different scale standard deviations are constructed; the Gaussian convolution kernels are used to perform convolution filtering on the monitoring area respectively, to generate two blurred images; based on the two blurred images, a Gaussian difference response graph is constructed; the Gaussian difference response graph is traversed, and a zero-crossing point of a response value is extracted as an edge feature point set; an algebraic distance target function describing an ellipse geometric equation is constructed; coordinate data of the edge feature point set is substituted into the algebraic distance target function, to obtain an over-determined linear equation set; a least square solution of the over-determined linear equation set is solved by using a singular value decomposition method, to determine geometric parameters of a fitted ellipse; a floating point coordinate of a center of the fitted ellipse is extracted as the execution end coordinates.
6. The machine vision-based machining trajectory control method for a fine engraving machine according to claim 1, wherein, The specific generation process of the tool tip feedback coordinates includes: A current tool shaft depth value fed back by an encoder of a numerical control system is read; sensor calibration parameters including an intrinsic matrix, a distortion coefficient and a hand-eye transformation matrix are called; a de-distortion operation is performed on the execution end coordinates by using the distortion coefficient, to eliminate radial and tangential nonlinear errors, to obtain de-distortion coordinates; the de-distortion coordinates are linearly transformed by using an inverse matrix of the intrinsic matrix, to obtain a unit view line vector; scalar multiplication is performed on the unit view line vector and the tool shaft depth value, to reconstruct three-dimensional space coordinates; a rotation and translation rigid body transformation is performed on the three-dimensional space coordinates by using the hand-eye transformation matrix, to output the tool tip feedback coordinates in a workpiece coordinate system.
7. The machine vision-based machining trajectory control method for a fine engraving machine according to claim 1, wherein, The specific process in which the driving feed shaft motor performs displacement compensation includes: Lock and extract the interpolation command coordinate data and original interpolation pulse generated by the interpolator in the current servo control cycle; call the tool tip feedback coordinate as a non-contact external feedback signal; calculate the position deviation vector between the theoretical interpolation command coordinate and the tool tip feedback coordinate through three-dimensional space vector subtraction operation; decompose the position deviation vector into independent scalar error components corresponding to each feed axis by using the inverse kinematics formula of the machine tool; write each independent scalar error component into the position loop controller; when performing position closed loop operation, the position loop controller digitally superimposes the independent scalar error components and the original interpolation pulse to generate a composite motion command containing dynamic correction, which is converted into a width-modulated pulse voltage by the servo driver to excite the feed shaft servo motor for displacement compensation.
Citation Information
Patent Citations
Glass single-side processing detection method, system and terminal
CN119444746A
Cutter cutting path machining error compensation method based on online monitoring
CN120044877A