A cigarette defect detection method and device
By using XML file storage and entropy weight method to calculate defect values, the accuracy and adaptability issues of existing cigarette detection systems have been solved, achieving full sample monitoring and reducing storage costs, thus promoting the digital upgrade of tobacco enterprises.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-19
- Publication Date
- 2026-03-17
AI Technical Summary
Existing cigarette appearance defect detection systems rely on manual feature extraction, resulting in poor detection accuracy and adaptability, inability to monitor the entire sample, and high storage costs.
The defect identification results are stored in XML files, and the defect detection model is used for identification. The defect value is calculated using the entropy weight method to improve the detection accuracy and adaptability. Full sample monitoring is achieved through digital analysis.
It improves the accuracy and adaptability of cigarette defect detection, reduces storage costs, and enables full-sample monitoring and efficient defect level assessment.
Smart Images

Figure CN116756372B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of quality inspection technology, and more specifically, to a method and apparatus for detecting defects in cigarettes. Background Technology
[0002] From tobacco leaf planting to the sale of boxed cigarettes, the tobacco industry chain encompasses extremely complex processes, mainly including tobacco processing, cigarette making, and packaging. As the core equipment in the cigarette making process, the cigarette rolling machine has seen a significant increase in automation and production speed along with the development of industrial technology in cigarette manufacturing. Therefore, under high-speed production conditions, defective cigarettes are inevitably produced.
[0003] Currently, China uses machine vision technology based on traditional image processing to detect cigarette appearance defects. This technology relies heavily on manual feature extraction, requiring manual definition and selection of features, a process that demands significant time and experience. This presents several challenges. First, cigarette appearance defects are diverse and complex, with some defects being quite small and difficult to detect. Current detection systems may have errors in identifying and analyzing certain defects, necessitating improvements in detection accuracy. Second, the wide variety of cigarette types and specifications means different types may have different appearance defect characteristics. Existing detection systems, relying on manually defined and selected defect features, suffer from poor adaptability and versatility in defect identification, failing to meet the detection needs of different types of cigarettes. Third, existing detection systems require storing images of defective cigarettes, resulting in massive image data that consumes significant storage space, thus increasing storage costs.
[0004] Furthermore, during real-time detection of cigarette appearance defects, the manufacturer's cigarette appearance defect detection system only records images of cigarettes with defects, thus requiring sampling to verify the system's accuracy. Therefore, the existing detection system cannot achieve full sample monitoring, which will hinder the manufacturer's lean management. Summary of the Invention
[0005] This application provides a method and apparatus for detecting cigarette defects. It uses XML files to store the defect identification results, which not only preserves the important information of the original cigarette images, but also greatly reduces the storage space occupied by each cigarette image, thus effectively reducing storage costs to a certain extent. Therefore, it can record the defect identification results of each cigarette image, laying the foundation for full sample monitoring of cigarette production. At the same time, using a defect detection model for defect identification can improve the accuracy, adaptability and versatility of the detection.
[0006] This application provides a method for detecting defects in cigarettes, including:
[0007] Receive cigarette images captured by an industrial camera;
[0008] Based on the defect detection model, defects in cigarette images are identified, and prediction boxes containing defect type and location information are obtained.
[0009] Convert the information from the prediction boxes into an XML file and store it;
[0010] Based on the XML file, the defect values corresponding to the cigarette images are obtained through digital parsing.
[0011] The defect level of cigarette images is evaluated based on the defect value.
[0012] Preferably, the defect value corresponding to the cigarette image is obtained by digitally parsing the XML file, specifically including:
[0013] Extracting multiple basic feature values of defects from cigarette images from XML files;
[0014] Determine the weight value corresponding to each basic feature value;
[0015] The first defect value is calculated based on all the basic feature values and corresponding weight values of the defect, and is used as the defect value corresponding to the cigarette image.
[0016] Preferably, if there are multiple defects in the cigarette image, the weighted sum of the first defect values of all defects is taken as the defect value corresponding to the cigarette image.
[0017] Preferably, the entropy weight method is used to determine the weight value corresponding to each basic feature value.
[0018] Preferably, training the defect detection model includes the following steps:
[0019] Acquire images of a batch of cigarettes captured by an industrial camera;
[0020] Defect categories were labeled on a batch of cigarette images to obtain a labeled dataset;
[0021] A defect detection model is obtained by training a neural network model using a labeled dataset.
[0022] The defect detection model is evaluated using multiple evaluation metrics. If the accuracy and speed of the defect detection model for each defect category meet the actual requirements, then the training is complete.
[0023] This application also provides a cigarette defect detection device, including an image receiving module, a recognition module, a conversion module, a parsing module, and a first evaluation module;
[0024] The image receiving module is used to receive cigarette images captured by an industrial camera;
[0025] The identification module is used to identify defects in cigarette images based on a defect detection model, and to obtain a prediction box containing information on the defect type and location.
[0026] The conversion module is used to convert the information of the prediction boxes into XML files and store them;
[0027] The parsing module is used to perform digital parsing based on the XML file to obtain the defect values corresponding to the cigarette images;
[0028] The first evaluation module is used to evaluate the defect level of cigarette images based on defect values.
[0029] Preferably, the parsing module includes a feature extraction module, a weight determination module, and a first calculation module;
[0030] The feature extraction module is used to extract multiple basic feature values of defects in cigarette images from XML files;
[0031] The weight determination module is used to determine the weight value corresponding to each basic feature value;
[0032] The first calculation module is used to calculate the first defect value based on all the basic feature values and corresponding weight values of the defect, which serves as the defect value corresponding to the cigarette image.
[0033] Preferably, the parsing module further includes a second calculation module, which is used to take the weighted sum of the first defect values of all defects as the defect value corresponding to the cigarette image when there are multiple defects in the cigarette image.
[0034] Preferably, the weight determination module is used to determine the weight value corresponding to each basic feature value using the entropy weight method.
[0035] Preferably, the cigarette defect detection device further includes a model acquisition module, which includes an image acquisition module, an annotation module, a training module, and a second evaluation module.
[0036] The image acquisition module is used to acquire images of a batch of cigarettes captured by an industrial camera;
[0037] The annotation module is used to annotate the defect categories of batch cigarette images to obtain an annotated dataset;
[0038] The training module is used to train the neural network model using a labeled dataset to obtain a defect detection model;
[0039] The second evaluation module is used to evaluate the defect detection model using multiple evaluation metrics. If the accuracy and speed of the defect detection model for each defect category meet the actual requirements, then the training is complete.
[0040] Other features and advantages of this application will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description
[0041] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments of the present application and, together with their description, serve to explain the principles of the present application.
[0042] Figure 1 A flowchart of the cigarette defect detection method provided in this application;
[0043] Figure 2 Example diagram of defect identification results provided for this application;
[0044] Figure 3 An example of an XML file provided for this application;
[0045] Figure 4 for Figure 3 The results of basic feature value extraction from the XML file shown;
[0046] Figure 5 This is a structural diagram of the cigarette defect detection device provided in this application. Detailed Implementation
[0047] Various exemplary embodiments of the present application will now be described in detail with reference to the accompanying drawings. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the present application.
[0048] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the scope of this application and its application or use.
[0049] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, they should be considered part of the specification.
[0050] In all the examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.
[0051] This application provides a method and apparatus for detecting cigarette defects. It uses XML files to store the defect identification results, which not only preserves the important information of the original cigarette images but also greatly reduces the storage space occupied by each cigarette image, thus effectively reducing storage costs to a certain extent. Therefore, it can record the defect identification results of each cigarette image, laying the foundation for full-sample monitoring of cigarette production. At the same time, using a defect detection model for defect identification can improve the accuracy, adaptability, and versatility of detection, promote the upgrading of cigarette manufacturing towards digitalization and intelligence, and promote the high-quality development of tobacco enterprises.
[0052] like Figure 1 As shown, the methods for detecting cigarette defects include:
[0053] S110: Receives images of cigarettes captured by an industrial camera.
[0054] S120: Based on a defect detection model, defects in cigarette images are identified, and predicted bounding boxes containing defect type and location information are obtained, such as... Figure 2 As shown, the prediction box represents basic information (such as length, width, and position coordinates) about defects in the cigarette stick and filter in each cigarette image.
[0055] S130: Convert the information of the prediction box into an XML file and store it.
[0056] As an example, the XML file obtained based on the predicted bounding box information includes the defect category and the position coordinates of the predicted bounding box. The position coordinates of the predicted bounding box include its boundary values, specifically the x and y coordinates of its upper left corner (i.e., the minimum x coordinate xmin and the minimum y coordinate ymin) and the x and y coordinates of its lower right corner (i.e., the maximum x coordinate xmax and the maximum y coordinate ymax).
[0057] like Figure 3 In the XML file shown, the serial number represents the order of the cigarette images. The specific meaning of this XML file is that the two defects appearing in the 1631st cigarette image are both filter blemishes (defect category WD12). The upper left corner coordinates of the prediction box for blemish one are (1071, 51), and the lower right corner coordinates are (1089, 71). The upper left corner coordinates of the prediction box for blemish two are (1068, 196), and the lower right corner coordinates are (1082, 212).
[0058] S140: Based on the XML file, perform digital parsing to obtain the defect value corresponding to the cigarette image.
[0059] As one example, the defect value corresponding to the cigarette image is obtained by digitally parsing the XML file, specifically including:
[0060] S1401: Extract multiple basic feature values of defects from cigarette images from XML files.
[0061] As an example, several basic feature values include defect category (denoted as A1), defect area (denoted as A2), center point value of defect horizontal coordinate (denoted as A3), and center point value of defect vertical coordinate (denoted as A4).
[0062] Specifically, firstly, the length and width of the prediction box are calculated using the following formulas (1) and (2). Then, the area of the prediction box, Square, is obtained by multiplying the length and width, and is taken as the defect area A2, as shown in formula (3). Based on formulas (4) and (5), the center point value X_centre of the horizontal coordinate of the prediction box and the center point value Y_centre of the vertical coordinate of the prediction box are calculated, and are taken as the center point value A3 of the defect horizontal coordinate and the center point value A4 of the defect vertical coordinate.
[0063] long = xmax - xmin (1)
[0064] wide=ymax-ymin (2)
[0065] Square = long × wide (3)
[0066]
[0067]
[0068] Figure 4 It shows Figure 3 The results of extracting basic feature values corresponding to the XML file.
[0069] S1402: Determine the weight value corresponding to each basic feature value.
[0070] As an example, the entropy weight method is used to determine the weight value corresponding to each basic feature value.
[0071] Based on the data obtained above, an evaluation matrix is established, using four basic feature values to describe the defects in each cigarette image: A1 (defect category), A2 (defect area), A3 (center point value of the defect's horizontal axis), and A4 (center point value of the defect's vertical axis). Since the defect category is a qualitative variable, it needs to be quantified; the other three basic features are quantitative variables. Furthermore, because the units of each basic feature are different, the evaluation matrix must first be standardized to eliminate the influence of dimensions and units.
[0072] Among them, A1 (defect category), A3 (center point value of the defect horizontal axis), and A4 (center point value of the defect vertical axis) are all negative indicators, and are standardized according to the following formula (6); A2 (defect area) is a positive indicator, and is standardized according to the following formula (7):
[0073]
[0074]
[0075] Where, r ij X is the standardized value of the j-th defect in the i-th defect category. ij Let X be the basic feature value of the j-th defect in the i-th defect category. max and X min Let be the maximum and minimum values for the i-th defect category.
[0076] Next, the weight of each basic feature value is calculated according to formula (8), the corresponding information entropy is calculated according to formula (9), the corresponding redundancy is calculated according to formula (10), and the weights corresponding to each basic feature are calculated according to formula (11), denoted as ω1, ω2, ω3 and ω4. The larger the weight value, the greater the influence of the basic feature on the defect.
[0077]
[0078]
[0079] D j =1-E j (10)
[0080]
[0081] S1403: Calculate the first defect value based on all the basic feature values and corresponding weight values of the defect, and use it as the defect value corresponding to the cigarette image.
[0082] Specifically, the first defect value R is calculated using formula (12) to characterize the condition of each defect:
[0083] R=ω1×A1+ω2×A2+ω3×A3+ω4×A4 (12)
[0084] Preferably, if there are multiple defects in the cigarette image, the weighted sum of the first defect values of all defects is taken as the defect value corresponding to the cigarette image.
[0085] Understandably, multiple basic characteristic values can also include the perimeter, texture, color, etc. of defects.
[0086] S150: The defect level of a cigarette image is evaluated based on its defect value. Specifically, the defect level characterizes the severity of defects in the cigarette image. Understandably, appropriate grading standards can be developed according to actual requirements.
[0087] The cigarette defect detection method of this application also includes training a defect detection model, specifically including the following steps:
[0088] P1: Acquire batch images of cigarettes captured by an industrial camera. It is understood that batch images of cigarettes can include images of various sizes and brands; models trained with comprehensive base data have higher detection accuracy and wider applicability.
[0089] P2: Label the defect categories of a batch of cigarette images to obtain a labeled dataset.
[0090] Specifically, the defect types are first defined, and then LabelImg is used to label the defect categories of the selected cigarette images.
[0091] As an example, defect categories include abnormal wrinkles, abnormal occlusion, abnormal texture, abnormal stains, abnormal curling, abnormal punctures, abnormal misalignment, abnormal splicing of paper, and abnormal bursting.
[0092] P3: Train the neural network model using the labeled dataset to obtain a defect detection model.
[0093] As an example, the neural network model can be the YOLOv5 network model, or other models such as transformer, SSD, etc.
[0094] P4: Evaluate the defect detection model using multiple evaluation metrics to determine whether the accuracy and speed of the defect detection model for each defect category meet the actual requirements. If yes, proceed to P5; otherwise, return to P3.
[0095] Specifically, multiple evaluation metrics include precision, recall, average accuracy, mean of average accuracy, and detection speed. If the score of each evaluation metric is within the preset range, then the accuracy and speed of the defect detection model for each defect category meet the actual requirements.
[0096] P5: If the accuracy and speed of the defect detection model for each defect category meet the actual requirements, then the training is complete, and the trained defect detection model is obtained.
[0097] Based on the above-described method for detecting cigarette defects, this application also provides a device for detecting cigarette defects. For example... Figure 5As shown, the cigarette defect detection device includes an image receiving module 510, an identification module 520, a conversion module 530, an analysis module 540, and a first evaluation module 550.
[0098] The image receiving module 510 is used to receive cigarette images captured by an industrial camera.
[0099] The recognition module 520 is used to identify defects in cigarette images based on a defect detection model, and obtain a prediction box containing defect type and location information.
[0100] The conversion module 530 is used to convert the information of the prediction box into an XML file and store it.
[0101] The parsing module 540 is used to perform digital parsing based on the XML file to obtain the defect value corresponding to the cigarette image.
[0102] The first evaluation module 550 is used to evaluate the defect level of the cigarette image based on the defect value.
[0103] Preferably, the parsing module 540 includes a feature extraction module 5401, a weight determination module 5402, and a first calculation module 5403.
[0104] The feature extraction module 5401 is used to extract multiple basic feature values of defects in cigarette images from XML files.
[0105] The weight determination module 5402 is used to determine the weight value corresponding to each basic feature value.
[0106] The first calculation module 5403 is used to calculate the first defect value based on all the basic feature values and corresponding weight values of the defect, which serves as the defect value corresponding to the cigarette image.
[0107] Preferably, the parsing module 540 further includes a second calculation module 5404, which is used to take the weighted sum of the first defect values of all defects as the defect value corresponding to the cigarette image when there are multiple defects in the cigarette image.
[0108] Preferably, the weight determination module 5402 is used to determine the weight value corresponding to each basic feature value using the entropy weight method.
[0109] Preferably, the cigarette defect detection device further includes a model acquisition module 560, which includes an image acquisition module 5601, an annotation module 5602, a training module 5603, and a second evaluation module 5604.
[0110] The image acquisition module 5601 is used to acquire images of a batch of cigarettes captured by an industrial camera.
[0111] The annotation module 5602 is used to annotate the defect categories of batch cigarette images to obtain an annotated dataset.
[0112] The training module 5603 is used to train the neural network model using the labeled dataset to obtain a defect detection model.
[0113] The second evaluation module 5604 is used to evaluate the defect detection model using multiple evaluation indicators. If the accuracy and speed of the defect detection model for each defect category meet the actual requirements, then the training is complete.
[0114] The beneficial effects of this application are as follows:
[0115] First, it has a high degree of automation: traditional methods for detecting defects in cigarette appearance usually require a lot of manual intervention, while digital analysis can achieve automated detection through image processing technology and machine learning algorithms, which improves detection efficiency and accuracy.
[0116] Second, the detection speed is fast: digital analysis can complete the detection and analysis of a large number of cigarette appearance defects in a very short time, which can greatly improve the detection speed and efficiency.
[0117] Third, high detection accuracy: Digital analysis can perform high-precision detection and classification of cigarette appearance defects, identify more defect types and details, and provide more accurate defect level assessments.
[0118] Fourth, visual analysis: Digital analysis can present the statistical data and distribution of cigarette defects through data visualization, helping production managers to better understand the defect situation and trends in the production process, and further improve production quality and efficiency.
[0119] Fifth, reducing storage costs: This method can extract digital features from each identified defective cigarette image and record and store each image in the form of numerical description. This method not only retains the important information of the original image but also greatly reduces the storage space occupied by each image, thus effectively reducing storage costs to a certain extent.
[0120] Sixth, achieve full sample monitoring: This method can be extended to record all cigarette images and store basic information about the stick, filter and defects of each cigarette in numerical form, which lays the foundation for full sample monitoring of cigarette production.
[0121] While specific embodiments of this application have been described in detail by way of examples, those skilled in the art should understand that the above examples are for illustrative purposes only and are not intended to limit the scope of this application. Those skilled in the art should understand that modifications can be made to the above embodiments without departing from the scope and spirit of this application. The scope of this application is defined by the appended claims.
Claims
1. A method of cigarette defect detection, the method comprising: The method comprises the following steps: receiving a cigarette image collected by an industrial camera; identifying defects in the cigarette image based on a defect detection model to obtain a prediction box containing defect type and position information; converting the information of the prediction box into an XML file and storing it, and the converted XML file at least includes the following information: a serial number representing the order of the cigarette image, a defect category, and position coordinates of the prediction box, wherein the position coordinates of the prediction box specifically include boundary values: the minimum value xmin of the x-coordinate of the upper left corner of the prediction box and the minimum value ymin of the y-coordinate, and the maximum value xmax of the x-coordinate of the lower right corner of the prediction box and the maximum value ymax of the y-coordinate; performing digital analysis according to the XML file to obtain a defect value corresponding to the cigarette image, including: extracting a plurality of basic feature values of the defects of the cigarette image from the XML file, at least including a defect category, a defect area, a defect horizontal coordinate center point value, and a defect vertical coordinate center point value; determining a weight value corresponding to each basic feature value, including: calculating the proportion of each basic feature value, calculating the corresponding information entropy using the proportion, calculating the corresponding redundancy based on the information entropy, and calculating the weight corresponding to each basic feature according to the redundancy; wherein the proportion calculation method includes: calculating using the standardized value of the jth defect of the ith defect category, the basic feature value of the jth defect of the ith defect category, the maximum value and the minimum value of the ith defect category; calculating a first defect value according to all basic feature values and corresponding weight values of the defects, as the defect value corresponding to the cigarette image; evaluating the defect level of the cigarette image according to the defect value.
2. The cigarette defect detection method according to claim 1, characterized in that, If the cigarette image has multiple defects, the weighted sum of the first defect values of all defects is taken as the defect value corresponding to the cigarette image.
3. The cigarette defect detection method according to claim 1, characterized in that, The training of the defect detection model comprises the following steps: obtaining a batch of cigarette images collected by an industrial camera; annotating the defect categories of the batch of cigarette images to obtain an annotation dataset; training a neural network model using the annotation dataset to obtain the defect detection model; evaluating the defect detection model using a plurality of evaluation indexes, and if the accuracy and speed of the defect detection model for each defect category meet the actual requirements, the training is completed.
4. A cigarette defect detection apparatus characterized by comprising: The method comprises an image receiving module, an identification module, a conversion module, an analysis module, and a first evaluation module; the image receiving module is used to receive a cigarette image collected by an industrial camera; the identification module is used to identify defects in the cigarette image based on a defect detection model to obtain a prediction box containing defect type and position information; the conversion module is used to convert the information of the prediction box into an XML file and store it, and the converted XML file at least includes the following information: a serial number representing the order of the cigarette image, a defect category, and position coordinates of the prediction box, wherein the position coordinates of the prediction box specifically include boundary values: the minimum value xmin of the x-coordinate of the upper left corner of the prediction box and the minimum value ymin of the y-coordinate, and the maximum value xmax of the x-coordinate of the lower right corner of the prediction box and the maximum value ymax of the y-coordinate; The analysis module is configured to digitally analyze the XML file to obtain a defect value corresponding to the cigarette image, including: extracting a plurality of basic characteristic values of the defect of the cigarette image from the XML file, including at least a defect category, a defect area, a defect horizontal coordinate center point value, and a defect vertical coordinate center point value; determining a weight value corresponding to each basic characteristic value, including: calculating a proportion of each basic characteristic value, calculating a corresponding information entropy using the proportion, calculating a redundancy degree based on the information entropy, and calculating a weight corresponding to each basic characteristic based on the redundancy degree; wherein the proportion calculation method includes: calculating using a standardized value of the jth defect of the ith defect category, a basic characteristic value of the jth defect of the ith defect category, a maximum value, and a minimum value of the ith defect category; calculating a first defect value based on all basic characteristic values of the defect and the corresponding weight value, as the defect value corresponding to the cigarette image; The first evaluation module is configured to evaluate the defect level of the cigarette image based on the defect value.
5. The cigarette defect detection apparatus according to claim 4, characterized by The analysis module includes a feature extraction module, a weight determination module, and a first calculation module. The feature extraction module is configured to extract a plurality of basic characteristic values of the defect of the cigarette image from the XML file. The weight determination module is configured to determine a weight value corresponding to each basic characteristic value. The first calculation module is configured to calculate a first defect value based on all basic characteristic values of the defect and the corresponding weight value, as the defect value corresponding to the cigarette image.
6. The cigarette defect detection apparatus according to claim 5, wherein The analysis module further includes a second calculation module, which is configured to, when there are a plurality of defects on the cigarette image, calculate a weighted sum of the first defect values of all defects as the defect value corresponding to the cigarette image.
7. The cigarette defect detection apparatus according to claim 5, wherein The weight determination module is configured to determine a weight value corresponding to each basic characteristic value using an entropy weight method.
8. The cigarette defect detection apparatus according to claim 4, wherein Further comprising a model obtaining module, the model obtaining module includes an image acquisition module, a labeling module, a training module, and a second evaluation module; The image acquisition module is configured to acquire a batch of cigarette images collected by an industrial camera; The labeling module is configured to label the defect category of the batch of cigarette images to obtain a labeled data set; The training module is configured to train a neural network model using the labeled data set to obtain the defect detection model; The second evaluation module is configured to evaluate the defect detection model using a plurality of evaluation indexes, and if the accuracy and speed of the defect detection model for each defect category meet the actual requirements, the training is completed.
Citation Information
Patent Citations
Defect grade classification method and system based on template matching and defect segmentation
CN115880520A