Workpiece defect detection system and method based on image recognition

By mapping image grayscale data to a gradient potential field and introducing virtual hydrodynamic evolution, combined with feedback optimization and few-sample calibration, the problem of low signal-to-noise ratio in the detection of weak defects on complex textured surfaces is solved, achieving efficient and flexible defect detection.

CN121707983APending Publication Date: 2026-03-20DONGYING JIASHENG NEW MATERIALS CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511923307.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-19
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing technologies have low signal-to-noise ratios in detecting weak defects on complex textured surfaces, making it difficult to effectively separate background textures from weak defects. Furthermore, deep learning methods rely on training with a large number of samples, which is difficult to obtain in precision manufacturing scenarios.

Method used

By mapping image grayscale data to a gradient potential energy field, a virtual fluid is introduced for dynamic evolution. Defects are identified by calculating the divergence of the flow field disturbance, and the system parameters are dynamically adjusted by combining a feedback optimization mechanism. A few-sample calibration method and hardware acceleration technology are employed.

Benefits of technology

It significantly improves the detection capability of weak defects in complex backgrounds, reduces the false negative rate, adapts to the consistency of inspection standards for different batches of workpieces, and takes into account the needs of rapid deployment and real-time detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121707983A_ABST
    Figure CN121707983A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of machine vision and industrial automatic detection, in particular to a workpiece defect detection system and method based on image recognition. An image mapping module, a flow field initialization module, a dynamic evolution module, a divergence identification module and a feedback optimization module are included; the system maps the gray scale into a terrain gradient potential energy field, and establishes a virtual flow field conforming to the texture; the core of the method is that dynamic evolution is carried out based on a Navier-Stokes equation, defects are converted into physical obstacles inducing flow field disturbance, and a defect area is judged according to divergence values; dynamically adjusting an evolution parameter according to the verification signal; according to the method, conversion from pixel statistics to physical simulation is realized, and the problem that weak defects are difficult to extract under a complex background is solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of machine vision and industrial automation detection, in particular to a workpiece defect detection system and method based on image recognition. BACKGROUND

[0002] In the field of machine vision industrial detection, the detection of weak defects on complex texture surfaces has always been a technical difficulty. Traditional detection algorithms mainly rely on pixel gray statistical characteristics or texture filtering methods based on frequency domain. However, when the workpiece surface itself has complex random texture or periodic pattern, the gray level change caused by tiny scratches or pits is often submerged in strong background texture noise, resulting in extremely low signal-to-noise ratio. Although existing deep learning methods have good detection effect, they are heavily dependent on massive defect samples for training, and it is extremely difficult to obtain a large number of defect samples in the precision manufacturing scene. Therefore, there is an urgent need for a detection technology that does not rely on massive sample training and can effectively separate background texture and weak defects from the physical mechanism. SUMMARY

[0003] To solve the above technical problems, the present application provides a workpiece defect detection system and method based on image recognition. Specifically, the technical solution of the present application is as follows: A workpiece defect detection system based on image recognition, the system comprising an image acquisition device, a memory and a processor, the processor executing a computer program stored in the memory to realize the following steps: Image acquisition mapping step: obtaining the original image of the workpiece surface to be detected through the image acquisition device, converting it into a single-channel gray data matrix, mapping the gray value of each pixel in the matrix to a terrain height value, and calculating the gradient vector of the terrain height value in two-dimensional space to generate gradient potential field data containing a resistance coefficient; Flow field initialization step: calculating the texture direction of the gray data matrix to obtain a main texture direction vector, and establishing an initial virtual laminar flow field with the same size as the gray data matrix, setting the initial velocity vector of each grid point in the initial virtual laminar flow field to be parallel to the main texture direction vector; Evolution calculation step: inputting the initial virtual laminar flow field as input data into the discrete solver of the nonlinear convection-diffusion evolution equation ignoring the pressure gradient term, and executing a preset number of time step iteration calculations under the resistance action of the gradient potential field data, outputting a flow field disturbance data matrix containing velocity vector variation; Defect identification steps: Calculate the divergence value of each coordinate point in the flow field disturbance data matrix to generate a divergence distribution map; compare the divergence value with a preset defect judgment threshold: if the divergence value is greater than the defect judgment threshold, the coordinate point is determined to be a defect area and an alarm signal is output; if the divergence value is less than or equal to the defect judgment threshold, the coordinate point is determined to be a background area and a normal signal is output. Feedback optimization steps: Receive external input verification signals. If the verification signal indicates a missed detection, increase the number of iterations of the evolution calculation step. If the verification signal indicates a false alarm, decrease the force intensity coefficient α of the gradient potential energy field data.

[0004] Preferably, the image acquisition and mapping step specifically includes: Grayscale conversion sub-step: Convert the acquired RGB image into a single-channel grayscale data matrix using a weighted average method; Potential energy modeling sub-steps: Define the potential energy function ,in equal to pixel coordinates The gray value at that point is multiplied by the preset potential energy conversion coefficient. ;calculate exist shaft and The partial derivatives in the axial direction are used to obtain the potential energy gradient vector. The magnitude of the potential energy gradient vector is used as the coefficient of the resistance term of the fluid flow to generate gradient potential energy field data corresponding to each image pixel.

[0005] Preferably, the flow field initialization step specifically includes: Direction extraction sub-step: Use Gabor filter bank to perform multi-angle convolution operation on grayscale data matrix, and select the angle with the largest response value as the main texture direction of workpiece surface; Fluid injection sub-step: Define the physical property parameters of the virtual fluid, including fluid density and viscosity coefficient values; construct a uniform velocity field across the entire field, setting the velocity direction of all grid points in the velocity field to the main texture direction, and setting the velocity magnitude to a preset constant value. This is used to generate initial virtual layer flow field data.

[0006] Preferably, the evolutionary calculation step specifically includes: Force analysis sub-step: Calculate the repulsive force vector acting on the virtual fluid at each grid point. The direction of the repulsive force vector is opposite to the gradient direction of the gradient potential energy field data, and its magnitude is proportional to the gradient magnitude. Iterative update sub-step: Based on the discrete form of the simplified quasi-fluid dynamics evolution equation, the state update is performed. For each time step, the momentum transport caused by the advection term, the viscous dissipation caused by the diffusion term, and the change of the external source term caused by the repulsive force vector are calculated. The velocity field data at the current time is added to the change to obtain the velocity field data at the next time step, until the preset number of evolution steps is completed, and the final flow field disturbance data matrix is ​​output.

[0007] Preferably, the defect identification module includes: a divergence calculation unit, used to perform vector calculus on the evolved flow field disturbance map, calculate the velocity vector divergence value at each pixel location, and generate a divergence distribution map, where the divergence value is used to characterize the degree of convergence or divergence of the fluid at that location; and a region segmentation unit, used to perform binarization segmentation on the image based on the divergence distribution map, and mark connected regions with abnormal divergence values ​​as defect candidate regions, where the defect candidate regions correspond to the physical locations in the flow field where vortices or obstructions are generated.

[0008] Preferably, the logic regarding threshold determination in the defect identification step is specifically executed as follows: Read the preset stored defect judgment threshold ; Traverse every pixel in the divergence distribution map Obtain its divergence value ; Execution logic judgment: when At that time, determine the current pixel point If there is a sudden change in the flow field, mark the pixel as a defective pixel, retain its velocity vector characteristics in the flow field disturbance data matrix, and add its coordinates to the defect list. when At that time, determine the current pixel point For the laminar flow region generated for the background texture, mark the pixel as a normal pixel and force its value in the divergence distribution map to zero.

[0009] A detection method for a workpiece defect detection system based on image recognition, the feedback optimization step specifically includes: Hardware acceleration sub-step: Call the tensor computation core in the graphics processing unit (GPU) to accelerate the matrix multiplication and convolution operations in the evolutionary computation step in parallel; Step adjustment sub-step: Monitor the rate of change of the total kinetic energy of the flow field during the iteration process; if the rate of change of the total kinetic energy exceeds the preset oscillation threshold for three consecutive time steps... , it is determined that the flow field is not converged, an operation of reducing the number of iteration evolution steps is performed, and a shock warning is output; if an external checking signal indicating that there is an un-detected small defect is received, an operation of increasing the number of iteration evolution steps is performed, and the increased number of steps is 10% of the current number of steps, so as to enhance the interaction between the fluid and the terrain.

[0010] Preferably, the feedback optimization step further comprises: A small sample calibration sub-step: in the system starting stage, the background texture of the workpiece is collected The good workpiece image is collected, wherein is an integer greater than or equal to 10; the evolution calculation step generates The group reference flow field features, calculates the mean value of the divergence value in the reference flow field features And the standard deviation ; An adaptive calibration sub-step: based on the statistical law, the defect judgment threshold in the defect recognition step is dynamically set, and the defect judgment threshold is set to When it is detected that the mean value of the background texture divergence of the new batch of workpieces changes, the small sample calibration sub-step is re-triggered to update the defect judgment threshold.

[0011] Compared with the prior art, the present application has the following beneficial effects: 1. The present application discards the traditional image processing logic based on pixel gray scale statistics or simple texture filtering, and innovatively establishes a physical simulation environment, maps the gray scale data of the workpiece surface to a gradient potential field with terrain height, and introduces virtual fluid for dynamic evolution; by making the virtual fluid flow along the main texture direction, the normal background texture acts as a river channel guiding the smooth flow of the fluid, and the measured defects are converted into physical reefs or pits that hinder the flow, which naturally assimilates complex background noise and generates strong flow field disturbance at the defect position, thereby significantly improving the extraction ability of weak defect signals in complex industrial environments and solving the problem of difficult differentiation between background noise and physical structural defects in the background technology; 2. The present application calculates the divergence of the evolved flow field disturbance data, and uses the divergence operator to represent the local convergence or divergence degree of the fluid velocity vector; due to the high sensitivity of the fluid dynamics equation to the change of the boundary condition, even a small scratch or a shallow pit that is difficult to detect by traditional visual algorithms will cause a significant mutation of the flow velocity vector in the physical field evolution; by monitoring the physical topological abnormalities of the flow field instead of only the brightness abnormalities, the system can effectively detect small defects with low contrast, and significantly reduce the missed detection rate in the precision manufacturing process; 3. The application constructs a closed-loop control mechanism based on feedback optimization, which can dynamically adjust the physical parameters of the system according to the external input verification signal; when there is a missed detection, the system automatically increases the number of iterations of evolutionary calculation to prolong the action time of the fluid and the terrain; when there is a false alarm, the force intensity coefficient of the gradient potential field is adjusted to smooth the terrain influence; this dynamic adjustment based on physical mechanism makes the detection system flexible to adapt to the changes in reflectivity characteristics between different batches of workpieces or upstream process fluctuations, without the need for frequent manual intervention to maintain the consistency of the detection standard; 4. Combined with statistical laws and fluid mechanics principles, the application proposes a few-sample calibration method based on the characteristics of good product reference flow field, which only needs a small amount of good product images to set dynamic threshold by calculating the divergence mean and standard deviation, avoiding the dependence of deep learning model on massive labeled data; at the same time, cooperating with the hardware acceleration scheme based on graphics processing unit, using tensor calculation core to parallel process matrix operation in evolutionary equation, the calculation time is greatly compressed under the premise of ensuring the accuracy of physical simulation, thus meeting the dual needs of rapid deployment and real-time online detection in industrial field. BRIEF DESCRIPTION OF DRAWINGS

[0012] The application will be further explained in conjunction with the drawings and examples: Figure 1 is a structural diagram of the system of the application; Figure 2 is a flow chart of the method of the application. DETAILED DESCRIPTION

[0013] In order to make the purpose, technical scheme and advantages of the application more clear and explicit, the application will be further explained in detail in conjunction with specific examples.

[0014] Example 1: Please refer to Figure 1 A workpiece defect detection system based on image recognition, the system comprises an image acquisition device, a memory and a processor, the processor executes the computer program stored in the memory to realize the following steps: Image acquisition mapping step: obtaining the original image of the surface of the workpiece to be detected through the image acquisition device, converting it into a single-channel gray data matrix, mapping the gray value of each pixel in the matrix to a terrain height value, and calculating the gradient vector of the terrain height value in two-dimensional space to generate gradient potential field data containing external repulsive force source term; Flow field initialization step: calculating the texture direction of the gray data matrix to obtain the main texture direction vector, and establishing an initial virtual laminar flow field with the same size as the gray data matrix, setting the initial velocity vector of each grid point in the initial virtual laminar flow field to be parallel to the main texture direction vector; Evolution calculation step: take the initial virtual laminar flow field as input data into the simplified nonlinear convection-diffusion evolution equation solver, under the resistance of the gradient potential field data, perform a preset number of time step iteration calculations, and output the flow field disturbance data matrix containing the velocity vector variation; Defect identification step: calculate the divergence value of each coordinate point in the flow field disturbance data matrix to generate a divergence distribution map; compare the divergence value with the preset defect judgment threshold value: if the divergence value is greater than the defect judgment threshold value, it is determined that the coordinate point is a defect area and an alarm signal is output; if the divergence value is less than or equal to the defect judgment threshold value, it is determined that the coordinate point is a background area and a normal signal is output; Feedback optimization step: receive the verification signal input from the outside, if the verification signal indicates that there is a missed detection, increase the number of iterations of the evolution calculation step; if the verification signal indicates that there is a false alarm, reduce the force intensity coefficient of the gradient potential field data.

[0015] Specifically, the adjustment operation adopts a decay update strategy, and the calculation formula is wherein, is a preset decay factor, and the value range is , thereby reducing the terrain resistance effect on the fluid; The embodiment discloses a workpiece defect detection system based on image recognition; Image acquisition and mapping module: the core of this module is to build a physical simulation environment; in this embodiment, the image acquisition and mapping step acquires the original image of the workpiece to be detected through an industrial camera; in order to model the physical field, the processor performs the following operations: gray level mapping: convert the original image into a single-channel gray data matrix ; in this way, the topological mapping relationship is established: the gray value of each pixel point in the image directly corresponds to the altitude of the virtual terrain ; gradient potential field generation: calculate the gradient vector of the terrain height value in the two-dimensional space ; data definition: the gradient potential field data refers to a vector field with the same size as the original image, wherein the value of each point represents the terrain resistance vector encountered by the fluid flowing through this position; by converting the texture image into a physical terrain, the subsequent algorithm can utilize physical laws to process data, rather than relying only on statistical characteristics; Flow field initialization module: the flow field initialization step aims to establish the baseline flow state under the defect-free state; the system performs texture main direction analysis on the gray data matrix to obtain the main texture direction vector ; an initial virtual laminar flow field is established , wherein each grid point in the field is assigned an initial velocity vector , and and Parallel; using the texture direction of the workpiece itself as the flow channel of the virtual fluid, ensuring that in the normal texture area, the fluid is in a smooth laminar flow state, laying a physical foundation for subsequent defect identification through turbulent flow; Evolutionary computing module: the evolutionary computing step is the core engine of the system; the processor takes the initial virtual laminar flow field as the initial value and the gradient potential field data as the external resistance source term, and substitutes them into the simplified nonlinear convection-diffusion evolutionary equation solver; iteration process: in the preset time step Internal execution Sub-iteration; variation generation: in the iteration, the flat or regular texture area guides the smooth flow of the fluid; while the defect area behaves as a sudden change in terrain, forcing the fluid to produce separation, vortex or blockage; output: the final output flow field disturbance data matrix, which is essentially the velocity vector field of the evolution final state ; Through physical evolution, signal enhancement is naturally achieved-the background texture is assimilated into the background flow by guiding the fluid, while the defect as an abnormal obstacle excites strong flow field disturbance, greatly improving the signal-to-noise ratio; Defect identification module: the defect identification step is responsible for converting the physical field anomaly into a binary detection result; divergence calculation: calculate the divergence of each point in the flow field disturbance data matrix ; The divergence here represents the local convergence or divergence of the fluid velocity vector, which corresponds to the physical behavior of fluid compression or flow around obstacles when encountering obstacles; threshold determination: generate a divergence distribution map and compare it with a preset defect judgment threshold ; If the divergence value , it is determined as a defect area and an alarm is given; otherwise, it is determined as the background; the divergence operator is extremely sensitive to flow field changes and can capture small physical structure changes that traditional filtering algorithms easily ignore; The feedback optimization module is used for adaptive adjustment of the system; when receiving the verification signal of external manual review or automatic verification: if there is a missed detection: it means that the fluid and the terrain are not affected for enough time, so the system automatically increases the number of iterations of evolutionary calculation, so that the fluid is more fully affected by the terrain; if there is a false alarm: it means that the terrain resistance is too large to cause turbulence in noise texture, so the system reduces the weight parameter of the gradient potential field data to smooth the terrain influence; it realizes the dynamic balance of detection sensitivity and specificity, and solves the problem of fixed parameters that cannot adapt to process fluctuations of different batches of products.

[0016] Example 2: The image acquisition mapping step specifically includes: Gray conversion sub-step: convert the collected RGB image into a single-channel gray data matrix by weighted average method; Potential modeling sub-step: define the potential function , where is equal to the pixel coordinate multiplying the gray value of the pixel at the position by a preset potential energy conversion coefficient ; calculating In the axial and axial direction partial derivatives to obtain a potential energy gradient vector, mapping the potential energy gradient vector as an external repulsive force vector in the fluid dynamics equation, generating a gradient potential energy field data corresponding to the image pixels.

[0017] The embodiment specifically implements the image acquisition and mapping step, especially the mathematical implementation of potential energy modeling; The gray scale conversion sub-step system usually acquires an RGB color image; the processor converts it by using the weighted average method, and the formula is as follows:

[0018] wherein, are the red, green and blue channel components respectively; the weight coefficient conforms to the human eye visual characteristics, and maximizes the texture details; The potential energy modeling sub-step is to convert the gray scale image into a physical potential energy field, and the embodiment defines the potential energy function :

[0019] In order to ensure the dimensional consistency of physical quantities and eliminate the influence of image bit depth, the gray scale data is normalized; the normalized potential energy function is defined as follows:

[0020] wherein, is the maximum luminance value of the 8-bit gray scale image; after this processing, the potential energy function becomes a dimensionless scalar, ensuring that the dimension of the subsequent gradient calculation is only ; wherein, the potential energy conversion coefficient k: is a preset proportional constant, used to adjust the blocking ability of the pixel gray scale value to the virtual flow field; preferably, the value range of k is to , and a too low value will lead to an unobvious disturbance of the defect to the flow field, and a too high value will lead to an over-amplification of the background noise; The greater the value is, the greater the resistance generated by the image light and dark changes to the fluid is; the calculation of the potential energy gradient vector is as follows:

[0021] The system calculates the partial derivatives by using the Sobel operator or the central difference method to obtain the gradient module length of each pixel position Data generation: The calculated gradient vector is used as the coefficient of the drag term in the fluid dynamics equations; By introducing the potential energy conversion coefficient By controllably mapping optical contrast to mechanical friction, the detection system can adjust the roughness of the physical model according to the reflective properties of different material surfaces, resulting in strong physical interpretability.

[0022] Example 3: The flow field initialization steps specifically include: Direction extraction sub-step: Use Gabor filter bank to perform multi-angle convolution operation on grayscale data matrix, and select the angle with the largest response value as the main texture direction of workpiece surface; Fluid Injection Sub-step: Define the physical property parameters of the virtual fluid, including fluid density and viscosity; construct a uniform velocity field across the entire field, set the velocity direction of all grid points in the velocity field as the main texture direction, and set the velocity magnitude to a preset constant value. This is used to generate initial virtual layer flow field data.

[0023] This embodiment details how to construct an anisotropic initial state through the flow field initialization steps, and supplements the key boundary condition settings to meet numerical stability. In the direction extraction sub-step, to allow the virtual fluid to flow along the texture of the workpiece, the system employs a Gabor filter bank. Filter parameter settings include: parameter preprocessing: performing a two-dimensional fast Fourier transform on the grayscale data matrix to obtain the spectrum; identifying the annular regions with the most concentrated energy in the spectrum and calculating their corresponding spatial frequencies. The average width of the workpiece texture is calculated as follows: ; Setting the wavelength of the Gabor nucleus Twice the average width of the workpiece texture, standard deviation To ensure the filter matches the texture scale; the operation method involves configuring a set of Gabor filter kernels with different directions and convolving them with the grayscale data matrix; the main direction is determined by selecting the angle with the largest average response energy across the entire image. As the main texture direction of the workpiece surface; the fluid injection sub-step establishes a constant environment on the virtual terrain; physical parameter definition sets the fluid density. and viscosity coefficient Initial field construction: Constructing a vector field For interior points initial velocity Boundary condition definition: To prevent numerical divergence of fluid at image edges, boundary conditions are defined as follows: Open boundary conditions are used to simulate a virtual wind tunnel effect: For directions perpendicular to the main texture... Neumann boundary condition is set, i.e. the normal derivative of velocity is zero , which allows fluid to flow freely in and out; for the two side boundaries parallel to the main texture direction, slip wall is set, i.e. the normal velocity is zero but the tangential velocity is not blocked, so as to eliminate the interference of boundary effect on the evolution of the central region; The scale parameter source of the filter and the boundary processing logic are clarified, and the code dead loop or numerical overflow problem caused by the missing boundary condition in the original scheme is solved.

[0024] Embodiment 4: The evolution calculation step specifically includes: The stress analysis sub-step: the repulsion force vector of the virtual fluid at each grid point is calculated, the direction of the repulsion force vector is opposite to the gradient direction of the gradient potential energy field data, and the size is proportional to the gradient modulus and the preset force intensity coefficient; The iteration update sub-step: the state update is performed based on the discrete form of the simplified pseudo-fluid dynamics evolution equation, for each time step, the momentum transport amount caused by the advection term, the viscous dissipation amount caused by the diffusion term and the external source term change amount caused by the repulsion force vector are calculated; the velocity field data at the current time is added to obtain the velocity field data at the next time, until the preset evolution step number is completed, and the final flow field disturbance data matrix is output.

[0025] Set the time step parameter , which has the dimension of time, and the numerical value needs to meet the Crank-Nicolson stability condition; Specifically, the time step needs to strictly satisfy the following inequality constraint, taking the smaller value of the advection stability limit and the diffusion stability limit:

[0026] Wherein, the first term represents the time limit of the advection process, and the second term represents the time limit of the viscous diffusion process; is the Courant number, and the value range is set to to ensure the convergence of the explicit solver; and are the estimated values of the maximum velocity component in the current flow field; the system dynamically adjusts according to the maximum flow velocity of the last frame before starting each evolution step to prevent numerical explosion; Euler forward integration is performed: after multiplying the above change amounts by the time step , the change amounts are added to the velocity field data at the current time; The calculation formula of the horizontal velocity component at the next time is:

[0027] The evolutionary model used in this embodiment is a simplified pseudo-fluid dynamics model. To focus on the direct impediment effect of terrain gradients on the flow field, the model neglects the pressure gradient term within the fluid (…). The model incorporates the constraints of mass conservation, retaining only the advection, diffusion, and external potential energy terms in the momentum equation, thus making the fluid behave as a compressible and relaxed medium. This model is essentially a simplified fluid dynamics model based on the extension of the Burgers equation. By removing the solution process of the pressure Poisson equation in incompressible fluids, the computational complexity is reduced, while retaining the fluid's flow around and hindrance characteristics to terrain obstacles. In this embodiment, the pressure gradient term is ignored. The physical basis for this is that the system does not aim to accurately simulate the physical conservation properties of real fluids, but rather to extract image features using the convection and diffusion mechanisms in the fluid equations. In this pseudo-fluid model, the gray-scale potential energy field plays a dominant rectifying role, while the pressure term is computationally expensive and contributes little to defect edge detection. Therefore, it is removed to improve computational efficiency, which is a common and effective simplification method in physical models in the field of image processing. This embodiment elaborates on the discrete solution logic in the evolutionary computation steps; to meet the code-level reproducibility requirements, this embodiment transforms the general Navier-Stokes equations into a specific explicit finite difference scheme and clarifies the spatial discrete step length. To ensure the consistency of physical dimensions; The force analysis substep defines the repulsive force components. The potential energy gradient is calculated using the central difference method. in, The potential energy field data is dimensionless. The calculation formula is as follows:

[0028] in, The grid space step size, The preset force strength coefficient has its physical unit set to . To ensure that the force term and the acceleration term in the momentum equation are consistent. The dimensions are consistent; it should be noted that, in the physical model constructed in this embodiment, in order to ensure dimensional closure, the potential energy function... After normalization, it is treated as a dimensionless scalar field; at this point, its spatial gradient term... The physical dimensions are Bond strength coefficient Dimensions set The calculated repulsive force term The final dimension is so as to keep strict dimensional consistency with the convection term and the diffusion term in the fluid dynamics equation; The iterative updating sub-step defines For The horizontal and vertical velocity components of the grid point at the moment; The following discrete operations are performed: the diffusion term: a five-point difference Laplace operator is adopted, and the square of the spatial step is included in the denominator of the term:

[0029]

[0030] The calculation of the advection term: in order to ensure numerical stability and adapt to the fluid backflow situation, a full-direction first-order upwind scheme is adopted; for the grid point , the spatial difference direction is dynamically selected according to the velocity vector direction of the point at the current moment; The calculation logic of the advection term of the component is as follows:

[0031] Wherein, the spatial difference terms and are determined by the following condition judgment logic: The horizontal difference : If , backward difference is adopted: ; If , forward difference is adopted: .

[0032] The vertical difference : If , backward difference is adopted: ; If , forward difference is adopted: ; The advection term of the component is calculated by using the same logic, and only the differentiated variable in the above formula is replaced by ; By disclosing the specific difference scheme and completing the spatial step parameter, the black box description based on the NS equation is eliminated, the dimensional mismatch problem in the original formula is corrected, the arithmetic implementation path of the advection term and the diffusion term is clarified, and it is ensured that the technical solution has programmability.

[0033] Embodiment 5:​ The defect recognition module comprises: a divergence calculation unit for performing vector calculus operation on the evolved flow field disturbance map, calculating the velocity vector divergence value of each pixel point position, and generating a divergence distribution map, the divergence value being used to represent the convergence or divergence degree of the fluid at the position; and a region segmentation unit for performing binary segmentation on the image according to the divergence distribution map, and marking the connected region with abnormal divergence value as a defect candidate region, the defect candidate region corresponding to the physical position where vortex or blockage is generated in the flow field.

[0034] The threshold determination logic in the defect recognition step is specifically implemented as follows: reading a preset stored defect determination threshold ; traversing each pixel point in the divergence distribution map , obtaining the divergence value thereof ; performing logical judgment: when , it is determined that the current pixel point has flow field mutation, the pixel point is marked as a defect pixel, the velocity vector feature thereof in the flow field disturbance data matrix is retained, and the coordinates thereof are recorded in a defect list; when , it is determined that the current pixel point is a laminar flow region generated by background texture, the pixel point is marked as a normal pixel, and the value thereof in the divergence distribution map is forced to be zero.

[0035] The embodiment describes the specific structure of the defect recognition module and the threshold determination logic thereof; The defect recognition module constructs a divergence calculation unit: for performing vector calculus operation; for any point in the discrete grid , the velocity vector thereof is , and the divergence calculation formula is:

[0036] The unit outputs a divergence distribution map with the same size as the original map; the region segmentation unit: performs binaryzation according to the divergence distribution map; it identifies the regions where the fluid cannot pass normally, and marks these connected regions as defect candidate regions; The threshold determination logic flow processor performs the following strict logical judgment flow: parameter reading: reading the preset defect determination threshold in the storage ; full field traversal: traversing each pixel point in the divergence distribution map ; conditional branching: if : it is determined that flow field mutation occurs at the position, the pixel point is marked as a defect pixel, the velocity feature is retained, and the coordinates are recorded; if : judge that the position is a stable laminar flow region, mark it as a normal pixel, and force its divergence value to be zero; By introducing the divergence calculation, the complex texture image analysis is directly simplified to the singular point detection of the flow field; using the threshold logic for hard classification can quickly and accurately generate a binary defect mask, which is convenient for subsequent defect area calculation and classification.

[0037] Embodiment 6: Please refer to Figure 2 A detection method of a workpiece defect detection system based on image recognition, the feedback optimization step specifically comprises: Hardware acceleration sub-step: calling the tensor calculation core in the graphics processing unit (GPU) to perform parallel acceleration on the matrix multiplication and convolution operation in the evolution calculation step; Step number adjustment sub-step: monitoring the change rate of the total kinetic energy of the flow field during the iteration process; if the change rate of the total kinetic energy of the continuous three time steps is greater than a preset oscillation threshold , it is determined that the flow field has not converged, the operation of reducing the iteration evolution step number is performed, and an oscillation warning is output; if an external check signal indicating that there is a small defect that has not been detected is received, the operation of increasing the iteration evolution step number is performed, and the increased step number is ten percent of the current step number, so as to enhance the interaction between the fluid and the terrain.

[0038] It should be noted that the system sets the priority of the adjustment logic: the numerical stability control has the highest priority; when the system simultaneously detects the total kinetic energy oscillation and the external missed detection signal, the processor preferentially performs the operation of reducing the iteration evolution step number, and simultaneously reduces the time step , and then tries to gradually increase the evolution step number after the flow field restores the numerical stability, so as to prevent the calculation from diverging due to the increase of the iteration number on the basis of the numerical instability; This embodiment details the feedback optimization step based on hardware acceleration and physical state monitoring; The hardware acceleration sub-step involves a large number of matrix multiplication and convolution in the evolution calculation, and the processor calls the general parallel computing unit in the GPU to perform parallel acceleration on the grid difference and field theory operation in the evolution calculation step; specifically, the discrete solution of the NS equation is mapped to a parallel computing kernel function, and parallel acceleration is performed using the CUDA or OpenCL architecture; in order to solve the thread divergence problem of conditional branch logic under the GPU single instruction multiple data architecture, this step uses the mask technology to realize the non-branch upwind format calculation: Constructing the X-direction derivative tensor and the Y-direction derivative tensor ; using the mask technology to process the branch logic of the upwind format: In the above tensor operation, the translation operator is defined as a tensor Shift right by one grid unit along the horizontal axis, left boundary padded with zeros; similarly, , and correspond to left, down and up shift and boundary zero padding operation respectively; Construct horizontal velocity mask tensor and ; X-direction partial derivative calculation:

[0039] Y-direction partial derivative calculation: Construct vertical velocity mask tensor and ;

[0040] Advection term Total tensor calculation: Superimpose the momentum transport effects of X and Y directions, here we need to pay attention to should be multiplied by the vertical velocity field :

[0041] where, denotes Hadamard product; replace the logical judgment with the above tensor operation to adapt to the GPU parallel computing architecture; Compress the fluid dynamics simulation that originally takes several seconds to milliseconds, meeting the real-time detection needs of industrial pipelines; Step adjustment sub-step system introduces the total kinetic energy of the flow field as a monitoring indicator:

[0042] Convergence monitoring: calculate the kinetic energy change rate of three consecutive time steps ; if , it indicates that the flow field value is unstable, the system automatically reduces the iteration step number and issues a warning to prevent numerical explosion; sensitivity enhancement: when the external check signal indicates that there is a small undetected, the system determines that the current fluid and defect interaction is insufficient; the processor executes instructions to increase the number of iteration evolution steps, and the increase amplitude is 10% of the current step number; this allows the fluid to have more time to bypass the small obstacle, thereby generating a disturbance in the wake region that can be detected; By monitoring the kinetic energy of the flow field, the numerical stability of the physical simulation is ensured; at the same time, a sensitivity adjustment mechanism based on physical time is established, which is more robust than simply adjusting the threshold.

[0043] Example 7: The feedback optimization step further comprises: Few-sample calibration sub-step: collect a few images of good workpieces at system startup phase , where is an integer greater than or equal to 10; generate a set of reference flow field features by evolutionary computation step , calculate the mean value of divergence values in reference flow field features and standard deviation ; Adaptive calibration sub-step: dynamically set defect judgment threshold in defect recognition step based on statistical rules, set defect judgment threshold to , when detecting that the mean value of background texture divergence of new batch of workpieces changes, re-trigger few-sample calibration sub-step to update defect judgment threshold.

[0044] As can be seen, although few-sample calibration sub-step is mainly executed at system startup phase, when feedback optimization step detects that background texture statistical characteristics significantly drift, it will be triggered again as a reset means by feedback mechanism, thus forming a complete closed-loop control.

[0045] This embodiment describes statistical-based few-sample calibration and adaptive calibration mechanism; Few-sample calibration sub-step does not need to be trained by a large number of defect samples at system startup or when workpiece batch is replaced; collect: only collect images of workpieces confirmed as good products by manual; reference generation: input these images into system, generate a set of reference flow field features after complete evolutionary computation; statistical calculation: calculate the mean value of divergence values of all pixel points in these reference flow field features and standard deviation ; mean value : represents inherent flow field noise level caused by background texture; standard deviation : represents consistency or fluctuation range of background texture; Adaptive calibration sub-step sets defect judgment threshold based on statistical principles:

[0046] Dynamic update: during detection process, system continuously calculates divergence mean value of new batch of workpieces judged as background area; if deviation of this mean value from exceeds preset range, system judges that upstream process has changed, automatically triggers re-calibration process to update and , and then adjusts ; Real small sample learning and unsupervised migration are realized; by defining normal through the flow field characteristics of good products, any flow field disturbance deviating from the statistical rule is regarded as a defect, greatly reducing the deployment cost of the system and the dependence on sample data.

[0047] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application rather than limit the present application. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present application.

Claims

1. A workpiece defect detection system based on image recognition, characterized in that: The system includes an image acquisition device, a memory, and a processor, the processor executing a computer program stored in the memory to perform the following steps: Image acquisition and mapping steps: The original image of the surface of the workpiece to be inspected is acquired through the image acquisition device, converted into a single-channel grayscale data matrix, the grayscale value of each pixel in the matrix is ​​mapped to the terrain height value, and the gradient vector of the terrain height value in two-dimensional space is calculated to generate gradient potential energy field data containing drag coefficient. Flow field initialization steps: Calculate the texture direction of the grayscale data matrix to obtain the main texture direction vector, and establish an initial virtual layer flow field with the same size as the grayscale data matrix. Set the initial velocity vector of each grid point in the initial virtual layer flow field to be parallel to the main texture direction vector. Evolution calculation steps: Substitute the initial virtual layer flow field as input data into the discrete solver of the nonlinear convection-diffusion evolution equation that ignores the pressure gradient term. Under the drag of the gradient potential energy field data, perform a preset number of time step iterations and output a flow field disturbance data matrix containing velocity vector variations. Defect identification steps: Calculate the divergence value of each coordinate point in the flow field disturbance data matrix to generate a divergence distribution map; compare the divergence value with a preset defect judgment threshold: if the divergence value is greater than the defect judgment threshold, the coordinate point is determined to be a defect area and an alarm signal is output; if the divergence value is less than or equal to the defect judgment threshold, the coordinate point is determined to be a background area and a normal signal is output. Feedback optimization steps: Receive external input verification signals. If the verification signal indicates a missed detection, increase the number of iterations of the evolution calculation step. If the verification signal indicates a false alarm, decrease the force intensity coefficient α of the gradient potential energy field data.

2. The workpiece defect detection system based on image recognition according to claim 1, characterized in that: The image acquisition and mapping steps specifically include: Grayscale conversion sub-step: Convert the acquired RGB image into a single-channel grayscale data matrix using a weighted average method; Potential energy modeling sub-steps: Define the potential energy function ,in equal to pixel coordinates The gray value at that point is multiplied by the preset potential energy conversion coefficient. ;calculate exist shaft and The partial derivatives in the axial direction are used to obtain the potential energy gradient vector. The magnitude of the potential energy gradient vector is used as the coefficient of the resistance term of the fluid flow to generate gradient potential energy field data corresponding to each image pixel.

3. The workpiece defect detection system based on image recognition according to claim 1, characterized in that: The flow field initialization step specifically includes: Direction extraction sub-step: Use Gabor filter bank to perform multi-angle convolution operation on grayscale data matrix, and select the angle with the largest response value as the main texture direction of workpiece surface; Fluid injection sub-step: Define the physical property parameters of the virtual fluid, including fluid density and viscosity coefficient values; construct a uniform velocity field across the entire field, setting the velocity direction of all grid points in the velocity field to the main texture direction, and setting the velocity magnitude to a preset constant value. This is used to generate initial virtual layer flow field data.

4. The workpiece defect detection system based on image recognition according to claim 1, characterized in that: The evolutionary calculation steps specifically include: Force analysis sub-step: Calculate the repulsive force vector acting on the virtual fluid at each grid point. The direction of the repulsive force vector is opposite to the gradient direction of the gradient potential energy field data, and its magnitude is proportional to the gradient magnitude. Iterative update sub-step: Based on the discrete form of the simplified quasi-fluid dynamics evolution equation, the state update is performed. For each time step, the momentum transport caused by the advection term, the viscous dissipation caused by the diffusion term, and the change of the external source term caused by the repulsive force vector are calculated. The velocity field data at the current time is added to the change to obtain the velocity field data at the next time step, until the preset number of evolution steps is completed, and the final flow field disturbance data matrix is ​​output.

5. The workpiece defect detection system based on image recognition according to claim 1, characterized in that: The defect identification module includes: a divergence calculation unit, which performs vector calculus on the evolved flow field disturbance map to calculate the velocity vector divergence value at each pixel location and generate a divergence distribution map. The divergence value is used to characterize the degree of convergence or divergence of the fluid at that location; and a region segmentation unit, which performs binarization segmentation on the image based on the divergence distribution map and marks connected regions with abnormal divergence values ​​as defect candidate regions. The defect candidate regions correspond to the physical locations in the flow field where vortices or obstructions are generated.

6. The workpiece defect detection system based on image recognition according to claim 5, characterized in that: The specific execution of the threshold determination logic in the defect identification step is as follows: Read the preset stored defect judgment threshold ; Traverse every pixel in the divergence distribution map Obtain its divergence value ; Execution logic judgment: when At that time, determine the current pixel point If there is a sudden change in the flow field, mark the pixel as a defective pixel, retain its velocity vector characteristics in the flow field disturbance data matrix, and add its coordinates to the defect list. when At that time, determine the current pixel point For the laminar flow region generated for the background texture, mark the pixel as a normal pixel and force its value in the divergence distribution map to zero.

7. The detection method of a workpiece defect detection system based on image recognition according to any one of claims 1-6, characterized in that: The feedback optimization steps specifically include: Hardware acceleration sub-step: Call the tensor computation core in the graphics processing unit (GPU) to accelerate the matrix multiplication and convolution operations in the evolutionary computation step in parallel; Step adjustment sub-step: Monitor the rate of change of the total kinetic energy of the flow field during the iteration process; if the rate of change of the total kinetic energy exceeds the preset oscillation threshold for three consecutive time steps... If the flow field is determined to be non-converged, the operation of reducing the number of iteration evolution steps is executed and an oscillation warning is output; if an external verification signal is received indicating the presence of undetected minor defects, the operation of increasing the number of iteration evolution steps is executed, with the number of steps increased by 10% of the current number of steps, in order to enhance the interaction between the fluid and the terrain.

8. A workpiece defect detection method based on image recognition, characterized in that, This method is performed based on the system as described in any one of claims 1-6, wherein the feedback optimization step further includes: Few-sample calibration sub-steps: During the system startup phase, data is collected. Images of good quality workpieces, among which It is an integer greater than or equal to 10; generated through the evolutionary calculation steps. Set up a reference flow field characteristic and calculate the mean of the divergence values ​​in the reference flow field characteristic. and standard deviation ; Adaptive calibration sub-step: Based on statistical laws, dynamically set the defect judgment threshold in the defect identification step, and set the defect judgment threshold to... When a change in the mean of the background texture divergence of a new batch of workpieces is detected, the few-sample scaling sub-step is re-triggered to update the defect determination threshold.

Citation Information

Cited By

  • Image enhancement method for surface defects of mining sputtering sensor

    CN121937329A