Method and terminal for detecting glass defect characteristics
By using line array cameras and deep learning models in glass detection, quickly switching light source conditions and recombining images, the problems of complex control logic and high hardware cost in traditional methods are solved, and efficient and accurate glass defect detection is achieved.
Patent Information
- Application Number
- CN202411830629.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-03-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When detecting glass defects, the traditional multi-camera multi-light source line array scanning method has complex control logic and low efficiency, high hardware cost, and is difficult to effectively arrange in a production line environment.
Linear array cameras are used for progressive scanning, quickly switch different light source conditions, capture images of the same glass under different light sources, and by splitting the collected data according to the light source conditions and recombining them into independent light source images, the image with the clearest defect characteristics is extracted, and defect detection is used using deep learning models.
It significantly simplifies complex image fusion and calibration problems in multi-camera systems, reduces hardware costs and system complexity, improves the accuracy and type coverage of defect detection, and is suitable for large-scale industrial applications.
Smart Images

Figure CN119574568A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of defect detection, and in particular to a method and a terminal for detecting glass defect characteristics. Background Art
[0002] At present, most domestic glass manufacturers and processing companies generally use the traditional multi-camera multi-group constant light source linear array scanning method to detect defects in glass and its surface printing. The advantage of this method is that it can design dedicated lighting conditions for different detection requirements, and improve the reliability of detection through the configuration of multiple cameras, and even serve as a redundant system.
[0003] However, this traditional method also has many disadvantages, which limits its efficiency and applicability in actual production scenarios. Traditional methods are highly dependent on light sources. For different types of glass defects, such as bubbles, scratches, or printing peeling, different light sources and photo-taking schemes usually need to be designed, which not only increases the complexity of the hardware, but also requires additional control logic to coordinate the synchronization of the light source and the camera. In addition, since the traditional method requires multiple sets of light sources and multiple cameras, the equipment is usually arranged in parallel, resulting in a large installation space requirement and difficult arrangement in some production line environments. At the same time, the hardware cost of the multi-camera multi-light source system is high. Each camera and light source needs to be installed and configured independently, which significantly increases the cost of system construction. At the same time, each set of light sources and cameras usually needs to develop specific algorithms for different detection requirements, which leads to an increase in the cost of algorithm development and the difficulty of subsequent maintenance and management. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a method and a terminal for detecting glass defect characteristics, so as to solve the problem of complex control logic and low efficiency of multi-camera scanning.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is: A method for detecting glass defect characteristics, comprising the steps of: S1. Scan the glass line by line using a line array camera, and switch a preset type of light source condition for each line of image during scanning; S2, respectively obtaining exposure data of each row of images under corresponding light source conditions; S3, splitting the collected exposure data into multiple sub-images according to light source conditions, and splicing the image rows under each light source condition to generate a corresponding independent light source image; S4. Based on each of the independent light source images, an image with the clearest defect features is extracted as the optimal image; S5. Use a deep learning model to perform defect detection on the optimal image and output the defect location and category.
[0006] In order to solve the above technical problems, another technical solution adopted by the present invention is: A terminal for detecting glass defect characteristics comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor completes the following steps when executing the computer program: S1. Scan the glass line by line using a line array camera, and switch a preset type of light source condition for each line of image during scanning; S2, respectively obtaining exposure data of each row of images under corresponding light source conditions; S3, splitting the collected exposure data into multiple sub-images according to light source conditions, and splicing the image rows under each light source condition to generate a corresponding independent light source image; S4. Based on each of the independent light source images, an image with the clearest defect features is extracted as the optimal image; S5. Use a deep learning model to perform defect detection on the optimal image and output the defect location and category.
[0007] The beneficial effects of the present invention are: providing a method and terminal for detecting glass defect characteristics, by quickly switching different light source conditions in a single scan, capturing images of the same piece of glass under different light sources, splitting the collected data according to the light source conditions and reorganizing them into independent light source images, effectively highlighting the defect characteristics. Using a deep learning model to detect the optimal image not only improves the accuracy and type coverage of defect detection, but also greatly simplifies the complex image fusion and calibration problems in multi-camera systems, significantly reducing hardware costs and system complexity. Since all images are collected by the same camera, data consistency is guaranteed, further simplifying subsequent image analysis and processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] Figure 1 is a flow chart of a method for detecting glass defect characteristics in an embodiment of the present invention; Figure 2 This is a schematic diagram of an image showing the clearest defect features in an embodiment of the present invention; Figure 3 It is a schematic diagram of an image of defect positions and categories in an optimal image output according to an embodiment of the present invention; Figure 4 is a specific flow chart of a method for detecting glass defect characteristics in an embodiment of the present invention; Figure 5 is a schematic diagram of a terminal for detecting glass defect characteristics in an embodiment of the present invention; Description of labels: 1. A terminal for detecting glass defect characteristics; 2. A memory; 3. A processor. DETAILED DESCRIPTION
[0009] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0010] Please refer to Figures 1 to 4 , a method for detecting glass defect characteristics, comprising the steps of: S1. Scan the glass line by line using a line array camera, and switch a preset type of light source condition for each line of image during scanning; S2, respectively obtaining exposure data of each row of images under corresponding light source conditions; S3, splitting the collected exposure data into multiple sub-images according to light source conditions, and splicing the image rows under each light source condition to generate a corresponding independent light source image; S4. Based on each of the independent light source images, an image with the clearest defect features is extracted as the optimal image; S5. Use a deep learning model to perform defect detection on the optimal image and output the defect location and category.
[0011] From the above description, it can be seen that the beneficial effects of the present invention are: by quickly switching between different light source conditions in a single scan, capturing images of the same piece of glass under different light sources, splitting the collected data according to the light source conditions and reorganizing them into independent light source images, effectively highlighting the characteristics of defects. Using a deep learning model to detect the optimal image not only improves the accuracy and type coverage of defect detection, but also greatly simplifies the complex image fusion and calibration problems in multi-camera systems, significantly reducing hardware costs and system complexity. Since all images are collected by the same camera, data consistency is guaranteed, further simplifying subsequent image analysis and processing In some implementations, in step S5, the deep learning model is a target detection algorithm model based on YOLOv8, and the training process of the target detection algorithm model is specifically as follows: Use annotation tools to annotate defective areas in the split multi-light source images and convert them into YOLOv8 compatible data files; Dividing the data file into a training set and a validation set according to a preset ratio to complete the data set production; The target detection algorithm model is trained based on the data set to generate model weights suitable for defect detection.
[0012] From the above description, we can see that the target detection algorithm model based on YOLOv8 can accurately detect defect areas in the optimal light source image by generating dedicated deep learning model weights through labeling and training. The application of the YOLOv8 model significantly improves the accuracy and speed of defect detection, and at the same time, through the standardized data set production process, the generalization ability and practicality of the model are guaranteed.
[0013] In some implementations, in step S5, the process of using the deep learning model to perform defect detection on the optimal image is specifically as follows: Convert the trained weight file of the target detection algorithm into a format suitable for the TensorRT model; The TensorRT model is called to load the optimal image, the detection results including the position coordinates and category information of the defect target are output, and the detection results are reversely mapped to the original image.
[0014] From the above description, we can see that by converting the weight file of the YOLOv8 model into the TensorRT model format and using the accelerated reasoning capability of TensorRT, the optimal image can be inspected in real time. The inspection results include the defect location coordinates and category information, and can be directly mapped back to the original image. This process significantly improves the inspection efficiency and system adaptability, while ensuring the visualization and ease of use of the inspection results.
[0015] In some embodiments, step S3 further comprises the steps of: According to the law of light source switching, the exposure data is classified according to the light source conditions; Splitting each type of exposure data into sub-images of fixed size at a row level, wherein the sub-images have a uniform resolution and format; All image rows under the same light source condition are spliced to generate corresponding independent light source images.
[0016] From the above description, we can see that by classifying and splitting the exposure data at the row level, the original scan data can be efficiently converted into independent light source images of fixed size, ensuring the uniform image format and adapting to the input requirements of the deep learning model. The method of stitching images based on light source conditions not only enhances the clarity of defect features, but also simplifies subsequent image processing steps.
[0017] In some embodiments, step S4 further comprises the steps of: Analyzing pixel contrast and texture features of corresponding areas in each of the independent light source images; The analysis results of each light source image are sorted according to the preset evaluation index, and the optimal image is selected according to the sorting results.
[0018] From the above description, it can be seen that by analyzing the pixel contrast and texture features of the independent light source image, the optimal image is selected according to the preset evaluation index. This process can automatically screen out the imaging results with the most significant defect features, reduce the subjectivity of manual judgment, and improve the accuracy and efficiency of defect detection.
[0019] Please refer to Figure 5 A terminal for detecting glass defect characteristics comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor completes the steps in the method for detecting glass defect characteristics when executing the computer program.
[0020] Please refer to Figures 1 to 4 , Embodiment 1 of the present invention is: A method for detecting glass defect characteristics, comprising the steps of: S1. Scan the glass line by line using a line array camera, and switch a preset type of light source condition for each line of image during scanning; S2, respectively obtaining exposure data of each row of images under corresponding light source conditions; S3, splitting the collected exposure data into multiple sub-images according to light source conditions, and splicing the image rows under each light source condition to generate a corresponding independent light source image; S4. Based on each independent light source image, the image with the clearest defect features is considered as the optimal image; S5. Use the deep learning model to perform defect detection on the optimal image and output the defect location and category.
[0021] A line array camera is used to scan the glass surface, and time-sharing stroboscopic technology is used to switch between three light source conditions (white light, blue light, and red light) to capture the imaging characteristics of the glass under different light sources.
[0022] The original image of each scan is split into three groups of exposure data according to the light source law, and each group of data is split into sub-images with fixed resolution (such as a resolution of 16384×1000) at the row level. These sub-images are spliced to generate three independent light source images. Through contrast analysis, the image with the most significant defect features is selected as the optimal image and input into the YOLOv8 model for detection. Finally, the coordinate position and category of the defect are output, and the defect area is marked on the detection result and displayed on the original image.
[0023] Embodiment 2 of the present invention is: Based on the first embodiment, in step S5, the deep learning model is a target detection algorithm model based on YOLOv8, and the training process of the target detection algorithm model is specifically as follows: Use annotation tools to annotate defective areas in the split multi-light source images and convert them into YOLOv8 compatible data files; Divide the data file into training set and validation set according to the preset ratio to complete the data set production; The target detection algorithm model is trained based on the data set to generate model weights suitable for defect detection.
[0024] Specifically, manually mark glass defect areas such as bubbles, scratches, and printing peeling from different light source images, and use the annotation tool to generate XML format files. Convert the XML file to a YOLOv8-compatible TXT file, and divide the training set and validation set into a ratio of 6:4. During the training process, set the training parameters: Set batch size to 64, which indicates the number of images in each batch. A high batch size can provide more stable gradient estimates and help the model learn a wider range of features. Set imgsz to 1024, which indicates the input image size, to make the features in the image richer; Setting cos_lr to true means using the cosine annealing learning rate to automatically adjust the learning rate according to the progress of training, making the model convergence more stable.
[0025] The data augmentation parameters flipud and fliplr are set to 0.5, which means that each image has a 50% probability of being flipped horizontally or vertically during training; Mosaic is set to 0.5, which means that during the training process, each image has a 50% chance of applying mosaic enhancement technology, allowing the model to identify objects in a smaller range; Mixup is set to 0.5, which means that two images are randomly selected from each batch and mixed at a ratio of 0.5 to generate a new image. The parameters of the network model are carefully configured to optimize the model performance.
[0026] In step S5, the process of using the deep learning model to perform defect detection on the optimal image is specifically as follows: Convert the trained weight file of the target detection algorithm into a format suitable for the TensorRT model; Call the TensorRT model to load the optimal image, output the detection results including the location coordinates and category information of the defect target, and map the detection results back to the original image.
[0027] Specifically, the trained model is first converted into an onnx model, and then converted into the trt format through the TensorRt engine. According to the industrial computer graphics card, the graphics card driver is updated to configure CUDA and cudNN to ensure compatibility with TensorRt to compile the TensorRt project, and the CMake file is written for compilation and generation. After generation, the CUDA properties are configured based on the project to generate a dll file; that is, the optimized TensorRT model file is loaded to accelerate reasoning through GPU resources. For each piece of glass, the optimal image generated by the time-sharing light source is input, and the model quickly outputs the location coordinates and category of the defect. The detection results are mapped to the original image through the algorithm, and the defective area is visually marked and fed back to the production line for quality control and defect classification.
[0028] Embodiment 3 of the present invention is: Based on the first embodiment, step S4 further includes the following steps: Analyze the pixel contrast and texture characteristics of the corresponding area in each independent light source image; The analysis results of each light source image are sorted according to the preset evaluation index, and the optimal image is selected according to the sorting results.
[0029] Specifically, the independent light source images are input into the analysis module to calculate the contrast, brightness difference and texture clarity of the defective area in each image. The evaluation index (such as contrast ≥ 0.8, texture clarity ≥ 0.7) is set, and the images under each light source are sorted. The image that meets the index requirements and has the highest score is selected as the optimal image, and further defect detection is performed through the deep learning model.
[0030] Please refer to Figure 5 , Embodiment 4 of the present invention is: A terminal 1 for detecting glass defect characteristics comprises a memory 2, a processor 3 and a computer program stored in the memory 2 and executable on the processor 3. When the processor 3 executes the computer program, the steps in the method for detecting glass defect characteristics are completed.
[0031] In summary, the present invention provides a method and terminal for detecting glass defect features, which realizes efficient detection of glass defect features by adopting a linear array camera combined with time-sharing stroboscopic technology. Compared with the traditional multi-camera multi-light source linear array scanning method, the present invention has the following beneficial effects: first, by dynamically switching the light source conditions of a single camera, the imaging of glass under different light sources is obtained in one scan, which greatly reduces the complexity and cost of hardware configuration, and avoids the parallax and illumination inconsistency problems caused by calibration errors in multi-camera systems. Secondly, by splitting and reorganizing the scan data into independent light source images according to the light source conditions, the image with the clearest defect features is extracted for deep learning detection, which significantly improves the detection accuracy and efficiency. Furthermore, combined with the YOLOv8 target detection model and TensorRT reasoning technology, it can realize intelligent detection of high-precision, real-time and diversified defects to meet the high-paced requirements of industrial production. In addition, the method unifies the detection algorithm process, reduces the complexity of algorithm customization in multi-camera systems, and reduces maintenance and management costs. Finally, through the optimization analysis of defect imaging characteristics, the present invention can adapt to complex lighting environments and is suitable for a variety of glass defect detection scenarios. The overall solution is efficient, low-cost, high-precision, and suitable for large-scale industrial applications.
[0032] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for detecting glass defect characteristics, characterized in that: Includes steps: S1. Scan the glass line by line using a line array camera, and switch a preset type of light source condition for each line of image during scanning; S2, respectively obtaining exposure data of each row of images under corresponding light source conditions; S3, splitting the collected exposure data into multiple sub-images according to light source conditions, and splicing the image rows under each light source condition to generate a corresponding independent light source image; S4. Based on each of the independent light source images, an image with the clearest defect features is extracted as the optimal image; S5. Use a deep learning model to perform defect detection on the optimal image and output the defect location and category.
2. A method for detecting glass defect characteristics according to claim 1, characterized in that: In step S5, the deep learning model is a target detection algorithm model based on YOLOv8, and the training process of the target detection algorithm model is specifically as follows: Use annotation tools to annotate defective areas in the split multi-light source images and convert them into YOLOv8 compatible data files; Dividing the data file into a training set and a validation set according to a preset ratio to complete the data set production; The target detection algorithm model is trained based on the data set to generate model weights suitable for defect detection.
3. A method for detecting glass defect characteristics according to claim 2, characterized in that: In step S5, the process of using the deep learning model to perform defect detection on the optimal image is specifically as follows: Convert the trained weight file of the target detection algorithm into a format suitable for the TensorRT model; The TensorRT model is called to load the optimal image, the detection results including the position coordinates and category information of the defect target are output, and the detection results are reversely mapped to the original image.
4. The method for detecting glass defect characteristics according to claim 1, characterized in that: The step S3 further comprises the steps of: According to the law of light source switching, the exposure data is classified according to the light source conditions; Splitting each type of exposure data into sub-images of fixed size at a row level, wherein the sub-images have a uniform resolution and format; All image rows under the same light source condition are spliced to generate corresponding independent light source images.
5. The method for detecting glass defect characteristics according to claim 1, characterized in that: The step S4 further comprises the steps of: Analyzing pixel contrast and texture features of corresponding areas in each of the independent light source images; The analysis results of each light source image are sorted according to the preset evaluation index, and the optimal image is selected according to the sorting results.
6. A terminal for detecting glass defect characteristics, characterized in that: The invention comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are performed: S1. Scan the glass line by line using a line array camera, and switch a preset type of light source condition for each line of image during scanning; S2, respectively obtaining exposure data of each row of images under corresponding light source conditions; S3, splitting the collected exposure data into multiple sub-images according to light source conditions, and splicing the image rows under each light source condition to generate a corresponding independent light source image; S4. Based on each of the independent light source images, an image with the clearest defect features is extracted as the optimal image; S5. Use a deep learning model to perform defect detection on the optimal image and output the defect location and category.
7. A terminal for detecting glass defect characteristics according to claim 6, characterized in that: In step S5, the deep learning model is a target detection algorithm model based on YOLOv8, and the training process of the target detection algorithm model is specifically as follows: Use annotation tools to annotate defective areas in the split multi-light source images and convert them into YOLOv8 compatible data files; Dividing the data file into a training set and a validation set according to a preset ratio to complete the data set production; The target detection algorithm model is trained based on the data set to generate model weights suitable for defect detection.
8. A terminal for detecting glass defect characteristics according to claim 7, characterized in that: In step S5, the process of using the deep learning model to perform defect detection on the optimal image is specifically as follows: Convert the trained weight file of the target detection algorithm into a format suitable for the TensorRT model; The TensorRT model is called to load the optimal image, the detection results including the position coordinates and category information of the defect target are output, and the detection results are reversely mapped to the original image.
9. A terminal for detecting glass defect characteristics according to claim 6, characterized in that: The step S3 further comprises the steps of: According to the law of light source switching, the exposure data is classified according to the light source conditions; Splitting each type of exposure data into sub-images of fixed size at a row level, wherein the sub-images have a uniform resolution and format; All image rows under the same light source condition are spliced to generate corresponding independent light source images.
10. A terminal for detecting glass defect characteristics according to claim 6, characterized in that: The step S4 further comprises the steps of: Analyzing pixel contrast and texture features of corresponding areas in each of the independent light source images; The analysis results of each light source image are sorted according to the preset evaluation index, and the optimal image is selected according to the sorting results.
Citation Information
Patent Citations
Method for detecting and classifying glass defects based on machine vision
CN102305798A
Glass surface defect enhancement device and detection method thereof
CN104897693A
Rolled glass defect detection device and method
CN110702699A
Visual detection system and method for through hole of transparent plate
CN111006608A
Glass defect visual detection algorithm
CN111709919A
Cited By
Quartz fiber glass bead defect detection method and system based on microscopic imaging
CN121147103A