Glass bottle defect detection method
By employing multi-view image acquisition and incremental learning, the problem of traditional detection techniques being unable to simultaneously detect defects in different parts of glass bottles has been solved, enabling rapid and efficient glass bottle defect detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-14
- Publication Date
- 2026-04-14
AI Technical Summary
Traditional testing techniques cannot fully cover defects in different parts of glass bottles, resulting in cumbersome testing procedures and making it difficult to achieve rapid testing.
A multi-view camera is used to capture side, top, and bottom views of the glass bottle, which are stored in their respective image libraries. Incremental learning is performed using a pre-trained model to generate detection models for the bottle body, mouth, and bottom, enabling simultaneous detection of different parts.
It enables rapid inspection of different parts of glass bottles at the same time, reducing inspection steps and improving inspection efficiency.
Smart Images

Figure CN121860916A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of defect detection technology, and in particular to a method for detecting defects in glass bottles. Background Technology
[0002] In the glass bottle manufacturing industry, defects commonly appear on the surface of products, including the bottle body, bottle neck, and bottle bottom. For the bottle body, defects such as cracks, bubbles, stains, deformation, foreign objects, and scratches may occur. For the bottle neck (such as chipping, cracks, bubbles, deformation, burrs, missing material, and foreign objects), due to the curved structure of the bottle neck, traditional single-angle visual inspection methods cannot fully cover the inner and outer areas of the bottle neck, easily resulting in blind spots. For the bottle bottom, defects such as cracks, bubbles, end marks, deformation, burrs, and glass fragments may occur. Because glass bottles have multiple different parts that need to be inspected for defects, traditional inspection techniques require different parts to be inspected at different times, increasing the number of inspection steps and making it difficult to achieve rapid inspection of glass bottles. Summary of the Invention
[0003] In order to overcome the shortcomings of the existing technology, the present invention provides a method for detecting defects in glass bottles to solve the above-mentioned problems.
[0004] The technical solution adopted by this invention to solve its technical problem is: a method for detecting defects in glass bottles, comprising the following steps: S1: Use different cameras to capture images of the glass bottle from three perspectives: side view, top view, and bottom view. Store the side view images in the bottle body image library, the top view images in the bottle mouth image library, and the bottom view images in the bottle bottom image library. S2: Mark the defect areas in all images and add corresponding defect labels to obtain the first preprocessed image with defect areas and defect labels; S3: Apply corresponding pre-trained models to the first pre-processed images in the bottle body image library, the bottle mouth image library, and the bottle bottom image library, respectively. Take the first pre-processed image as input and output the predicted defect region and the predicted defect label. Based on the difference between the defect region in the first pre-processed image and the predicted defect region, as well as the difference between the defect label in the first pre-processed image and the predicted defect label, perform incremental learning on the corresponding pre-trained models to obtain the detection models corresponding to the bottle body, bottle mouth, and bottle bottom, respectively. S4: Input the newly acquired images from the bottle body image library, bottle mouth image library, and bottle bottom image library into the corresponding detection models to obtain the corresponding defect labels, defect regions, and confidence levels.
[0005] Preferably, in step S2, the images in the bottle body image library, bottle mouth image library and bottle bottom image library are classified according to morphological features, illumination distribution and texture features, and the images are assigned classification labels corresponding to the classification results according to the classification results; Based on the classification labels, the corresponding defect labeling model is obtained using a mapping table. The image is input into the defect labeling model corresponding to its classification label to obtain the defect region and defect label.
[0006] It is worth noting that in step S3, based on the difference between the defect region in the first preprocessed image and the predicted defect region, and the difference between the defect label in the first preprocessed image and the predicted defect label, the precision, recall, and mean precision (mAP@0.5) of the model are calculated. The current model is used as the detection model when the precision, recall, and mean precision (mAP@0.5) of the previous time are all equal to those of the current time.
[0007] Optionally, in step S4, for defects labeled as small black dot defects and small bubble defects, the corresponding defect regions are obtained, cropped and stored, and then the defect regions are enlarged proportionally and input into the trained fine defect detection model to obtain the model output to update the corresponding defect labels, defect regions and confidence levels.
[0008] Specifically, in step S2, for the images in the bottle bottom image library, the model number area and model number type of the bottle bottom model number in the image are marked to obtain a second preprocessed image marked with the model number area and model number type. In step S3, a pre-trained model for pattern number detection is used on the second pre-processed image. The second pre-processed image is taken as input, and the pattern number region and pattern number type are taken as output. Incremental learning is performed on the pre-trained model for pattern number detection to obtain the pattern number detection model. In step S4, the newly acquired image from the bottle bottom image library is input into the model number detection model to obtain the corresponding model number region and model number type.
[0009] Preferably, in step S4, for newly acquired images from the bottle body image library, bottle mouth image library, and bottle bottom image library, before inputting them into the corresponding detection model, the images are first scaled proportionally to the input size required by the corresponding detection model.
[0010] Specifically, for newly acquired images from the bottle body image library, bottle mouth image library, and bottle bottom image library, before inputting them into the corresponding detection model, the images are scaled proportionally and edge-filled to expand the side length of the image to an integer multiple of the convolution kernel of the corresponding detection model.
[0011] It is worth noting that in step S3, after obtaining the detection models corresponding to the bottle body, bottle mouth and bottle bottom, the detection models are converted into TensorRT format and OpenVINO format respectively. The TensorRT format detection model is deployed on the GPU, and the OpenVINO format detection model is deployed on the CPU.
[0012] Specifically, in step S4, the defect region output by the detection model is represented by defect coordinates; The area of the defect is obtained from its coordinates; The defect region is cropped from the first preprocessed image using the defect coordinates, and then the grayscale and contrast of the cropped defect region are calculated using OpenCV. Threshold comparisons are performed on the area, confidence level, gray level, and contrast of the defect to obtain the corresponding threshold comparison results. Then, the threshold comparison results are used to obtain the label of whether the current defect can be ignored by using a mapping table. For defects labeled as "cannot be ignored", the defect label and defect area are recorded in the database and associated with the bottle number of the corresponding batch.
[0013] The beneficial effects of this invention are as follows: In the glass bottle defect detection method, after acquiring images of the bottle body, bottle mouth, and bottle bottom at once, classifying them, and storing them in a pre-defined image library, incremental learning is performed using corresponding pre-trained models based on these three types of images to obtain corresponding detection models. Then, based on the trained detection models, detection is performed on newly input bottle body, bottle mouth, and bottle bottom images respectively, thereby obtaining defect labels, defect regions, and confidence levels. In this way, different parts of the glass bottle can be detected simultaneously, thereby reducing the total process time and achieving rapid glass bottle detection. Attached Figure Description
[0014] Figure 1 This is a flowchart of a glass bottle defect detection method in one embodiment of the present invention. Detailed Implementation
[0015] The specific embodiments of the present invention will be further described below with reference to the accompanying drawings. It should be noted that these descriptions are for the purpose of aiding understanding the present invention, but do not constitute a limitation thereof. Furthermore, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0016] like Figure 1 As shown, a method for detecting defects in glass bottles includes the following steps: S1: Use different cameras to capture images of the glass bottle from three perspectives: side view, top view, and bottom view. Store the side view images in the bottle body image library, the top view images in the bottle mouth image library, and the bottom view images in the bottle bottom image library. S2: Mark the defect areas in all images and add corresponding defect labels to obtain the first preprocessed image with defect areas and defect labels; S3: For the first pre-processed images in the bottle body image library, the bottle mouth image library, and the bottle bottom image library, respectively, apply the corresponding pre-trained models. Take the first pre-processed image as input and output the predicted defect region and the predicted defect label. Based on the difference between the defect region in the first pre-processed image and the predicted defect region, as well as the difference between the defect label in the first pre-processed image and the predicted defect label, perform incremental learning on the corresponding pre-trained models to obtain the detection models corresponding to the bottle body, bottle mouth, and bottle bottom, respectively. In this scheme, the pre-trained model refers to the pre-trained model obtained by training on the deep learning framework PyTorch using more than 100,000 real and non-repeating data from the production line. At this time, the parameters required by the model have been adjusted and optimized to a relatively stable state (including learning rate, detection box loss weight, detection category loss weight, and data augmentation parameters). Retraining on the basis of this pre-trained model to achieve incremental learning can make the model converge faster and achieve the ideal effect faster. Compared with training on a model with random parameters, the training time can be improved by at least 100%. S4: Input the newly acquired images from the bottle body image library, bottle mouth image library, and bottle bottom image library into the corresponding detection models to obtain the corresponding defect labels, defect regions, and confidence levels.
[0017] In the described glass bottle defect detection method, after acquiring images of the bottle body, bottle mouth, and bottle bottom at once, classifying them, and storing them in a pre-defined image library, incremental learning is performed using corresponding pre-trained models based on these three image types to obtain corresponding detection models. Then, based on the trained detection models, detection is performed on newly input bottle body, bottle mouth, and bottle bottom images respectively, thereby obtaining defect labels, defect regions, and confidence scores. In this way, different parts of the glass bottle can be detected simultaneously, reducing the total process time and achieving rapid glass bottle inspection.
[0018] It is worth noting that in step S2, the images in the bottle body image library, bottle mouth image library, and bottle bottom image library are classified according to morphological features, illumination distribution, and texture features, and the images are assigned classification labels corresponding to the classification results. Based on the classification labels, the corresponding defect labeling model is obtained using a mapping table. The image is input into the defect labeling model corresponding to its classification label to obtain the defect region and defect label.
[0019] For example, the bottle body has 40 defects, the bottle mouth has 10 defects, and the bottle bottom has 40 defects. The defect labels corresponding to each defect category are separately distinguished for the bottle body, bottle mouth, and bottle bottom. The defect characteristics of each part of the bottle body, bottle mouth, and bottle bottom differ significantly, so different defect labeling models are used for labeling. For instance, the bottle body is assigned code A, the bottle mouth code B, and the bottle bottom code C. Then, the morphological characteristics of the bottle body are divided into two categories based on the bottle type and expert observation, and assigned codes A11 and A12 respectively. Similarly, the morphological characteristics of the bottle mouth are divided into two categories based on the bottle type and expert observation, and assigned codes B11 and B12 respectively. The morphological characteristics of the bottle bottom are divided into two categories based on the bottle type and expert observation, and assigned codes C11 and C12 respectively. Then, the light distribution of the bottle body is divided into two categories based on expert observation, according to daytime and nighttime, and assigned codes A21 and A22 respectively. The illumination distribution of the bottle is divided into two categories based on expert observation, daytime and nighttime, and assigned codes B21 and B22 respectively. Similarly, the illumination distribution of the bottle bottom is also divided into two categories based on expert observation, daytime and nighttime, and assigned codes C21 and C22 respectively. Then, the texture features of the bottle body are divided into two categories based on expert observation, frosted and polished, and assigned codes A31 and A32 respectively. The texture features of the bottle mouth are also divided into two categories based on expert observation, frosted and polished, and assigned codes B31 and B32 respectively. The texture features of the bottle bottom are also divided into two categories based on expert observation, frosted and polished, and assigned codes C31 and C32 respectively. The mapping table stores combinations of numbers and the corresponding defect annotation model numbers. For example, if the combination of numbers is A-A11-A22-A31, in the mapping table, this combination of numbers corresponds to defect annotation model number X10. Therefore, defect annotation model number X10 will be used to annotate the defect areas and defect labels on the image of the combination of numbers.
[0020] In this embodiment, the defect annotation model stored in the mapping table is a selected model trained on a large number of images similar to the current image. This defect annotation model is an existing model used for image annotation, and will not be described in detail again. By inputting the image into this defect annotation model for detection, the detected defects (defect regions and defect labels) are saved as a JSON file. Since the model may detect new data correctly or incorrectly, or the detected defect locations may be inaccurate, after detection by the defect annotation model, the corresponding image and the defect information saved in the JSON file can be opened through LabelMe for manual fine-tuning to the correct annotation. Compared to completely manual re-annotation, the speed is significantly improved.
[0021] Preferably, in step S3, based on the difference between the defect region in the first preprocessed image and the predicted defect region, and the difference between the defect label in the first preprocessed image and the predicted defect label, the precision, recall, and mean precision (mAP@0.5) of the model are calculated. The current model is used as the detection model when the precision, recall, and mean precision (mAP@0.5) of the previous time are all equal to the precision, recall, and mean precision (mAP@0.5) of the current time.
[0022] Beneficial effects: Precision is used to evaluate the model's ability to detect correctly; a higher value indicates fewer false positives. Recall is used to evaluate the model's ability to detect correctly without missing objects; a higher value indicates fewer missed objects. Mean Accuracy (mAP@0.5) represents the average accuracy when the Intersection over Union (IoU) between the detected bounding box and the ground truth bounding box is greater than 0.5. During model training, after each input of the first preprocessed image to the model and the output of the predicted defect region and the predicted defect label, the model's precision, recall, and mean accuracy (mAP@0.5) are calculated. When precision, recall, and mean accuracy (mAP@0.5) no longer improve, it indicates that the model has been successfully trained.
[0023] Calculation process: The pre-trained model outputs a predicted bounding box, pred, where pred = [x1, y1, x2, y2, conf, cls], x1 is the top-left corner coordinate (x), y1 is the bottom-left corner coordinate (y), x2 is the top-right corner coordinate (x), y2 is the bottom-right corner coordinate (y), conf is the confidence score, and cls is the predicted defect label. The four coordinates x1, y1, x2, and y2 together form the predicted defect region. The predicted defect region is then compared with the defect region and defect label in the ground truth labeled targets (the defect region and defect label in the first pre-processed image) to calculate TP and FP. TP (True Positive) is the number of correctly detected positive samples, and FP (False Positive) is the number of samples incorrectly detected as positive samples.
[0024] Specifically, accuracy: During model detection, each predicted bounding box (pred) is matched with the ground truth labeled targets using Intersection over Union (IoU). If the IoU between the predicted bounding box (pred) and the ground truth labeled targets is ≥ 0.5, and the defect label matches, the number of predicted totals (TPs) is incremented by one; if the IoU between the predicted bounding box (pred) and any ground truth labeled targets is < 0.5, or the defect label does not match, the number of predicted partials (FPs) is incremented by one.
[0025] Specifically, recall rate: FN (False Negative) represents the number of real positive samples that were not detected by the model. For each ground truth labeled target, if there is no predicted bounding box with an IoU ≥ 0.5 with it, the number of FN is incremented by one.
[0026] Average accuracy (mAP@0.5): Plot a Precision-Recall curve for each defect label: the horizontal axis represents Recall, and the vertical axis represents Precision. Then calculate Average Precision (AP). ; It is the recall value of the i-th term in the Precision-Recall curve. It is the recall value of the (i-1)th term in the Precision-Recall curve. This represents the precision value of the i-th element in the precision-recall curve, where n is the total number of recalls. The average precision mAP is obtained by averaging the AP values for all defect labels. C represents the total number of defect labels, and c=1 represents the first defect label. This represents the AP value corresponding to the c-th defect label.
[0027] Optionally, in step S4, for defects labeled as small black dot defects and small bubble defects, the corresponding defect regions are obtained, cropped and stored, and then the defect regions are enlarged proportionally (specifically enlarged to a preset size), and then input into the trained fine defect detection model to obtain the model output to update the corresponding defect labels, defect regions and confidence levels.
[0028] In this embodiment, the trained small defect detection model is trained through the following steps: the defect regions labeled as small black dot defects and small bubble defects in the preprocessed image obtained in step S2 are cropped out and enlarged proportionally. The enlarged image is then labeled with the defect regions and corresponding defect labels to obtain the corresponding image, which is recorded as the small defect preprocessed image. Then, a pre-trained model, independent of the preprocessed images in the bottle body image library, the bottle mouth image library, and the bottle bottom image library, is used. The small defect preprocessed image is taken as input, and the defect regions and defect labels are taken as output. Incremental learning is performed on the corresponding pre-trained model to train the small defect detection model.
[0029] Specifically, in step S2, for the images in the bottle bottom image library, the model number area and model number type of the bottle bottom model number in the image are marked to obtain a second preprocessed image marked with the model number area and model number type. In step S3, a pre-trained model for pattern number detection is used on the second pre-processed image. The second pre-processed image is taken as input, and the pattern number region and pattern number type are taken as output. Incremental learning is performed on the pre-trained model for pattern number detection to obtain the pattern number detection model. In step S4, the newly acquired image from the bottle bottom image library is input into the model number detection model to obtain the corresponding model number region and model number type.
[0030] In this embodiment, the module type is the number 0 to 9, and the module on the bottom of the bottle is used to identify information about the bottle, such as the production date. To differentiate it from defect detection, a different module detection pre-trained model is used for incremental learning. Specifically, the module detection pre-trained model is also based on the deep learning framework PyTorch, and is trained using over 100,000 real and non-repeating data points from the production line.
[0031] It is worth noting that in step S4, for newly acquired images from the bottle body image library, bottle mouth image library, and bottle bottom image library, before inputting them into the corresponding detection model, the images are first scaled proportionally to the input size required by the corresponding detection model.
[0032] Specifically, for newly acquired images from the bottle body image library, bottle mouth image library, and bottle bottom image library, before inputting them into the corresponding detection model, the images are scaled proportionally and edge-filled to expand the side length of the image to an integer multiple of the convolution kernel of the corresponding detection model.
[0033] Image scaling is the process of proportionally scaling image data to the input size required by the detection model, such as 800. (800), this size can be changed arbitrarily for different needs. Edge padding: Since the detection model extracts features from the image through convolutional kernels, edge padding is needed to expand the side length of the scaled image to an integer multiple of the convolutional kernel. The advantage is that the computational load can be reduced by customizing the padding to a minimum multiple of the convolutional kernel. After edge padding, channel padding is used to expand the dimension of the single-channel image to the 3 channels required by the detection model.
[0034] Specifically, image scaling, edge padding, and channel padding are implemented using CUDA kernel functions, and the specific process is as follows: Copy image data from the CPU to the GPU; Operate the GPU to calculate the source image coordinates (e.g., src_x, src_y) for the target image coordinates (e.g., dx, dy) for each thread of the GPU. The target image is scaled by affine transformation, and the coordinates of the scaled target image are mapped back to the coordinates of the source image using the affine matrix. If the coordinates of the source image are outside the source image, edge padding will be applied (default grayscale value 114). The above operations are faster when performed using a single channel. Since the actual detection uses grayscale images, it is necessary to copy two identical single-channel images and stack them to form a 3-channel image to fit the input of the detection model.
[0035] Preferably, in step S3, after obtaining the detection models corresponding to the bottle body, bottle mouth and bottle bottom, the detection models are converted into TensorRT format and OpenVINO format respectively, wherein the TensorRT format detection model is deployed on the GPU and the OpenVINO format detection model is deployed on the CPU.
[0036] Beneficial effects: In this embodiment, the detection model is converted between TensorRT and OpenVino formats to be suitable for use on GPU and CPU, respectively.
[0037] It is worth noting that in step S4, the defect area output by the detection model is represented by defect coordinates; The area of the defect is obtained from its coordinates; The defect region is cropped from the first preprocessed image using the defect coordinates, and then the grayscale and contrast of the cropped defect region are calculated using OpenCV (OpenSource Computer Vision Library). Threshold comparisons are performed on the area, confidence level, gray level, and contrast of the defect to obtain the corresponding threshold comparison results. Then, the threshold comparison results are used to obtain the label of whether the current defect can be ignored by using a mapping table. For defects labeled as "cannot be ignored", the defect label and defect area are recorded in the database and associated with the bottle number of the corresponding batch.
[0038] The detection model outputs the defect label, confidence score (probability of the predicted defect label), and defect region (defect coordinates) of the current image. The defect region is cropped from the image using the defect coordinates. Then, OpenCV is used to analyze the defect, calculate the grayscale and contrast of the current defect region, and calculate the area of the defect using the defect coordinates. Finally, the current defect is filtered by comparing it with the area, confidence score, grayscale, and contrast of the defect input by the user and the corresponding threshold.
[0039] In this embodiment, the mapping table stores combinations of the area, confidence level, grayscale, and contrast of defects compared to thresholds. For example, if the defect area is greater than the corresponding threshold, it is denoted as W1; if the defect area is less than or equal to the corresponding threshold, it is denoted as W0; if the confidence level is greater than the corresponding threshold, it is denoted as X1; if the confidence level is less than or equal to the corresponding threshold, it is denoted as X0; if the grayscale is greater than the corresponding threshold, it is denoted as Y1; if the grayscale is less than or equal to the corresponding threshold, it is denoted as Y0; if the contrast is greater than the corresponding threshold, it is denoted as Z1; if the contrast is less than or equal to the corresponding threshold, it is denoted as Z0. Each combination corresponds to a filtering index in the mapping table, which is either negligible (represented by code 1) or non-negligible (represented by code 0). For the combination W1-X1-Y0-Z1, its filtering index in the mapping table may be 0, so the mapping table will output a label that cannot be ignored. In addition, when the output is negligible, the defect label and defect area of the image are not recorded in the database to indicate that this defect can be ignored. In this embodiment, when image acquisition is performed in step S1, the batch of the glass bottle corresponding to the image and the number of the glass bottle in the batch are recorded in the image and stored in the database. After the defect label and defect area are determined in step S4 and stored in the database, the association with the batch and bottle number can be realized.
[0040] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings, but the present invention is not limited to the described embodiments. For those skilled in the art, various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention, and these variations still fall within the protection scope of the present invention.
Claims
1. A method for detecting defects in glass bottles, characterized in that, Includes the following steps: S1: Use different cameras to capture images of the glass bottle from three perspectives: side view, top view, and bottom view. Store the side view images in the bottle body image library, the top view images in the bottle mouth image library, and the bottom view images in the bottle bottom image library. S2: Mark the defect areas in all images and add corresponding defect labels to obtain the first preprocessed image with defect areas and defect labels; S3: Apply corresponding pre-trained models to the first pre-processed images in the bottle body image library, the bottle mouth image library, and the bottle bottom image library, respectively. Take the first pre-processed image as input and output the predicted defect region and the predicted defect label. Based on the difference between the defect region in the first pre-processed image and the predicted defect region, as well as the difference between the defect label in the first pre-processed image and the predicted defect label, perform incremental learning on the corresponding pre-trained models to obtain the detection models corresponding to the bottle body, bottle mouth, and bottle bottom, respectively. S4: Input the newly acquired images from the bottle body image library, bottle mouth image library, and bottle bottom image library into the corresponding detection models to obtain the corresponding defect labels, defect regions, and confidence levels.
2. The method for detecting defects in glass bottles according to claim 1, characterized in that: In step S2, images in the bottle body image library, bottle mouth image library, and bottle bottom image library are classified according to morphological features, illumination distribution, and texture features, and the images are assigned classification labels corresponding to the classification results. Based on the classification labels, the corresponding defect labeling model is obtained using a mapping table. The image is input into the defect labeling model corresponding to its classification label to obtain the defect region and defect label.
3. The method for detecting defects in glass bottles according to claim 1, characterized in that: In step S3, based on the difference between the defect region in the first preprocessed image and the predicted defect region, and the difference between the defect label in the first preprocessed image and the predicted defect label, the precision, recall, and mean precision (mAP@0.5) of the model are calculated. The current model is used as the detection model when the precision, recall, and mean precision (mAP@0.5) of the previous time are all equal to the precision, recall, and mean precision (mAP@0.5) of the current time.
4. The method for detecting defects in glass bottles according to claim 1, characterized in that: In step S4, for defects labeled as small black dot defects and small bubble defects, the corresponding defect regions are obtained, cropped and stored, and then the defect regions are enlarged proportionally and input into the trained fine defect detection model to obtain the model output to update the corresponding defect labels, defect regions and confidence levels.
5. The method for detecting defects in glass bottles according to claim 1, characterized in that: In step S2, for the images in the bottle bottom image library, the model number area and model number type of the bottle bottom model number in the image are marked to obtain a second preprocessed image marked with the model number area and model number type. In step S3, a pre-trained model for pattern number detection is used on the second pre-processed image. The second pre-processed image is taken as input, and the pattern number region and pattern number type are taken as output. Incremental learning is performed on the pre-trained model for pattern number detection to obtain the pattern number detection model. In step S4, the newly acquired image from the bottle bottom image library is input into the model number detection model to obtain the corresponding model number region and model number type.
6. The method for detecting defects in glass bottles according to claim 1, characterized in that: In step S4, for newly acquired images from the bottle body image library, bottle mouth image library, and bottle bottom image library, the images are first scaled proportionally to the input size required by the corresponding detection model before being input into the corresponding detection model.
7. The method for detecting defects in glass bottles according to claim 6, characterized in that: For newly acquired images from the bottle body image library, bottle mouth image library, and bottle bottom image library, before inputting them into the corresponding detection model, the images are scaled proportionally and edge-filled to expand the side length of the image to an integer multiple of the convolution kernel of the corresponding detection model.
8. The method for detecting defects in glass bottles according to claim 1, characterized in that: In step S3, after obtaining the detection models corresponding to the bottle body, bottle mouth and bottle bottom, the detection models are converted into TensorRT format and OpenVINO format respectively. The TensorRT format detection model is deployed on the GPU and the OpenVINO format detection model is deployed on the CPU.
9. The method for detecting defects in glass bottles according to claim 1, characterized in that: In step S4, the defect region output by the detection model is represented by defect coordinates; The area of the defect is obtained from its coordinates; The defect region is cropped from the first preprocessed image using the defect coordinates, and then the grayscale and contrast of the cropped defect region are calculated using OpenCV. Threshold comparisons are performed on the area, confidence level, gray level, and contrast of the defect to obtain the corresponding threshold comparison results. Then, the threshold comparison results are used to obtain the label of whether the current defect can be ignored by using a mapping table. For defects labeled as "cannot be ignored", the defect label and defect area are recorded in the database and associated with the bottle number of the corresponding batch.
Citation Information
Cited By
Glass bottle flaw recognition device and method based on double-ring track sampling
CN122090239A