Industrial article appearance detection method and system based on machine vision
Through the machine vision-based industrial object appearance detection method, combined with multi-source information fusion and distributed architecture, the problems of detection accuracy and data management efficiency in the existing technology are solved, and efficient and reliable industrial product appearance detection and quality traceability are achieved.
Patent Information
- Application Number
- CN202510185660.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-03-21
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing technology is difficult to deal with complex defects in industrial product appearance detection, especially in environments with unstable lighting and high background interference, detection accuracy is difficult to ensure; at the same time, centralized storage architecture has bottlenecks in data processing capabilities and access efficiency, and it is difficult to meet the real-time detection needs of large-scale production lines; lack of consideration of environmental factors for detection, and fluctuations in environmental parameters affect the reliability of the detection results; the quality traceability system lacks in-depth analysis and mining of data, and cannot provide effective decision-making support for quality improvement.
The appearance detection method of industrial items based on machine vision is adopted to improve detection accuracy through multi-source information fusion, and a distributed architecture is used to achieve efficient management and analysis of massive detection data. The specific steps include: collecting workpiece images based on industrial cameras, performing noise reduction processing and image enhancement, extracting workpiece feature vectors, model training through convolutional neural networks with attention mechanisms, multi-source information fusion using Dempster-Shafer evidence theory, and establishing a quality traceability database for data storage and analysis.
It improves the accuracy and robustness of industrial product appearance inspection, can effectively detect defects in complex environments, realizes efficient management and analysis of massive inspection data, and provides effective decision-making support for quality improvement.
Smart Images

Figure CN119672020A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to a method and system for detecting the appearance of industrial objects based on machine vision. Background Art
[0002] In the industrial production process, product appearance quality inspection is an important part of ensuring product quality. With the continuous improvement of industrial automation level, automated inspection technology based on machine vision has been widely used. Traditional machine vision inspection methods mainly use a single image processing algorithm for defect detection, such as edge detection, morphological processing, texture analysis, etc. At the same time, the storage and management of inspection data usually adopts a centralized architecture, storing all data in a single database server, and achieving quality traceability through simple database queries.
[0003] However, the existing technology has the following shortcomings: First, a single image processing algorithm is difficult to cope with complex appearance defects, especially in environments with unstable lighting conditions and large background interference, and the detection accuracy is difficult to guarantee; second, with the rapid growth of the amount of detection data, the centralized storage architecture faces serious bottlenecks in data processing capabilities and access efficiency, and it is difficult to meet the real-time detection needs of large-scale production lines; third, there is a lack of consideration of detection environmental factors. Fluctuations in environmental parameters will affect the reliability of detection results, and existing methods cannot effectively deal with this uncertainty; finally, quality traceability systems often only focus on data storage and query, lack in-depth analysis and mining of data, and cannot provide effective decision-making support for quality improvement. Summary of the invention
[0004] The present application provides a method and system for detecting the appearance of industrial objects based on machine vision, which is used to improve detection accuracy through multi-source information fusion and to achieve efficient management and analysis of massive detection data using a distributed architecture.
[0005] In a first aspect, the present application provides an industrial article appearance detection method based on machine vision, the industrial article appearance detection method based on machine vision comprising: acquiring a workpiece image based on an industrial camera, performing noise reduction processing on the workpiece image through a Gaussian filtering algorithm, performing image enhancement through adaptive histogram equalization, and performing image segmentation using an improved Otsu algorithm to obtain a standardized preprocessed image; According to the standardized preprocessed image, the workpiece size feature is extracted by using an edge detection algorithm, the workpiece contour feature is extracted by using a Hough transform, and the workpiece surface texture feature is extracted based on a gray level co-occurrence matrix to obtain a workpiece feature vector; Using the workpiece feature vector, a convolutional neural network with an attention mechanism is used to train the model, and an improved Adam optimizer is used to optimize the model parameters to obtain a workpiece defect recognition model; The standardized pre-processed image is input into the workpiece defect recognition model, a dynamic threshold mechanism is established based on the probability distribution of defect features, and the workpiece image is detected in real time to obtain a preliminary detection result; Based on the preliminary detection results, the Dempster-Shafer evidence theory is used to perform multi-source information fusion on the visual detection data and the environmental parameter data to obtain a comprehensive detection result; Based on the comprehensive test results, a quality traceability database is established through a distributed architecture, the test data is statistically analyzed and stored, and a workpiece quality report is generated.
[0006] In a second aspect, the present application provides an industrial article appearance detection system based on machine vision, the industrial article appearance detection system based on machine vision comprising: An acquisition module is used to acquire workpiece images based on an industrial camera, perform noise reduction on the workpiece images through a Gaussian filtering algorithm, perform image enhancement through adaptive histogram equalization, and perform image segmentation using an improved Otsu algorithm to obtain a standardized preprocessed image; An extraction module is used to extract workpiece size features using an edge detection algorithm based on the standardized preprocessed image, extract workpiece contour features through Hough transform, and extract workpiece surface texture features based on a gray level co-occurrence matrix to obtain a workpiece feature vector; A training module is used to use the workpiece feature vector to perform model training through a convolutional neural network with an attention mechanism, and to optimize the model parameters using an improved Adam optimizer to obtain a workpiece defect recognition model; Establishing a module, for inputting the standardized pre-processed image into the workpiece defect recognition model, establishing a dynamic threshold mechanism based on the probability distribution of defect features, performing real-time detection on the workpiece image, and obtaining preliminary detection results; A fusion module is used to perform multi-source information fusion of visual detection data and environmental parameter data based on the preliminary detection results using Dempster-Shafer evidence theory to obtain a comprehensive detection result; The storage module is used to establish a quality traceability database through a distributed architecture based on the comprehensive test results, perform statistical analysis and storage on the test data, and generate a workpiece quality report.
[0007] A third aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned industrial article appearance detection method based on machine vision.
[0008] In the technical solution provided by the present application, the workpiece image is subjected to denoising by the Gaussian filtering algorithm, and the image segmentation is performed by combining adaptive histogram equalization and improved Otsu algorithm, which effectively eliminates the interference of image noise, enhances the expressiveness of target features, and provides high-quality standardized pre-processed images for subsequent feature extraction. The size features, contour features and surface texture features of the workpiece are comprehensively extracted by combining edge detection algorithm, Hough transform and gray-level co-occurrence matrix to form a multi-dimensional workpiece feature vector, which fully reflects the appearance feature information of the workpiece. Feature learning is performed by convolutional neural network with attention mechanism, and the model parameters are optimized by combining improved Adam optimizer to construct a workpiece defect recognition model with strong generalization ability, which improves the accuracy and robustness of defect detection. A dynamic threshold mechanism is established based on the probability distribution of defect features to perform real-time detection of workpiece images, and the detection parameters can be adaptively adjusted according to the characteristics of different workpieces to improve the flexibility of detection. Multi-source information fusion of visual inspection data and environmental parameter data is performed by using Dempster-Shafer evidence theory, and the reliability of the detection results is improved by considering the influence of environmental factors on the detection results. Finally, a quality traceability database was established using a distributed architecture, which enabled efficient storage and retrieval of inspection data, and generated workpiece quality reports through statistical analysis and data mining. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0010] Figure 1 A schematic diagram of an embodiment of a method for detecting the appearance of an industrial object based on machine vision in an embodiment of the present application; Figure 2 This is a schematic diagram of the camera arrangement for the appearance inspection of industrial articles in an embodiment of the present application; Figure 3 A schematic diagram of the network structure of a workpiece defect recognition model in an embodiment of the present application; Figure 4 Schematic diagram of an embodiment of an industrial object appearance inspection system based on machine vision in an embodiment of the present application. DETAILED DESCRIPTION
[0011] The embodiment of the present application provides a method and system for detecting the appearance of industrial articles based on machine vision. The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described here can be implemented in an order other than that illustrated or described here. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0012] For ease of understanding, the specific process of the embodiment of the present application is described below. Figure 1 In the embodiments of the present application, an embodiment of the method for detecting the appearance of industrial articles based on machine vision includes: Step S101, collecting workpiece images based on industrial cameras, performing noise reduction processing on the workpiece images through Gaussian filtering algorithm, performing image enhancement through adaptive histogram equalization, and performing image segmentation using improved Otsu algorithm to obtain standardized preprocessed images; Step S102, according to the standardized preprocessed image, using the edge detection algorithm to extract the workpiece size features, using the Hough transform to extract the workpiece contour features, and based on the gray level co-occurrence matrix to extract the workpiece surface texture features, to obtain the workpiece feature vector; Step S103, using the workpiece feature vector, performing model training through a convolutional neural network with an attention mechanism, and using an improved Adam optimizer to optimize the model parameters to obtain a workpiece defect recognition model; Step S104, input the standardized pre-processed image into the workpiece defect recognition model, establish a dynamic threshold mechanism based on the probability distribution of defect features, perform real-time detection on the workpiece image, and obtain preliminary detection results; Step S105: Based on the preliminary detection results, multi-source information fusion is performed on the visual detection data and the environmental parameter data using the Dempster-Shafer evidence theory to obtain a comprehensive detection result; Step S106: Based on the comprehensive test results, a quality traceability database is established through a distributed architecture, the test data is statistically analyzed and stored, and a workpiece quality report is generated.
[0013] It is understandable that the execution subject of the present application may be an industrial article appearance inspection system based on machine vision, or a terminal or a server, which is not specifically limited here. The present application embodiment is described by taking a server as the execution subject as an example.
[0014] Specifically, the workpiece is imaged by an industrial camera, which is set at different positions in the inspection area and takes pictures from the front, side and 45-degree angle of the workpiece to obtain multi-angle image data of the workpiece. Figure 2 As shown, it is a schematic diagram of the camera arrangement for the appearance inspection of industrial items in the embodiment of the present application. The workpiece is placed on the work surface, and three industrial cameras are respectively set at different positions: the front camera is set vertically downward directly above the workpiece to collect the top view image of the workpiece; the side camera is set horizontally on the side of the workpiece to collect the side view image of the workpiece; the 45-degree angle camera is set obliquely above the workpiece to collect the oblique perspective image of the workpiece. The dotted lines in the figure indicate the shooting direction of each camera, and the center of the field of view of all cameras points to the center of the workpiece. The acquired raw image data often contains noise interference, so it needs to be denoised by a Gaussian filtering algorithm. The Gaussian filtering algorithm performs convolution operations on the image based on a two-dimensional Gaussian function. The convolution kernel size is set to 5×5, and the standard deviation is set to 1.5. The random noise in the image is eliminated by weighted averaging each pixel and its neighborhood. The denoised image is enhanced by adaptive histogram equalization. Adaptive histogram equalization divides the image into several equal-sized sub-blocks, calculates the grayscale histogram for each sub-block and performs equalization, and then smoothes the boundaries between blocks using the bilinear interpolation method to avoid the generation of blocking effects. The processed image has a more uniform grayscale distribution and clearer image details.
[0015] After image enhancement, the improved Otsu algorithm is used to segment the image. The improved Otsu algorithm divides the image into the target area and the background area by iteratively calculating the threshold with the largest inter-class variance. Compared with the traditional Otsu algorithm, the improved algorithm introduces local area information and dynamically adjusts the threshold according to the spatial position relationship of the pixel points to improve the segmentation accuracy. The segmented image is normalized to obtain a standardized preprocessed image. The feature information of the workpiece is extracted from the standardized preprocessed image. The edge detection algorithm is used to extract the size features of the workpiece. The edge points in the image are detected by calculating the gradient value and direction of the image, and the local maximum gradient value points are retained by non-maximum suppression. Then, the Hough transform is used to extract the contour features of the workpiece, and the straight line in the image space is mapped to the parameter space. The straight line parameters are counted by the accumulator array, and the local peak points are extracted as the contour features. At the same time, the surface texture features of the workpiece are extracted based on the gray level co-occurrence matrix, and the spatial correlation and gray value distribution of the pixel pairs are calculated to generate the texture feature descriptor. These features are combined to form the workpiece feature vector.
[0016] The workpiece feature vector is input as training data into the convolutional neural network with attention mechanism. The attention mechanism highlights the important feature areas by calculating the spatial attention weight and channel attention weight of the feature map. The improved Adam optimizer is used to optimize the network parameters, and the model convergence speed is accelerated by adaptively adjusting the learning rate and momentum coefficient. After multiple rounds of iterative training, the workpiece defect recognition model is obtained. In the actual detection process, the standardized preprocessed image is input into the trained workpiece defect recognition model, the image is processed in blocks, and the defect feature map is generated. The dynamic threshold is calculated based on the probability distribution of the defect feature, and the defect area is identified by threshold judgment to obtain the preliminary detection result.
[0017] In order to improve the reliability of detection, the Dempster-Shafer evidence theory is used to fuse the multi-source information of the detection results. Basic probability assignment is performed on the visual inspection data and environmental parameter data, and the credibility of each evidence source is calculated. Then, the multi-source information is fused based on the combination rules of evidence theory to obtain the comprehensive detection results. A quality traceability database is established based on the comprehensive detection results. By establishing the association between workpiece identification, detection time, defect type and location, a data storage template is generated. The data storage system is deployed using a distributed architecture, and the data is divided into fixed-size data blocks and allocated to multiple storage nodes. Statistical analysis is performed on the data, the defect distribution law and change trend are calculated, and a workpiece quality report is generated.
[0018] Taking the appearance defect detection of mobile phone battery cover as an example, the original image resolution collected by the industrial camera is 1920×1080 pixels. After Gaussian filtering and denoising, the image noise is effectively suppressed. Adaptive histogram equalization divides the image into 64×64 pixel sub-blocks for processing to enhance image contrast and detail performance. The improved Otsu algorithm segments the image and accurately extracts the battery cover area. Edge detection, Hough transform and grayscale co-occurrence matrix extract the size, contour and surface texture features of the battery cover respectively to form a feature vector. The convolutional neural network with attention mechanism trains the feature vector to identify a variety of surface defects including scratches, dents and bubbles. The test results are fused with environmental parameter data for evidence theory, stored and analyzed through a distributed database, and the whole traceability of the battery cover quality is realized. In the embodiment of the present application, the workpiece image is denoised by a Gaussian filtering algorithm, and image segmentation is performed in combination with adaptive histogram equalization and the improved Otsu algorithm, which effectively eliminates image noise interference, enhances the expressiveness of target features, and provides high-quality standardized pre-processed images for subsequent feature extraction. By combining edge detection algorithm, Hough transform and gray-level co-occurrence matrix, the size features, contour features and surface texture features of the workpiece are comprehensively extracted to form a multi-dimensional workpiece feature vector, which fully reflects the appearance feature information of the workpiece. Feature learning is performed through a convolutional neural network with an attention mechanism, and the model parameters are optimized in combination with an improved Adam optimizer. A workpiece defect recognition model with strong generalization ability is constructed, which improves the accuracy and robustness of defect detection. A dynamic threshold mechanism is established based on the probability distribution of defect features to perform real-time detection of workpiece images. The detection parameters can be adaptively adjusted according to the characteristics of different workpieces to improve the flexibility of detection. The Dempster-Shafer evidence theory is used to fuse multi-source information of visual inspection data and environmental parameter data. By considering the impact of environmental factors on the inspection results, the reliability of the inspection results is improved. Finally, a quality traceability database is established using a distributed architecture to achieve efficient storage and retrieval of inspection data. Workpiece quality reports are generated through statistical analysis and data mining. In a specific embodiment, the process of executing step S101 may specifically include the following steps: (1) The workpiece image is captured by industrial cameras at three different angles and converted into a grayscale image; (2) The grayscale image is denoised using a Gaussian filter algorithm, where the kernel size of the Gaussian filter is 5×5 and the standard deviation is set to 1.5; (3) The denoised image is processed by adaptive histogram equalization, and the pixel values of the image are remapped by calculating the grayscale distribution histogram of the image; (4) Use the improved Otsu algorithm to segment the equalized image, determine the optimal segmentation threshold by maximizing the inter-class variance, and segment the image into the target area and the background area; (5) Normalize the segmented image and adjust the pixel value range to the [0, 1] interval; (6) The normalized image is normalized by subtracting the mean and dividing by the standard deviation to obtain a standardized preprocessed image.
[0019] Specifically, image preprocessing is a key link. Three industrial cameras are used to shoot the workpiece from the front, side and 45 degrees respectively. The image resolution of each camera is 1920×1080 pixels, and RGB color images are captured. When converting the acquired color image to a grayscale image, the standard RGB to grayscale formula is used: grayscale value = 0.299×R + 0.587×G +0.114×B, where R, G, and B represent the red, green, and blue component values of the pixel point, respectively. The grayscale image obtained after conversion has a pixel value range between 0 and 255. Gaussian filtering is performed on the converted grayscale image to reduce noise. The core of Gaussian filtering is to construct a 5×5 Gaussian kernel matrix and calculate the weight value of each position in the matrix with a standard deviation of σ=1.5. For each pixel in the image, a weighted average is taken with the pixel values in the surrounding 5×5 neighborhood, and the weight value is determined by the Gaussian kernel matrix. The farther the point is from the center pixel, the smaller the weight value is, thereby effectively suppressing noise interference while retaining image details.
[0020] The denoised image is enhanced by adaptive histogram equalization. The image is divided into multiple 8×8 pixel sub-blocks, and the grayscale histogram is calculated for each sub-block. The grayscale histogram reflects the distribution of pixel values. The cumulative distribution function is obtained by counting the frequency of each grayscale level. The pixel values are remapped based on the cumulative distribution function, and the original grayscale values are mapped to the new grayscale range, so that the grayscale distribution of the image is more uniform. Bilinear interpolation is used for smooth transition at the sub-block boundary to eliminate the block effect. After image enhancement, the improved Otsu algorithm is used for image segmentation. The traditional Otsu algorithm determines the global threshold based on the principle of maximizing the inter-class variance, while the improved algorithm introduces local area information. The specific process is: calculate the grayscale histogram of the image and count the number of pixels at each grayscale level. Then traverse all possible thresholds, and calculate the mean, variance, and inter-class variance of the target area and background area under the current threshold. At the same time, the spatial position relationship of the pixels is considered. For the pixels located in the boundary area, the threshold is dynamically adjusted according to the distribution of pixels in its neighborhood. The threshold that maximizes the inter-class variance is selected as the optimal segmentation threshold to segment the image into the target area and the background area.
[0021] The segmented image needs to be normalized to adjust the pixel value range to the [0,1] interval. The normalization calculation method is: for the original pixel value x, the normalized value is (x-min) / (max-min), where min and max are the minimum and maximum pixel values in the image, respectively. Normalization eliminates the scale differences between different images, making it easier to process them later.
[0022] Standardization is performed to make the data distribution more normalized by subtracting the mean and dividing by the standard deviation. The mean μ and standard deviation σ of all pixel values of the image are calculated, and then each pixel value x is standardized: (x-μ) / σ. Through standardization, a standardized preprocessed image is obtained.
[0023] For example: three industrial cameras collect images of the front, side and 45-degree angle of the battery cover respectively. Through RGB to grayscale processing, a grayscale image reflecting the brightness distribution of the battery cover surface is obtained. Gaussian filtering effectively removes interference caused by factors such as uneven lighting and camera sensor noise. Adaptive histogram equalization enhances the detailed features of the battery cover surface, especially the contrast of subtle defect areas such as scratches and dents. The improved Otsu algorithm accurately segments the battery cover area and eliminates the influence of background and other interference areas. Normalization and standardization processing make images taken from different batches and different angles have unified data distribution characteristics.
[0024] In a specific embodiment, the process of executing step S102 may specifically include the following steps: (1) Perform edge detection on the standardized preprocessed image and generate an image edge gradient map by calculating the gradient value and direction of the image pixel points; (2) Perform non-maximum suppression on the image edge gradient map, compare the gradient values of each pixel with those of its adjacent points in the gradient direction, retain the local maximum point, and generate the workpiece size feature; (3) Perform Hough transform on the standardized preprocessed image, map the straight line in the image space to the parameter space through polar coordinate transformation, and generate accumulator space data; (4) Extract the local peak points in the accumulator space data and convert them into straight line parameters in the image space through reverse mapping to generate the workpiece contour features; (5) Extract the gray-level co-occurrence matrix from the standardized preprocessed image, and obtain the texture feature data by calculating the spatial correlation and gray-level value distribution of pixel pairs; (6) The workpiece size feature, workpiece contour feature and texture feature data are combined and normalized to obtain the workpiece feature vector.
[0025] Specifically, when edge detection is performed on a standardized preprocessed image, the Sobel operator is used to calculate the gradients in the horizontal and vertical directions. For each pixel (x, y) in the image, its gradient values Gx and Gy in the x and y directions are calculated, and then the gradient magnitude and direction angle are obtained. The gradient magnitude indicates the edge strength, and the direction angle indicates the edge direction. These data constitute the image edge gradient map.
[0026] For the non-maximum suppression processing of the image edge gradient map, the mathematical expression is defined:
[0027] in, represents the gradient value after non-maximum suppression, is the original gradient value, Represents the set of adjacent points in the gradient direction θ. By comparing the gradient values of each pixel with its adjacent points in the gradient direction, the local maximum point is retained to generate the workpiece size feature.
[0028] When performing Hough transform on the standardized preprocessed image, the following mapping relationship is used:
[0029] in, is the vertical distance from the line to the origin, is the angle between the vertical line and the x-axis, (x, y) is the point coordinate in the image space, β is the scale factor, is the workpiece feature distance. This formula maps the straight line in the image space to the parameter space and generates the accumulator space data.
[0030] The process of extracting local peak points from the accumulator spatial data includes the following steps: setting a threshold and finding elements in the accumulator array that are greater than the threshold; then performing a maximum value search in the local neighborhood of these elements; converting the local peak points found back to the image space through an inverse transform to obtain the line parameters, and then generating the workpiece contour features. For texture feature extraction, the spatial correlation of pixel pairs is analyzed by calculating the gray level co-occurrence matrix. The gray level co-occurrence matrix is a statistical tool that records the frequency of occurrence of gray value pairs with a specific spatial relationship in an image. When calculating, the distance and direction parameters are selected, and then the number of pixel pairs that meet these parameters appearing in the image is counted to form a co-occurrence matrix. Statistical features such as contrast, correlation, and energy are extracted from the co-occurrence matrix to obtain texture feature data.
[0031] Perform feature fusion to combine the workpiece size feature, workpiece contour feature, and texture feature data. Since different types of features have different numerical ranges and physical meanings, the feature data needs to be normalized so that they are distributed in the same numerical range. The normalized feature data is combined into a vector in a predefined order to form a workpiece feature vector.
[0032] For example, in the edge detection stage, the gradient map calculated by the Sobel operator clearly shows the edge contour of the battery cover. The non-maximum suppression process refines the blurred edge lines into precise edges with a single pixel width. The Hough transform converts these edge points into parameter space and counts the straight line features through the accumulator array. In actual processing, considering the geometric features of the battery cover, a suitable parameter threshold is set to accurately extract the straight line boundary of the battery cover. At the same time, the texture features of the battery cover surface are analyzed by calculating the gray level co-occurrence matrix to obtain the feature parameters reflecting the surface texture. These features are combined into a unified feature vector to fully describe the shape, size and surface features of the battery cover. This multi-feature fusion method makes full use of various feature information of the workpiece and provides a reliable data basis for subsequent defect detection. When processing actual data, edge detection calculates the gradient value of the image. For example, for a pixel point in a local area, its horizontal and vertical gradient values are calculated to obtain the gradient amplitude and direction angle. Then, the non-maximum suppression algorithm is used to compare the gradient value of the point with the adjacent points in the gradient direction, and only the local maximum point is retained. In the Hough transform process, the spatial coordinates of the edge points are mapped to the parameter space, and the frequency of occurrence of different parameter combinations is recorded through the accumulator array. For texture features, four directions of 0 degrees, 45 degrees, 90 degrees and 135 degrees are selected to count the co-occurrence frequency of pixel pairs, and a gray-level co-occurrence matrix is constructed to extract statistics reflecting texture characteristics. All features are combined in a predefined order to form a vector that describes the complete features of the workpiece.
[0033] In a specific embodiment, the process of executing step S103 may specifically include the following steps: (1) Organize the workpiece feature vectors in batches, divide the data into training set and validation set by random sampling, and generate a training data matrix; (2) Input the training data matrix into the convolutional layer with attention mechanism, and generate the attention-weighted feature map by calculating the spatial attention weight and channel attention weight of the feature map; (3) Perform nonlinear transformation and pooling operations on the attention-weighted feature map, and obtain a feature map sequence by calculating the activation function and the maximum pooling response; (4) The feature map sequence is fused through the fully connected layer, and the fused feature data is generated by calculating the product of the weight matrix and the input feature; (5) Calculate the loss function value based on the fused feature data, iteratively update the parameters through the improved Adam optimizer to obtain the optimized network parameters; (6) The optimized network parameters are saved as a workpiece defect recognition model, which includes network structure parameters and weight parameters.
[0034] Specifically, the workpiece feature vectors are organized in batches, and all sample data are grouped according to a fixed batch size. The data set is divided into a training set and a validation set by a random sampling method, with the training set accounting for 80% of the total data volume and the validation set accounting for 20%. The data of each batch is organized into a training data matrix, and each row of the matrix represents the feature vector of a sample. When the training data matrix is processed by the attention mechanism, features are extracted through a convolution layer with an attention mechanism. The input of the convolution layer is the training data matrix, and the input data is convolved by the set convolution kernel to generate an initial feature map. Then the spatial attention weight of the feature map is calculated. The spatial attention mechanism focuses on the importance of different spatial positions in the feature map. By calculating the attention coefficient of each spatial position, different weights are assigned to different areas of the feature map. At the same time, the channel attention weight is calculated. The channel attention mechanism focuses on the importance of different feature channels. By calculating the attention coefficient of each channel, different weights are assigned to different feature channels. The spatial attention weight and the channel attention weight are multiplied with the original feature map to obtain the attention-weighted feature map.
[0035] The attention-weighted feature map is subjected to nonlinear transformation and pooling operations. The nonlinear transformation uses the ReLU activation function to process each element in the feature map: when the input is greater than 0, the output is equal to the input; when the input is less than or equal to 0, the output is 0. This nonlinear transformation enhances the expressive power of the model. The feature map is then downsampled through the maximum pooling operation, and the maximum value in each 2×2 window is selected as the output to generate a feature map sequence.
[0036] The feature map sequence is input into the fully connected layer for feature fusion. The fully connected layer converts the input features into a vector of fixed dimension through the weight matrix. Each element in the weight matrix represents the connection strength between the input feature and the output feature. The product of the weight matrix and the input feature is calculated by matrix multiplication, and then the bias term is added to obtain the fused feature data. The loss function value is calculated based on the fused feature data. The loss function uses the cross entropy loss to measure the difference between the predicted result and the true label. Then the improved Adam optimizer is used to iteratively update the network parameters. The Adam optimizer combines the advantages of momentum and adaptive learning rate. In each iteration, the network parameters are updated according to the gradient information of the loss function. Through multiple rounds of iterative training, the network parameters are continuously adjusted until the loss function converges to obtain the optimized network parameters.
[0037] The optimized network parameters are saved as a workpiece defect recognition model, such as Figure 3 As shown, it is a schematic diagram of the network structure of the workpiece defect recognition model in the embodiment of the present application, from left to right: feature vector input layer, receiving multi-dimensional feature data of the workpiece; attention mechanism convolution layer, including two sub-modules of spatial attention and channel attention, weighting the spatial position and channel dimension of the feature respectively; ReLU activation and pooling layer, performing nonlinear transformation and feature dimension reduction; fully connected layer, realizing deep fusion of features; finally, the defect recognition result is obtained through the output layer. The layers are connected by arrows, indicating the flow direction of data, forming a complete deep learning network structure. The saved model file contains two parts: network structure parameters and weight parameters. The network structure parameters describe the hierarchical structure, connection mode and other information of the model, and the weight parameters store the weights and bias values of each layer of the network. These parameters jointly determine how the model works.
[0038] For example: collect a data set containing normal samples and various defective samples, and extract feature vectors containing size features, contour features, and texture features for each sample. After randomly dividing the data set, each batch contains feature vectors of 32 samples. These feature vectors are processed by the convolution layer of the attention mechanism to generate feature maps that highlight important features. The feature map is subjected to nonlinear transformation and pooling operations to extract key feature information. The fully connected layer fuses these features into a vector of fixed dimension for defect classification. The difference between the predicted value and the true label is calculated through the loss function, and the network parameters are adjusted using the Adam optimizer. The resulting model can accurately identify defects such as scratches, dents, and bubbles on the surface of the battery cover.
[0039] In a specific embodiment, the process of executing step S104 may specifically include the following steps: (1) Perform data block processing on the standardized preprocessed image, divide the image into multiple overlapping sub-regions using the sliding window method, and generate an image sub-block sequence; (2) Input the image sub-block sequence into the workpiece defect recognition model, and generate a defect feature map by calculating the feature response value of each sub-block; (3) Perform probability statistical analysis on the defect feature map and generate defect feature probability distribution data by calculating the defect probability value of each feature point; (4) Calculate statistics based on the defect feature probability distribution data, and obtain dynamic threshold parameters by analyzing the mean and standard deviation of the defect probability; (5) Compare the dynamic threshold parameters with the defect feature map, identify the defect area through threshold judgment, and generate defect detection data; (6) Perform spatial position mapping and feature clustering on the defect detection data, and obtain preliminary detection results by integrating the defect information of adjacent areas.
[0040] Specifically, the processing of the standardized preprocessed image uses the sliding window method to perform data block division. The size of the sliding window is set to 64×64 pixels, and the step size is 32 pixels, that is, there is a 50% overlap area between two adjacent windows. For the original image with a resolution of 1920×1080, a series of overlapping sub-regions are obtained by sliding window division to form an image sub-block sequence. The design of the overlapping area ensures the complete capture of the defect boundary area and avoids the loss of defect features at the sub-block boundary. The generated image sub-block sequence is input into the trained workpiece defect recognition model. The model extracts features and identifies defects for each sub-block and outputs the feature response value of each sub-block. The feature response value reflects whether there is a defect in the sub-block and the type and severity of the defect. By reorganizing the feature response values of all sub-blocks according to their original spatial positions, a complete defect feature map is generated. The defect feature map retains the spatial structure information of the original image and contains the defect feature information of each area.
[0041] When performing probability statistical analysis on the defect feature map, the defect probability value of each feature point is calculated. The defect probability value is obtained by analyzing the distribution characteristics of the characteristic response value, which reflects the possibility that the point is a defect. For overlapping areas, the probability values of multiple sub-blocks are combined by weighted averaging, and the weight is inversely proportional to the distance from the pixel point to the center of the sub-block. In this way, complete defect feature probability distribution data is generated. After obtaining the defect feature probability distribution data, the statistics are calculated to determine the dynamic threshold parameters. The mean and standard deviation of the defect probability values in the entire image area are calculated. The mean reflects the overall defect level, and the standard deviation reflects the degree of discreteness of the defect distribution. Based on these statistics, the initial threshold is set, and the threshold is dynamically adjusted according to the characteristic distribution of the local area to obtain dynamic threshold parameters that adapt to the characteristics of different regions.
[0042] Compare the dynamic threshold parameters with the defect feature map, and determine whether the point belongs to the defect area by comparing the feature value of each point with the corresponding dynamic threshold. For points whose feature values exceed the threshold, mark them as potential defect points. At the same time, consider spatial continuity, combine adjacent defect points into defect areas, and generate complete defect detection data. Perform spatial position mapping and feature clustering on the defect detection data. Spatial position mapping maps the detected defect points back to the original image coordinate system to determine the specific location of the defect. Feature clustering aggregates related defect points into complete defect areas based on the spatial proximity and feature similarity of defect points. By analyzing the clustering results, merge adjacent defect areas, eliminate duplicate detection, and obtain accurate preliminary detection results.
[0043] For example, for a battery cover with a size of 120mm×60mm, the image resolution collected by the industrial camera is 1920×1080 pixels. A sliding window of 64×64 pixels and a step size of 32 pixels are used to divide the standardized preprocessed image into blocks to generate a sequence of sub-blocks containing adjacent 50% overlapping areas. After each sub-block is input into the defect recognition model, a response value reflecting the defect characteristics is obtained. These response values are reorganized to form a feature map with the same size as the original image. The defect probability is calculated for each point in the feature map, and the overlapping area merges the results of multiple sub-blocks by distance weighted averaging. By analyzing the probability distribution characteristics, the overall mean and standard deviation are calculated, and the benchmark threshold is set accordingly, and dynamically adjusted according to the local area characteristics. The adjusted threshold is compared with the feature value to identify potential defect points. Through spatial position mapping and feature clustering, adjacent defect points are combined into a complete defect area to obtain detection results containing information such as defect location, type, and area.
[0044] In a specific embodiment, the process of executing step S105 may specifically include the following steps: (1) Extract inspection parameter data based on preliminary inspection results, convert defect inspection data into standardized probability values through numerical mapping, and generate visual inspection data; (2) Collect temperature, humidity and light intensity data through multiple environmental sensors, standardize the temperature, humidity and light intensity data, and generate environmental parameter data; (3) Perform basic probability assignment on visual inspection data and obtain the visual inspection evidence matrix by calculating the credibility of each evidence source; (4) Assign basic probabilities to environmental parameter data and obtain the environmental parameter evidence matrix by calculating the degree of influence of environmental parameters on the test results; (5) Based on the Dempster-Shafer evidence theory, the visual detection evidence matrix and the environmental parameter evidence matrix are combined and the fused evidence data is generated by calculating the combined probability mass; (6) Perform decision analysis on the fused evidence data and obtain comprehensive detection results by calculating the confidence interval and uncertainty interval.
[0045] Specifically, the detection parameter data, including defect location, area, grayscale value, gradient and other features, are extracted from the preliminary detection results. By establishing a numerical mapping relationship, these detection data are converted into standardized probability values in the range of 0-1. The mapping process takes into account the physical meaning and dimensions of different parameters to ensure that the converted data are comparable, thereby generating standardized visual inspection data. Temperature sensors, humidity sensors and light intensity sensors are installed in the detection environment to collect environmental parameters in real time. The measuring range of the temperature sensor is -10℃ to 50℃, the measuring range of the humidity sensor is 0% to 100%, and the measuring range of the light intensity sensor is 0 to 100000lux. The collected environmental data is standardized, and the data of different dimensions are uniformly mapped to the 0-1 interval to generate standardized environmental parameter data.
[0046] The standardized visual inspection data is assigned basic probabilities, and a credibility assessment model is established by analyzing historical data. The basic probability assignment takes into account factors such as the confidence, stability, and consistency of the inspection results, calculates the credibility of each inspection feature as an evidence source, and constructs a visual inspection evidence matrix.
[0047] Basic probability assignment is also performed on environmental parameter data to evaluate the impact of environmental factors on the test results. By establishing a mapping relationship between environmental parameters and test reliability, the uncertainty of the test results under different environmental conditions is calculated to generate an environmental parameter evidence matrix.
[0048] Based on the Dempster-Shafer evidence theory, the two evidence matrices are fused, and the fusion calculation formula is:
[0049] in, represents the visual detection evidence matrix, represents the environmental parameter evidence matrix, is the weight of evidence, is the visual detection probability value, is the environmental influencing factor, n and m are the dimensions of visual features and environmental parameters respectively.
[0050] Perform decision analysis on the fused evidence data and calculate the confidence interval:
[0051] in, Represents the set of detection results, is the probability mass of the fused evidence, is the decision rule weight, is the support index, and p is the number of decision rules.
[0052] For example: visual inspection identifies a scratch defect, and its location, length, depth and other features are converted into standardized probability values. At the same time, environmental monitoring shows that the temperature is 25°C, the relative humidity is 60%, and the light intensity is 5000 lux. After standardization, the environmental parameter data is obtained. Basic probability values are assigned to the visual inspection data, and the visual evidence matrix is calculated considering the significance and consistency of the defect characteristics. Probability values are assigned to the environmental parameter data, the influence of the current environmental conditions on defect detection is evaluated, and the environmental evidence matrix is generated. The two evidence matrices are fused through DS theory, the combined probability mass is calculated, and the confidence interval analysis is combined to determine the reliability of the defect detection result and form a comprehensive detection result.
[0053] In a specific embodiment, the process of executing step S106 may specifically include the following steps: (1) Construct a data table structure based on the comprehensive inspection results, and generate a data storage template by establishing the association between workpiece identification, inspection time, defect type, and defect location; (2) Distribute the data storage templates, distribute the data to multiple storage nodes through the master-slave architecture, and establish a quality traceability database; (3) Extract the inspection parameters from the comprehensive inspection results and generate statistical analysis data by calculating the defect distribution frequency and defect severity; (4) Perform time series analysis on the statistical analysis data, and obtain trend prediction results by calculating the change trend and periodic characteristics of the detection parameters; (5) Write statistical analysis data and trend prediction results into the quality traceability database, establish test records through data indexing, and form a test data archive; (6) Perform data aggregation and visualization based on the inspection data archive, and obtain a workpiece quality report by generating defect distribution charts and quality trend curves.
[0054] Specifically, the data table includes a main table and multiple associated tables. The main table stores the basic information of the workpiece, including fields such as workpiece ID, production batch, and production time; the associated table stores detection-related information, including fields such as detection time, detection equipment, and detection results. By establishing foreign key constraints, the workpiece identification is associated with the detection data. For defect information, a defect table is specially designed to record characteristic parameters such as defect type, location coordinates, and area size. All these table structures together constitute a data storage template. The data storage template is deployed using a distributed architecture, dividing the database into a master node and multiple slave nodes. The master node is responsible for data writing operations and data consistency maintenance, and the slave node is responsible for data reading operations. Through data sharding technology, data from different time periods or batches are allocated to different storage nodes. Each storage node is configured with independent storage space and processing resources, and the reliability of data is ensured through a data replication mechanism. This distributed architecture forms a complete quality traceability database.
[0055] When extracting test parameters from comprehensive test results for statistical analysis, the defect data is classified and counted. The frequency of occurrence is counted according to the defect type, and the proportion of each type of defect in the total test volume is calculated. For each defect type, its severity is analyzed, and the defect scoring mechanism is established by comprehensively considering the characteristic parameters such as defect area, depth, and location. Through these statistical indicators, statistical analysis data reflecting the current quality status is generated. Time series analysis is performed on the statistical analysis data to study the change pattern of the test parameters over time. The test data is organized according to the time dimension, and the change trend under different time scales is analyzed. The short-term trend is calculated by the sliding window method to identify the periodic fluctuation characteristics. The time series analysis method is used to establish a trend prediction model to predict the quality change trend in the future.
[0056] When writing statistical analysis data and trend prediction results into the quality traceability database, they are stored in a predefined data format. To improve data retrieval efficiency, a multi-level index structure is established, including time index, workpiece index, and defect type index. Each inspection record contains complete inspection process information, forming an inspection data archive. A workpiece quality report is generated based on the stored inspection data archive. The quality report contains analysis results in multiple dimensions: the defect distribution diagram shows the spatial distribution characteristics of different types of defects; the quality trend curve reflects the changing trends of various indicators; the defect statistics table lists detailed statistical data. Through these intuitive charts, the quality status of the workpiece is fully displayed.
[0057] For example: Each battery cover has a unique QR code to record its production batch and time information. The specific parameters of each test are recorded in the test data table, including the test time, defect characteristics, etc. When a scratch defect is detected, the database records its location coordinates, length, depth and other characteristic parameters. These raw data are statistically analyzed to obtain the defect distribution of the batch of products. Through time series analysis, it is found that the frequency of defects occurs more frequently in a specific period of time, and historical data is combined to predict future quality trends. The generated quality report intuitively displays the defect distribution and trend changes, providing data support for quality improvement. This complete data management solution realizes the traceability of the entire process from detection to analysis, ensuring the reliability and effectiveness of quality management.
[0058] In a specific embodiment, the process of executing the distributed deployment step of the data storage template may specifically include the following steps: (1) Perform data sharding on the data storage template to generate a data sharding sequence by dividing the data into data blocks of fixed size; (2) Perform load calculation on the data shard sequence and obtain a resource allocation plan by evaluating the storage capacity and processing power of each storage node; (3) Map the resource allocation scheme to the master-slave architecture and generate a node allocation table by setting a topological structure of a master node and multiple slave nodes; (4) Distribute the data shard sequence according to the node allocation table, and obtain distributed storage data through data replication and synchronization mechanism; (5) Establish an index structure for distributed storage data and generate a data retrieval table by constructing a primary key index and associated index; (6) Distribute the data retrieval table to each storage node, synchronize it through the data consistency protocol, and establish a quality traceability database.
[0059] Specifically, when sharding the data storage template, the sharding strategy is determined according to the characteristics of the data. The data is divided into fixed-size data blocks, each of which contains a complete set of records. The size of the shard is determined according to the processing power of the storage node, and is usually set to 64MB or 128MB. For detection data, sharding is performed according to the time dimension, and each shard contains detection records within a certain time range. The sharded data forms an ordered sequence of data shards. The load calculation is performed on the generated data shard sequence to evaluate the resource situation of the storage node. The evaluation indicators of the storage node include parameters such as storage capacity, processor performance, memory size, and network bandwidth. Based on these parameters, the load bearing capacity of each node is calculated, and a reasonable resource allocation plan is formulated in combination with the size and access frequency of the data shards. The resource allocation plan clearly specifies which storage node each shard should be allocated to.
[0060] Map the resource allocation plan to the specific master-slave architecture and design the topology of the data nodes. The master node is responsible for data writing and distribution control, and the slave node is responsible for data storage and query services. For each master node, configure multiple slave nodes to form data copies and provide data redundancy backup. Record the storage location of each shard in the node allocation table, including the location of the master copy and the location of the backup copy. Distribute data according to the node allocation table, and use data replication and synchronization mechanisms to ensure data consistency. When a new data shard is generated, it is written to the master node, and then the master node synchronizes the data to the corresponding slave node. Data synchronization uses asynchronous replication to ensure data consistency while reducing synchronization delays. The master and slave nodes maintain connection through the heartbeat mechanism to detect node status in a timely manner.
[0061] A multi-level index structure is established for distributed stored data to speed up data retrieval. The primary key index is established based on the workpiece ID to support the rapid location of the inspection record of a single workpiece. The associated index is created based on fields such as inspection time and defect type to support complex query conditions. The index structure is implemented using a B+ tree, and the index data is stored in memory to increase the retrieval speed. The constructed data retrieval table is distributed to each storage node, and the synchronous update of the index data is ensured through the data consistency protocol. When the index changes, the change information will be broadcast to all relevant nodes, and each node will update the index according to the predetermined protocol. This distributed index mechanism constitutes a complete quality traceability database.
[0062] For example, a production line generates 100,000 inspection records every day, each of which contains basic information about the workpiece, inspection parameters, defect characteristics and other data. These data are sharded into time segments of 4 hours each, and each shard contains about 16,000 records. By evaluating the resource status of the storage node, the shards are allocated to nodes with sufficient storage space and processing power. The master node receives the inspection data generated in real time and synchronizes the data to the corresponding slave node. In order to quickly retrieve the inspection records of a specific workpiece, a primary key index based on the workpiece ID and a range index based on the inspection time are established. When it is necessary to query defect statistics within a certain time period, the relevant shards are located through the time index to quickly obtain the required inspection records. This distributed storage architecture effectively manages massive inspection data and supports efficient data storage and retrieval operations.
[0063] In a specific embodiment, the process of executing the step of mapping the resource allocation scheme to the master-slave architecture may specifically include the following steps: (1) Divide the resource allocation scheme into node roles and generate a node role table by setting the master-slave attributes and priority weights of the nodes; (2) Map the node role table to the network topology structure, and obtain the topological connection diagram by establishing communication links and data transmission paths between nodes; (3) Perform reachability analysis on the topological connection graph and generate routing strategy data by calculating the shortest path and backup path between nodes; (4) Data traffic planning is performed based on routing policy data. The traffic allocation matrix is obtained by calculating the data transmission load and bandwidth requirements between nodes. (5) Optimize the traffic distribution matrix and generate a load balancing strategy by balancing the data transmission pressure between nodes; (6) Integrate the load balancing strategy with the node role table, and generate a node allocation table by establishing a mapping relationship between node identification and resource configuration.
[0064] Specifically, the role of each storage node is defined, and the nodes are divided into two types: master node and slave node. The master node is responsible for data writing and distribution control, and has the highest priority weight; the slave node is responsible for data backup and query services, and different priority weights are set according to its hardware configuration and network conditions. The specific attributes of each node are recorded in the node role table, including information such as node ID, role type, priority weight, etc. When converting the node role table into an actual network topology, it is necessary to establish communication links between nodes. The communication link defines the physical path for data transmission, including the data synchronization path from the master node to the slave node, and the data replication path between the slave nodes. Each communication link has its bandwidth capacity and delay characteristics, and these parameters determine the performance of data transmission. By planning the communication links, a complete topological connection diagram is drawn.
[0065] Perform reachability analysis on the topology connection graph to determine the optimal path for data transmission. Use the Dijkstra shortest path algorithm to calculate the shortest path between any two nodes. At the same time, in order to improve system reliability, it is also necessary to calculate the suboptimal path as a backup path. Organize these path information into routing policy data, which contains complete information about the primary path and the backup path. Plan the data traffic distribution based on the routing policy data. Count the data write and read requests for each node, including real-time writing of detection data and query of historical data. Calculate the data transmission load on each communication link based on the request volume and data volume. At the same time, evaluate the bandwidth requirements of each node and generate a traffic allocation matrix that reflects the data traffic distribution.
[0066] Optimize the traffic distribution matrix to avoid overload on certain nodes or links. The goal of optimization is to make the load of each node as balanced as possible while ensuring that the data transmission delay meets the requirements. By adjusting the distribution and replication strategy of data shards, the data transmission pressure of each node is balanced to form a load balancing strategy. Integrate the load balancing strategy with the node role table to establish a complete node allocation plan. The plan defines in detail the functional role, resource configuration, data distribution and other information of each node, which is organized into a node allocation table. The node allocation table is an important configuration basis for database operation and guides the data storage and access process.
[0067] For example, the test line contains three test stations, each station is equipped with a data collection node, and these nodes serve as data sources to continuously generate test data. In the storage layer, one master node and four slave nodes are set up. The master node has the highest priority and is responsible for receiving all write requests for test data; the four slave nodes are assigned different priority weights according to their hardware configurations and are responsible for data backup and query services. The nodes are connected through Gigabit Ethernet to form a star topology. There is a direct communication link from the master node to each slave node, and backup links are also established between the slave nodes. Through reachability analysis, the optimal path for data replication is determined: the master node preferentially uses the direct link to synchronize data to the slave node. When the direct link is congested, data can be transferred through other slave nodes. According to the generation rate and query frequency of the test data, the data traffic distribution of each link is calculated. Through the load balancing algorithm, the data fragments are evenly distributed to the four slave nodes to avoid excessive load on a single node. The node allocation table records the responsibilities and resource allocation plan of each node in detail.
[0068] The above describes the industrial object appearance detection method based on machine vision in the embodiment of the present application. The following describes the industrial object appearance detection system based on machine vision in the embodiment of the present application. Figure 4 In the embodiments of the present application, an industrial article appearance detection system based on machine vision includes: The acquisition module 201 is used to acquire workpiece images based on an industrial camera, perform noise reduction processing on the workpiece images through a Gaussian filtering algorithm, perform image enhancement through adaptive histogram equalization, and perform image segmentation using an improved Otsu algorithm to obtain a standardized preprocessed image; An extraction module 202 is used to extract workpiece size features using an edge detection algorithm based on the standardized preprocessed image, extract workpiece contour features through Hough transform, and extract workpiece surface texture features based on a gray level co-occurrence matrix to obtain a workpiece feature vector; A training module 203 is used to use the workpiece feature vector to perform model training through a convolutional neural network with an attention mechanism, and use an improved Adam optimizer to optimize the model parameters to obtain a workpiece defect recognition model; Establishing module 204, for inputting the standardized pre-processed image into the workpiece defect recognition model, establishing a dynamic threshold mechanism based on the probability distribution of defect features, performing real-time detection on the workpiece image, and obtaining preliminary detection results; A fusion module 205 is used to perform multi-source information fusion on the visual detection data and the environmental parameter data according to the preliminary detection results using the Dempster-Shafer evidence theory to obtain a comprehensive detection result; The storage module 206 is used to establish a quality traceability database through a distributed architecture based on the comprehensive test results, perform statistical analysis and storage on the test data, and generate a workpiece quality report.
[0069] Through the cooperation of the above components, the workpiece image is denoised by Gaussian filtering algorithm, and image segmentation is performed by combining adaptive histogram equalization and improved Otsu algorithm, which effectively eliminates image noise interference, enhances the expressiveness of target features, and provides high-quality standardized preprocessed images for subsequent feature extraction. The size features, contour features and surface texture features of the workpiece are comprehensively extracted by combining edge detection algorithm, Hough transform and gray-level co-occurrence matrix to form a multi-dimensional workpiece feature vector, which fully reflects the appearance feature information of the workpiece. Feature learning is performed by convolutional neural network with attention mechanism, and the model parameters are optimized by improved Adam optimizer. A workpiece defect recognition model with strong generalization ability is constructed, which improves the accuracy and robustness of defect detection. A dynamic threshold mechanism is established based on the probability distribution of defect features to detect workpiece images in real time. The detection parameters can be adaptively adjusted according to the characteristics of different workpieces to improve the flexibility of detection. Dempster-Shafer evidence theory is used to fuse multi-source information of visual inspection data and environmental parameter data. The reliability of the detection results is improved by considering the influence of environmental factors on the detection results. Finally, a quality traceability database was established using a distributed architecture, which enabled efficient storage and retrieval of inspection data, and generated workpiece quality reports through statistical analysis and data mining.
[0070] The present application also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores instructions, and when the instructions are executed on a computer, the computer executes the steps of the method for detecting the appearance of industrial objects based on machine vision.
[0071] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described systems, systems and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0072] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0073] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for detecting the appearance of industrial objects based on machine vision, characterized in that: The industrial article appearance detection method based on machine vision includes: Based on the industrial camera, the workpiece image is collected, the noise of the workpiece image is reduced by using the Gaussian filtering algorithm, the image is enhanced by adaptive histogram equalization, and the image is segmented by using the improved Otsu algorithm to obtain a standardized preprocessed image; According to the standardized preprocessed image, the workpiece size feature is extracted by using an edge detection algorithm, the workpiece contour feature is extracted by using a Hough transform, and the workpiece surface texture feature is extracted based on a gray level co-occurrence matrix to obtain a workpiece feature vector; Using the workpiece feature vector, a convolutional neural network with an attention mechanism is used to train the model, and an improved Adam optimizer is used to optimize the model parameters to obtain a workpiece defect recognition model; Inputting the standardized preprocessed image into the workpiece defect recognition model, establishing a dynamic threshold mechanism based on the probability distribution of defect features, performing real-time detection on the workpiece image, and obtaining preliminary detection results; Based on the preliminary detection results, the Dempster-Shafer evidence theory is used to perform multi-source information fusion on the visual detection data and the environmental parameter data to obtain a comprehensive detection result; Based on the comprehensive test results, a quality traceability database is established through a distributed architecture, the test data is statistically analyzed and stored, and a workpiece quality report is generated.
2. The method for detecting the appearance of industrial articles based on machine vision according to claim 1, characterized in that: The workpiece image is collected based on an industrial camera, the workpiece image is subjected to noise reduction processing by a Gaussian filtering algorithm, the image is enhanced by an adaptive histogram equalization, and the image is segmented by an improved Otsu algorithm to obtain a standardized preprocessed image, including: Capturing images of the workpiece using three industrial cameras at different angles, and converting the workpiece images into grayscale images; The grayscale image is subjected to noise reduction processing by using a Gaussian filter algorithm, wherein the kernel size of the Gaussian filter is 5×5 and the standard deviation is set to 1.5; The image after noise reduction is processed by adaptive histogram equalization, and the pixel values of the image are remapped by calculating the grayscale distribution histogram of the image; The improved Otsu algorithm is used to segment the equalized image. The optimal segmentation threshold is determined by maximizing the inter-class variance and the image is segmented into the target area and the background area. Normalize the segmented image and adjust the pixel value range to the [0,1] interval; The normalized image is subjected to standardization processing, and the standardized pre-processed image is obtained by subtracting the mean and dividing by the standard deviation.
3. The method for detecting the appearance of industrial articles based on machine vision according to claim 1, characterized in that: The process of extracting workpiece size features by edge detection algorithm based on the standardized preprocessed image, extracting workpiece contour features by Hough transform, and extracting workpiece surface texture features based on gray-level co-occurrence matrix to obtain a workpiece feature vector includes: Performing edge detection on the standardized preprocessed image, and generating an image edge gradient map by calculating the gradient value and direction of the image pixel points; The image edge gradient map is subjected to non-maximum suppression processing, and the local maximum point is retained by comparing the gradient value of each pixel point with the gradient value of the adjacent point in the gradient direction, so as to generate the workpiece size feature; Performing Hough transformation on the standardized preprocessed image, mapping the straight line in the image space to the parameter space through polar coordinate transformation, and generating accumulator space data; Extracting local peak points from the accumulator spatial data, converting them into straight line parameters in the image space through reverse mapping, and generating workpiece contour features; Extracting a gray level co-occurrence matrix from the standardized pre-processed image, and obtaining texture feature data by calculating the spatial correlation and gray value distribution of pixel pairs; The workpiece size feature, the workpiece contour feature and the texture feature data are spliced and combined, and normalized to obtain the workpiece feature vector.
4. The method for detecting the appearance of industrial articles based on machine vision according to claim 1, characterized in that: The workpiece feature vector is used to train the model through a convolutional neural network with an attention mechanism, and the improved Adam optimizer is used to optimize the model parameters to obtain a workpiece defect recognition model, including: The workpiece feature vectors are organized in batches, and the data are divided into a training set and a validation set by random sampling to generate a training data matrix; Input the training data matrix into a convolutional layer with an attention mechanism, and generate an attention-weighted feature map by calculating the spatial attention weight and channel attention weight of the feature map; Performing nonlinear transformation and pooling operations on the attention weighted feature map, and obtaining a feature map sequence by calculating an activation function and a maximum pooling response; The feature map sequence is subjected to feature fusion through a fully connected layer, and fusion feature data is generated by calculating the product of a weight matrix and an input feature; Calculating the loss function value based on the fused feature data, iteratively updating the parameters through the improved Adam optimizer to obtain optimized network parameters; The optimized network parameters are saved as the workpiece defect recognition model, which includes network structure parameters and weight parameters.
5. The method for detecting the appearance of industrial articles based on machine vision according to claim 1, characterized in that: The step of inputting the standardized preprocessed image into the workpiece defect recognition model, establishing a dynamic threshold mechanism based on the probability distribution of defect features, and performing real-time detection on the workpiece image to obtain preliminary detection results includes: Performing data block processing on the standardized preprocessed image, dividing the image into a plurality of overlapping sub-regions by a sliding window method, and generating an image sub-block sequence; Inputting the image sub-block sequence into the workpiece defect recognition model, and generating a defect feature map by calculating the feature response value of each sub-block; Performing probability statistical analysis on the defect feature graph, and generating defect feature probability distribution data by calculating the defect probability value of each feature point; Calculating statistics based on the defect feature probability distribution data, and obtaining dynamic threshold parameters by analyzing the mean and standard deviation of the defect probability; Comparing the dynamic threshold parameter with the defect feature map, identifying the defect area through threshold judgment, and generating defect detection data; The defect detection data is spatially mapped and feature clustered, and the preliminary detection result is obtained by integrating the defect information of adjacent areas.
6. The method for detecting the appearance of industrial articles based on machine vision according to claim 1, characterized in that: According to the preliminary detection results, the Dempster-Shafer evidence theory is used to perform multi-source information fusion on the visual detection data and the environmental parameter data to obtain a comprehensive detection result, including: Extracting detection parameter data according to the preliminary detection results, converting defect detection data into standardized probability values through numerical mapping, and generating visual inspection data; Collect temperature, humidity and light intensity data through multiple environmental sensors, standardize the temperature, humidity and light intensity data, and generate the environmental parameter data; Performing basic probability assignment on the visual inspection data, and obtaining a visual inspection evidence matrix by calculating the credibility of each evidence source; Performing basic probability assignment on the environmental parameter data, and obtaining an environmental parameter evidence matrix by calculating the degree of influence of the environmental parameters on the detection results; Based on the Dempster-Shafer evidence theory, the visual detection evidence matrix and the environmental parameter evidence matrix are combined and operated, and fusion evidence data is generated by calculating the combined probability mass; A decision analysis is performed on the fused evidence data, and the comprehensive detection result is obtained by calculating the confidence interval and the uncertainty interval.
7. The method for detecting the appearance of industrial articles based on machine vision according to claim 1, characterized in that: Based on the comprehensive test results, a quality traceability database is established through a distributed architecture, the test data is statistically analyzed and stored, and a workpiece quality report is generated, including: Building a data table structure based on the comprehensive detection results, and generating a data storage template by establishing an association between workpiece identification, detection time, defect type and defect location; Distributed deployment of the data storage template is performed, and data is distributed to multiple storage nodes through a master-slave architecture to establish the quality traceability database; Extracting detection parameters from the comprehensive detection results, and generating statistical analysis data by calculating defect distribution frequency and defect severity; Performing time series analysis on the statistical analysis data, and obtaining trend prediction results by calculating the change trend and periodic characteristics of the detection parameters; Writing the statistical analysis data and the trend prediction results into the quality traceability database, establishing test records through data indexing, and forming a test data archive; Data aggregation and visualization processing are performed based on the detection data archive, and the workpiece quality report is obtained by generating a defect distribution chart and a quality trend curve.
8. The method for detecting the appearance of industrial articles based on machine vision according to claim 7, characterized in that: The distributed deployment of the data storage template, distributing the data to multiple storage nodes through a master-slave architecture, and establishing the quality traceability database include: Performing data slicing processing on the data storage template, and generating a data slicing sequence by dividing the data into data blocks of fixed sizes; Perform load calculation on the data shard sequence, and obtain a resource allocation plan by evaluating the storage capacity and processing capability of each storage node; Mapping the resource allocation scheme to a master-slave architecture, generating a node allocation table by setting a topological structure of a master node and multiple slave nodes; Distribute the data shard sequence according to the node allocation table, and obtain distributed storage data through data replication and synchronization mechanism; Establishing an index structure for the distributed storage data, and generating a data retrieval table by constructing a primary key index and an associated index; The data retrieval table is distributed to each storage node, synchronized through a data consistency protocol, and the quality traceability database is established.
9. The method for detecting the appearance of industrial articles based on machine vision according to claim 8, characterized in that: Mapping the resource allocation scheme to the master-slave architecture, by setting a topological structure of a master node and multiple slave nodes, to generate a node allocation table, includes: Dividing the resource allocation scheme into node roles, and generating a node role table by setting the master-slave attributes and priority weights of the nodes; Mapping the node role table into a network topology structure, and obtaining a topological connection diagram by establishing communication links and data transmission paths between nodes; Performing reachability analysis on the topological connection graph, and generating routing strategy data by calculating the shortest path and backup path between nodes; Perform data flow planning based on the routing policy data, and obtain a flow distribution matrix by calculating the data transmission load and bandwidth requirements between nodes; Optimizing the traffic distribution matrix to generate a load balancing strategy by balancing the data transmission pressure between nodes; The load balancing strategy is integrated with the node role table, and the node allocation table is generated by establishing a mapping relationship between node identification and resource configuration.
10. A machine vision-based industrial article appearance detection system, used to implement the machine vision-based industrial article appearance detection method according to any one of claims 1 to 9, characterized in that: The industrial article appearance detection system based on machine vision includes: An acquisition module is used to acquire workpiece images based on an industrial camera, perform noise reduction on the workpiece images through a Gaussian filtering algorithm, perform image enhancement through adaptive histogram equalization, and perform image segmentation using an improved Otsu algorithm to obtain a standardized preprocessed image; An extraction module is used to extract workpiece size features using an edge detection algorithm based on the standardized preprocessed image, extract workpiece contour features through Hough transform, and extract workpiece surface texture features based on a gray level co-occurrence matrix to obtain a workpiece feature vector; A training module is used to use the workpiece feature vector to perform model training through a convolutional neural network with an attention mechanism, and to optimize the model parameters using an improved Adam optimizer to obtain a workpiece defect recognition model; Establishing a module, for inputting the standardized pre-processed image into the workpiece defect recognition model, establishing a dynamic threshold mechanism based on the probability distribution of defect features, performing real-time detection on the workpiece image, and obtaining preliminary detection results; A fusion module is used to perform multi-source information fusion of visual detection data and environmental parameter data based on the preliminary detection results using Dempster-Shafer evidence theory to obtain a comprehensive detection result; The storage module is used to establish a quality traceability database through a distributed architecture based on the comprehensive test results, perform statistical analysis and storage on the test data, and generate a workpiece quality report.
Citation Information
Patent Citations
Fused partial discharge type identification method based on DS evidence theory
CN112686093A
Early fire monitoring and early warning method and device
CN113936413A
Production quality management method and device based on machine learning and computer equipment
CN117094599A
Standard quality detection management platform based on image detection and recognition
CN117252851A
Building material tracing system and method based on big data
CN118586929A
Cited By
Battery assembly process defect real-time detection and classification method and system
CN119904704A
Real-time Detection and Classification Method and System for Defects in Battery Assembly Processes
CN119904704B
Method and device for detecting installation quality of crutch elastic piece and marble
CN119919420A
Bearing defect identification method and system, electronic equipment and readable storage medium
CN119919421A
Visual inspection method based on workpiece inspection equipment
CN120198430A