A visual detection method for multiple types of assembly defects in a cylinder
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANDONG UNIV
- Filing Date
- 2026-05-18
- Publication Date
- 2026-06-19
Smart Images

Figure CN122244018A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent manufacturing and machine vision inspection technology, specifically a visual inspection method for multiple types of assembly defects inside a cylinder. Background Technology
[0002] Long, narrow cylindrical structural components are typical assembly carriers in industrial manufacturing within confined spaces. These components have a large length-to-diameter ratio and extend deep into the interior, making their internal assembly the most critical and demanding quality control stage in the final product assembly process. Assembly operations require the installation of multiple types of parts, the fixing of small fasteners, the laying of flexible cables, the affixing of product labels, the setting of anti-loosening labels, and the connection of grounding wires within the confined and deep cylindrical space. Manual assembly makes it difficult to achieve uniformity, and assembly quality is highly dependent on the standardization of manual operations. Therefore, automated inspection methods are urgently needed to replace manual quality control.
[0003] Currently, the quality inspection of assembly in narrow cylindrical spaces still relies primarily on manual visual inspection. Inspectors judge whether the assembly is qualified based solely on their personal experience, and the inspection conclusion is simply recorded in written form as qualified / unqualified. This method suffers from problems such as strong subjectivity in inspection, inconsistent standards, high rate of missed inspections, low efficiency, and inability to quantify and retain inspection data, failing to meet the quality control requirements of high-precision assembly.
[0004] With the widespread application of machine vision inspection technology in manufacturing, automated quality inspection based on image acquisition and intelligent algorithms has become an industry trend. However, when applying existing general machine vision inspection methods to this confined space assembly scenario, there are three major technical drawbacks that are difficult to overcome: First, there are many types of defects with great differences in characteristics. The cylinder needs to detect a variety of defects such as missing fasteners, cable routing, binding points, product markings, anti-loosening markings, and installation direction. Different defects have very different image characteristics. Existing technologies use a single algorithm for detection and do not match specific strategies for different defects, so they cannot fully cover all detection types. Second, there is a lack of small-batch manufacturing samples. Most cylindrical structural parts are produced in small batches, and the number of image samples that can be collected is limited. Due to the lack of training data, deep learning models are prone to overfitting or underfitting, and the detection accuracy cannot meet the standards. Third, there are no effective detection criteria for flexible cables. The shape of the cables is not fixed after they are laid. Existing algorithms can only locate the position of the cables and cannot perform quantitative analysis on the cable path length, laying position, bending curvature, etc. There is a lack of an automated judgment system for the correctness of the cable route, and cable laying defects still cannot be intelligently detected.
[0005] Therefore, there is an urgent need for a digital intelligent inspection method for assembly components in confined spaces that can cover multiple types of assembly defects, adapt to small sample training scenarios, and have the ability to quantitatively detect flexible cable paths, so as to achieve automated, standardized, and high-precision inspection of the assembly quality of long and narrow cylindrical bodies in confined spaces. Summary of the Invention
[0006] To address the aforementioned problems in the prior art, this invention provides a visual inspection method for multiple types of assembly defects inside a cylinder, effectively solving the problems of difficulty in covering multiple defects, insufficient training with small samples, and lack of quantitative criteria for cable inspection, thereby improving the accuracy, automation, and standardization of assembly inspection.
[0007] To achieve the above objectives, this invention proposes a visual inspection method for multiple types of assembly defects inside a cylinder, comprising: S1. Training set construction: Collect positive samples in normal assembly state, and create reverse samples by artificially removing parts and occluding feature parts. The positive and reverse samples together constitute the training set, and data augmentation is performed on the images in the training set. S2. Detection Model Training: The YOLOv7 detection algorithm is used to build a detection model. Transfer learning is used to train the model. The network parameters are frozen and unfrozen in stages to complete the model training. S3. Categorized Dynamic Detection: For assembly defects, the corresponding detection strategy is matched according to the defect type.
[0008] Preferably, the data enhancement includes rotating, translating, scaling, and horizontally flipping the original image.
[0009] Preferably, in S2, the detection model adopts the YOLOV7 detection algorithm, with CSPDarknet53 as the backbone feature extraction network. After fusing feature maps of three different scales through FPN, the data is input into the YOLO layer to achieve class prediction and bounding box regression. The specific steps for training a model using transfer learning, which involves freezing and unfreezing network parameters in stages, are as follows: Use pre-trained YOLO weights as initial weights; during training, first freeze the backbone network parameters and train only the detection head part; then unfreeze all network parameters for global optimization.
[0010] Preferably, in the classification and dynamic detection, for cable laying defects, the YOLOv7 detection model is used to locate the cable object and extract the cable skeleton line. Geometric feature analysis is performed from four dimensions: skeleton line length, allowable position of the cable in the cylinder, cable curvature, and cable color, in order to determine the correctness of the path. The method for locating cable objects and extracting cable skeleton lines using the YOLOv7 detection model is as follows: first, the area where the cable object is located is located using the YOLOv7 detection model; then, image filtering is performed using the cable's unique color features; finally, a fixed threshold algorithm is used for binarization; and finally, the cable skeleton lines are extracted using a skeleton extraction algorithm. For other types of defects, including defects such as missing fasteners, defects in the location and quantity of binding points, product marking defects, defects in anti-loosening markings, and defects in installation direction, the missing fastener defects are detected by comparing the normal installation state with the feature missing state using a trained YOLOv7 detection model, and directly outputting the detection conclusion of whether the target exists or not.
[0011] Preferably, the geometric feature analysis of cable laying defects from the dimension of skeleton line length includes: obtaining the cable skeleton line length by integrating an infinite number of equal infinitesimal intervals on the curve, and comparing the obtained cable skeleton line length with the allowable deviation threshold set by the process requirements.
[0012] Preferably, the geometric feature analysis of the cable laying defects from the dimension of the allowable position of the cable in the cylinder includes: extracting the cross-sectional area of the cylinder using an image segmentation algorithm, delineating one or more pixel areas in the image where the cable cannot appear and calculating the corresponding coordinate set, and considering the cable laying as unqualified when the cable image features appear in the pixel areas where the cable cannot appear.
[0013] Preferably, the geometric feature analysis of cable laying defects from the perspective of cable curvature includes: obtaining the two ends of the cable and dividing it into several segments along the Y-axis; calculating the average curvature and maximum curvature of each segment; comparing the calculated average curvature and maximum curvature of each segment with the maximum allowable average curvature and maximum allowable instantaneous curvature of this type of cable specified in the process standard; if any curvature value exceeds the corresponding threshold, the cable laying of that segment is deemed unqualified; the formula for calculating the average curvature is the ratio of the angle change to the curve arc length change; the method for calculating the maximum curvature is to calculate the reciprocal of the radius of the arc determined by three adjacent points for each pixel point on the cable skeleton line of that segment, and take the maximum value of the curvature of all pixels as the maximum curvature of that segment.
[0014] Preferably, the geometric feature analysis of cable laying defects from the cable color dimension includes: extracting the HSV color histogram of the cable area, comparing it with the standard cable color template specified in the process, and if the similarity is lower than a set threshold or the color category does not match, the cable laying is determined to be unqualified.
[0015] Preferably, in the dynamic classification detection, for defects related to the location and quantity of binding points, the pixel range of the cable is picked up through the combined application of color filtering and dilation algorithms, and the area of the connected component of a specific color is determined. When the area of the connected component is greater than a specified value, it is considered a valid binding point, and the number of connected components corresponding to the valid binding point is calculated. For defects related to product identification, the text region is automatically located and the entire line of text is recognized through an OCR algorithm. The OCR algorithm first locates the text region through morphological operations, then extracts character features through CNN, and then realizes character recognition on the grayscale image through RNN+LSTM sequence modeling. For defects related to anti-loosening labels, candidate regions are first screened in the HSV space based on the specific color of the anti-loosening label, and then edge detection or template matching is used within the region to determine whether the label is broken or misaligned. For defects related to installation direction, the HOG or SIFT appearance features of the component are extracted, and combined with the combined features of other components that are matched with the component, the input is used to the classifier to determine whether the direction is correct.
[0016] Preferably, in the classification dynamic detection, the corresponding detection strategy is automatically retrieved according to the inspection content of the current inspection process, the image recognition engine performs automatic detection in real time based on the captured photos, and after the detection is completed, the feedback of the detection results is used to supplement and improve the YOLOv7 detection model and the OCR recognition model.
[0017] Therefore, this invention proposes a visual inspection method for multiple types of assembly defects inside a cylinder, with the following beneficial effects: (1) In response to the problem of many types of defects and large differences in characteristics in the narrow cylindrical body, the corresponding detection strategy is matched according to the defect type, which can comprehensively cover many typical assembly defects such as missing fasteners, cable laying, binding point location and quantity, product identification, anti-loosening mark, and installation direction, thus breaking through the detection coverage limitation of a single algorithm.
[0018] (2) By combining positive and negative sample construction, data augmentation and transfer learning, the problem of model overfitting and underfitting caused by insufficient small batch manufacturing samples is solved, and the detection accuracy in small sample scenarios is improved.
[0019] (3) Establish a four-dimensional geometric feature criterion system for flexible cables to realize the quantitative determination of cable paths and solve the technical problem that existing algorithms can only locate cables but cannot determine the qualification of the direction.
[0020] (4) The manual subjective inspection is transformed into machine quantitative inspection, the inspection standards are unified, the results can be quantified and stored, and the automation level and reliability of assembly inspection in narrow space are greatly improved.
[0021] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0022] Figure 1 This is a schematic diagram of the overall process of a visual inspection method for multiple types of assembly defects inside a cylinder, according to the present invention. Figure 2 This is a schematic diagram of the feature extraction network structure with CSPDarknet53 as the backbone, which is a visual detection method for multiple types of assembly defects in a cylinder according to the present invention. Figure 3 This is a schematic diagram comparing the target detection results of the YOLOV7 detection model (using CSPDarknet53 as the backbone feature extraction network) with the traditional YOLO model, which employs the YOLOV7 detection algorithm for a visual detection method of multiple types of assembly defects inside a cylinder according to the present invention. Detailed Implementation
[0023] To make the technical solutions, advantages, and objectives of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below. The described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the described embodiments of the present invention without creative effort are within the protection scope of this application.
[0024] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning as understood by one of ordinary skill in the art to which this invention pertains.
[0025] like Figures 1-3 As shown, the present invention provides a visual inspection method for multiple types of assembly defects inside a cylinder, comprising: S1. Training set construction: Collect positive samples in normal assembly state, and create reverse samples by artificially removing parts and occluding feature parts. The positive and reverse samples together constitute the training set, and data augmentation is performed on the images in the training set. Data augmentation includes rotating, translating, scaling, and horizontally flipping the original image.
[0026] S2. Detection Model Training: The YOLOv7 detection algorithm is used to build a detection model. Transfer learning is used to train the model. The network parameters are frozen and unfrozen in stages to complete the model training. The detection model employs the YOLOv7 detection algorithm, and its network structure follows the standard YOLOv7 architecture: the input image is processed by BackboneCSPDarknet53 to extract features, and three feature maps of different scales are fused through the Neck (FPN). Finally, the Head (YOLO layer) outputs the class prediction and bounding box regression. Based on the YOLOv7 network layer structure, transfer learning and a staged training strategy are used to optimize the detection performance under small sample sizes.
[0027] Specifically, the CSPDarknet53 backbone feature extraction network consists of a CBM convolutional module, a CBL convolutional module, and a CSP residual network module. The CSP residual network module splits the feature map into two parts: one part is processed by multiple residual units, and the other part is directly convolved. Finally, the two feature paths are concatenated to reduce computation and enhance gradient flow. CSPDarknet53 extracts basic image features through convolutional layers, performs feature normalization through BN layers, introduces nonlinear transformations through activation functions, implements residual feature fusion through the add operator, and completes feature dimensionality reduction and extraction through the DBL convolutional module, ensuring the robustness of feature extraction. The DBL operator refers to the basic convolutional unit Conv+BatchNorm+LeakyReLU, which is used in multiple stacks in CSPDarknet53.
[0028] like Figure 2 As shown, the input image passes through the CBM module, multiple CBL modules, and the CSP residual module in sequence, and outputs three feature maps of different scales to the FPN for fusion.
[0029] The specific steps for training a model using transfer learning and freezing and unfreezing network parameters in stages are as follows: Use YOLO pre-trained weights as initial weights. The entire training process is divided into 50 rounds. First, freeze the backbone network parameters and train only the detection head part. Then, unfreeze all network parameters for global optimization.
[0030] The dataset is used for training at 90% and validation at 10%. The weights of each training round are saved and the loss value is calculated. The loss values of the training set and validation set decrease and tend to converge with each training round. After the model training is completed, a training model file is generated. The image recognition code and recognition model are packaged into an executable file for the detection system to call.
[0031] S3. Categorized Dynamic Detection: For assembly defects, the corresponding detection strategy is matched according to the defect type.
[0032] In the dynamic classification inspection, for cable laying defects, the YOLOv7 inspection model is used to locate the cable object and extract the cable skeleton line. Geometric feature analysis is performed from four dimensions: skeleton line length, allowable position of the cable in the cylinder, cable curvature, and cable color, in order to determine the correctness of the path.
[0033] The method for locating cable objects and extracting cable skeleton lines using the YOLOv7 detection model is as follows: First, the YOLOv7 detection model is used to locate the area where the cable object is located. Then, the image is filtered using the cable's unique color features. Next, a fixed threshold algorithm is used for binarization. Finally, the cable skeleton lines are extracted using a skeleton extraction algorithm.
[0034] Other types of defects include missing fasteners, defects in the location and quantity of binding points, product marking defects, anti-loosening marking defects, and installation direction defects.
[0035] For defects such as missing fasteners, a trained YOLOv7 detection model is used to compare the normal installation state with the feature missing state, and directly output the detection conclusion of whether the target exists or not.
[0036] In the dynamic classification detection, for defects related to the location and quantity of binding points, the pixel range of the cable is picked up by the combined application of color filtering and dilation algorithm. The area of the connected component of a specific color is judged. When the area of the connected component is greater than a specified value, it is considered a valid binding point, and the number of connected components corresponding to the valid binding point is calculated.
[0037] In dynamic classification detection, for product identification defects, the OCR algorithm is used to automatically locate the text region and recognize the entire line of text. The OCR algorithm first locates the text region through morphological operations, then extracts character features through CNN, and finally realizes character recognition on the grayscale image through RNN+LSTM sequence modeling.
[0038] For defects such as anti-loosening markings, firstly, candidate areas are selected in the HSV space based on the specific color of the anti-loosening marking. Then, within this area, edge detection or template matching is used to determine whether the marking is broken or misaligned.
[0039] For installation orientation defects, extract the HOG or SIFT appearance features of the component, and combine them with the combined features of other components that are matched with the component to input the classifier to determine whether the orientation is correct.
[0040] Geometric feature analysis of cable laying defects from the perspective of skeleton line length includes: obtaining the cable skeleton line length by integrating over infinitely many equal infinitesimal intervals on the curve, and comparing the obtained cable skeleton line length with the allowable deviation threshold set by the process requirements.
[0041] The formula for calculating the length of the cable skeleton is obtained by integrating over infinitely many equal infinitesimal intervals on the curve: ; In the formula, Indicates the distance between the two endpoints Distance along the axis Indicates the distance between the two endpoints Distance along the axis For the curve at point The slope of the tangent at that point.
[0042] The allowable deviation thresholds include the longest deviation and the shortest allowable deviation threshold L. min With L max During the testing process, the cable length should be within L.min With L max between.
[0043] The geometric feature analysis for cable laying defects, based on the permissible position dimension of the cable within the cylinder, includes: using image segmentation algorithms to extract the cross-sectional area of the cylinder, delineating one or more pixel areas in the image where the cable cannot appear, and calculating the corresponding coordinate set; when the cable image features appear in the pixel areas where the cable cannot appear, the cable laying is considered unqualified.
[0044] Geometric feature analysis of cable laying defects from the curvature dimension includes: obtaining the two ends of the cable and dividing it into several segments along the Y-axis; calculating the average curvature and maximum curvature of each segment; comparing them with the maximum allowable average curvature and maximum allowable instantaneous curvature of this type of cable specified in the process standard; if any curvature value exceeds the corresponding threshold, the cable laying of that segment is deemed unqualified.
[0045] The formula for calculating the average curvature is the ratio of the change in angle to the change in the arc length of the curve. The formula is as follows: ; In the formula, Indicates the amount of angle change. It represents the change in the arc length of the curve.
[0046] The method for calculating the maximum curvature is to calculate the reciprocal of the radius of the arc determined by three adjacent points for each pixel on the cable skeleton line, and take the maximum value of the curvature of all pixels as the maximum curvature of the segment.
[0047] Geometric feature analysis of cable laying defects from the perspective of cable color includes: extracting the HSV color histogram of the cable area and comparing it with the standard cable color template specified in the process. If the similarity is lower than the set threshold or the color category does not match, the cable laying is deemed unqualified.
[0048] In the dynamic classification inspection, the corresponding inspection strategy is automatically retrieved according to the inspection content of the current inspection process. The image recognition engine performs automatic inspection in real time based on the captured photo. If the inspection result is unqualified, the specific unqualified item is indicated, and the inspector makes a manual judgment and repeats the inspection. If the inspection result is qualified, the subsequent process inspection is automatically carried out. If there is no subsequent process, the inspection is completed. After the inspection is completed, the feedback of the inspection results is used to supplement and improve the YOLOv7 inspection model and OCR recognition model.
[0049] This invention takes the assembly and testing of components in a narrow, elongated cylindrical space as an example. The specific implementation process is as follows: Training set construction: Collect positive samples of the normal assembly state inside the narrow cylindrical body, and create defect-type reverse samples by artificially removing parts and occluding feature parts. The positive and reverse samples together form the training set. Perform data augmentation operations such as rotation, translation, scaling and horizontal flipping on the original images in the training set to expand the training sample size.
[0050] Detection model training: The detection model is built using the YOLOv7 detection algorithm, with CSPDarknet53 as the backbone feature extraction network. After fusing feature maps of three different scales through FPN, the data are input into the YOLO layer to complete class prediction and bounding box regression. YOLO pre-trained weights are used as initial weights. The training process is executed in stages. In the early stage, the backbone network parameters are frozen and only the detection head part is trained. In the later stage, all network parameters are unfrozen for global optimization. The model training is completed and a callable detection model file is generated.
[0051] Categorized dynamic inspection: Based on the inspection content of the narrow cylindrical assembly inspection process, the corresponding defect type inspection strategy is automatically retrieved, and the acquired assembly images are inspected in real time through the image recognition engine.
[0052] For defects such as missing fasteners, a trained YOLOv7 detection model is used to compare the normal installation state with the feature missing state, and directly output the detection conclusion of whether the target exists or not.
[0053] In the dynamic classification detection, for defects related to the location and quantity of binding points, the pixel range of the cable is picked up by the combined application of color filtering and dilation algorithm. The area of the connected component of a specific color is judged. When the area of the connected component is greater than a specified value, it is considered a valid binding point, and the number of connected components corresponding to the valid binding point is calculated.
[0054] In dynamic classification detection, for product identification defects, the OCR algorithm is used to automatically locate the text region and recognize the entire line of text. The OCR algorithm first locates the text region through morphological operations, then extracts character features through CNN, and finally realizes character recognition on the grayscale image through RNN+LSTM sequence modeling.
[0055] For defects such as anti-loosening markings, firstly, candidate areas are selected in the HSV space based on the specific color of the anti-loosening marking. Then, within this area, edge detection or template matching is used to determine whether the marking is broken or misaligned.
[0056] For installation orientation defects, extract the HOG or SIFT appearance features of the component, and combine them with the combined features of other components that are matched with the component to input the classifier to determine whether the orientation is correct.
[0057] If the test result is unqualified, the specific unqualified items will be indicated, and the tester will need to manually determine and repeat the test. If the test result is qualified, the subsequent process will be automatically initiated. If there is no subsequent process, the test will be completed.
[0058] After the detection is completed, the detection results are fed back to the system to supplement and improve the YOLOv7 detection model and OCR recognition model, and continuously improve the detection accuracy.
[0059] Figure 3 This invention presents a performance comparison curve of precision-recall between the improved YOLOV7 detection model and the traditional YOLO model in a narrow, confined space scenario for detecting multiple types of assembly defects. The horizontal axis represents the detection recall rate, which characterizes the model's coverage of defect targets; the vertical axis represents the detection precision rate, which characterizes the model's accuracy in identifying defects; and the area under the curve (AP value) is the core quantitative indicator of the model's overall detection accuracy, with a higher AP value indicating better model detection performance.
[0060] Depend on Figure 3 It can be intuitively concluded that: Traditional YOLO models suffer from low precision and recall rates and drastic fluctuations in curves under scenarios such as small sample training, complex background interference in confined spaces, and large differences in the characteristics of various types of defects. They are prone to missed detections and false detections, and cannot meet the requirements for high-precision detection of defects in cylinder assembly. This invention employs an improved model combining the YOLOV7 algorithm, the CSPDarknet53 backbone feature extraction network, the FPN multi-scale feature fusion, and staged transfer learning. This model effectively addresses issues such as overfitting in small samples, insufficient feature extraction in narrow spaces, and poor adaptability to multiple defects. The model's detection curve is smooth and stable, with an average precision (AP) of 85.37%.
[0061] Compared to the traditional YOLO model, the precision and recall of the model in this invention are significantly improved, which fully demonstrates that it has higher detection accuracy, stronger feature robustness and better small sample adaptation capability for multiple types of assembly defects in narrow cylindrical space scenarios. It can stably realize automated and high-precision quantitative detection of assembly defects.
[0062] The results of this embodiment show that the digital intelligent detection method for assemblies in confined spaces can comprehensively detect a variety of typical assembly defects in long and narrow cylinders. The small sample training strategy effectively avoids overfitting and underfitting of the model. The four-dimensional geometric features can accurately determine the qualification of cable laying, realize standardized and quantitative detection by machines, and meet the requirements of assembly quality control in terms of accuracy, efficiency and stability.
[0063] Therefore, this invention provides a visual detection method for multiple types of assembly defects within a cylindrical body. This method enables automated quantitative detection of various assembly defects in narrow, confined spaces within a cylindrical body, solving the problems of single algorithms being unable to cover multiple types of differential defects, insufficient sample size in small-batch manufacturing leading to low model accuracy, and the lack of effective automated criteria for flexible cable laying. This method utilizes forward and reverse sample construction combined with data augmentation and transfer learning to optimize small-sample training. It matches specific detection strategies according to defect type and establishes a four-dimensional geometric feature criterion system for cables. This transforms subjective manual inspection into standardized machine inspection, comprehensively covering multiple types of assembly defects and significantly improving the accuracy, efficiency, and standardization of assembly inspection in confined spaces.
[0064] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.
Claims
1. A visual inspection method for multiple types of assembly defects inside a cylinder, characterized in that, Includes the following steps: S1. Training set construction: Collect positive samples in normal assembly state, and create reverse samples by artificially removing parts and occluding feature parts. The positive and reverse samples together constitute the training set, and data augmentation is performed on the images in the training set. S2. Detection Model Training: The YOLOv7 detection algorithm is used to build a detection model. Transfer learning is used to train the model. The network parameters are frozen and unfrozen in stages to complete the model training. S3. Categorized Dynamic Detection: For assembly defects, the corresponding detection strategy is matched according to the defect type.
2. The visual inspection method for multiple types of assembly defects inside a cylinder according to claim 1, characterized in that, The data augmentation includes rotating, translating, scaling, and horizontally flipping the original image.
3. The visual inspection method for multiple types of assembly defects inside a cylinder according to claim 1, characterized in that, In S2, the detection model adopts the YOLOV7 detection algorithm, with CSPDarknet53 as the backbone feature extraction network. After fusing feature maps of three different scales through FPN, the data is input into the YOLO layer to achieve class prediction and bounding box regression. The specific steps for training a model using transfer learning, which involves freezing and unfreezing network parameters in stages, are as follows: Use pre-trained YOLO weights as initial weights; during training, first freeze the backbone network parameters and train only the detection head part; then unfreeze all network parameters for global optimization.
4. The visual inspection method for multiple types of assembly defects inside a cylinder according to claim 1, characterized in that, In the classification and dynamic detection, for cable laying defects, the YOLOv7 detection model is used to locate the cable object and extract the cable skeleton line. Geometric feature analysis is performed from four dimensions: skeleton line length, allowable position of the cable in the cylinder, cable curvature, and cable color, in order to determine the correctness of the path. The method for locating cable objects and extracting cable skeleton lines using the YOLOv7 detection model is as follows: first, the area where the cable object is located is located using the YOLOv7 detection model; then, image filtering is performed using the cable's unique color features; finally, a fixed threshold algorithm is used for binarization; and finally, the cable skeleton lines are extracted using a skeleton extraction algorithm. For other types of defects, including defects such as missing fasteners, defects in the location and quantity of binding points, product marking defects, defects in anti-loosening markings, and defects in installation direction, the missing fastener defects are detected by comparing the normal installation state with the feature missing state using a trained YOLOv7 detection model, and directly outputting the detection conclusion of whether the target exists or not.
5. The visual inspection method for multiple types of assembly defects inside a cylinder according to claim 4, characterized in that, The geometric feature analysis of cable laying defects from the dimension of skeleton line length includes: obtaining the cable skeleton line length by integrating an infinite number of equal infinitesimal intervals on the curve, and comparing the obtained cable skeleton line length with the allowable deviation threshold set by the process requirements.
6. The visual inspection method for multiple types of assembly defects inside a cylinder according to claim 4, characterized in that, The geometric feature analysis of cable laying defects based on the allowable position dimension of the cable within the cylinder includes: extracting the cross-sectional area of the cylinder using an image segmentation algorithm, delineating one or more pixel areas in the image where the cable cannot appear, and calculating the corresponding coordinate set; when the cable image features appear in the pixel areas where the cable cannot appear, the cable laying is considered unqualified.
7. The visual inspection method for multiple types of assembly defects inside a cylinder according to claim 4, characterized in that, The geometric feature analysis of cable laying defects from the perspective of cable curvature includes: obtaining the two ends of the cable and dividing it into several segments along the Y-axis; calculating the average curvature and maximum curvature of each segment; comparing the calculated average curvature and maximum curvature of each segment with the maximum allowable average curvature and maximum allowable instantaneous curvature of this type of cable specified in the process standard; if any curvature value exceeds the corresponding threshold, the cable laying of that segment is deemed unqualified; the formula for calculating the average curvature is the ratio of the change in angle to the change in the arc length of the curve; the method for calculating the maximum curvature is to calculate the reciprocal of the radius of the arc determined by three adjacent points for each pixel point on the cable skeleton line of that segment, and take the maximum value of the curvature of all pixels as the maximum curvature of that segment.
8. The visual inspection method for multiple types of assembly defects inside a cylinder according to claim 1, characterized in that, In the classified dynamic detection, the geometric feature analysis of cable laying defects from the cable color dimension includes: extracting the HSV color histogram of the cable area and comparing it with the standard cable color template specified in the process. If the similarity is lower than the set threshold or the color category does not match, the cable laying is determined to be unqualified.
9. The visual inspection method for multiple types of assembly defects inside a cylinder according to claim 1, characterized in that, In the dynamic classification detection, for defects related to the location and quantity of binding points, the pixel range of the cable is picked up through the combined application of color filtering and dilation algorithms. The area of the connected component of a specific color is determined. When the area of the connected component is greater than a specified value, it is considered a valid binding point, and the number of connected components corresponding to the valid binding point is calculated. For defects related to product identification, the text region is automatically located and the entire line of text is recognized through OCR algorithms. The OCR algorithm first locates the text region through morphological operations, then extracts character features through CNN, and then realizes character recognition on the grayscale image through RNN+LSTM sequence modeling. For defects related to anti-loosening labels, candidate regions are first screened in the HSV space based on the specific color of the anti-loosening label. Then, edge detection or template matching is used within the region to determine whether the label is broken or misaligned. For defects related to installation direction, the HOG or SIFT appearance features of the component are extracted and combined with the combined features of other components that are matched with the component, and then input into the classifier to determine whether the direction is correct.
10. A visual inspection method for multiple types of assembly defects inside a cylinder according to claim 1, characterized in that, In the dynamic classification detection, the corresponding detection strategy is automatically retrieved according to the inspection content of the current inspection process. The image recognition engine performs automatic detection in real time based on the captured photos. After the detection is completed, the YOLOv7 detection model and OCR recognition model are supplemented and improved using the feedback of the detection results.