Paper cup defect detection method and device, electronic equipment and storage medium

By combining color image processing and brightness change analysis with convolution kernel and contour fitting techniques, multi-region detection of paper cups is performed, solving the problem of low detection efficiency in existing technologies and realizing full automation and improved yield in paper cup production.

CN116188365BActive Publication Date: 2026-05-15LENS SYST INTEGRATION CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
LENS SYST INTEGRATION CO LTD
Filing Date
2022-12-02
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing technologies have low paper cup inspection efficiency. Manual inspection is inefficient and highly random. Machine vision inspection can only detect stains and cannot effectively identify multiple defects, making it difficult to guarantee the yield rate of production products.

Method used

By employing color image processing and brightness variation map analysis, combined with convolution kernel and contour fitting techniques, defect detection is performed on multiple areas of the paper cup, including the cup rim, sidewalls, and seams. Abnormal areas are screened out by brightness component image difference and predicted values.

Benefits of technology

It has achieved fully automated inspection in paper cup production, improved production yield, reduced manpower waste, accurately adjusted production status, and improved production efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116188365B_ABST
    Figure CN116188365B_ABST
Patent Text Reader

Abstract

The application discloses a paper cup defect detection method and device, electronic equipment and storage medium, and belongs to the technical field of automatic detection. The method comprises the following steps: acquiring a color image of a paper cup to be detected, preprocessing the color image to obtain an overall brightness change graph; positioning a target detection area of the paper cup to be detected according to the overall brightness change graph; and performing defect detection on the target detection area. Through the application, the technical problem of low detection efficiency in the related art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of automated inspection technology, and more specifically, to a method, apparatus, electronic device, and storage medium for detecting defects in paper cups. Background Technology

[0002] During the paper cup production process, the pass rate is affected by various factors (such as the mechanical condition of the paper cup forming machine, the quality of the bottom paper, the quality of the paper sheet, temperature, and moisture). Paper cups may exhibit various defects, such as bursting, size issues, dirty sidewalls, dirty bottoms, poor seams, and cups that are not perfectly round. Therefore, it is necessary to continuously check the quality of the current paper cups to confirm the production status. Usually, the occurrence of the same type of defect several times in a row indicates a problem with the paper cup forming machine, requiring timely adjustments to ensure production quality. Furthermore, after paper cups are produced and shipped, all products undergo quality inspection to screen out unqualified products.

[0003] In related technologies, there are two detection modes. One is manual inspection, which requires continuous random sampling of paper cups to ensure a high yield rate and classify all produced paper cups into qualified and unqualified products. Manual inspection is inefficient and random, making it difficult to guarantee a high yield rate. The other mode uses machine vision to photograph paper cups, acquire images, and analyze them using algorithms. However, this mode only detects blemishes. In actual production, paper cups have many types of defects, and blemishes account for less than one-tenth of all defects. Detecting only one type of defect is not very meaningful and cannot replace manual inspection.

[0004] There are currently no effective solutions to the aforementioned problems in the relevant technologies. Summary of the Invention

[0005] This invention provides a method, apparatus, electronic device, and storage medium for detecting defects in paper cups, in order to solve the technical problem of low detection efficiency in related technologies.

[0006] According to one aspect of the embodiments of this application, a method for detecting defects in a paper cup is provided, comprising: acquiring a color image of the paper cup to be detected; preprocessing the color image to obtain an overall brightness variation map; locating a target detection area of ​​the paper cup to be detected based on the overall brightness variation map; and performing defect detection on the target detection area.

[0007] Further, defect detection of the target detection area includes: obtaining a mask corresponding to the target detection area; using the mask to obtain a luminance component image corresponding to the target detection area; obtaining a predicted value corresponding to the target detection area; and performing differential processing between the predicted value and the luminance component image to perform defect detection.

[0008] Furthermore, the target detection area is the seam area between the bottom of the cup and the side wall. Obtaining the predicted value corresponding to the target detection area includes: performing polar coordinate transformation on the first brightness component image corresponding to the seam area; using a convolution kernel to perform brightness mean filtering on the transformed image to obtain an intermediate image; and using the intermediate image as the predicted value corresponding to the seam area.

[0009] Further, defect detection of the target detection area includes: extracting the outer contour of the paper cup to be detected based on the overall brightness change map, and using the outer contour as the target detection area; obtaining the point set of the outer contour, fitting an outer contour circle based on the point set of the outer contour to obtain an outer contour fitting circle; locating the center of the outer contour fitting circle; dividing the outer contour into multiple sub-contours; traversing the distance from all points on the sub-contours to the center of the circle, and obtaining the minimum and maximum distances corresponding to each sub-contour; and detecting the flatness of the outer contour based on the minimum and maximum distances and a preset abnormal distance difference threshold.

[0010] Further, the target detection area is the gradient region between the inner cup rim and the sidewall. Locating the target detection area of ​​the paper cup to be detected based on the overall brightness change map includes: extracting the annular contour of the bright area of ​​the cup rim in the overall brightness change map, and fitting the inner cup rim circle with the inner ring contour of the annular contour; using the inner cup rim circle as the starting circle of the gradient region, reducing the radius of the inner cup rim circle according to the gradient, and obtaining the total brightness change value corresponding to the circle after the radius reduction; using the circle with a total brightness change value less than a preset value as the ending circle of the gradient region, and positioning the area between the starting circle and the ending circle as the gradient region.

[0011] Further, the target detection area is the gradient region between the inner rim of the cup and the cup wall. Defect detection in the target detection area includes: performing convolution operations on the overall brightness change map using two sets of convolution kernels to extract a highlight image and a dark image respectively; using a mask of the gradient region to crop the highlight image and the dark image, and extracting the contour through binarization; detecting whether the brightness change of the contour conforms to the change trend of a preset model; if the brightness change of the contour does not conform to the change trend of the preset model, then obtaining the brightness model of the side wall for re-inspection, calculating the predicted brightness value based on the brightness model of the side wall, setting a threshold to filter out contours that exceed the predicted brightness value by a certain amount as abnormal areas.

[0012] Further, defect detection of the target detection area includes: extracting the annular contour of the bright area of ​​the cup rim in the overall brightness change map; fitting the outer ring contour of the annular contour to obtain an outer cup rim fitting circle, reducing the radius of the outer cup rim fitting circle according to the gradient, and selecting the circle with the highest total brightness change as the outer cup rim circle; fitting the inner ring contour of the annular contour to obtain an inner cup rim circle; calculating the actual physical diameter of the paper cup based on the outer cup rim circle and the inner cup rim circle; and detecting the size of the paper cup based on the actual physical diameter.

[0013] According to another aspect of the embodiments of this application, a defect detection device for paper cups is also provided, comprising: an acquisition module for acquiring a color image of a paper cup to be detected, preprocessing the color image to obtain an overall brightness variation map; a positioning module for positioning a target detection area of ​​the paper cup to be detected according to the overall brightness variation map; and a detection module for detecting defects in the target detection area.

[0014] Furthermore, the detection module includes a detection submodule, used to obtain a mask corresponding to the target detection area; use the mask to obtain a luminance component image corresponding to the target detection area; obtain a predicted value corresponding to the target detection area; and perform differential processing between the predicted value and the luminance component image to perform defect detection.

[0015] Furthermore, the detection submodule is also used to perform polar coordinate transformation on the first brightness component image corresponding to the seam region; to perform brightness mean filtering on the transformed image using a convolution kernel to obtain an intermediate image; and to use the intermediate image as the predicted value corresponding to the seam region.

[0016] Furthermore, the detection module includes a first detection unit, used to extract the outer contour of the paper cup to be detected based on the overall brightness change map, and use the outer contour as the target detection area; obtain the point set of the outer contour, fit an outer contour circle based on the point set of the outer contour to obtain an outer contour fitting circle; locate the center of the outer contour fitting circle, and divide the outer contour into multiple sub-contours; traverse the distance from all points on the sub-contours to the center of the circle, and obtain the minimum distance and maximum distance corresponding to each sub-contour; and detect the flatness of the outer contour based on the minimum distance, the maximum distance, and a preset abnormal distance difference threshold.

[0017] Furthermore, the positioning module includes a first positioning unit, used to extract the annular contour of the bright area at the rim of the cup in the overall brightness change image, and fit the inner ring contour of the annular contour to the inner rim circle; using the inner rim circle as the starting circle of the gradient region, reducing the radius of the inner rim circle according to the gradient, and obtaining the total brightness change value corresponding to the circle after the radius reduction; using the circle whose total brightness change value is less than a preset value as the ending circle of the gradient region, and positioning the area between the starting circle and the ending circle as the gradient region.

[0018] Furthermore, the detection module includes a second detection unit, used to perform convolution operations on the overall brightness change map using two sets of convolution kernels to extract a highlight image and a dark image respectively; to use a mask of the gradient region to crop the highlight image and the dark image, and to extract the contour through binarization; to detect whether the brightness change of the contour conforms to the change trend of a preset model; if the brightness change of the contour does not conform to the change trend of the preset model, then the brightness model of the sidewall is obtained for re-examination, the predicted value of the brightness is calculated according to the brightness model of the sidewall, and a threshold is set to filter out contours that exceed the predicted value of the brightness by a certain amount as abnormal regions.

[0019] Furthermore, the detection module includes a third detection unit, which extracts the annular contour of the bright area at the rim of the cup from the overall brightness change graph; fits the outer ring contour of the annular contour to obtain an outer cup rim fitting circle, reduces the radius of the outer cup rim fitting circle according to a gradient, and selects the circle with the highest total brightness change as the outer cup rim circle; fits the inner ring contour of the annular contour to obtain an inner cup rim circle; calculates the actual physical diameter of the paper cup based on the outer cup rim circle and the inner cup rim circle; and detects the size of the paper cup based on the actual physical diameter.

[0020] According to another aspect of the embodiments of this application, a storage medium is also provided, the storage medium including a stored program that executes the above steps when the program is run.

[0021] According to another aspect of the embodiments of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the programs stored in the memory.

[0022] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to perform the steps in the above-described method.

[0023] This invention acquires a color image of a paper cup to be inspected, preprocesses the image to obtain an overall brightness variation map, locates the target detection area of ​​the paper cup based on the overall brightness variation map, and performs defect detection on the target detection area. The paper cup is divided into multiple regions based on its characteristics, and each region is inspected separately using the overall brightness variation map. This invention bridges the gap between the paper cup forming machine and the packaging machine, achieving full automation of production and quality inspection, saving manpower. Furthermore, by accurately adjusting the production status based on defect detection results, it can improve production yield, reduce production waste, greatly enhance productivity, and liberate manual labor. Attached Figure Description

[0024] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:

[0025] Figure 1 This is a hardware structure block diagram of a computer according to an embodiment of the present invention;

[0026] Figure 2 This is a flowchart of a defect detection method for paper cups according to an embodiment of the present invention;

[0027] Figure 3 This is a diagram showing the overall brightness variation in an embodiment of the present invention;

[0028] Figure 4 This is a schematic diagram of the target detection area in an embodiment of the present invention;

[0029] Figure 5 This is a schematic diagram of the joint defect extraction process in an embodiment of the present invention;

[0030] Figure 6 This is a schematic diagram of the outer contour flatness detection effect in an embodiment of the present invention;

[0031] Figure 7 This is a schematic diagram of the algorithm flow in an embodiment of the present invention;

[0032] Figure 8 This is a structural block diagram of a paper cup defect detection device according to an embodiment of the present invention. Detailed Implementation

[0033] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, and not all of them. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present application. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of the present application can be combined with each other.

[0034] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0035] Example 1

[0036] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile phone, computer, tablet, or similar computing device. Taking running on a computer as an example, Figure 1 This is a hardware structure block diagram of a computer according to an embodiment of the present invention. For example... Figure 1 As shown, a computer may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. Optionally, the computer may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer described above. For example, the computer may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0037] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to a video motion rate recognition method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the aforementioned method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0038] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a computer's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.

[0039] This embodiment provides a method for detecting defects in paper cups. Figure 2 This is a flowchart of a defect detection method for paper cups according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:

[0040] Step S10: Obtain a color image of the paper cup to be detected, and preprocess the color image to obtain an overall brightness change map;

[0041] A color image of the paper cup to be inspected is acquired and preprocessed to obtain an overall brightness variation map of the paper cup. Specifically, the color image can be acquired using a color CMOS industrial camera. The color image is converted into an HSV (Hue, Saturation, Value, HSV color model) image and separated into three component images: H (Hue), S (Saturation), and V (Value). The Scharr algorithm is used to obtain the horizontal and vertical brightness variation maps, and a weighted average is then used to obtain the overall brightness variation map, as shown below. Figure 3 As shown.

[0042] Step S20: Locate the target detection area of ​​the paper cup to be detected based on the overall brightness change map;

[0043] Step S30: Perform defect detection on the target detection area.

[0044] Based on the overall brightness variation map, the target detection area of ​​the paper cup to be inspected is located, and defect detection is performed on the target detection area. The paper cup is divided into multiple regions based on its characteristics, and each region is inspected separately using the overall brightness variation map.

[0045] Through the above steps, a color image of the paper cup to be inspected is acquired. The color image is preprocessed to obtain an overall brightness variation map. Based on this map, the target detection area of ​​the paper cup is located, and defect detection is performed on this area. The paper cup is divided into multiple regions based on its characteristics, and each region is inspected separately using the overall brightness variation map. This process bridges the gap between the paper cup forming machine and the packaging machine, achieving full automation of production and quality inspection, saving manpower. Furthermore, by accurately adjusting the production status based on defect detection results, production yield can be improved, production waste reduced, and productivity greatly increased while freeing up manual labor.

[0046] In one embodiment of this example, defect detection of the target detection area includes: obtaining a mask corresponding to the target monitoring area; using the mask to obtain a luminance component image corresponding to the target detection area; detecting defects in the paper cup based on the luminance component image; dividing the paper cup into multiple regions based on its characteristics; and detecting the multiple regions separately by combining the overall luminance change map.

[0047] In one embodiment of this example, defect detection of the target detection area includes:

[0048] Step a1: Extract the annular outline of the bright area at the rim of the cup in the overall brightness change graph;

[0049] Step a2: The outer ring contour of the annular contour is used to fit the outer cup rim to obtain the fitting circle. The radius of the fitting circle of the outer cup rim is reduced according to the gradient, and the circle with the highest total brightness change is selected as the outer cup rim circle.

[0050] Step a3: The inner cup rim circle is obtained by fitting the inner ring profile of the aforementioned annular contour.

[0051] Step a4: Calculate the actual physical diameter of the paper cup based on the outer cup rim circle and the inner cup rim circle;

[0052] Step a5: Detect the size of the paper cup based on the actual physical diameter.

[0053] Positioning and measurement of the inner and outer cup rims: The annular contour of the bright area at the cup rim is extracted from the overall brightness variation map. The outer ring contour of this annular contour is used to fit the outer cup rim to obtain a fitted circle. The radius of the fitted circle is gradually reduced, and the circle with the highest total brightness variation is selected as the outer cup rim circle. The inner ring contour of the annular contour is used to fit the inner cup rim circle. The diameters corresponding to the outer and inner cup rim circles are multiplied by their respective preset conversion ratios to obtain the actual physical diameter of the paper cup. The size of the paper cup is then measured based on the actual physical diameter. In this embodiment, the fitted circles of the outer and inner cup rims can be fitted using the least squares method. Since the outer cup rim circle is affected by burrs, etc., a more accurate outer cup rim circle can be obtained by gradually reducing the radius and selecting the circle with the highest total brightness variation.

[0054] In this embodiment, the target detection area is the cup rim area. Locating the outer and inner cup rims facilitates subsequent defect detection of the paper cup rim. The paper cup is divided into regions based on the inner and outer cup rim circles. The rim mask corresponding to the cup rim area is extracted. The HSV-V component image is cropped based on the rim mask. The brightness of the HSV-V component image is tested for normal distribution. For brightness that does not meet the normal distribution, a connection determination is made. The set span and depth thresholds are obtained to perform defect detection in the regions that do not meet the normal distribution. In this embodiment, the defect can be an abnormal condition such as dirt or stains.

[0055] In another embodiment of this example, the target detection area is a gradient area between the inner rim of the cup and the cup wall. Locating the target detection area of ​​the paper cup to be detected based on the overall brightness variation map includes:

[0056] Step b1: Extract the annular contour of the bright area at the rim of the cup in the overall brightness change graph, and fit the inner ring contour of the annular contour to the inner rim circle.

[0057] Step b2: Using the inner cup rim circle as the starting circle of the gradient region, reduce the radius of the inner cup rim circle according to the gradient, and obtain the total brightness change value corresponding to the circle after the radius reduction;

[0058] Step b3: The circle whose total brightness change value is less than a preset value is used as the termination circle of the gradient region, and the area between the starting circle and the termination circle is positioned as the gradient region.

[0059] The gradient region is located by combining the inner cup rim circle with the brightness change diagram. The radius of the inner cup rim circle is iteratively reduced, and the total brightness change value corresponding to the circle after the radius reduction is calculated. If the total brightness change value is less than a preset value, it indicates that the total brightness change value tends to be relatively stable, and it is considered as the termination circle of the gradient region. Figure 4As shown, the area between the inner cup rim circle and the termination circle is the gradient area. For the gradient area at the lower edge of the cup rim, which is difficult to process, differential processing is performed based on the current image features and the brightness of the relevant areas is preset, so as to more accurately locate the defects in the gradient area.

[0060] Specifically, defect detection of the target detection area includes:

[0061] Step b4: Perform convolution operation on the overall brightness change map using two sets of convolution kernels to extract the highlight map and the dark map respectively;

[0062] Step b5: Use the mask of the gradient region to crop the highlight image and the dark image, and extract the contour through binarization;

[0063] Step b6: Detect whether the brightness change of the contour conforms to the change trend of the preset model;

[0064] Step b7: If the brightness change of the contour does not conform to the change trend of the preset model, then obtain the brightness model of the sidewall for re-examination.

[0065] Two sets of convolutional kernels are used to perform convolution operations on the overall brightness change map to extract highlight and dark areas respectively. Highlight and dark areas are cropped using masks of the gradient regions, and a threshold is set for binarization. The contours of the gradient regions are extracted through binarization, and the brightness change of the contours is checked to see if it meets the trend of a preset model. The trend of the preset model is the brightness change trend corresponding to the gradient region, which is that the total brightness change from the inner cup rim circle to the terminal circle gradually decreases. If the brightness change of the contours does not meet the trend of the preset model, the brightness model of the sidewalls is obtained for re-examination. The predicted brightness value is calculated based on the brightness model of the sidewalls, and a threshold is set to filter out contours that exceed the predicted value by a certain amount as abnormal regions. For those that meet the brightness change of the cup rim, annular brightness detection is performed. Annular brightness detection includes obtaining the brightness distribution of the concentric circles of the corresponding position relative to the inner cup rim circle, detecting whether the brightness change is smooth, and setting a threshold to determine whether there are abrupt changes.

[0066] In another embodiment of this example, the target detection area is the bottom of the cup. The feature of bright mirror reflection at the bottom of the paper cup is used. The K-Mean algorithm is used to obtain an adaptive brightness threshold. The image is binarized using the threshold and the contour is extracted. The cup bottom contour is extracted based on the circular feature of the cup bottom. The cup bottom contour is fitted to obtain the cup bottom circle. The area enclosed by the cup bottom circle is the cup bottom area.

[0067] In this embodiment, the target detection area is the bottom area of ​​the cup, and defect detection in the target detection area includes:

[0068] Step c1: Obtain the cup bottom mask of the cup bottom region;

[0069] Step c2: Use the cup bottom mask to extract the second brightness component image corresponding to the cup bottom area in the overall brightness change image;

[0070] Step c3: Perform mean filtering on the brightness of the cup bottom region, use the mean-filtered image as the predicted value corresponding to the cup bottom region, and perform difference calculation between the predicted value corresponding to the cup bottom region and the second brightness component image to obtain the spot outline;

[0071] Step c4: Areas where the outline of the spot is larger than a preset size are identified as abnormal areas.

[0072] First, an inner cup rim mask is used to extract the HSV-V component images of the paper cup's sidewall and bottom. Local adaptive binarization is then used to extract the HSV-V component images. A bottom mask is used to separate the bottom binarized image, extracting the bottom contour. The bottom mask is then used to extract the second brightness component image corresponding to the bottom region in the overall brightness variation image. Mean filtering is applied to the brightness of the bottom region, and the filtered image is used as the predicted value for the bottom region. The average brightness and distribution of the entire bottom region are statistically analyzed. Mean filtering is then performed, and the predicted value for the bottom region is compared with the second brightness component image to obtain the spot contour. The features of the spot contour (length, width, area, etc.) are acquired. The spot contours are then filtered to remove areas with excessively small contours, and areas with contours larger than a preset size are identified as abnormal areas. Automatic compensation is implemented to address unavoidable mechanical errors and brightness unevenness in different detection areas, ensuring detection accuracy.

[0073] In another embodiment of this example, the target detection area is the seam area between the bottom and sidewall of the cup. Utilizing the significant brightness difference between the seam and the bottom and sidewall, local adaptive binarization is used to obtain either a brighter or darker image. The bottom circle is fitted using the least squares method based on the cup bottom contour. A preset area is then expanded outward from the bottom circle to the expanded circle. The area enclosed between the bottom circle and the expanded circle is used as the seam observation area. A brighter or darker image is cropped from this area. Based on seam characteristics, a darker image is generally cropped from the darker seam. A threshold is set to filter noise, and RANSAC is used to fit a circle to determine the seam center, thus completing the precise localization of the seam area. Expansion and contraction (increasing or decreasing the radius of the circle) are performed based on the bottom circle. Based on the feature of the greatest brightness change at the seam edge, the maximum value of the derivative is obtained using the HSV-V image as the endpoint of the contraction and expansion to confirm the coverage area of ​​the bottom seam.

[0074] Defect detection in the joint area includes:

[0075] Step d1: Perform polar coordinate transformation on the first luminance component image corresponding to the seam area;

[0076] Step d2, and then use a convolution kernel to perform brightness mean filtering on the transformed image to obtain an intermediate image;

[0077] Step d3: Use the intermediate image as the predicted value corresponding to the seam area.

[0078] Obtain the seam mask corresponding to the seam detection area. Extract the first luminance component image corresponding to the seam area using the seam mask. Perform polar coordinate transformation on the first luminance component image corresponding to the seam area, and apply a convolutional kernel to the transformed image for luminance mean filtering to obtain an intermediate image. Use the intermediate image as the predicted value corresponding to the seam area. Apply a convolutional kernel to the entire image for mean filtering, then differ from the original image. Set a threshold to extract the contour, and filter the contour features (area, length, width). For example, the detection result is as follows: Figure 5 The crack defect shown.

[0079] In another embodiment of this invention, the target detection area is the sidewall area of ​​the paper cup, and the area enclosed between the inner cup rim circle and the extended circle of the seam area is defined as the sidewall area.

[0080] Step e1: Extract the sidewall mask of the sidewall region based on the inner cup rim circle and the extended circle;

[0081] Step e2: Use the sidewall mask to extract the third brightness component image corresponding to the sidewall region in the overall brightness change image;

[0082] Step e3: Extract the average brightness of the detection position facing the center of the cup rim in the third brightness component image as the predicted value;

[0083] Step e4: Extract the grayscale value of the third luminance component image and calculate the difference between the grayscale value and the predicted value;

[0084] Step e5: The detection position corresponding to the gray value whose difference exceeds the preset difference is determined as an abnormal position.

[0085] The sidewall mask of the sidewall region is extracted based on the inner cup rim circle and the extended circle. The third brightness component image corresponding to the sidewall region in the overall brightness variation map is then extracted using the sidewall mask. The average brightness of the detection position facing the center of the cup rim in the third brightness component image is extracted as the predicted value. The grayscale value of the third brightness component image is extracted, and the difference between the grayscale value and the predicted value is calculated. Detection positions corresponding to grayscale values ​​with differences exceeding a preset value are identified as abnormal positions. The sidewall mask is used to separate the sidewall regions corresponding to the brightness map and the overall adaptive binarized map. Contours are extracted and filtered according to a certain size. For contours that meet the conditions, the average brightness of the current position facing the center of the cup rim is extracted as the predicted value. The difference between the grayscale value within the contour and the predicted value is further used for filtering, clearing the contours of the side seam region.

[0086] In another embodiment of this example, defect detection of the target detection area includes:

[0087] Step f1: Extract the outer contour of the paper cup to be detected based on the overall brightness change map, and use the outer contour as the target detection area;

[0088] Step f2: Obtain the point set of the outer contour, and fit the outer contour circle according to the point set of the outer contour to obtain the fitted outer contour circle;

[0089] Step f3: Locate the center of the fitted circle for the outer contour.

[0090] Step f4: Divide the outer contour into multiple sub-contours;

[0091] Step f5: Traverse the distances from all points on the sub-contour to the center of the circle, and obtain the minimum and maximum distances corresponding to each sub-contour;

[0092] Step f6: Detect the smoothness of the outer contour based on the minimum distance, the maximum distance, and a preset abnormal distance difference threshold.

[0093] Preliminary positioning of the paper cup is achieved through fixed binarization, extracting the outer contour of the paper cup to be inspected. The outer contour is used as the target detection area, and a point set is obtained. An outer contour circle is fitted based on the point set, resulting in a fitted circle. The center of the fitted circle is located, and the outer contour is divided into multiple sub-contours. The distances from all points on each sub-contour to the center are iterated, and the minimum and maximum distances for each sub-contour are obtained. The smoothness of the outer contour is detected based on the minimum and maximum distances and a preset abnormal distance difference threshold. Specifically, an angle A is set, and the entire fitted circle is divided into 720 / A regions, each spanning A. The Euclidean distances from all points on the contour corresponding to angle A to the center of the outer contour are iterated, and the minimum and maximum distances are calculated for each region. An abnormal distance difference threshold is set; if the difference between the minimum and maximum distances exceeds the preset abnormal distance difference threshold, the outer contour is determined to be uneven. (See reference...) Figure 6 .

[0094] Furthermore, the continuity of the cup rim contour is detected. Based on the characteristics of the paper cup, K-Mean clustering is used to statistically analyze the brightness of the paper cup, a threshold is set, and the bright area of ​​the cup rim is extracted. The contour of the bright area is extracted to obtain multiple features such as the area, length and width of the bright area. The relationship between the area of ​​the contour and the size of the circle corresponding to the length and width is used to determine whether it is continuous and forms a closure.

[0095] In another embodiment of this example, the target detection area is a side seam, and defect detection of the target detection area includes:

[0096] Side seam location: Using the sidewall region, extract the local bright and low bright areas within the sidewall region, and combine with the overall brightness change map to extract the sidewall contour; based on the characteristics of the side seam being close to the bottom circle and the inner rim circle of the cup, the contour is filtered, and the distance from the two ends of the contour rectangle to the bottom circle center and the inner rim circle center is compared for judgment; the brightness variation extreme points are obtained by iteratively calculating the brightness variation extreme points in the direction of the bottom circle center of the filtered contour (circle radius); the least squares method is used to fit all extreme points to obtain the straight line where the side seam is located, and the location is completed; the obtained straight line is confirmed to confirm the proportion of extreme points crossed by the straight line. If the proportion is not high, it is determined that the extreme points are discrete and the location is invalid; if the location is effective, the mask of the located side seam is obtained, and the corresponding areas such as the mouth seam are extended and masked to complete the data integration.

[0097] In one embodiment of this example, as Figure 7 As shown, S1 acquires a color image of the paper cup to be inspected, preprocesses the color image to obtain an overall brightness variation map, S2 detects the flatness of the outer contour, S3 detects the continuity of the cup rim contour, S4 measures the positioning of the inner and outer cup rims, S5 locates the gradient area and the bottom, S6 divides the area in detail, S7 integrates the side seam detection data, S8 detects the rim of the paper cup, S9 detects the side wall of the paper cup, S10 detects the bottom, S11 detects the bottom seam, and S12 detects the gradient area of ​​the inner cup rim. If all of these steps are qualified, the product is judged to be qualified.

[0098] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0099] Example 2

[0100] This embodiment also provides a defect detection device for paper cups, used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0101] Figure 8 This is a structural block diagram of a paper cup defect detection device according to an embodiment of the present invention, as shown below. Figure 8 As shown, the device includes: an acquisition module 60, a positioning module 61, and a detection module 62, wherein,

[0102] The acquisition module 60 is used to acquire a color image of the paper cup to be detected, and to preprocess the color image to obtain an overall brightness change map;

[0103] Positioning module 61 is used to locate the target detection area of ​​the paper cup to be detected according to the overall brightness change map;

[0104] The detection module 62 is used to perform defect detection on the target detection area.

[0105] Optionally, the detection module includes a detection submodule, used to obtain a mask corresponding to the target detection area; use the mask to obtain a luminance component image corresponding to the target detection area; obtain a predicted value corresponding to the target detection area; and perform differential processing between the predicted value and the luminance component image to perform defect detection.

[0106] Optionally, the detection submodule is further configured to perform polar coordinate transformation on the first brightness component image corresponding to the seam region; perform brightness mean filtering on the transformed image using a convolution kernel to obtain an intermediate image; and use the intermediate image as the predicted value corresponding to the seam region.

[0107] Optionally, the detection module includes a first detection unit, configured to extract the outer contour of the paper cup to be detected based on the overall brightness change map, and use the outer contour as the target detection area; obtain the point set of the outer contour, fit an outer contour circle based on the point set of the outer contour to obtain an outer contour fitting circle; locate the center of the outer contour fitting circle, and divide the outer contour into multiple sub-contours; traverse the distance from all points on the sub-contours to the center of the circle, and obtain the minimum distance and maximum distance corresponding to each sub-contour; and detect the flatness of the outer contour based on the minimum distance, the maximum distance, and a preset abnormal distance difference threshold.

[0108] Optionally, the positioning module includes a first positioning unit, used to extract the annular contour of the bright area at the rim of the cup in the overall brightness change image, and fit the inner ring contour of the annular contour to the inner rim circle; using the inner rim circle as the starting circle of the gradient region, reducing the radius of the inner rim circle according to a gradient, and obtaining the total brightness change value corresponding to the circle after the radius reduction; using the circle with a total brightness change value less than a preset value as the ending circle of the gradient region, and positioning the area between the starting circle and the ending circle as the gradient region.

[0109] Optionally, the detection module includes a second detection unit, used to perform convolution operations on the overall brightness change map using two sets of convolution kernels to extract a highlight image and a dark image respectively; to use a mask of the gradient region to crop the highlight image and the dark image, and to extract the contour through binarization; to detect whether the brightness change of the contour conforms to the change trend of a preset model; if the brightness change of the contour does not conform to the change trend of the preset model, then the brightness model of the sidewall is obtained for re-examination, the predicted value of the brightness is calculated according to the brightness model of the sidewall, and a threshold is set to filter out contours that exceed the predicted value of the brightness by a certain amount as abnormal regions.

[0110] Optionally, the detection module includes a third detection unit, which extracts the annular contour of the bright area at the rim of the cup from the overall brightness change graph; fits the outer ring contour of the annular contour to obtain an outer cup rim fitting circle, reduces the radius of the outer cup rim fitting circle according to a gradient, and selects the circle with the highest total brightness change as the outer cup rim circle; fits the inner ring contour of the annular contour to obtain an inner cup rim circle; calculates the actual physical diameter of the paper cup based on the outer cup rim circle and the inner cup rim circle; and detects the size of the paper cup based on the actual physical diameter.

[0111] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.

[0112] Example 3

[0113] Embodiments of the present invention also provide a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.

[0114] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:

[0115] S21, acquire a color image of the paper cup to be detected, preprocess the color image to obtain an overall brightness change map;

[0116] S22, locate the target detection area of ​​the paper cup to be detected according to the overall brightness change map;

[0117] S23, Defect detection is performed on the target detection area.

[0118] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0119] Embodiments of the present invention also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0120] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0121] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:

[0122] S21, acquire a color image of the paper cup to be detected, preprocess the color image to obtain an overall brightness change map;

[0123] S22, locate the target detection area of ​​the paper cup to be detected according to the overall brightness change map;

[0124] S23, Defect detection is performed on the target detection area.

[0125] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.

[0126] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0127] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0128] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0129] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0130] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0131] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0132] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for detecting defects in paper cups, characterized in that, The method includes: A color image of the paper cup to be detected is acquired, and the color image is preprocessed to obtain an overall brightness change map. The preprocessing includes converting the color image into a color model image and separating it into three component images. The target detection area of ​​the paper cup to be tested is located based on the overall brightness change map; Defect detection is performed on the target detection area; The target detection area is the seam area between the bottom of the cup and the side wall; the target detection area is the gradient area between the inner rim of the cup and the side wall; the target detection area is the side wall area of ​​the paper cup; and the area enclosed by the inner rim circle and the extended circle of the seam area is defined as the side wall area. Extract the sidewall mask of the sidewall region based on the inner cup rim circle and the extended circle; The third brightness component image corresponding to the sidewall region in the overall brightness change image is extracted using the sidewall mask. The average brightness of the detection position facing the center of the cup rim in the third brightness component image is extracted as the predicted value. Extract the grayscale value of the third luminance component image, and calculate the difference between the grayscale value and the predicted value; The detection location corresponding to the gray value whose difference exceeds the preset difference is determined as an abnormal location.

2. The method according to claim 1, characterized in that, Defect detection in the target detection area includes: Obtain the mask corresponding to the target detection region; The mask is used to obtain the brightness component image corresponding to the target detection area; Obtain the predicted value corresponding to the target detection area, and perform differential processing between the predicted value and the brightness component image to perform defect detection.

3. The method according to claim 2, characterized in that, Obtaining the predicted value corresponding to the target detection region includes: Perform polar coordinate transformation on the first luminance component image corresponding to the seam area; The converted image is filtered by brightness mean using a convolution kernel to obtain an intermediate image. The intermediate image is used as the predicted value corresponding to the seam area.

4. The method according to claim 1, characterized in that, Defect detection in the target detection area includes: The outer contour of the paper cup to be detected is extracted based on the overall brightness change map, and the outer contour is used as the target detection area. Obtain the point set of the outer contour, and fit the outer contour circle according to the point set of the outer contour to obtain the fitted outer contour circle; Locate the center of the fitted circle of the outer contour, and divide the outer contour into multiple sub-contours; Iterate through the distances from all points on the sub-contour to the center of the circle, and obtain the minimum and maximum distances for each sub-contour; The smoothness of the outer contour is detected based on the minimum distance, the maximum distance, and a preset abnormal distance difference threshold.

5. The method according to claim 1, characterized in that, Locating the target detection area of ​​the paper cup to be detected based on the overall brightness change map includes: Extract the annular contour of the bright area at the rim of the cup from the overall brightness variation graph, and fit the inner ring contour of the annular contour to the inner rim circle. The inner cup rim circle is used as the starting circle of the gradient region. The radius of the inner cup rim circle is reduced according to the gradient, and the total value of brightness change corresponding to the circle after the radius is reduced is obtained. The circle whose total brightness change is less than a preset value is used as the termination circle of the gradient region, and the area between the starting circle and the termination circle is defined as the gradient region.

6. The method according to claim 1, characterized in that, The target detection area is the gradient region between the inner rim of the cup and the cup wall. Defect detection in the target detection area includes: Two sets of convolution kernels are used to perform convolution operations on the overall brightness change map to extract the highlight map and the dark map respectively. The highlight image and the dark image are cropped using the mask of the gradient region, and the contour is extracted by binarization. Detect whether the brightness changes of the contour conform to the trend of the preset model; If the brightness change of the contour does not conform to the trend of the preset model, the brightness model of the sidewall is obtained for re-examination. The predicted value of the brightness is calculated based on the brightness model of the sidewall, and a threshold is set to filter out contours that exceed the predicted value of the brightness by a certain amount as abnormal areas.

7. The method according to claim 1, characterized in that, Defect detection in the target detection area includes: Extract the annular outline of the bright area at the rim of the cup from the overall brightness variation graph; The outer ring contour of the aforementioned annular contour is used to fit the outer cup rim to obtain a fitting circle. The radius of the fitting circle of the outer cup rim is reduced according to the gradient, and the circle with the highest total brightness change is selected as the outer cup rim circle. The inner cup rim circle is obtained by fitting the inner ring profile of the aforementioned annular profile. Calculate the actual physical diameter of the paper cup based on the outer cup rim circle and the inner cup rim circle; The size of the paper cup is determined based on its actual physical diameter.

8. A defect detection device for paper cups, characterized in that, include: The acquisition module is used to acquire a color image of the paper cup to be detected, preprocess the color image to obtain an overall brightness change map, and the preprocessing includes converting the color image into a color model image and separating it into three component images; The positioning module is used to locate the target detection area of ​​the paper cup to be detected based on the overall brightness change map; The detection module is used to perform defect detection on the target detection area; The target detection area is the seam area between the bottom of the cup and the side wall; the target detection area is the gradient area between the inner rim of the cup and the side wall; the target detection area is the side wall area of ​​the paper cup; and the area enclosed by the inner rim circle and the extended circle of the seam area is defined as the side wall area. Extract the sidewall mask of the sidewall region based on the inner cup rim circle and the extended circle; The third brightness component image corresponding to the sidewall region in the overall brightness change image is extracted using the sidewall mask. The average brightness of the detection position facing the center of the cup rim in the third brightness component image is extracted as the predicted value. Extract the grayscale value of the third luminance component image, and calculate the difference between the grayscale value and the predicted value; The detection location corresponding to the gray value whose difference exceeds the preset difference is determined as an abnormal location.

9. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, communication interface, and memory communicate with each other through the communication bus; wherein: Memory, used to store computer programs; A processor for executing the method steps of any one of claims 1 to 7 by running a program stored in memory.

10. A storage medium, characterized in that, The storage medium includes a stored program, wherein the program, when executed, performs the method steps of any one of claims 1 to 7.