Cup seam positioning method and paper cup detection system
Through the cup slit positioning method, image preprocessing and block gradient scanning algorithms are used to quickly locate the cup slit position of the paper cup, achieving efficient and accurate paper cup detection, solving the efficiency and accuracy problems of manual detection.
Patent Information
- Application Number
- CN202011303103.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-19
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2040-11-19
AI Technical Summary
In the prior art, the quality inspection of paper cups mainly relies on manual visual inspection, which has low efficiency, poor accuracy, and is prone to secondary pollution.
The cup slit positioning method is adopted, by obtaining the cup body image of the paper cup, image preprocessing is performed to obtain the cup body gradient image, positioning the cup bottom or cup mouth, determining the cup wall area, and scanning the cup wall area using the block gradient scanning algorithm to determine the cup slit position.
It quickly locates the cup-slit position of the paper cup, accurately detects the dirt at the cup-slit, and solves the problems of inefficiency and secondary pollution of manual testing.
Smart Images

Figure CN114529496B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine vision, and in particular to a cup seam positioning method and a paper cup detection system. Background Art
[0002] Machine vision is widely used in the fields of automated production that we are familiar with: electronic manufacturing, automotive industry, pharmaceutical industry, food packaging, printing industry, etc. The function or action it realizes is to identify or detect an object: electronic component positioning, AOI optical inspection, assembly positioning and inspection, sorting and packaging, appearance inspection, etc. It plays a vital role and has unique advantages in the automation process of production and manufacturing: avoiding the outflow of defective products and reducing customer complaint costs; high-speed inspection, improving equipment capacity and operating efficiency, and reducing production costs. Its high precision, continuity, flexibility, and repeatability are unmatched by traditional inspection methods.
[0003] For example, after the paper cup manufacturers have mass-produced paper cups, the hygiene inspection link is particularly important. At present, the main test mode for paper cups is manual testing. The advantage of this mode is that it has high flexibility and can be flexibly tested and judged according to different specifications. However, if the human eye is used alone to judge whether there are stains on the inner wall of the paper cup, the human eye will quickly become tired, and the detection efficiency is low, and it may even cause secondary contamination of the paper cup. Therefore, the disadvantages of this mode are low efficiency, poor accuracy, and high long-term costs.
[0004] Therefore, how to effectively use machine vision systems to achieve quality inspection of paper cups has become one of the problems that the industry urgently needs to solve. Summary of the invention
[0005] The object of the present invention is to provide a cup seam positioning method and a paper cup detection system, which can realize the detection of paper cups.
[0006] In order to achieve the above-mentioned purpose, the present invention provides a cup seam positioning method, which comprises: step S1, acquiring a cup body image of a paper cup; step S2, performing image preprocessing on the cup body image to obtain a cup body gradient image at least including a cup bottom feature or a cup mouth feature of the paper cup; step S3, performing cup bottom positioning or cup mouth positioning according to the cup body gradient image, and correspondingly determining the cup bottom position or cup mouth position of the paper cup; step S4, performing cup wall positioning on the cup body gradient image according to the cup bottom position or the cup mouth position, and determining the annular cup wall area of the paper cup; step S5, scanning the annular cup wall area using a block gradient scanning algorithm to determine the cup seam position of the cup body.
[0007] In one embodiment of the present invention, in the step S1, when the paper cup is conveyed to the field of view of the industrial camera, the stroboscopic sphere integrating light source is triggered and a photo is taken to obtain the cup body image.
[0008] In one embodiment of the present invention, the image preprocessing in step S2 further includes: grayscale processing the cup body image to obtain a grayscale image.
[0009] In one embodiment of the present invention, the grayscale image is filtered to obtain a filtered image.
[0010] In one embodiment of the present invention, a guided filtering algorithm is used to remove interference points from the grayscale image to obtain a filtered image.
[0011] In one embodiment of the present invention, the filtered image is processed by a Sobel gradient algorithm to obtain the cup body gradient image.
[0012] In one embodiment of the present invention, in step S3, Hough circle detection is performed on the cup bottom or cup mouth of the cup body gradient image to obtain the cup bottom fitting circle or cup mouth fitting circle of the paper cup accordingly, thereby determining the cup bottom position or the cup mouth position.
[0013] In one embodiment of the present invention, in step S4, the annular cup wall area is determined according to the center position of the cup bottom fitting circle or the cup mouth fitting circle.
[0014] In one embodiment of the present invention, the step S5 includes: step S51, performing block gradient scanning on the annular cup wall area; step S52, recording contour points whose gradient is greater than a set threshold; step S53, performing straight line fitting based on the obtained contour points to obtain a cup seam fitting straight line; step S54, determining the cup seam position based on the cup seam fitting straight line.
[0015] In one embodiment of the present invention, in step S53, the RANSAC straight line fitting method is used to obtain the cup seam fitting straight line.
[0016] In an embodiment of the present invention, the step S51 further includes: determining the size of the scanning block and the displacement of each scanning; and determining the starting position and scanning direction of the scanning block.
[0017] In an embodiment of the present invention, the step S52 further includes calculating the average pixel grayscale of the cup body image.
[0018] In one embodiment of the present invention, in step S52, the average pixel grayscale of the position scanned by the scanning block is calculated, wherein the gradient of the position scanned by the scanning block is equal to the average pixel grayscale of the position scanned by the scanning block minus the average pixel grayscale of the cup body image, and the contour points whose gradient is greater than the set threshold are recorded.
[0019] In one embodiment of the present invention, after determining the cup seam position, the method further includes: step S6, performing stain detection on the cup body image outside the cup seam position.
[0020] In order to achieve the above-mentioned purpose, the present invention also provides a paper cup detection system, which includes: a conveying mechanism, used to convey the paper cup to be detected to a position to be detected; an industrial camera, correspondingly arranged at the position to be detected, used to obtain a cup body image of the paper cup located at the position to be detected; a processor, used to execute the cup seam positioning method as described above.
[0021] In one embodiment of the present invention, the paper cup detection system further includes: an annular stroboscopic sphere integrating light source, which is set corresponding to the industrial camera and is used to be triggered when the paper cup to be detected is conveyed to the position to be detected so as to provide light compensation for the industrial camera when taking pictures.
[0022] The present invention can quickly locate the cup seam position of a paper cup at a random angle, accurately detect dirt at the cup seam, and solve the defects of low efficiency, easy fatigue, and secondary pollution in manual visual inspection of paper cup dirt.
[0023] Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The above and other features and advantages of the present invention will become more apparent by describing in detail exemplary embodiments thereof with reference to the attached drawings.
[0025] Figure 1 It is a schematic flow chart of the cup seam positioning method of the present invention;
[0026] Figure 2 The specific process of the cup seam positioning method according to a preferred embodiment of the present invention is shown;
[0027] Figure 3 Shows Figure 2 The specific process of image preprocessing in
[0028] Figure 4 Shows Figure 2 The specific process of positioning the middle cup wall;
[0029] Figure 5 Shows Figure 2 The specific process of positioning the middle cup seam;
[0030] Figure 6 Shows Figure 2 Schematic diagram of paper cup imaging;
[0031] Figure 7FIG. 1 is a schematic structural diagram of a paper cup detection system according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0032] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that the present invention will be comprehensive and complete and fully convey the concepts of the example embodiments to those skilled in the art. The same reference numerals in the figures represent the same or similar structures, and thus their detailed description will be omitted.
[0033] When introducing the elements / components / etc. described and / or illustrated herein, the terms "a", "an", "the", "said", and "at least one" are used to indicate the presence of one or more elements / components / etc. The terms "comprises", "includes", and "have" are used to indicate an open-ended inclusive meaning and mean that additional elements / components / etc. may be present in addition to the listed elements / components / etc. Relative terms may be used in the embodiments, such as "upper" or "lower" to describe the relative relationship of one component of the icon to another component. It is understood that if the device of the icon is turned over so that it is upside down, the component described on the "upper" side will become the component on the "lower" side. In addition, the terms "first", "second", etc. in the claims are used only as labels and are not numerical limitations on their objects.
[0034] like Figure 1 As shown, a cup seam positioning method 100 provided by the present invention mainly includes:
[0035] Step S1, obtaining a cup body image of a paper cup.
[0036] Step S2: performing image preprocessing on the cup body image to obtain a cup body gradient image that at least includes a cup bottom feature or a cup mouth feature of the paper cup.
[0037] Step S3: positioning the cup bottom or the cup mouth according to the cup body gradient image, and determining the cup bottom position or the cup mouth position of the paper cup accordingly.
[0038] Step S4: positioning the cup wall of the cup body gradient image according to the cup bottom position or the cup mouth position, and determining the annular cup wall area of the paper cup.
[0039] Step S5: Scan the annular cup wall region using a block gradient scanning algorithm to determine the position of the cup seam of the cup body.
[0040] In other embodiments, after determining the cup seam position, the present invention may further include:
[0041] Step S6: Perform stain detection on the cup body image except for the cup seam position.
[0042] Preferably, in step S1, when the paper cup is conveyed to the field of view of the industrial camera, the stroboscopic sphere integrating light source may be triggered and a photo may be taken to obtain an image of the cup body, for example, a complete image of the cup body.
[0043] In some embodiments, in step S2, the image preprocessing can be performed on the complete cup body image, or on a portion of the cup body image, but it is necessary to obtain a cup body gradient image that at least contains the cup bottom features or cup mouth features of the paper cup. Step S2 can also further include: graying the cup body image to obtain a grayscale image. In addition, the interference points can be removed by using a guided filtering algorithm on the grayscale image to obtain a filtered image; and the cup body gradient image can be obtained by performing a Sobel gradient algorithm on the filtered image.
[0044] In some embodiments, in step S3, hough circle detection is performed on the cup body gradient image at the cup bottom or cup mouth to obtain the cup bottom fitting circle or cup mouth fitting circle of the paper cup accordingly, thereby determining the cup bottom position or cup mouth position.
[0045] Furthermore, in step S4, the annular cup wall area is determined according to the center position of the cup bottom fitting circle or the cup mouth fitting circle.
[0046] Among them, the determination of the cup seam position is as follows: Figure 5 As shown, step S5 may include:
[0047] Step S51, performing block gradient scanning on the annular cup wall area.
[0048] Before scanning, the size of the rectangular scanning block and the displacement of each scan can be determined; and the starting position and scanning direction of the scanning block can be determined.
[0049] Step S52: Record the contour points whose gradient is greater than the set threshold.
[0050] In this step, for example, the average pixel grayscale of the position scanned by the scanning block and the average pixel grayscale of the entire image can be calculated, wherein the average pixel grayscale of each scanning block minus the average pixel grayscale of the entire image is the gradient of each scanning block, and the contour points whose gradients are higher than the set threshold are recorded.
[0051] Step S53: performing straight line fitting according to the obtained contour points to obtain a cup seam fitting straight line.
[0052] Step S54, determining the cup seam position according to the cup seam fitting line.
[0053] like Figure 2 As shown, it shows the specific process of the cup seam positioning method of a preferred embodiment of the present invention, which may include:
[0054] The first step is to grab the image:
[0055] When the paper cup to be inspected is conveyed to the field of view of the industrial camera, the stroboscopic light source can be triggered and a photo can be taken to grab the paper cup to obtain a cup body image. The captured cup body image should show the cup bottom and the edge of the cup seam as clearly as possible for subsequent cup seam positioning. In other embodiments, the subsequent cup seam positioning can also be performed by grabbing the cup mouth and the edge of the cup seam at the top of the cup.
[0056] The second step is image preprocessing:
[0057] Preprocess the current cup body image obtained by the industrial camera, such as Figure 3 As shown, it may include, for example:
[0058] Step S21, grayscale the cup body image to obtain a grayscale image.
[0059] If the current paper cup image is a grayscale image, the grayscale processing can be skipped.
[0060] Step S22: filter the grayscale image to obtain a filtered image.
[0061] Among them, the filtering process can remove some interference points to better preserve the details of the cup seam, cup bottom, and cup bottom edge. In some embodiments, a guided filtering method can be used for filtering, and guided filtering can be used for noise reduction, detail smoothing, HDR compression, cutout, defogging, and joint sampling. It should be noted that in other embodiments, other filtering methods, such as bilateral filtering, can also be used. In terms of filtering effect, guided filtering is similar to bilateral filtering. Among them, the biggest advantage of guided filtering is that an algorithm whose time complexity is independent of the window size can be written, so it is more efficient when using a large window to process pictures.
[0062] Among them, the specific algorithm of guided filtering is implemented as follows:
[0063] 1) Assume that the image is at w k The window has the following linear relationship:
[0064] 2) According to the guide graph G, and satisfying the minimum pixel deviation between G and Q, that is, find Minimize value:
[0065]
[0066] 3) By linear regression method, we can get and
[0067] 4) When the guide image G is the original image I,
[0068] in, Represents in w k Grayscale variance in the window, |w| represents the total number of pixels in the window area, μ k Represents the grayscale mean of the I image window, p k Represents the grayscale mean of the G map window.
[0069] Therefore, when the window scans to the edge position, Q i =I i , thereby maintaining edge pixels; when the window scans at a non-edge position, Q i =μ k , thereby smoothing the window area.
[0070] Step S23: Perform Sobel edge detection on the filtered image to obtain a cup body gradient image.
[0071] When a paper cup is imaged under a light source, the image of the cup seam is weak, and it is easy to misjudge the position of the cup seam by directly locating it. The guided filter fusion Sobel gradient algorithm can smooth out the pseudo stains under the weak features of the paper cup, and can enhance the information of the cup bottom and cup seam edge, thereby improving the accuracy of cup bottom and cup seam positioning.
[0072] Step 3: Cup seam positioning:
[0073] By positioning the bottom of the cup or the mouth of the cup, the annular cup wall area of the paper cup is determined, and then the cup seam is positioned. Figure 4 As shown, including:
[0074] Step S31: perform Hough circle detection on the cup body gradient image to obtain a cup bottom fitting circle or a cup mouth fitting circle.
[0075] Combined with reference Figure 6 After image preprocessing, the cup bottom hough circle detection is performed on the obtained paper cup gradient image 60 to obtain the cup bottom fitting circle 61 of the paper cup.
[0076] Step S32: determine the center position according to the cup bottom fitting circle or the cup mouth fitting circle, and determine the annular cup wall area according to the center position.
[0077] Among them, the center position of the cup bottom can be determined according to the cup bottom fitting circle 61 of the paper cup, and further, the annular cup wall area 62 can be determined according to the center position of the cup bottom fitting circle, so as to realize the cup wall positioning. In this embodiment, the cup seam positioning is to determine the position of the cup wall area according to the center position of the cup bottom, that is, to realize the cup seam positioning by cup bottom positioning and cup wall positioning. In other embodiments, the position of the cup wall area can also be determined by the center position of the cup mouth, that is, the cup seam positioning can be realized by cup mouth positioning and cup wall positioning.
[0078] like Figure 5 As shown, after the cup wall is located, the annular cup wall area can be gradient scanned to determine the position of the cup seam, wherein the cup seam edge scanning algorithm can be divided into the following steps:
[0079] Step S51, performing block gradient scanning on the annular cup wall area. Figure 6 Before scanning, determine the size of the rectangular scanning block 63 and the displacement of each scan; determine the starting position of the scanning block and the scanning direction S, such as the detection area of the scanning block can be scanned clockwise or counterclockwise; the annular detection area can be scanned from inside to outside, or from outside to inside.
[0080] Step S52, record the contour points whose gradient is greater than the set threshold. Specifically, calculate the average pixel grayscale of the entire image, and calculate the average pixel grayscale of each scanned position of the scanning block each time. The average pixel grayscale of each scanning block minus the average pixel grayscale of the entire image is the gradient of each scanning block. Then, identify the edge type by the gradient direction, and then filter the required edges, and record the positions where the gradient is higher than the set threshold. For example, if a sudden change occurs from a position with higher brightness to a position with lower brightness, the set threshold is triggered. This gradient is positive, and the corresponding edge should be an edge that changes from "light to dark". Conversely, the set threshold can be triggered according to the edge that changes from "dark to light". The method for calculating the gradient is not limited to this.
[0081] Step S53, perform straight line fitting based on the obtained contour points to obtain the cup seam fitting straight line. After scanning, a set of pixel positions with gradients greater than a set threshold can be obtained, and the coordinate points are fitted by a straight line fitting method to obtain a cup seam fitting straight line 64. In some embodiments, the RANSAC (RANdom Sample Consensus) straight line fitting method is used to fit the cup seam. The RANSAC straight line fitting method can determine a straight line based on any two points, and then calculate the number of position points whose distance from the remaining points to the straight line is less than a given threshold, so as to find the optimal fitting straight line, that is, to obtain the cup seam fitting straight line 64.
[0082] It is understandable that the present invention can also fit a straight line by other methods, such as fitting a straight line by the least square method, which is not intended to limit the present invention. However, the RANSAC straight line fitting method is better than the least square method for fitting a straight line, because the RANSAC straight line fitting method can eliminate the interference of discrete points formed by stains on the cup wall, and the fitting method can automatically discard the coordinate points that are not on the edge of the cup seam, which can effectively avoid the influence of stains on the position accuracy of the fitted straight line. The least square method fitting adopts a global fitting method, and each point will affect the position of the fitted straight line, so it is not suitable for finding the best cup seam position. The fitting algorithm will calculate the center position of the cup seam based on all the cup seam coordinate points used to obtain the final fitted straight line according to these coordinate points.
[0083] Step S54, the cup seam position can be determined according to the cup seam fitting line. Specifically, the cup seam position 65 can be determined according to the cup seam fitting line 64.
[0084] Further, such as Figure 2 As shown, after determining the cup seam position, the present invention can also perform stain detection on the cup body image other than the cup seam position. The detection method can adopt various existing detection methods, which will not be repeated here.
[0085] like Figure 7 As shown, the present invention also provides a paper cup detection system 700, which mainly includes a conveying mechanism 71, an industrial camera 72 and a processor (not shown in the figure). Among them, the conveying mechanism 71 can be provided with a paper cup fixing groove 711, and the paper cup fixing groove 711 can accommodate a paper cup 712 to be detected, and the conveying mechanism 71 can be used to convey the paper cup 712 to be detected to a position to be detected. The industrial camera 72 is correspondingly arranged at the position to be detected, and is used to obtain a cup body image of the paper cup 712 located at the position to be detected. The industrial camera 72 can be composed of a CCD camera 721 and an industrial lens 722, for example. The processor can be used to execute the above cup seam positioning method.
[0086] In the present invention, the paper cup detection system 700 may further include an annular stroboscopic sphere integrating light source 73, which is arranged corresponding to the industrial camera 72 and can be used to be triggered when the paper cup 712 to be detected is conveyed to the position to be detected so as to provide light compensation for the industrial camera 72 when taking pictures.
[0087] The cup seam positioning method of the present invention can quickly locate the cup seam position of a paper cup at a random angle, and can accurately detect dirt at the cup seam, thereby effectively solving the defects of low efficiency, easy fatigue, and secondary pollution of manual visual inspection of paper cup dirt.
[0088] The exemplary embodiments of the present invention are specifically shown and described above. It should be understood that the present invention is not limited to the disclosed embodiments, but rather is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Claims
1. A cup seam positioning method, characterized in that: include: Step S1, obtaining a cup body image of a paper cup; Step S2, performing image preprocessing on the cup body image to obtain a cup body gradient image at least including a cup bottom feature or a cup mouth feature of the paper cup; Step S3, positioning the cup bottom or the cup mouth according to the cup body gradient image, and correspondingly determining the cup bottom position or the cup mouth position of the paper cup; Step S4, performing cup wall positioning on the cup body gradient image according to the cup bottom position or the cup mouth position, and determining the annular cup wall area of the paper cup; Step S5, scanning the annular cup wall region using a block gradient scanning algorithm to determine the cup seam position of the paper cup, comprising: Step S51, performing block gradient scanning on the annular cup wall area; Step S52, recording contour points whose gradient is greater than a set threshold; Step S53, performing straight line fitting according to the obtained contour points to obtain a cup seam fitting straight line; Step S54, determining the cup seam position according to the cup seam fitting straight line.
2. The cup seam positioning method according to claim 1, characterized in that: In the step S1, when the paper cup is conveyed to the field of view of the industrial camera, the stroboscopic sphere integrating light source is triggered and a photo is taken to obtain the cup body image.
3. The cup seam positioning method according to claim 1, characterized in that: The image preprocessing in step S2 includes: The cup body image is grayed to obtain a grayscale image.
4. The cup seam positioning method according to claim 3, characterized in that: The image preprocessing in step S2 further includes: The grayscale image is filtered to obtain a filtered image.
5. The cup seam positioning method according to claim 4, characterized in that: A guided filtering algorithm is used to remove interference points from the grayscale image to obtain a filtered image.
6. The cup seam positioning method according to claim 5, characterized in that: The image preprocessing in step S2 further includes: The filtered image is processed by a Sobel gradient algorithm to obtain the cup body gradient image.
7. The cup seam positioning method according to any one of claims 1 to 6, characterized in that: In step S3, the cup bottom or cup mouth is detected by Hough circle detection on the cup body gradient image to obtain the cup bottom fitting circle or cup mouth fitting circle of the paper cup accordingly, so as to determine the cup bottom position or the cup mouth position.
8. The cup seam positioning method according to claim 7, characterized in that: In step S4, the annular cup wall area is determined according to the center position of the cup bottom fitting circle or the cup mouth fitting circle.
9. The cup seam positioning method according to claim 1, characterized in that: In step S53, the RANSAC straight line fitting method is used to obtain the cup seam fitting straight line.
10. The cup seam positioning method according to claim 1, characterized in that: The step S51 also includes: determining the size of the scanning block and the displacement of each scan; and determining the starting position and scanning direction of the scanning block.
11. The cup seam positioning method according to claim 1, characterized in that: Before step S52, the process also includes calculating the average pixel grayscale of the cup body image.
12. The cup seam positioning method according to claim 11, characterized in that: In step S52, the average pixel grayscale of the position scanned by the scanning block is calculated, wherein the gradient of the position scanned by the scanning block is equal to the average pixel grayscale of the position scanned by the scanning block minus the average pixel grayscale of the cup body image, and the contour points whose gradient is greater than the set threshold are recorded.
13. The cup seam positioning method according to claim 1, characterized in that: After determining the cup seam position, the method further includes: Step S6: performing stain detection on the cup body image outside the cup seam position.
14. A paper cup detection system, characterized in that: Included are: A conveying mechanism, used for conveying the paper cup to be inspected to a position to be inspected; An industrial camera, arranged corresponding to the position to be detected, and used for acquiring a cup body image of the paper cup located at the position to be detected; A processor, used to execute the cup seam positioning method according to any one of claims 1 to 13.
15. The paper cup detection system according to claim 14, characterized in that: Also included are: The annular stroboscopic sphere integrating light source is set corresponding to the industrial camera and is used to be triggered when the paper cup to be inspected is conveyed to the position to be inspected so as to provide light compensation for the industrial camera when taking pictures.
Citation Information
Patent Citations
Visual inspection method and system device for paper cup defects
CN104297255A