A paper cup detection method, device and system
By obtaining and analyzing the image of the paper cup, identifying the color value, edge line and circular characteristics, calculate the comprehensive circular deviation, solve the problem of inaccurate detection in the existing technology, and achieve comprehensive testing and quality assessment of the paper cup.
Patent Information
- Application Number
- CN202411583113.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-11-07
AI Technical Summary
The existing paper cup detection methods are difficult to comprehensively detect the defects of paper cups, especially structural defects such as explosive edges and insufficient roundness, resulting in inaccurate detection.
By obtaining the cup mouth and bottom image of the paper cup, identify the pixel color, edge lines and circular features in the image, calculate the comprehensive roundness deviation, and determine whether the paper cup is qualified.
The multi -dimensional detection of paper cups can not only detect surface defects, but also detect structural defects, which significantly improves the accuracy and comprehensiveness of the detection.
Smart Images

Figure CN119090884B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a paper cup detection method, device and system. Background Art
[0002] During the production process, paper cups may have defects, which may lead to unqualified quality of paper cups. Therefore, it is necessary to screen out defective paper cups.
[0003] Currently, there are methods for defect detection of paper cups through visual inspection, but the existing paper cup inspection methods can often only detect whether the surface of the cup is dirty, that is, they can only perform single-dimensional inspection, and it is difficult to detect defects such as cracked edges and insufficient roundness of paper cups, that is, the inspection is not comprehensive, which leads to inaccurate judgment on whether the paper cups are qualified or not. Summary of the invention
[0004] Based on this, it is necessary to provide a paper cup detection method, device and system to address the above problems.
[0005] The embodiment of the present invention is implemented by providing a paper cup detection method, the method comprising:
[0006] S1: For each finished paper cup, obtain a cup mouth image and a cup bottom image of the finished paper cup;
[0007] S2: Identify the color value of the pixel in the area where the finished paper cup is located in the acquired image, and determine whether there is a surface defect on the surface of the finished paper cup according to the identified color value. If there is a surface defect, the finished paper cup is unqualified;
[0008] S3: If there is no surface defect on the surface of the finished paper cup, the edge line of the finished paper cup is identified in the cup mouth image and the cup bottom image, so as to determine whether the finished paper cup has cracked edges according to the bending degree of the edge line. If so, the finished paper cup is unqualified;
[0009] S4: If the finished paper cup has no cracked edge, identify the cup bottom circle and the cup mouth circle in the cup mouth image;
[0010] S5: Generate a first standard circle closest to the cup bottom circle and a second standard circle closest to the cup mouth circle;
[0011] S6: determining a first roundness deviation according to the first standard circle and the cup bottom circle, and determining a second roundness deviation according to the second standard circle and the cup mouth circle;
[0012] S7: determining a comprehensive roundness deviation according to the first roundness deviation and the second roundness deviation;
[0013] S8: Determine whether the comprehensive roundness deviation exceeds the preset roundness deviation. If so, the finished paper cup is unqualified; if not, the finished paper cup is qualified.
[0014] In one embodiment, the present invention provides a paper cup detection device, the device comprising:
[0015] An acquisition module, used for acquiring a cup mouth image and a cup bottom image of each finished paper cup;
[0016] The first judgment module is used to identify the color value of the pixel in the area where the finished paper cup is located in the acquired image, and judge whether there is a surface defect on the surface of the finished paper cup according to the identified color value, and if so, the finished paper cup is unqualified;
[0017] The second judgment module is used to identify the edge line of the finished paper cup in the cup mouth image and the cup bottom image if there is no surface defect on the surface of the finished paper cup, so as to judge whether the finished paper cup has cracked edges according to the bending degree of the edge line. If so, the finished paper cup is unqualified;
[0018] The first processing module is used to identify the cup bottom circle and the cup mouth circle in the cup mouth image if the finished paper cup has no broken edge;
[0019] The second processing module is used to generate a first standard circle closest to the cup bottom circle and a second standard circle closest to the cup mouth circle;
[0020] A third processing module is used to determine a first roundness deviation according to the first standard circle and the cup bottom circle, and to determine a second roundness deviation according to the second standard circle and the cup mouth circle;
[0021] A fourth processing module, configured to determine a comprehensive roundness deviation according to the first roundness deviation and the second roundness deviation;
[0022] The third judgment module is used to judge whether the comprehensive roundness deviation exceeds the preset roundness deviation. If so, the finished paper cup is unqualified; if not, the finished paper cup is qualified.
[0023] In one embodiment, the present invention provides a paper cup detection system, the system comprising:
[0024] An image acquisition device, used for acquiring images of the cup mouth and the cup bottom;
[0025] A computer device is connected to the image acquisition device and is used to execute the paper cup detection method.
[0026] The present invention provides a paper cup detection method, device and system, wherein the method comprises, for each finished paper cup, obtaining a cup mouth image and a cup bottom image of the finished paper cup; identifying the color value of the pixel in the area where the finished paper cup is located in the acquired image, and judging whether the surface of the finished paper cup has surface defects according to the identified color value, if so, the finished paper cup is unqualified; if the surface of the finished paper cup has no surface defects, then identifying the edge line of the finished paper cup in the cup mouth image and the cup bottom image, so as to judge whether the finished paper cup has cracked edges according to the bending degree of the edge line, if so, the finished paper cup is unqualified; if the finished paper cup has no cracked edges, then identifying the cup bottom in the cup mouth image circle and cup mouth circle; generate a first standard circle closest to the cup bottom circle and a second standard circle closest to the cup mouth circle; determine the first roundness deviation based on the first standard circle and the cup bottom circle, and determine the second roundness deviation based on the second standard circle and the cup mouth circle; determine the comprehensive roundness deviation based on the first roundness deviation and the second roundness deviation; determine whether the comprehensive roundness deviation exceeds the preset roundness deviation, if so, the finished paper cup is unqualified, if not, the finished paper cup is qualified; this method can detect both surface defects and structural defects (burst edge, insufficient roundness, etc.) of paper cups, realizes a comprehensive evaluation of the quality of paper cups, and significantly improves the accuracy of paper cup detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 is a first flow chart of a paper cup detection method provided in one embodiment;
[0028] Figure 2 is a second flow chart of a paper cup detection method provided in one embodiment;
[0029] Figure 3 A cup mouth image of a paper cup detection method provided in an embodiment;
[0030] Figure 4 A cup bottom image of a paper cup detection method provided in an embodiment;
[0031] Figure 5 A schematic diagram of surface defects of a paper cup detection method provided in one embodiment;
[0032] Figure 6 A schematic diagram of a paper cup edge bursting detection method provided in an embodiment;
[0033] Figure 7 It is a module flow chart of a paper cup detection device provided in one embodiment;
[0034] Figure 8 A schematic diagram of the composition of a paper cup detection system provided in one embodiment;
[0035] Fig. 9 FIG. 4 is a block diagram of the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0037] It is understood that the terms "first", "second", etc. used in the present invention may be used herein to describe various elements, but unless otherwise specified, these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, a first xx script may be referred to as a second xx script, and similarly, a second xx script may be referred to as a first xx script without departing from the scope of the present invention.
[0038] like Figure 1-Figure 2 As shown, in one embodiment, a paper cup detection method is proposed, the method comprising:
[0039] S1: For each finished paper cup, obtain a cup mouth image and a cup bottom image of the finished paper cup;
[0040] S2: Identify the color value of the pixel in the area where the finished paper cup is located in the acquired image, and determine whether there is a surface defect on the surface of the finished paper cup according to the identified color value. If there is a surface defect, the finished paper cup is unqualified;
[0041] S3: If the surface of the finished paper cup has no surface defects, the edge line of the finished paper cup is identified in the cup mouth image and the cup bottom image, so as to determine whether the finished paper cup has cracked edges according to the bending degree of the edge line. If so, the finished paper cup is unqualified;
[0042] S4: If the finished paper cup has no cracked edge, identify the cup bottom circle and the cup mouth circle in the cup mouth image;
[0043] S5: Generate a first standard circle closest to the cup bottom circle and a second standard circle closest to the cup mouth circle;
[0044] S6: determining a first roundness deviation according to the first standard circle and the cup bottom circle, and determining a second roundness deviation according to the second standard circle and the cup mouth circle;
[0045] S7: determining a comprehensive roundness deviation according to the first roundness deviation and the second roundness deviation;
[0046] S8: Determine whether the comprehensive roundness deviation exceeds the preset roundness deviation. If so, the finished paper cup is unqualified; if not, the finished paper cup is qualified.
[0047] In this embodiment, the method is executed in a computer device, which may be an independent physical server or terminal, or a server cluster consisting of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud servers, cloud databases, cloud storage, and CDN; Figure 3-Figure 4 As shown, in this embodiment, the image of the cup mouth and the image of the cup bottom are collected by an image acquisition device. The image acquisition device can be a high-definition industrial camera or other image acquisition equipment. The image acquisition device communicates with a computer device. After the image of the cup mouth and the image of the cup bottom are collected, the image of the cup mouth and the image of the cup bottom can be sent to the computer device for analysis and processing.
[0048] In this embodiment, this method is used to detect finished paper cups produced by a paper cup machine to determine whether the finished paper cups are of qualified quality; the image acquisition device is installed on the paper cup machine, and during the process of the finished paper cups being conveyed on the paper cup machine, the image acquisition device can acquire the cup mouth image and cup bottom image of the finished paper cup; the cup mouth image is the image acquired when the lens of the image acquisition device is facing the cup mouth; the cup bottom image is the image acquired when the lens of the image acquisition device is facing the cup bottom.
[0049] In this embodiment, this method is mainly used to detect pure color paper cups (such as pure white). If there are surface defects such as dirt and cracks on the surface of the paper cup, these defects will appear in different colors in the collected image, and then they can be identified; edge bursting is the warping of the mouth or bottom of the paper cup under the condition of external force. When edge bursting occurs, the bending of the edge of the paper cup will change. By detecting this change, it can be determined whether the paper cup has edge bursting; roundness is a geometric concept used to describe the shape characteristics of an object, especially to measure the degree of proximity of a surface or cross-section of an object to an ideal circle. The first standard circle and the second standard circle are ideal circles; the roundness of the paper cup mainly refers to the roundness of the mouth of the cup and the roundness of the bottom of the cup. The higher the roundness of the paper cup, the closer the paper cup is to a cylinder or a truncated cone, which is convenient for users to hold and stack paper cups, and has a higher aesthetics. The roundness deviation calculated in this embodiment can represent the level of roundness. For example, the larger the roundness deviation, the higher the roundness, and the smaller the roundness deviation, the greater the roundness.
[0050] In this embodiment, the color values of pixels in the area where the paper cup is located can be detected to determine whether the paper cup has surface defects. Furthermore, it is possible to determine whether the finished paper cup has cracked edges based on the degree of bending of the edge line. In addition, it is possible to determine whether the roundness of the finished paper cup meets the standard by detecting the comprehensive roundness deviation of the finished paper cup. That is, it is possible to detect multiple dimensions of the finished paper cup, detect both surface defects and structural defects (cracked edges, insufficient roundness, etc.) of the paper cup, thereby achieving a comprehensive evaluation of the quality of the paper cup and significantly improving the accuracy of paper cup detection.
[0051] As a preferred embodiment, the step of identifying the color value of the pixel in the area where the finished paper cup is located in the acquired image, and judging whether there is a surface defect on the surface of the finished paper cup according to the identified color value includes:
[0052] S21: grayscale processing is performed on the cup mouth image and the cup bottom image;
[0053] S22: for any one of the cup mouth image and the cup bottom image, a number of background pixels are taken at a set edge position of the image, and the color value of each background pixel is identified;
[0054] S23: Calculate the average color value of each background pixel to obtain the background color value;
[0055] S24: determining the critical pixels between the paper cup and the background according to the background color value, and identifying the area surrounded by the critical pixels, that is, the area where the finished paper cup is located;
[0056] S25: Determine whether there is a color value mutation area in the area where the finished paper cup is located. If yes, the surface of the finished paper cup has surface defects. Otherwise, the surface of the finished paper cup has no surface defects.
[0057] In this embodiment, the edge position can be set on the edge line of the image, such as the center, both ends or a certain distance from the center of the edge line, which is not limited here; the color of the background is obviously different from the color of the paper cup (the color of the background is black, and the color of the paper cup is white), so there is an obvious boundary between the two. The critical pixel is a pixel on the boundary. This embodiment can determine the boundary between the background and the area where the paper cup is located by determining the critical pixel, and then determine the area where the paper cup is located; the color value mutation area is an area where the color value is obviously different from the color value of the surrounding area, such as an average color value difference of 50. Under normal circumstances, the area where the paper cup is located is white, and the color value range is 230~255. If there is a surface defect, there will be a color value mutation area that is obviously lower than the color value range in the area where the paper cup is located. This embodiment can determine whether the finished paper cup has a surface defect by detecting the color value mutation area.
[0058] As a preferred embodiment, the critical pixels between the paper cup and the background are determined based on the background color value, and the area surrounded by the critical pixels is identified, that is, the area where the finished paper cup is located includes:
[0059] S241: subtracting a set value from the background color value to obtain a minimum value, adding the set value to the background color value to obtain a maximum value, and then obtaining a background color value interval with the minimum value and the maximum value as boundary values;
[0060] S242: Identify the central pixel of the image;
[0061] S243: taking a pixel on the edge of the image as a base pixel, and connecting the base pixel and the center pixel with a straight line;
[0062] S244: starting from the base pixel, determining one by one whether the color value of each pixel on the straight line falls within the background color value interval;
[0063] S245: taking the first pixel that does not fall into the background color value area as the critical pixel corresponding to the basic pixel;
[0064] S246: Take another pixel on the edge of the image as the basic pixel, connect the basic pixel and the center pixel with a straight line, and execute steps S244 to S246 until the critical pixel corresponding to each pixel on the edge of the image is obtained, and then the critical line composed of the critical pixels is obtained. The area within the critical line is the area where the finished paper cup is located.
[0065] In this embodiment, the area where the paper cup is located is a circular area located in the center of the image. The central pixel of the image can be regarded as the center of the area where the paper cup is located. The straight line connecting the central pixel and a pixel on the edge of the image will inevitably pass through the boundary of the area where the paper cup is located. The first pixel that does not fall into the background color value area is the pixel on the boundary. By repeatedly using the above method, all critical pixels on the boundary can be determined, and the entire boundary (critical line) can be determined, and then the area where the paper cup is located can be determined.
[0066] like Figure 5 As shown, as a preferred embodiment, judging whether there is a color value mutation area in the area where the finished paper cup is located includes:
[0067] S251: Generate a selection box of a set size in the area where the finished paper cup is located;
[0068] S252: Determine the highest color value range and the lowest color value range of the area within the selection box;
[0069] S253: Calculate the difference between the center value of the highest color value range and the center value of the lowest color value range, and determine whether the difference is greater than a preset difference. If not, after moving the selection box, execute steps S252 to S253 until the area passed by the selection box covers the area where the finished paper cup is located, and there is no color value mutation area in the area where the finished paper cup is located;
[0070] S254: If the difference is greater than the preset difference, identify whether the number of connected pixels whose color values are in the lowest color value range exceeds the preset number in the area within the frame. If so, there is a color value mutation area in the area where the finished paper cup is located. If not, after moving the frame, execute steps S252 to S254 until the area passed by the frame covers the area where the finished paper cup is located. In this case, there is no color value mutation area in the area where the finished paper cup is located.
[0071] In this embodiment, the preset difference value may be 50, the preset number may be 1000, which are not limited here; the selection box may be a circular box, a square box or a box of other shapes, which are not limited here; the width of the highest color value range and the lowest color value range is the set width, such as 10; for example, in the absence of surface defects, the highest color value range is relatively close to the lowest color value range, such as the highest color value range is 245~255 (the center value is 250), and the lowest color value range is 230~240 (the center value is 235); and when there are surface defects, the highest color value range is relatively close to the lowest color value range. The low color value range may be 180~190 (the center value is 185), and the difference at this time is 250-185=65, which is greater than the preset difference. If the number of connected pixels in the area within the frame whose color values are in the lowest color value range is 1200, which is greater than the preset number, then there is a color value mutation area in the area where the finished paper cup is located. This embodiment can allow paper cups with only minor defects to pass the inspection by setting the preset number, thereby ensuring the inspection pass rate, and can also avoid identifying the inner edge line of the area where the paper cup is located (the number in the selection box does not exceed the preset number) as a defect.
[0072] As a preferred embodiment, identifying the edge line of the finished paper cup in the cup mouth image and the cup bottom image to determine whether the finished paper cup has cracked edges according to the bending degree of the edge line includes:
[0073] S31: Identify the outer edge line of the cup mouth image and the inner edge line of the cup bottom image;
[0074] S32: for each identified edge line, identifying whether there is a non-curve segment in the edge line, if not, the edge line has no edge burst;
[0075] S33: If so, draw a tangent of the curved segment at the connection point between the non-curved segment and the connected curved segment, identify the angle between the tangent and the non-curved segment, and determine whether the angle exceeds a preset angle. If so, the edge line has no edge burst; if not, the edge line has edge burst.
[0076] In this embodiment, edge burst refers to the warping of the mouth or bottom of the paper cup under the condition of external force. When edge burst does not occur, the edge of the mouth or the bottom of the cup is often a closed curve. After edge burst occurs, Figure 6As shown, the area will be partially offset at the position of the edge burst, and the offset segment presents a straight line segment, and the angle between the straight line segment and the tangent of the connected curve segment is often large, such as 80°~90°. At the same time, the edge of the paper cup may be squeezed during the production process, and at this time, the local edge may also appear as a straight line segment, but the angle between the straight line segment and the tangent of the connected curve segment is often small, such as 10°~20°; therefore, in this embodiment, a straight line segment (i.e., a line segment without curvature) is first identified on the edge line, and then it is determined whether the angle between the straight line segment and the tangent of the connected curve segment exceeds a preset angle (such as 70°) to determine whether an edge burst occurs.
[0077] As a preferred embodiment, identifying the cup bottom circle and the cup mouth circle in the cup mouth image includes:
[0078] Identify the inner edge line and the outer edge line of the cup mouth image, wherein the circle enclosed by the inner edge line is the cup bottom circle, and the circle enclosed by the outer edge line is the cup mouth circle;
[0079] Generate a first standard circle with the most pixels overlapping with the inner edge line;
[0080] Generate a second standard circle that has the most pixels overlapping with the outer edge line.
[0081] In this embodiment, the finished paper cup is a paper cup with a larger mouth than the bottom, so both the mouth (outer edge) and the bottom (inner edge) can be seen in the mouth image; when determining the first standard circle, an ideal circle with a smaller diameter can be generated with the center of the image, and then the diameter of the circle can be gradually expanded, and the number of pixels that overlap with the bottom circle of the cup under each diameter is identified, and the ideal circle with the largest number of pixels overlapping is taken as the first standard circle. Similarly, the second standard circle can be determined.
[0082] As a preferred embodiment, determining the first roundness deviation according to the first standard circle and the cup bottom circle includes:
[0083] S61: select a point on the first standard circle as the target point, and draw a ray passing through the target point with the center of the first standard circle as the starting point;
[0084] S62: Identify the intersection point of the ray and the bottom circle, and identify the deviation distance between the intersection point and the target point;
[0085] S63: taking a point on the first standard circle adjacent to the previous target point as the target point, and drawing a ray passing through the target point with the center of the first standard circle as the starting point, and executing steps S62 to S63 until the deviation distance corresponding to each point on the first standard circle is obtained;
[0086] S64: Calculate the first roundness deviation by the following formula:
[0087]
[0088] in, is the first roundness deviation, is the deviation distance corresponding to the i-th point on the first standard circle, and n is the number of points on the first standard circle;
[0089] Determining the second roundness deviation based on the second standard circle and the cup mouth circle includes:
[0090] S65: select a point on the second standard circle as the target point, and draw a ray passing through the target point with the center of the second standard circle as the starting point;
[0091] S66: Identify the intersection of the ray and the cup mouth circle, and identify the deviation distance between the intersection and the target point;
[0092] S67: Take a point on the second standard circle that is adjacent to the previous target point as the target point, and make a ray passing through the target point with the center of the second standard circle as the starting point, and execute steps S66 to S67 until the deviation distance corresponding to each point on the second standard circle is obtained;
[0093] S68: Calculate the second roundness deviation by the following formula:
[0094]
[0095] in, is the second roundness deviation, is the deviation distance corresponding to the jth point on the second standard circle, and m is the number of points on the second standard circle.
[0096] The comprehensive roundness deviation of the finished paper cup is calculated by the following formula:
[0097]
[0098] Where D is the comprehensive roundness deviation, for The weight coefficient of .
[0099] In this embodiment, the first roundness deviation can characterize the deviation between each point on the cup bottom circle and the corresponding point of the first standard circle, and the second roundness deviation can characterize the deviation between each point on the cup mouth circle and the corresponding point of the second standard circle. The comprehensive roundness deviation is determined by the first roundness deviation and the second roundness deviation, and can comprehensively characterize the roundness of the entire paper cup. The smaller the comprehensive roundness deviation is, the higher the roundness of the paper cup is. The value range of is 0~1, and can be determined according to the emphasis on the roundness of the cup bottom and the far end of the cup mouth, and is not limited here.
[0100] like Figure 7As shown, in one embodiment, a paper cup detection device is provided, the device comprising:
[0101] An acquisition module, used for acquiring a cup mouth image and a cup bottom image of each finished paper cup;
[0102] The first judgment module is used to identify the color value of the pixel in the area where the finished paper cup is located in the acquired image, and judge whether there is a surface defect on the surface of the finished paper cup according to the identified color value, and if so, the finished paper cup is unqualified;
[0103] The second judgment module is used to identify the edge line of the finished paper cup in the cup mouth image and the cup bottom image if there is no surface defect on the surface of the finished paper cup, so as to judge whether the finished paper cup has cracked edges according to the bending degree of the edge line. If so, the finished paper cup is unqualified;
[0104] The first processing module is used to identify the cup bottom circle and the cup mouth circle in the cup mouth image if the finished paper cup has no broken edge;
[0105] The second processing module is used to generate a first standard circle closest to the cup bottom circle and a second standard circle closest to the cup mouth circle;
[0106] A third processing module is used to determine a first roundness deviation according to the first standard circle and the cup bottom circle, and to determine a second roundness deviation according to the second standard circle and the cup mouth circle;
[0107] A fourth processing module, configured to determine a comprehensive roundness deviation according to the first roundness deviation and the second roundness deviation;
[0108] The third judgment module is used to judge whether the comprehensive roundness deviation exceeds the preset roundness deviation. If so, the finished paper cup is unqualified; if not, the finished paper cup is qualified.
[0109] The process of each module in the paper cup detection device provided in the embodiment of the present application realizing its own function can be specifically referred to the aforementioned Figure 1 The description of the illustrated embodiment will not be repeated here.
[0110] like Figure 8 As shown, in one embodiment, a paper cup detection system is provided, the system comprising:
[0111] An image acquisition device, used for acquiring images of the cup mouth and the cup bottom;
[0112] A computer device is connected to the image acquisition device and is used to execute the paper cup detection method.
[0113] In this embodiment, the computer device cooperates with the image acquisition device to execute the paper cup detection method, wherein the method can detect the color value of the pixels in the area where the paper cup is located to determine whether the paper cup has surface defects. Furthermore, it can also determine whether the finished paper cup has cracked edges according to the bending degree of the edge line. In addition, it can detect the comprehensive roundness deviation of the finished paper cup to determine whether the roundness of the finished paper cup meets the standard, that is, it can realize the detection of multiple dimensions of the finished paper cup, and can detect both the surface defects of the paper cup and the structural defects (cracked edges, insufficient roundness, etc.), thereby realizing a comprehensive evaluation of the quality of the paper cup and significantly improving the accuracy of the paper cup detection.
[0114] Fig. 9 FIG. 2 shows an internal structure diagram of a computer device in one embodiment. Fig. 9 As shown, the computer device includes a processor, a memory, a network interface, an input device and a display screen connected through a system bus. Among them, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor can implement the paper cup detection method provided in the embodiment of the present invention. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor can execute the paper cup detection method provided in the embodiment of the present invention. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covered on the display screen, or a button, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.
[0115] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device to which the solution of the present invention is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0116] In one embodiment, the paper cup detection device provided by the embodiment of the present invention can be implemented in the form of a computer program. The computer program can be Fig. 9 The computer device shown in the figure is run. The memory of the computer device can store various program modules constituting the paper cup detection device, for example, Figure 7 The acquisition module, the first judgment module, the second judgment module, the first processing module, the second processing module, the third processing module, the fourth processing module, and the third judgment module shown in the figure. The computer program composed of each program module enables the processor to execute the steps of the paper cup detection method of each embodiment of the present invention described in this specification.
[0117] For example, Fig. 9 The computer device shown can be Figure 7 The acquisition module in the paper cup detection device shown executes step S1; the computer device may execute step S2 through the first judgment module; the computer device may execute step S3 through the second judgment module; the computer device may execute step S4 through the first processing module; the computer device may execute step S5 through the second processing module; the computer device may execute step S6 through the third processing module; the computer device may execute step S7 through the fourth processing module; the computer device may execute step S8 through the third judgment module.
[0118] In one embodiment, a computer device is provided, the computer device comprising 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 implemented:
[0119] S1: For each finished paper cup, obtain a cup mouth image and a cup bottom image of the finished paper cup;
[0120] S2: Identify the color value of the pixel in the area where the finished paper cup is located in the acquired image, and determine whether there is a surface defect on the surface of the finished paper cup according to the identified color value. If there is a surface defect, the finished paper cup is unqualified;
[0121] S3: If there is no surface defect on the surface of the finished paper cup, the edge line of the finished paper cup is identified in the cup mouth image and the cup bottom image, so as to determine whether the finished paper cup has cracked edges according to the bending degree of the edge line. If so, the finished paper cup is unqualified;
[0122] S4: If the finished paper cup has no cracked edge, identify the cup bottom circle and the cup mouth circle in the cup mouth image;
[0123] S5: Generate a first standard circle closest to the cup bottom circle and a second standard circle closest to the cup mouth circle;
[0124] S6: determining a first roundness deviation according to the first standard circle and the cup bottom circle, and determining a second roundness deviation according to the second standard circle and the cup mouth circle;
[0125] S7: determining a comprehensive roundness deviation according to the first roundness deviation and the second roundness deviation;
[0126] S8: Determine whether the comprehensive roundness deviation exceeds the preset roundness deviation. If so, the finished paper cup is unqualified; if not, the finished paper cup is qualified.
[0127] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the processor performs the following steps:
[0128] S1: For each finished paper cup, obtain a cup mouth image and a cup bottom image of the finished paper cup;
[0129] S2: Identify the color value of the pixel in the area where the finished paper cup is located in the acquired image, and determine whether there is a surface defect on the surface of the finished paper cup according to the identified color value. If there is a surface defect, the finished paper cup is unqualified;
[0130] S3: If the surface of the finished paper cup has no surface defects, the edge line of the finished paper cup is identified in the cup mouth image and the cup bottom image, so as to determine whether the finished paper cup has cracked edges according to the bending degree of the edge line. If so, the finished paper cup is unqualified;
[0131] S4: If the finished paper cup has no cracked edge, identify the cup bottom circle and the cup mouth circle in the cup mouth image;
[0132] S5: Generate a first standard circle closest to the cup bottom circle and a second standard circle closest to the cup mouth circle;
[0133] S6: determining a first roundness deviation according to the first standard circle and the cup bottom circle, and determining a second roundness deviation according to the second standard circle and the cup mouth circle;
[0134] S7: determining a comprehensive roundness deviation according to the first roundness deviation and the second roundness deviation;
[0135] S8: Determine whether the comprehensive roundness deviation exceeds the preset roundness deviation. If so, the finished paper cup is unqualified; if not, the finished paper cup is qualified.
[0136] It should be understood that, although each step in the flow chart of each embodiment of the present invention is shown in sequence according to the indication of the arrow, these steps are not necessarily performed in sequence according to the order indicated by the arrow. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in each embodiment may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these sub-steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of other steps or sub-steps or stages of other steps.
[0137] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0138] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0139] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A paper cup detection method, characterized in that: The method comprises: S1: For each finished paper cup, obtain a cup mouth image and a cup bottom image of the finished paper cup; S2: Identify the color value of the pixel in the area where the finished paper cup is located in the acquired image, and determine whether there is a surface defect on the surface of the finished paper cup according to the identified color value. If there is a surface defect, the finished paper cup is unqualified; S3: If there is no surface defect on the surface of the finished paper cup, the edge line of the finished paper cup is identified in the cup mouth image and the cup bottom image, so as to determine whether the finished paper cup has cracked edges according to the bending degree of the edge line. If so, the finished paper cup is unqualified; S4: If the finished paper cup has no cracked edge, identify the cup bottom circle and the cup mouth circle in the cup mouth image; S5: Generate a first standard circle closest to the cup bottom circle and a second standard circle closest to the cup mouth circle; S6: determining a first roundness deviation according to the first standard circle and the cup bottom circle, and determining a second roundness deviation according to the second standard circle and the cup mouth circle; S7: determining a comprehensive roundness deviation according to the first roundness deviation and the second roundness deviation; S8: Determine whether the comprehensive roundness deviation exceeds the preset roundness deviation. If so, the finished paper cup is unqualified; if not, the finished paper cup is qualified; Then, the edge line of the finished paper cup is identified in the cup mouth image and the cup bottom image, and whether the finished paper cup has cracked edges is determined according to the bending degree of the edge line, including: S31: Identify the outer edge line of the cup mouth image and the inner edge line of the cup bottom image; S32: for each identified edge line, identifying whether there is a straight line segment in the edge line, if not, the edge line has no edge burst; S33: If yes, draw a tangent line of the curve segment at the connection point between the straight line segment and the connected curve segment, identify the angle between the tangent line and the straight line segment, and determine whether the angle exceeds a preset angle. If yes, the edge line has no edge burst; if no, the edge line has edge burst. Recognizing the cup bottom circle and cup mouth circle in the cup mouth image includes: Identify the inner edge line and the outer edge line of the cup mouth image, wherein the circle enclosed by the inner edge line is the cup bottom circle, and the circle enclosed by the outer edge line is the cup mouth circle; Generate a first standard circle with the most pixels overlapping with the inner edge line; Generate a second standard circle with the most pixels overlapping with the outer edge line; Determining the first roundness deviation based on the first standard circle and the cup bottom circle includes: S61: select a point on the first standard circle as the target point, and draw a ray passing through the target point with the center of the first standard circle as the starting point; S62: Identify the intersection point of the ray and the bottom circle, and identify the deviation distance between the intersection point and the target point; S63: taking a point on the first standard circle adjacent to the previous target point as the target point, and drawing a ray passing through the target point with the center of the first standard circle as the starting point, and executing steps S62 to S63 until the deviation distance corresponding to each point on the first standard circle is obtained; S64: Calculate the first roundness deviation by the following formula: in, is the first roundness deviation, is the deviation distance corresponding to the i-th point on the first standard circle, and n is the number of points on the first standard circle; Determining the second roundness deviation based on the second standard circle and the cup mouth circle includes: S65: select a point on the second standard circle as the target point, and draw a ray passing through the target point with the center of the second standard circle as the starting point; S66: Identify the intersection of the ray and the cup mouth circle, and identify the deviation distance between the intersection and the target point; S67: Take a point on the second standard circle that is adjacent to the previous target point as the target point, and make a ray passing through the target point with the center of the second standard circle as the starting point, and execute steps S66 to S67 until the deviation distance corresponding to each point on the second standard circle is obtained; S68: Calculate the second roundness deviation by the following formula: in, is the second roundness deviation, is the deviation distance corresponding to the jth point on the second standard circle, and m is the number of points on the second standard circle.
2. The method according to claim 1, characterized in that The step of identifying the color value of the pixel in the area where the finished paper cup is located in the acquired image, and judging whether there is a surface defect on the surface of the finished paper cup according to the identified color value includes: S21: grayscale processing is performed on the cup mouth image and the cup bottom image; S22: for any one of the cup mouth image and the cup bottom image, a number of background pixels are taken at a set edge position of the image, and the color value of each background pixel is identified; S23: Calculate the average color value of each background pixel to obtain the background color value; S24: determining the critical pixels between the paper cup and the background according to the background color value, and identifying the area surrounded by the critical pixels, that is, the area where the finished paper cup is located; S25: Determine whether there is a color value mutation area in the area where the finished paper cup is located. If yes, the surface of the finished paper cup has surface defects. Otherwise, the surface of the finished paper cup has no surface defects.
3. The method according to claim 2, characterized in that The critical pixels between the paper cup and the background are determined according to the background color value, and the area surrounded by the critical pixels is identified, that is, the area where the finished paper cup is located includes: S241: subtracting a set value from the background color value to obtain a minimum value, adding the set value to the background color value to obtain a maximum value, and then obtaining a background color value interval with the minimum value and the maximum value as boundary values; S242: Identify the central pixel of the image; S243: taking a pixel on the edge of the image as a base pixel, and connecting the base pixel and the center pixel with a straight line; S244: starting from the base pixel, determining one by one whether the color value of each pixel on the straight line falls within the background color value interval; S245: taking the first pixel that does not fall into the background color value area as the critical pixel corresponding to the basic pixel; S246: Take another pixel on the edge of the image as the basic pixel, connect the basic pixel and the center pixel with a straight line, and execute steps S244 to S246 until the critical pixel corresponding to each pixel on the edge of the image is obtained, and then the critical line composed of the critical pixels is obtained. The area within the critical line is the area where the finished paper cup is located.
4. The method according to claim 2, characterized in that: Determining whether there is a color value mutation region in the area where the finished paper cup is located includes: S251: Generate a selection box of a set size in the area where the finished paper cup is located; S252: Determine the highest color value range and the lowest color value range of the area within the selection box; S253: Calculate the difference between the center value of the highest color value range and the center value of the lowest color value range, and determine whether the difference is greater than a preset difference. If not, after moving the selection box, execute steps S252 to S253 until the area passed by the selection box covers the area where the finished paper cup is located, and there is no color value mutation area in the area where the finished paper cup is located; S254: If the difference is greater than the preset difference, identify whether the number of connected pixels whose color values are in the lowest color value range exceeds the preset number in the area within the frame. If so, there is a color value mutation area in the area where the finished paper cup is located. If not, after moving the frame, execute steps S252 to S254 until the area passed by the frame covers the area where the finished paper cup is located. In this case, there is no color value mutation area in the area where the finished paper cup is located.
5. The method according to claim 1, characterized in that The comprehensive roundness deviation of the finished paper cup is calculated by the following formula: Where D is the comprehensive roundness deviation, for The weight coefficient of .
6. A paper cup detection device, characterized in that: The device comprises: An acquisition module, used for acquiring a cup mouth image and a cup bottom image of each finished paper cup; The first judgment module is used to identify the color value of the pixel in the area where the finished paper cup is located in the acquired image, and judge whether there is a surface defect on the surface of the finished paper cup according to the identified color value, and if so, the finished paper cup is unqualified; The second judgment module is used to identify the edge line of the finished paper cup in the cup mouth image and the cup bottom image if there is no surface defect on the surface of the finished paper cup, so as to judge whether the finished paper cup has cracked edges according to the bending degree of the edge line. If so, the finished paper cup is unqualified; The first processing module is used to identify the cup bottom circle and the cup mouth circle in the cup mouth image if the finished paper cup has no broken edge; The second processing module is used to generate a first standard circle closest to the cup bottom circle and a second standard circle closest to the cup mouth circle; A third processing module is used to determine a first roundness deviation according to the first standard circle and the cup bottom circle, and to determine a second roundness deviation according to the second standard circle and the cup mouth circle; A fourth processing module, configured to determine a comprehensive roundness deviation according to the first roundness deviation and the second roundness deviation; The third judgment module is used to judge whether the comprehensive roundness deviation exceeds the preset roundness deviation. If so, the finished paper cup is unqualified; if not, the finished paper cup is qualified; Then, the edge line of the finished paper cup is identified in the cup mouth image and the cup bottom image, and whether the finished paper cup has cracked edges is determined according to the bending degree of the edge line, including: S31: Identify the outer edge line of the cup mouth image and the inner edge line of the cup bottom image; S32: for each identified edge line, identifying whether there is a straight line segment in the edge line, if not, the edge line has no edge burst; S33: If yes, draw a tangent line of the curve segment at the connection point between the straight line segment and the connected curve segment, identify the angle between the tangent line and the straight line segment, and determine whether the angle exceeds a preset angle. If yes, the edge line has no edge burst; if no, the edge line has edge burst. Recognizing the cup bottom circle and cup mouth circle in the cup mouth image includes: Identify the inner edge line and the outer edge line of the cup mouth image, wherein the circle enclosed by the inner edge line is the cup bottom circle, and the circle enclosed by the outer edge line is the cup mouth circle; Generate a first standard circle with the most pixels overlapping with the inner edge line; Generate a second standard circle with the most pixels overlapping with the outer edge line; Determining the first roundness deviation based on the first standard circle and the cup bottom circle includes: S61: select a point on the first standard circle as the target point, and draw a ray passing through the target point with the center of the first standard circle as the starting point; S62: Identify the intersection point of the ray and the bottom circle, and identify the deviation distance between the intersection point and the target point; S63: taking a point on the first standard circle adjacent to the previous target point as the target point, and drawing a ray passing through the target point with the center of the first standard circle as the starting point, and executing steps S62 to S63 until the deviation distance corresponding to each point on the first standard circle is obtained; S64: Calculate the first roundness deviation by the following formula: in, is the first roundness deviation, is the deviation distance corresponding to the i-th point on the first standard circle, and n is the number of points on the first standard circle; Determining the second roundness deviation based on the second standard circle and the cup mouth circle includes: S65: select a point on the second standard circle as the target point, and draw a ray passing through the target point with the center of the second standard circle as the starting point; S66: Identify the intersection of the ray and the cup mouth circle, and identify the deviation distance between the intersection and the target point; S67: Take a point on the second standard circle that is adjacent to the previous target point as the target point, and make a ray passing through the target point with the center of the second standard circle as the starting point, and execute steps S66 to S67 until the deviation distance corresponding to each point on the second standard circle is obtained; S68: Calculate the second roundness deviation by the following formula: in, is the second roundness deviation, is the deviation distance corresponding to the jth point on the second standard circle, and m is the number of points on the second standard circle.
7. A paper cup detection system, characterized in that: The system comprises: An image acquisition device, used for acquiring images of the cup mouth and the cup bottom; A computer device is connected to the image acquisition device and is used to execute the paper cup detection method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Defect detection method and device applied to inner surface of cylinder
CN118130501A
Workpiece surface defect detection device and detection method, workpiece surface inspection system, and program
US20220335586A1