Cylinder connection port defect detection method based on machine vision
Through the machine vision-based cylinder connection defect detection method, the YOLOv5 algorithm and data enhancement technology are used to solve the problems of low manual detection efficiency and high cost in cylinder production, and efficient and accurate defect detection is achieved, suitable for production lines Demand improves the company's production efficiency and inspection accuracy.
Patent Information
- Application Number
- CN202310628586.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-31
- Publication Date
- 2024-12-03
AI Technical Summary
In the prior art, manual testing is relied on in the production process of cylinders, resulting in low detection efficiency, high cost, and inability to achieve objective judgment, which cannot meet the needs of modern processes. Especially in the detection of surface defects of cylinder connection ports, intelligent detection technology is needed to replace it. Manual testing.
Using machine vision-based cylindrical connection defect detection method, including image acquisition, feature extraction, data set production, object detection and model training, defect detection is performed using YOLOv5 algorithm, combined with HSV spatial transformation, mirror type, canvas expansion, and cutting and data enhancement technologies such as affine transformation to achieve efficient identification of defects.
It realizes automatic detection and identification of surface defects of cylinder connection ports, improves detection accuracy and efficiency, reduces production costs, fills the gap in open source data sets in this field, is suitable for actual production lines, and improves the enterprise's Productivity.
Smart Images

Figure CN119067907A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of defect detection technology, and in particular to a method for detecting defects at a cylinder joint based on machine vision. Background Art
[0002] The cylinder is composed of an inner circular model and an outer paper or glue packaging. The two are pressed tightly together by a fixed roller. It has the characteristics of small size, good waterproofness and beautiful appearance. It is widely used in food packaging, silk, tea and other fields. The market demand for packaging cylinders is gradually increasing. However, affected by multiple factors such as production equipment, raw materials and processing technology, this type of cylinder may have various defects on its surface during the production process, seriously affecting the quality and appearance. At present, the production process of cylinders has been basically unmanned, but its quality inspection process still relies heavily on manual inspection. According to investigation, a production line needs to be equipped with 2-3 workers for inspection, but manual inspection has the following disadvantages: under high-intensity work in the workshop, as the working time becomes longer, the inspection efficiency will also decrease after people feel tired; manual inspection is highly subjective and cannot make objective judgment standards; The labor and management costs are high; manual inspection has gradually become the biggest obstacle for enterprises to increase production and save costs. With the rapid development of machine vision, many enterprises will use machines for industrial target detection. The idea is to use computer vision to simulate the functions of human vision, collect, process and calculate images from specific objects, and finally perform actual machine detection and control. Since manual inspection cannot meet the needs of modern process inspection, the use of machine vision can well overcome this problem. The surface defect detection system based on machine vision can bring high-quality and efficient production to enterprises. Domestic enterprises producing cylinders use surface defect detection systems less, and most of them are still using manual inspection. Therefore, in the surface defect detection link of the cylinder joint, there is an urgent need for an intelligent detection technology and equipment that can replace manual inspection. In the process of producing cylinders, it can automatically detect, identify various defects and make corresponding treatments.
[0003] The purpose of the present invention is to solve the shortcomings of the prior art and to propose a method for detecting surface defects of a cylinder joint based on machine vision.
[0004] In order to achieve the above purpose, the present invention adopts the following technical solution: a method for detecting defects of a cylinder joint based on machine vision, comprising the following steps: S1: image acquisition based on a single camera; S2: extract features from the image and mark them; S3: compile the extracted features into a data set; S4: Object Detection ;S5: Create image model; S6: Improve training parameters; S7: training model; S8: Defect detection based on template.
[0005] In order to specifically limit the collected data, the present invention has the following improvements: the collected data in S1 is specifically collected by an industrial area array camera after obtaining the target sample, and the industrial area array camera uses a CMOS photosensitive chip, an area array scanning method, and a GigE type black and white industrial camera interface.
[0006] In order to specifically define the features, the present invention has been improved in that the feature extraction and marking of the image in S2 is performed in a visual deep learning system, and the image features are extracted by drawing areas. The image features need to be marked and distinguished, including image threshold segmentation.
[0007] In order to explain the image threshold in detail, the present invention has the following improvements: the image threshold is used to segment the grayscale value of the image, which is to divide the image grayscale into different levels and then determine the grayscale threshold. Grayscale threshold segmentation is actually a binarization process, that is, selecting a threshold value to convert the image into a black and white binary image for image segmentation and edge extraction. Obviously, image thresholding is a step function, which is a nonlinear operation of the image grayscale. The conversion function curve is shown in the figure. Its function is to allow the user to specify a threshold value. If the grayscale value of a pixel in the image is greater than the threshold value, the grayscale value of the pixel is set to 255, otherwise its grayscale value is set to 0.
[0008] To limit the compilation of extracted features into a data set, the present invention has improved that, in S3, the compilation into a data set specifically involves performing the above-mentioned analysis on the original image data and defining the cylindrical joint features as wrinkles, fractures, and offsets. Classification tools are then used to compile the data set into a data set.
[0009] In order to refine the target detection, the present invention has the following improvements: the target detection in S4 is specifically to determine the type and position of the target in the picture, and the algorithm used is the YOLOv5 algorithm, which includes Mosaic data enhancement, adaptive anchor box calculation, and adaptive picture scaling operation at the input end; the Focus structure and CSP structure at the reference end; the SPP and FPN+PAN structure at the Neck end, the loss function GIOU_Loss at the output end, and the DIOU_nms for prediction box screening.
[0010] In order to limit the creation of the image model, the present invention has an improvement in that the image model created in S5 is a defect model derived based on the above parameters and data sets.
[0011] In order to limit the improved training parameters, the present invention has the following improvements: the improved training parameters in S6 are data enhancement for the model, including HSV space transformation; mirror type; canvas expansion; cropping; affine transformation; and noise reduction.
[0012] To limit the training model, the present invention improves that the training model in S7 refers to training the model by maximizing the loss function for the standard learning objective. The mean squared error loss (MSE) is calculated by subtracting the squared average of the sample prediction values from the predicted values. , by minimizing the cross entropy loss, the model prediction distribution is made as consistent as possible with the actual data empirical distribution. In terms of evaluation, precision, recall, and F1 score are used to measure the detection effect, and the F1 score is maximized by adjusting parameters.
[0013] In order to realize the defect detection function, the present invention has been improved. The template-based defect detection in S8 is specifically to detect whether the product has defects by real-time capturing the production line data through the area array camera. The captured image needs to be transmitted back for analysis and compared with the correct model to determine whether the product has defects. If defects occur, corresponding downstream operations are performed.
[0014] A method for detecting defects in cylinder joints based on machine vision is characterized by comprising an image acquisition module, a feature extraction module, a dataset creation module, a target detection module, a graph creation module, a training parameter improvement module, a training model module, and a defect detection module. The output of the image acquisition module is electrically connected to the input of the feature extraction module, the output of the feature extraction module is electrically connected to the input of the dataset creation module, the output of the dataset creation module is electrically connected to the input of the target detection module, the output of the target detection module is electrically connected to the input of the graph creation module, the output of the graph creation module is electrically connected to the input of the parameter improvement module, the output of the parameter improvement module is electrically connected to the input of the training model module, and the output of the training model module is electrically connected to the input of the defect detection module. The image acquisition module uses an industrial area array camera corresponding to the target size and working range to acquire a target sample and then install the device for image acquisition. The feature extraction module performs feature matching on the image, which is blurred and lacks obvious features, to enhance feature processing. Dataset creation module: According to the above technical solution, define the defect categories of the cylindrical joints, label the categories, and compile them into a dataset. Target detection module: The target detection module algorithm uses the YOLOv5 algorithm, which includes Mosaic data enhancement, adaptive anchor box calculation, and adaptive image scaling operations at the input end; Focus structure and CSP structure at the reference end; SPP and FPN+PAN structure at the neck end, GIOU_Loss loss function at the output end, and DIOU_nms for prediction box screening. Improved training parameter module: Research on defect detection algorithms for the surface of cylindrical joints, improve the target algorithm network model YOLOv5, perform HSV space transformation on the image; mirror type; canvas expansion; cropping; affine transformation; noise attenuation data enhancement. Training model module: According to step 7 of the above technical solution, the mean square error loss function MSE and the minimization of cross entropy loss are involved. To achieve end-to-end joint training, the algorithm selects one parameter at a time and adjusts the other parameters while keeping them fixed. The validation set is then used for 50 tests. When the average F1-score reaches its maximum, the parameter is considered optimal. The next parameter is then adjusted, and the above steps are repeated until all parameters are optimal. The defect detection module uses real-time data from an industrial area scan camera, which is then input into the model through rapid feature matching. This allows the module to accurately and efficiently identify various defects at the cylindrical joints and address them accordingly.
[0015] Compared with existing technologies, the advantages and positive effects of this invention lie in: When detecting surface defects at cylindrical joints, the invention considers the difficulty of feature extraction in traditional target detection methods and proposes a YOLOv5 network model that enhances image features and integrates datasets and deep learning algorithms for target detection. Specifically, during the training phase, the invention employs Mosaic data augmentation, adaptive anchor box calculation, and adaptive image scaling at the input; Focus and CSP structures at the reference end; SPP and FPN+PAN structures at the neck end; and the output loss function GIOU_Loss and DIOU_nms for prediction box screening. Furthermore, the invention employs HSV spatial transformation, mirror type, canvas expansion, cropping, affine transformation, and noise reduction data augmentation. Efficient image feature training is achieved. On this basis, the defects on the product surface are detected and identified based on the data returned by the production line, and the results are automatically recorded and a product inspection log is produced. It can be used for production guidance and product quality problem analysis to resolve quality doubts. Compared with traditional target detection methods, the present invention is more versatile. Compared with most deep learning methods, the present invention is improved according to the actual needs of the production line of cylinders, and the accuracy and efficiency of detection are further improved. The surface defect dataset of the cylinder joint constructed by the present invention can fill the gap of open source datasets in this field, and can train effective defect detection models according to the actual needs of the production line, further improving the speed and accuracy of detection, improving enterprise production efficiency and reducing production costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] FIG1 is an overall flow chart of a method for detecting surface defects of a cylinder joint based on machine vision proposed by the present invention; FIG2 is an image threshold segmentation diagram of the method for detecting surface defects of a cylindrical joint based on machine vision proposed by the present invention. DETAILED DESCRIPTION
[0017] In order to make the purpose, technical solutions and advantages of the present invention clearer, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In the description of the present invention, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or positional relationship, are based on the orientation and positional relationship shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and are therefore not understood as limiting the present invention. In addition, in the description of the present invention, the meaning of "multiple" refers to two or more, unless otherwise clearly and specifically defined.
[0018] Example 1 Referring to Figures 1-2, the present invention provides a technical solution: a method for detecting surface defects of a cylindrical joint based on machine vision, comprising the following steps: S1: image acquisition based on a single camera; S2: extract features from the image and mark them; S3: compile the extracted features into a data set; S4: target detection; S5: Create an image model ;S6: Improve training parameters ;S7: training model; S8: Defect detection based on template;
[0019] In S1, data is collected by acquiring the target sample using an industrial area scan camera. This camera uses a CMOS sensor, an area scan method, and a GigE interface. As one of the most critical hardware components in machine vision solutions, the selection of an industrial area scan camera is closely linked to the entire quality inspection process. This selection ensures that excellent graphical information is captured for subsequent image processing, improving the accuracy and efficiency of inspection results.
[0020] In S2, the features of images collected at industrial production sites are often not obvious enough, and the images need to be feature extracted and marked. In the visual deep learning system, image features are extracted by drawing areas, and the image features need to be marked and distinguished, including image threshold segmentation.
[0021] In S3, the dataset is created by performing the aforementioned analysis on the original image data, defining the cylindrical joint features as wrinkles, fractures, and offsets. Classification tools are then used to compile the dataset into a data set. The dataset constructed by this invention can, to some extent, fill the gap in open source datasets in this field.
[0022] In S4, the specific algorithm used for target detection is the YOLOv5 algorithm, which includes Mosaic data enhancement, adaptive anchor box calculation, and adaptive image scaling operations at the input end; the Focus structure and CSP structure at the reference end; the SPP and FPN+PAN structures at the neck end, the loss function GIOU_Loss at the output end, and the prediction box screening DIOU_nms.
[0023] In S5, the image model is created based on the defect model obtained from the above parameters and data set.
[0024] In S6, the improved training parameters specifically include image data enhancement, including HSV space transformation; mirror type; canvas expansion; cropping; affine transformation; and noise reduction.
[0025] In S7, model training involves maximizing the loss function for a standard learning objective. The mean squared error (MSE) is the error in the model's regression predictions, calculated by subtracting the squared average from the predicted values. , by minimizing the cross entropy loss, the model prediction distribution is made as consistent as possible with the actual data empirical distribution. In terms of evaluation, precision, recall, and F1 score are used to measure the detection effect, and the F1 score is maximized by adjusting parameters.
[0026] In S8, defect detection specifically involves using an area array camera to capture production line data in real time to detect whether a product has defects. The captured image needs to be transmitted back for analysis and compared with the correct model to determine whether the product has defects. If defects occur, corresponding downstream operations can be performed.
[0027] A method for detecting defects in cylinder joints based on machine vision is characterized in that: the method for detecting defects in cylinder joints based on machine vision is composed of an image acquisition module, a feature extraction module, a data set production module, a target detection module, a graphics creation module, an improved training parameter module, a training model module and a defect detection module, the output end of the image acquisition module is electrically connected to the input end of the feature extraction module, the output end of the feature extraction module is electrically connected to the input end of the data set production module, the output end of the data set production module is electrically connected to the input end of the target detection module, the output end of the target detection module is electrically connected to the input end of the graphics creation module, the output end of the graphics creation module is electrically connected to the input end of the improved parameter module, the output end of the improved parameter module is electrically connected to the input end of the training model module, and the output end of the training model module is electrically connected to the input end of the defect detection module, wherein the image acquisition module: uses the corresponding industrial area array camera according to the target size and working range, obtains the target sample and then installs the equipment for image acquisition.
[0028] Feature extraction module: The collected image is blurry and has no obvious features. In this module, the image is matched with obvious features, image threshold segmentation is performed, and feature processing is enhanced.
[0029] Dataset creation module: According to the above technical solution, the defect categories of the cylinder joints are defined and labeled, and then compiled into a dataset.
[0030] Object detection module: The object detection module uses the YOLOv5 algorithm, which includes Mosaic data enhancement, adaptive anchor box calculation, and adaptive image scaling operations at the input end; the Focus structure and CSP structure at the reference end; the SPP and FPN+PAN structures at the neck end; the loss function GIOU_Loss at the output end and the prediction box screening DIOU_nms.
[0031] Improved training parameter module: Research on defect detection algorithm for the surface of cylindrical joints, improve the target algorithm network model YOLOv5, perform HSV space transformation on the image; mirror type; canvas expansion; cropping; affine transformation; noise attenuation data enhancement.
[0032] Training model module: According to step 7 of the above technical solution, the mean square error loss function MSE and the minimization of cross entropy loss are involved. To achieve end-to-end joint training, the specific operation method is to select one parameter at a time and fix the other parameters for adjustment. 50 tests are performed on the validation set. When the average F1-score value reaches the maximum value, the parameter is considered to be optimized. Then the next parameter is adjusted and the above steps are repeated until all parameters are optimized. Defect detection module: The real-time data of the industrial area array camera is input into the model through rapid feature matching, which can accurately and efficiently identify various defects in the cylindrical joint and make corresponding treatments.
[0033] Working Principle: First, a black-and-white industrial camera with a CMOS sensor, an area array scanning method, and a GigE interface is used to capture images of the sample. Feature extraction is then performed on the raw data captured by the industrial camera. Specifically, threshold segmentation and feature analysis are performed based on a formula algorithm. Based on step 2, surface defect categories for cylindrical joints are defined, labeled, and compiled into a dataset. The YOLOv5 algorithm in the object detection module is selected as the basic object detection model. This includes Mosaic data augmentation, adaptive anchor box calculation, and adaptive image scaling at the input end; Focus and CSP structures at the reference end; SPP and FPN+PAN structures at the neck end; and the output loss function GIOU_Loss and DIOU_nms for prediction box selection. Based on this, the model parameters are refined and optimized. The product image to be inspected is input into the optimal inspection model saved in step 7, and the cylinder joint surface defect detection results are output.
[0034] The above is only a preferred experiment of the present invention and does not limit the present invention in any other form. Anyone familiar with the profession may use the technical content disclosed above to modify and apply it to other fields, but everything does not deviate from the technical solution of the present invention. Simple modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention still fall within the scope of protection of the technical solution of the present invention.
Claims
1. A method for detecting defects at a cylinder joint based on machine vision, characterized in that: The following steps are involved: S1: image acquisition based on a single camera; S2: extract features from the image and mark them; S3: compile the extracted features into a data set; S4: object detection; S5: Create image model; S6: Improve training parameters; S7: training model; S8: Defect detection based on template.
2. The method for detecting defects of cylinder joints based on machine vision according to claim 1, characterized in that: In S1, the data collection is specifically to obtain the target sample and then collect the data through an industrial area array camera, wherein the industrial area array camera adopts a CMOS photosensitive chip, an area array scanning method, and a GigE type black and white industrial camera interface.
3. The method for detecting defects of cylinder joints based on machine vision according to claim 1, characterized in that: In S2, feature extraction and labeling of the image is performed in a visual deep learning system, and image features are extracted by drawing regions. Image features need to be labeled and distinguished, including image threshold segmentation.
4. The method for detecting defects of cylinder joints based on machine vision according to claim 1, characterized in that: In S3, the data set is specifically edited into image data after the above analysis, and the cylindrical joint features are defined as wrinkles, fractures, and offsets. Then, the data set is edited using a classification tool.
5. The method for detecting defects of cylinder joints based on machine vision according to claim 1, characterized in that: In S4, target detection specifically determines the type and position of the target in the image. The algorithm used is the YOLOv5 algorithm, which includes Mosaic data enhancement, adaptive anchor box calculation, and adaptive image scaling operation at the input end; Focus structure and CSP structure at the reference end; SPP and FPN+PAN structure at the neck end, loss function GIOU_Loss at the output end, and DIOU_nms for prediction box screening.
6. The method for detecting defects of cylinder joints based on machine vision according to claim 1, characterized in that: In S5, creating the image model is a defect model derived based on the above parameters and data sets.
7. The method for detecting defects of cylinder joints based on machine vision according to claim 1, characterized in that: In S6, improving the training parameters is to perform data enhancement on the model, including HSV space transformation; Image type; Canvas expansion; cropping; affine transformation; noise reduction.
8. The method for detecting defects of cylinder joints based on machine vision according to claim 1, characterized in that: In S7, training the model means training the model for the standard learning goal by maximizing the loss function. The error of the model regression prediction is measured by subtracting the squared average value from the predicted value of the sample, which is the mean square error loss. , by minimizing the cross entropy loss, the model prediction distribution is made as consistent as possible with the actual data empirical distribution. In terms of evaluation, accuracy, recall and F1 score are used to measure the detection effect, and the F1 score is maximized by adjusting parameters.
9. The method for detecting defects of cylinder joints based on machine vision according to claim 1, characterized in that: In S8, the template-based defect detection specifically involves using a facial diagnosis camera to capture production line data in real time to detect whether a product has defects. The captured image needs to be transmitted back for analysis and compared with the correct model to determine whether the product has defects. If defects occur, corresponding downstream operations can be performed.
10. A method for detecting defects at the joint of a cylinder based on machine vision, characterized in that: The cylinder joint defect detection method based on machine vision is composed of an image acquisition module, a feature extraction module, a data set production module, a target detection module, a graphics creation module, an improved training parameter module, a training model module and a defect detection module. The output end of the image acquisition module is electrically connected to the input end of the feature extraction module, the output end of the feature extraction module is electrically connected to the input end of the data set production module, the output end of the data set production module is electrically connected to the input end of the target detection module, the output end of the target detection module is electrically connected to the input end of the graphics creation module, the output end of the graphics creation module is electrically connected to the input end of the improved parameter module, and the improved The output end of the parameter module is electrically connected to the input end of the training model module, and the output end of the training model module is electrically connected to the input end of the defect detection module, wherein the image acquisition module: uses the corresponding industrial array camera according to the target size and working range, obtains the target sample and then installs the equipment for image acquisition; the feature extraction module: the acquired image is blurred and has no obvious features, in this module, the image is matched with obvious features, image threshold segmentation is performed, and feature processing is enhanced; the data set production module: according to the above technical solution, the defect category of the cylinder joint is defined and the classification is marked, and edited into a data set; the target detection module: the target detection module algorithm uses YOLOv5 Algorithms, including Mosaic data enhancement, adaptive anchor frame calculation, and adaptive image scaling operations at the input end; Focus structure and CSP structure at the reference end; SPP and FPN+PAN structure at the neck end, GIOU_Loss loss function at the output end, and DIOU_nms for prediction frame screening; improved training parameter module: research on defect detection algorithm for the surface of cylindrical joints, improvement of the target algorithm network model YOLOv5, and HSV space transformation of images; mirror type; canvas expansion; cropping; affine transformation; noise weakening data enhancement; training model module: according to the mean square error loss function MSE and minimization of cross entropy loss involved in step 7 of the above technical solution. To achieve end-to-end joint training, the specific operation method is to select one parameter each time and fix other parameters for adjustment, use the verification set to perform 50 tests, and when the average F1-score value reaches the maximum value, the parameter is considered to be adjusted to the optimal value, and then adjust the next parameter, and repeat the above steps until all parameters are adjusted to the optimal value; Defect detection module: The real-time data of the industrial area array camera is input into the model through fast feature matching, so that various defects of the cylinder joint can be accurately and efficiently identified and corresponding processing can be made.
Citation Information
Cited By
Self-adhesive label defect detection device and detection method based on machine vision
CN122193238A
Machine vision-based adhesive label defect detection device and detection method
CN122193238B
