Method and device for detecting foreign matters in glass bottle and storage medium

By using X-ray sources and high-low frequency separation technology with different voltages at the same viewing angle in the detection of foreign matter in glass bottles, the problems of detection accuracy and production line flow efficiency are solved, and high-precision foreign matter detection and efficient production line flow are achieved.

CN119880962AActive Publication Date: 2025-04-25TECHIK INSTR SHANGHAI

Patent Information

Application Number
CN202510376843.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-28
Publication Date
2025-04-25
Estimated Expiration
2045-03-28

AI Technical Summary

Technical Problem

When detecting foreign matter in glass bottles, it is difficult to obtain clear images in different density areas, resulting in a decrease in detection accuracy and requires a long time to stand after filling to perform detection, which reduces the production line flow efficiency.

Method used

The X-ray source with different voltages at the same viewing angle is taken, and the output picture is obtained through high and low frequency separation, high frequency enhancement and splicing and convolution, which significantly displays the foreign objects suspended in the glass bottle, and is detected through the target detection model.

Benefits of technology

The detection accuracy and reliability are improved, and foreign matter detection can be performed immediately after the filling process, avoiding waiting while standing, and significantly improving the flow efficiency of the entire production line.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119880962A_ABST
    Figure CN119880962A_ABST
Patent Text Reader

Abstract

The invention relates to the field of filled food foreign matter detection, in particular to a method and a device for detecting foreign matters in a glass bottle and a storage medium, and the method comprises the following steps: S1, respectively acquiring a plurality of X-ray pictures of different voltages under the same visual angle for a glass bottle to be detected; s2, aligning all the obtained X-ray pictures, and synthesizing to obtain a multi-channel first picture; s3, performing convolution and up-sampling on the first picture to obtain a low-frequency feature map, and subtracting the low-frequency feature map from the first picture to obtain a high-frequency feature map; s4, enhancing the high-frequency feature map; s5, fusing the enhanced high-frequency feature map and the up-sampled low-frequency feature map, and performing convolution to obtain an output picture; and S6, inputting the output picture into a target detection model to obtain a foreign matter detection result. Compared with the prior art, suspended foreign matters at different positions can be detected under the condition that long-time standing is not needed after filling.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of foreign matter detection in filled food, and in particular to a method, a device and a storage medium for detecting foreign matter in a glass bottle. Background Art

[0002] With the continuous development of industrial automation, the quality inspection technology of bottled products has become an important link in the food, medicine and other industries. As a common packaging material, the detection of foreign matter inside glass bottles is of great significance to ensure product quality and consumer safety.

[0003] Although some existing technologies provide detection solutions for glass bottle defects, for example, Chinese patent CN117351314A discloses a glass bottle defect recognition method and system, the light source used in the glass bottle defect recognition method is a visible light source, which can only be used to detect defects in the glass bottle itself with high light transmittance. When the glass bottle is filled with related products, or when the bottle body of the glass bottle is affixed with a label, it cannot penetrate the glass bottle for imaging, so it cannot detect foreign objects in the glass bottle. In addition, Chinese patent CN118090743A provides a porcelain wine bottle quality inspection system based on multimodality. Similarly, its purpose is also to detect defects in the bottle itself, so it also relies on visible light images.

[0004] In this regard, some improved existing technologies have improved the penetration ability by replacing the light source with an X-ray light source, thereby realizing the detection of the inside of thicker glass bottles. For example, Chinese patent CN112508930A discloses a food foreign body detection method and device based on deep learning, or Chinese patent CN 113567478 A discloses a new X-ray foreign body detection system with a single light source and three viewing angles. Both use X-ray light sources to detect foreign bodies in food packaging. In particular, Chinese patent CN 113567478 A is mainly aimed at detecting foreign bodies in glass cans. However, this solution still has the following problems: Due to the complex structural characteristics of glass bottles, such as the different thicknesses and densities of the bottle body, bottle cap, and bottle bottom, the traditional single voltage X-ray imaging technology is difficult to effectively detect foreign bodies in various parts in the same image. The existing X-ray detection method usually uses a single voltage or a simple image processing algorithm to identify foreign bodies. This method may perform well when detecting foreign bodies in thinner areas of the bottle body, but when processing denser areas such as the bottle bottom or bottle cap, the image contrast and resolution are insufficient, which can easily lead to a decrease in detection accuracy. In addition, excessively increasing the voltage may cause overexposure of the bottle body area, thereby covering up subtle foreign objects. Therefore, how to obtain clear images in different density areas and accurately detect foreign objects has become a technical problem that needs to be solved urgently.

[0005] In this regard, although Chinese patent CN 113567478 A attempts to use multiple viewing angles for shooting, different viewing angles correspond to different travel paths, which can achieve the effect of reducing blind spots, and has achieved certain results in foreign body detection at the bottom of the bottle, it still has the following defects: 1. Some foreign matter suspended in the solution cannot be effectively detected. Therefore, on the one hand, the types of foreign matter that can be detected are limited. On the other hand, the product needs to be left to stand for a long time after filling before foreign matter detection can be performed, which undoubtedly reduces the flow efficiency of the entire production line; 2. The deviations of the three views used are large, and image registration is difficult. If the fusion process is forced, there is a defect of misleading the model, which may easily lead to the model being unable to converge or specialize. Therefore, images from different perspectives can only be preprocessed and feature extracted separately, and then classified, which undoubtedly reduces efficiency. Summary of the invention

[0006] The purpose of the present invention is to solve the problem in the prior art that foreign matter detection can only be performed after the filling is completed after a long period of static standing. A method, device and storage medium for detecting foreign matter in a glass bottle are provided. X-ray light sources with the same viewing angle but different voltages are used for shooting, so that the viewing angles of all single-channel X-ray images obtained are the same, the registration difficulty is low, and no new errors are introduced due to scaling and fusion. In addition, due to the use of different voltages, the imaging requirements of different density areas can be effectively covered. The output image obtained by subsequent high- and low-frequency separation, high-frequency enhancement, and convolution can clearly display foreign matter suspended in the glass bottle. While improving the detection accuracy and reliability, the foreign matter detection process can be placed close to the filling process, and there is no need to static stand after filling, which greatly improves the circulation efficiency of the entire production line.

[0007] The purpose of the present invention can be achieved by the following technical solutions: A method for detecting foreign matter in a glass bottle, comprising: Step S1: for the glass bottle to be inspected, a plurality of X-ray images of different voltages at the same viewing angle are obtained respectively; Step S2: aligning all acquired X-ray images and synthesizing them to obtain a multi-channel first image; Step S3: after convolving and upsampling the first image to obtain a low-frequency feature map, subtract the low-frequency feature map from the first image to obtain a high-frequency feature map; Step S4: enhancing the high-frequency feature map; Step S5: After fusing the enhanced high-frequency feature map and the upsampled low-frequency feature map, convolution is performed to obtain an output image; Step S6: Input the output image into the target detection model to obtain the foreign body detection result.

[0008] In the step S1, three X-ray images with different voltages at the same viewing angle are obtained, and the first image is a three-channel image.

[0009] The size of the first convolution kernel in the convolution process in step S3 is 3*3, and the step length is 2.

[0010] The upsampling process in step S3 adopts a bilinear interpolation method, and the size of the low-frequency feature map is the same as the size of the first image.

[0011] During the enhancement process in step S4, the enhanced high-frequency feature map is: F EP =Concat( F H * Conv 4 ,( F H * Conv2*CBAM *Conv3)) in: F H is the high-frequency feature map before enhancement, F EP is the enhanced high-frequency feature map, Conv2 is the second convolution kernel, Conv3 is the third convolution kernel, Conv 4 is the fourth convolution kernel, CBAM is the attention module operator, and Concat is the concatenation operation.

[0012] The step S5 comprises: Step S5-1: splicing the enhanced high-frequency feature map and the upsampled low-frequency feature map along the channel dimension to obtain a first intermediate map; Step S5-2: Use the fifth convolution kernel to perform a convolution operation on the first intermediate image to obtain an output image.

[0013] All convolution kernels and operators in step S2 to step S5 are obtained by deep learning training, and the training process is adjusted based on the first loss function, and the first loss function is:

[0014] in: L is the first loss function, is the output image obtained by step S5 i OK j The normalized pixel value of the pixel point in the column, is the output image in the training sample i OK j The normalized pixel value of the pixel point in the column, γ is the dynamic weight amplitude control parameter, is the L1 norm.

[0015] The normalized pixel value of any pixel is:

[0016] in: For the i OK j The pixel value of the normalized pixel point in the column k The value of the channel, For the i OK j The pixel value of the pixel point in the column before normalization k The value of the channel, For the i OK j The minimum value of all channels before the pixel of the column is normalized. For the i OK j The maximum value of all channels before the pixel in the column is normalized.

[0017] A foreign body detection device in a glass bottle comprises a memory, a processor, and a program stored in the memory, wherein the processor implements the above method when executing the program.

[0018] A storage medium stores a program, which implements the above method when executed.

[0019] Compared with the prior art, the present invention has the following beneficial effects: 1. Use X-ray light sources with the same viewing angle but different voltages to shoot, so that all single-channel X-ray images have the same viewing angle, low registration difficulty, and no new errors will be introduced due to scaling and fusion. In addition, due to the use of different voltages, the imaging needs of different density areas can be effectively covered. The output image obtained by subsequent high- and low-frequency separation, high-frequency enhancement, and convolution can clearly display foreign matter suspended in the glass bottle. While improving detection accuracy and reliability, the foreign matter detection process can be placed close to the filling process, without the need for static placement after filling, which greatly improves the flow efficiency of the entire production line.

[0020] 2. Compared with the conventional convolution and pooling enhancement methods, the high-frequency features are enhanced by three convolutions and one attention combined with splicing, which can highlight the advantages of details and clarity and completely ignore the contours and background. Figure 2The second splicing and re-convolution can make up for the lack of contour in the high-frequency feature map, thereby identifying foreign objects suspended in various positions of the glass bottle.

[0021] 3. The first loss function adopted can give higher weights to pixels with larger prediction errors, so as to better handle areas with inaccurate predictions. At the same time, normalizing each pixel based on the linear mapping of the three channels can fully integrate the information of different channels, so that the details and contours of the imaging of each voltage can be fully displayed. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 It is a schematic flow chart of the main steps of the method of the present invention; Figure 2 Schematic diagram of an X-ray image under a single voltage. DETAILED DESCRIPTION

[0023] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.

[0024] Example 1 A method for detecting foreign matter in a glass bottle, such as Figure 1 As shown, including: Step S1: for the glass bottle to be inspected, a plurality of X-ray images of different voltages at the same viewing angle are obtained respectively; Different from the foreign body detection methods including the prior art CN 113567478 A, the technical solution adopted in this application is single-viewing angle, which has the advantages of low material cost, simple on-site layout, and convenient maintenance. This application uses three different voltages to shoot glass bottles at the same viewing angle. Since the shooting time is very short, at the normal conveyor belt conveying speed, the deviation of the three X-ray images is extremely small. The specific shooting interval needs to be determined according to the device performance of the electronic control part on site, and the processing speed of CCD will not become a limiting factor. Generally, if the switching speed supported by the X-ray light source and its driver is faster, the interval can be smaller, so that the position deviation of the three X-ray images is also smaller. It is generally believed that the deviation is less than the physical length corresponding to one pixel, that is, there is no deviation.

[0025] In particular, in this embodiment, three X-ray images with different voltages at the same viewing angle are obtained, such as Figure 2 As shown, each X-ray image is a single-channel image taken under a single voltage, and after synthesis, a first image of three channels can be obtained.

[0026] Among them, due to the use of different voltages, the energy of the light emitted by the X-ray source at different voltages is different, which can effectively cover the imaging needs of different density areas.

[0027] Step S2: Align all acquired X-ray images and synthesize them to obtain a multi-channel first image. Generally, since the shooting angles are the same, if the deviation is less than the physical length corresponding to one pixel, the single image is aligned by default. Of course, in some embodiments, if the deviation is too large, alignment can be performed by translation.

[0028] In addition, in this embodiment, the alignment process also includes cropping, cropping the glass bottle part as much as possible and keeping the size of the overall image smaller, which can effectively reduce the computing power requirements in the subsequent processing process and also reduce noise. In this cropping process, the specific cropping area can be determined by selecting the medium voltage imaging image. In the medium voltage imaging image, the distinction between the background and the foreground is more obvious, which can improve the accuracy of cropping. Of course, in other embodiments, other cropping methods can also be used.

[0029] Step S3: after convolving and upsampling the first image to obtain a low-frequency feature map, subtract the low-frequency feature map from the first image to obtain a high-frequency feature map; In this embodiment, the size of the first convolution kernel in the convolution process is 3*3, the step size is 2, the upsampling process adopts a bilinear interpolation method, and the size of the low-frequency feature map is the same as the size of the first image.

[0030] Among them, the low-frequency information can reflect the general outline and background of the image, thus cooperating with the subsequent high-frequency enhancement method.

[0031] Step S4: Enhance the high-frequency feature map. In this embodiment, during the enhancement process, the enhanced high-frequency feature map is: F EP =Concat( F H * Conv 4 ,( F H * Conv2*CBAM *Conv3)) in: F H is the high-frequency feature map before enhancement, F EP is the enhanced high-frequency feature map, Conv2 is the second convolution kernel, Conv3 is the third convolution kernel, Conv 4 is the fourth convolution kernel, CBAM is the attention module operator, and Concat is the concatenation operation.

[0032] Compared with the conventional convolution and pooling enhancement method, the high-frequency features are enhanced by three convolutions and one attention combined with splicing, which can highlight the advantages of details and clarity and completely ignore the contours and background. Figure 2 The second splicing and re-convolution can make up for the lack of contour in the high-frequency feature map, thereby identifying foreign objects suspended in various positions of the glass bottle.

[0033] In this embodiment, the sizes of the second convolution kernel, the third convolution kernel and the fourth convolution kernel are all 3*3.

[0034] Step S5: After fusing the enhanced high-frequency feature map and the up-sampled low-frequency feature map, convolution is performed to obtain an output image. In this embodiment, the steps include: Step S5-1: splicing the enhanced high-frequency feature map and the upsampled low-frequency feature map along the channel dimension to obtain a first intermediate map; Step S5-2: Use the fifth convolution kernel to perform a convolution operation on the first intermediate image to obtain an output image. In this embodiment, the size of the fifth convolution kernel is also 3*3.

[0035] Additionally, in some embodiments, a 1*1 convolution may be used to adjust the output channels.

[0036] Step S6: Input the output image into the target detection model to obtain the foreign body detection result.

[0037] All convolution kernels and operators in the above steps S2 to S5 are obtained by deep learning training. The training process is adjusted based on the first loss function. The first loss function is:

[0038] in: L is the first loss function, is the output image obtained by step S5 i OK j The normalized pixel value of the pixel point in the column, is the output image in the training sample i OK j The normalized pixel value of the pixel point in the column, γ is a dynamic weight amplitude control parameter. In this embodiment, it is set to be greater than 1. is the L1 norm.

[0039] In this embodiment, the normalized pixel value of any pixel is:

[0040] in: For the i OK j The pixel value of the normalized pixel point in the column k The value of the channel, For the i OK j The pixel value of the pixel point in the column before normalization k The value of the channel, For the i OK j The minimum value of all channels before the pixel of the column is normalized. For the i OK j The maximum value of all channels before the pixel in the column is normalized.

[0041] In summary, by using X-ray light sources with the same viewing angle but different voltages to shoot, all single-channel X-ray images have the same viewing angle, low registration difficulty, and no new errors will be introduced due to scaling and fusion. In addition, due to the use of different voltages, the imaging needs of different density areas can be effectively covered. The output image obtained by subsequent high- and low-frequency separation, high-frequency enhancement, and convolution can clearly display foreign matter suspended in the glass bottle. While improving detection accuracy and reliability, the foreign matter detection process can be placed close to the filling process, without the need for static placement after filling, which greatly improves the flow efficiency of the entire production line.

[0042] Example 2 This embodiment is generally similar to Embodiment 1, with only a few differences. Specifically, the difference between this embodiment and Embodiment 1 is that in step S4 of this embodiment, the high-frequency features are Figure 1 A total of two enhancements were performed, and the two enhancements were performed in the same way.

[0043] In addition, in order to further verify the effect of this application, a comparative example is set as follows: Comparative Example 1 This comparative example is designed with reference to Example 1, and the difference from Example 1 is that in step S4 of this comparative example, only convolution and pooling operations are used without splicing, that is, the size of the high-frequency feature map after enhancement is consistent with that before enhancement, and the rest is the same as Example 1.

[0044] Comparative Example 2 This comparative example refers to the design of Chinese patent CN117351314A combined with Chinese patent CN112508930A, and a total of three different viewing angles are arranged to synchronously collect the glass bottles to be tested. The light source used is an X-ray light source. The arrangement directions of the three viewing angles are the same as Chinese patent CN117351314A, and different voltages are used. The rest are arranged with reference to CN117351314A.

[0045] By testing the glass filling beverage production line data, it was found that the time interval between the filling process and the foreign matter detection process in the production line was about 6 seconds, and there was not enough time to wait for stagnancy. A total of 1,000 groups of samples were obtained, each group of samples included three single-channel X-ray images, of which 700 groups were used as training set samples and the remaining 300 groups were used as test sets. Among them, the foreign matter detection rate of Example 2 exceeded 97%, and that of Example 1 also exceeded 91%. The detection rate of Comparative Example 2 was less than 10%, and the detection rate of Comparative Example 1 was about 60%.

[0046] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.

Claims

1. A method for detecting foreign matter in a glass bottle, characterized in that: include: Step S1: for the glass bottle to be inspected, a plurality of X-ray images of different voltages at the same viewing angle are obtained respectively; Step S2: aligning all acquired X-ray images and synthesizing them to obtain a multi-channel first image; Step S3: after convolving and upsampling the first image to obtain a low-frequency feature map, subtract the low-frequency feature map from the first image to obtain a high-frequency feature map; Step S4: enhancing the high-frequency feature map; Step S5: After fusing the enhanced high-frequency feature map and the upsampled low-frequency feature map, convolution is performed to obtain an output image; Step S6: Input the output image into the target detection model to obtain the foreign body detection result.

2. A method for detecting foreign matter in a glass bottle according to claim 1, characterized in that: In the step S1, three X-ray images with different voltages at the same viewing angle are obtained, and the first image is a three-channel image.

3. A method for detecting foreign matter in a glass bottle according to claim 1, characterized in that: The size of the first convolution kernel in the convolution process in step S3 is 3*3, and the step length is 2.

4. A method for detecting foreign matter in a glass bottle according to claim 1, characterized in that: The upsampling process in step S3 adopts a bilinear interpolation method, and the size of the low-frequency feature map is the same as the size of the first image.

5. The method for detecting foreign matter in a glass bottle according to claim 1, characterized in that: During the enhancement process in step S4, the enhanced high-frequency feature map is: F EP =Concat( F H * Conv 4 ,( F H * Conv2*CBAM *Conv3)) in: F H is the high-frequency feature map before enhancement, F EP is the enhanced high-frequency feature map, Conv2 is the second convolution kernel, Conv3 is the third convolution kernel, Conv 4 is the fourth convolution kernel, CBAM is the attention module operator, and Concat is the concatenation operation.

6. A method for detecting foreign matter in a glass bottle according to claim 1, characterized in that: The step S5 comprises: Step S5-1: splicing the enhanced high-frequency feature map and the upsampled low-frequency feature map along the channel dimension to obtain a first intermediate map; Step S5-2: Use the fifth convolution kernel to perform a convolution operation on the first intermediate image to obtain an output image.

7. A method for detecting foreign matter in a glass bottle according to claim 1, characterized in that: All convolution kernels and operators in step S2 to step S5 are obtained by deep learning training, and the training process is adjusted based on the first loss function, and the first loss function is: in: L is the first loss function, is the output image obtained by step S5 i OK j The normalized pixel value of the pixel point in the column, is the output image in the training sample i OK j The normalized pixel value of the pixel point in the column, γ It is the dynamic weight amplitude control parameter.

8. The method for detecting foreign matter in a glass bottle according to claim 1, characterized in that: The normalized pixel value of any pixel is: in: For the i OK j The pixel value of the normalized pixel point in the column k The value of the channel, For the i OK j The pixel value of the pixel point in the column before normalization k The value of the channel, For the i OK j The minimum value of all channels before the pixel of the column is normalized. For the i OK j The maximum value of all channels before the pixel in the column is normalized.

9. A foreign body detection device in a glass bottle, comprising a memory, a processor, and a program stored in the memory, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.

10. A storage medium having a program stored thereon, characterized in that: When the program is executed, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Food foreign matter detection method and device based on deep learning

    CN112508930A

  • Novel single-light-source three-view-angle X-ray foreign matter detection system

    CN113567478A

  • Porcelain wine bottle quality detection system based on multi-modal image recognition technology

    CN118090743A

  • Energy spectrum CT image domain material identification method based on 3D full convolutional neural network

    CN111950714A

  • Image fusion method and system based on error texture elimination strategy

    CN116091373A

Cited By

  • Liquid medicine filling online intelligent detection system of pharmaceutical production line based on visual detection

    CN122426698A