A method for detecting a neck deficiency of a glass bottle
By using computer vision technology and image processing methods, high-precision detection of minute defects at the mouth of glass bottles has been achieved, solving the problem that existing technologies cannot reliably detect minute defects at the mouth of bottles, thus improving detection accuracy and food safety.
Patent Information
- Application Number
- CN202211281486.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-19
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2042-10-19
AI Technical Summary
Existing technologies cannot effectively detect minute defects in the glass bottle opening, leading to food safety risks and failing to meet the higher requirements of downstream customers.
Using computer vision technology, non-contact inspection of glass bottle openings is performed through image processing. The quality of the bottle opening is determined by fitting a line segment parameter array and slope change trend. The Douglas-Puk algorithm is combined for fitting to achieve high-precision defect detection.
It improves detection accuracy, reduces the rate of missed detections and false detections, avoids the impact of mechanical vibration, simplifies production line equipment, and ensures food safety.
Smart Images

Figure CN115713485B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of glass bottle mouth defect detection, and particularly relates to a defect detection method for a glass bottle mouth. BACKGROUND
[0002] In the process of producing large-mouth glass bottles, mouth deficiency is a common defect. The relatively obvious mouth deficiency defect can be detected by the air tightness detection function of the comprehensive bottle inspection machine. The small mouth deficiency defect cannot be detected by the existing equipment in the production stage, and the artificial lamp inspection also cannot detect it. When the downstream customers use large-mouth bottles as food containers, they generally use screw caps with safety buttons for sealing. The air leakage caused by small mouth deficiency will make the safety button float, thereby playing a reminding role. Now the requirements of downstream customers for bottle and can manufacturers are further improved, and they require that the bottle and can match the bottle cap without safety button, and at the same time, there should be no air leakage and deterioration of the product to flow to the end consumer. Therefore, the bottle and can manufacturers must use a new method to reliably detect the small mouth deficiency defect to meet the needs of customers. SUMMARY
[0003] The purpose of the present application is to provide a defect detection method for a glass bottle mouth, which solves the technical problem of low defect detection precision of the existing large-mouth glass bottles, which affects the quality of food production and packaging.
[0004] In order to achieve the above purpose, the technical scheme adopted by the present application is as follows:
[0005] A defect detection method for a glass bottle mouth, the method comprising the following steps:
[0006] Step 1: selecting the range of the glass bottle mouth to be detected to obtain a bottle mouth to be detected region;
[0007] Step 2: identifying the glass bottle mouth frame in the bottle mouth to be detected region, then generating the minimum circumscribed rectangle of the glass bottle mouth, and then performing a reduction process on the minimum circumscribed rectangle to obtain a reduced rectangular region;
[0008] Step 3: performing fusion processing on the rectangular region and the bottle mouth to be detected region to obtain a filled region;
[0009] Step 4: generating a contour line for the filled region, then fitting the contour line to obtain the coordinates and slope of a plurality of line segments;
[0010] Step 5: filtering the coordinates and slope of the plurality of line segments to obtain a fitting line segment parameter array;
[0011] Step 6: arranging the line segment starting point horizontal coordinates in the fitting line segment parameter array in ascending order to obtain a sorted slope array;
[0012] Step 7: The elements in the slope array are sorted according to the subscript from small to large. When the slope value changes continuously, it indicates that the bottle mouth is qualified, otherwise it is unqualified.
[0013] Further, the specific process of step 1 is as follows: the camera is installed above the conveying line conveying the glass bottle, and then the glass bottle is placed on the conveying line for conveying. The camera is used to shoot the area of the glass bottle mouth to be detected to obtain an image of the detected glass bottle mouth area. Then a rectangular selection area is manually set on the image of the detected glass bottle mouth area. Then the rectangular selection area is threshold segmented and the background and noise points are filtered out to obtain the effective pixels of the glass bottle mouth image.
[0014] Further, in step 2, the minimum circumscribed rectangle of the glass bottle mouth is taken as a reference. The vertical coordinates of the top edge remain unchanged, the horizontal coordinates of the left and right edges are symmetrically moved inward, and the vertical coordinates of the bottom edge are moved upward to obtain a reduced rectangular selection area. The vertical edges of the bottle mouth on both sides of the bottle mouth and the bottle mouth range on both sides of the vertical edges of the bottle mouth are filtered out.
[0015] Further, in step 3, the reduced rectangular selection area is subjected to Boolean operation with the bottle mouth area to be detected to retain the overlapping area. Then the overlapping area is filled to obtain a filling area to be detected without pores. The filling area to be detected is a closed area surrounded by vertical lines on the left and right, a horizontal line at the bottom, and an arc line at the top. The arc line at the top is a curve coinciding with the curvature of the bottle mouth.
[0016] Further, in step 4, the filling area is attached to a two-dimensional coordinate axis, and then a contour line is generated outside the filling area. The left and right vertical lines and the horizontal line at the bottom are deleted, and only the top curve is retained. Then the Douglas-Peucker algorithm is used to fit the top curve. The fitting process is as follows:
[0017] 1) A line segment XY is connected between the X and Y points at the beginning and end of the top curve. The line segment is the chord of the curve.
[0018] 2) The point Z on the curve farthest from the XY line segment is obtained, and the distance d between Z and XY is calculated.
[0019] 3) The distance d is compared with the pre-set threshold Max1. If d<Max1, the line segment XY is taken as the fitting line segment of the curve, and the curve segment is processed.
[0020] 4) If d>Max1, the curve is divided into XZ and ZY by point Z, and the curves on both ends are processed according to 1-3.
[0021] 5) When all curves are processed, the broken line formed by connecting each segmented point once can be taken as the fitting line of the top curve.
[0022] 6) Get the start point horizontal coordinate and slope of each fitting line segment, and put them into the array for use.
[0023] Further, in step 6: set the mapping relationship between the horizontal coordinate of the start point of each line segment and the slope of each line segment, then perform ascending processing on the numerical value of the horizontal coordinate to obtain an array of sorted horizontal coordinate numerical values, and then replace the numerical value of the horizontal coordinate with the mapped slope to obtain a slope array.
[0024] Further, in step 7: subtract the n-th item from the n+1-th item of the slope array, and check whether all the results are sequentially decreasing. If they are sequentially decreasing, it means that the bottle mouth curve is a continuous arch-shaped curve, and the bottle mouth can be determined to be qualified. If the calculation results are not sequentially decreasing, but increase, it means that the bottle mouth curve has a concave or convex protrusion on the arch, and the bottle mouth can be determined to be unqualified.
[0025] The present application has the following beneficial effects due to the use of the above technical solutions:
[0026] The present application uses computer vision technology, and the detection equipment based on the present application can achieve non-contact detection without relying on complex machinery, so the detection rate can be much higher than that of mechanical contact detection. The feature parameters extracted through image processing have a significant causal relationship with the actual defects, so the detection accuracy is also much higher than that of mechanical contact detection. In addition, due to the avoidance of the influence of mechanical vibration and jamming, the miss detection rate and the false detection rate are greatly reduced, the debugging difficulty and maintenance cost are also reduced, and ordinary mouth defects can also be detected, so the comprehensive bottle inspection machine at the back end of the production line can omit a set of mechanical air tightness detection equipment, freeing up a valuable workstation for other detection, while improving the detection accuracy and avoiding the deterioration of food storage in the later stage. BRIEF DESCRIPTION OF DRAWINGS
[0027] Fig. 1 is a method flowchart of the present application;
[0028] Fig. 2 is a detection process diagram of the present application;
[0029] Fig. 3 is a filling area diagram of the present application. DETAILED DESCRIPTION
[0030] To make the purpose, technical solutions and advantages of the present application clearer and more apparent, the following preferred embodiments are described in detail with reference to the accompanying drawings. However, it should be noted that many details in the description are only used to make the reader have a thorough understanding of one or more aspects of the present application, and the aspects of the present application can be realized without these specific details.
[0031] As Figs. 1-3 shown in the figure, a method for detecting the defect of insufficient mouth of glass bottle, the method comprises the following steps:
[0032] Step 1: install a camera above the conveying line of the glass bottle conveying, then put the glass bottle on the conveying line for conveying, use the camera to shoot the area of the glass bottle mouth to be detected, get the image of the detection glass bottle mouth area, then manually set a rectangular selection area on the image of the detection glass bottle mouth area, then binarize the rectangular selection area and filter out the noise points.
[0033] Step 2: identify the glass bottle mouth edge in the bottle mouth area to be detected, then generate the minimum circumscribed rectangle of the glass bottle effective image, then reduce the minimum circumscribed rectangle to obtain a reduced rectangular area to filter out the part that does not need to be detected. Take the minimum circumscribed rectangle of the glass bottle mouth as the benchmark, keep the longitudinal coordinate of the top edge unchanged, symmetrically move the horizontal coordinates of the left and right edges inward, and move the bottom edge longitudinal coordinate upward to obtain a reduced rectangular selection area, and filter out the bottle mouth vertical edges on both sides of the bottle mouth and the bottle mouth range on both sides of the bottle mouth vertical edges.
[0034] Step 3: take out the overlapping part of the reduced rectangular area and the bottle mouth area to be detected to obtain the overlapping area. Fill the overlapping area to obtain the measured filling area, which is a closed area including the vertical lines on both sides, the horizontal line of the bottom edge and the arc line of the top end. The left and right edges are vertical lines, and the arc line of the top end is a curve that coincides with the curvature of the bottle mouth.
[0035] Step 4: generate the contour line of the filling area, then fit the contour line to obtain the coordinates and slope of several line segments. Attach the filling area to the two-dimensional coordinate axis, then generate the contour line outside the filling area, then fit the contour line. In the fitting process, the parameters are constantly adjusted to ensure that the measured contour is fitted and the length of the line segment is the optimal solution, avoiding the appearance of fine line segments, and then put the starting point coordinates and slope of each line segment into an array.
[0036] The fitting process of the top curve comprises the following steps:
[0037] 1) Connect a line segment XY between the first and last X, Y points of the top curve, which is the chord of the curve;
[0038] 2) Get the point Z on the curve farthest from the XY line segment, and calculate the distance d between the curve and XY;
[0039] 3) Compare the distance d with the pre-given threshold Max1, if d<Max1, then the line segment XY is the fitting line segment of the curve, and the curve segment is processed;
[0040] 4) If d>Max1, then divide the curve into two ends with point Z, and process the two ends curve with step 1)~3) respectively;
[0041] 5) When all curves are processed, connect the broken lines formed by the segmentation points to obtain the fitting line of the top curve;
[0042] 6) Obtain the starting point horizontal coordinate and slope of each fitting line segment, and put them into an array for use.
[0043] Step 5: Filter the coordinates and slopes of several line segments to obtain the fitting line segment parameter array. Filter the coordinates and slope numbers of the fitting line segments corresponding to the left and right vertical lines and the bottom edge of the to-be-tested filling area, and obtain the fitting line segment parameter array of the bottle opening to-be-tested area.
[0044] Step 6: Sort the line segment starting point horizontal coordinates in the fitting line segment parameter array in ascending order to obtain the sorted slope array. Obtain the horizontal coordinate values of the starting points of each line segment in the fitting line segment parameter array, set the mapping relationship between the horizontal coordinate values of the starting points of each line segment and the slopes of each line segment, then sort the horizontal coordinate values in ascending order to obtain the sorted horizontal coordinate value array, then replace the slope values mapped by the horizontal coordinate values to obtain the slope array.
[0045] Step 7: Determine the trend of the elements in the slope array according to the index from small to large. When the slope values change continuously, it indicates that the bottle opening is qualified, otherwise it is unqualified.
[0046] The slope change trend of the bottle opening contour fitting line segment is used to judge whether the bottle opening has defects. The detection equipment based on the algorithm described in the present application has been successfully put into use in Yuhua Glass, and after months of actual use, the effect meets the expectation, solving the problem of unreliable detection of small mouth defects.
[0047] The above is only the preferred embodiment of the present application, it should be noted that for ordinary skilled in the art, without departing from the principles of the present application, can make a number of improvements and refinements, these improvements and refinements should be considered as the protection scope of the present application.
Claims
1. A method for detecting defects in the neck of glass bottles, characterized in that: The method includes the following steps: Step 1: Manually set a rectangular selection area on the glass bottle image to roughly include the glass bottle image; Step 2: Binarize the selected area of the image from Step 1, adjust the parameters to remove the background and noise, generate the effective pixel area of the bottle, generate the minimum bounding rectangle of the effective pixel area, and then shrink the minimum bounding rectangle to filter out the bottle area that does not need to be detected, and obtain the bottle mouth selection area. Step 3: Extract the overlapping area between the bottle mouth selection area and the effective pixel area of the bottle body to obtain the filling area; Step 4: Generate an outline for the filled area, retain the curve at the top of the bottle opening, and then use the Douglas-Puk algorithm to fit line segments to the curve at the top of the bottle opening, and put the starting point x-coordinate and slope of several line segments into an array; Step 5: Sort the elements in the array in ascending order by the starting x-coordinate to obtain the slope array of each line segment of the bottle mouth curve fitting line segment from left to right; Step 6: Judge the elements in the slope array according to the index from small to large. When the slope value changes continuously, it means that the bottle opening is qualified; otherwise, it is unqualified. In Step 4: Attach the filled area to the two-dimensional coordinate axis, and then generate the outline outside the filled area, keeping only the top curve. Then fit the top curve. During the fitting process, adjust the parameters to make the fitted line segment as close to the curve as possible and avoid the appearance of fragmented line segments. Then put the starting point x-coordinate and slope of each line segment into an array. In step 5: obtain the x-coordinate value of the starting point of each line segment in the fitted line segment parameter array, set the x-coordinate of the starting point of each line segment to the slope mapping relationship of each line segment, then sort the x-coordinate values in ascending order to obtain a sorted x-coordinate value array, and then replace the values with the slope mapping of the x-coordinate values to obtain a slope array. The process of fitting the top curve includes the following steps: 1) Connect the first and last points X and Y of the top curve with a line segment XY, where line segment XY is a chord of the curve; 2) Find the point Z on the curve that is the furthest from the XY line segment, and calculate the distance d between the curve and the XY line segment; 3) Compare the distance d with the pre-given threshold Max1. If d < Max1, then the line segment XY is used as the fitting line segment of the curve, and the curve segment is processed. 4) If d > Max1, then divide the curve into two ends, XZ and ZY, using point Z, and process the curves at both ends respectively using steps 1) to 3). 5) When all curves have been processed, the polyline formed by connecting all the division points at once can be used as the fitting line for the top curve. 6) Obtain the starting point x-coordinate and slope of each fitted line segment and put them into an array for later use.
2. The defect detection method for insufficient glass bottle opening according to claim 1, characterized in that: The specific process of step 1 is as follows: install the camera diagonally above the conveyor line for transporting glass bottles, then place the glass bottles on the conveyor line for transport, use the camera to capture the area of the glass bottle opening to be detected, obtain an image of the glass bottle opening area to be detected, then manually set a rectangular selection area on the image of the glass bottle opening area to be detected, and then perform threshold segmentation on the rectangular selection area and filter out noise.
3. The defect detection method for insufficient glass bottle opening according to claim 1, characterized in that: In step 2: Using the smallest bounding rectangle of the glass bottle opening as the reference, the ordinate of the fixed end remains unchanged, the horizontal coordinates of the left and right sides move symmetrically inward, and the ordinate of the bottom side moves upward to obtain a reduced rectangular selection area, filtering out the vertical edges of the bottle opening on both sides and the bottle opening range on both sides of the vertical edges of the bottle opening.
4. The defect detection method for insufficient glass bottle opening according to claim 1, characterized in that: In step 3: Perform a Boolean operation on the rectangular area and the area to be detected at the bottle mouth, then retain the overlapping area, and fill the overlapping area to obtain the area to be tested. The shape of the area to be tested is a closed area, including the vertical lines on the left and right sides, the horizontal line at the bottom, and the arc line at the top. The vertical lines on the left and right sides are vertical lines, and the arc line at the top is a curve that coincides with the curvature of the bottle mouth.
Citation Information
Patent Citations
Work edge detecting image processor
JP1997251544A
Enhancing the tonal characteristics of digital images
US20030235342A1