Cigarette defect detection method, electronic equipment and program product

By acquiring and preprocessing the finished cigarette stick image, extracting and normalizing its color and texture characteristics, and inputting a defect detection model, the problems of low efficiency and incomplete detection of traditional cigarette sticks are solved, and efficient and automated detection of cigarette sticks are achieved.

CN120070305APending Publication Date: 2025-05-30CHONGQING CHINA TOBACCO IND CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411903098.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

The traditional tobacco defect detection method is inefficient and incomplete, and cannot adapt to the fast tobacco production line, resulting in a gradual increase in the rate of false detection and missed detection.

Method used

By obtaining the appearance images of the finished cigarette sticks at different angles, pre-processing is performed to extract color features and texture features, obtain comprehensive feature parameters, and normalize them and input the preset defect detection model to realize automatic detection of cigarette sticks.

Benefits of technology

Automatic detection of cigarette plugs is achieved through machine vision, which improves detection efficiency, reduces false detection and missed detection rates, and improves the quality and production efficiency of cigarette plug products.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120070305A_ABST
    Figure CN120070305A_ABST
Patent Text Reader

Abstract

The invention provides a cigarette defect detection method, electronic equipment and a program product, and relates to the technical field of cigarette detection. The method comprises the following steps: obtaining cigarette images obtained by shooting the appearance of a finished cigarette product at different angles; preprocessing the cigarette image to extract color features and texture features of the cigarette image to obtain comprehensive feature parameters representing the color features and the texture features; normalizing the comprehensive characteristic parameters to obtain normalized comprehensive characteristic parameters; the normalized comprehensive characteristic parameters are input into a preset defect detection model, a detection result is obtained, and when the cigarette finished product has defects, the detection result comprises the types and the positions of the defects. In this way, automatic detection of the cigarettes is achieved through machine vision, and the problems that a traditional cigarette defect detection mode is low in efficiency and incomplete in detection are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of artificial intelligence, and in particular, to a method for detecting cigarette defects, an electronic device, and a program product. Background Art

[0002] The tobacco industry is one of the important sources of economic growth in China, and tobacco is closely related to people's daily lives. With the rapid development of artificial intelligence (AI), the manufacturing industry is no longer limited to traditional manual labor, and automated and intelligent production operations have become the mainstream of current production and manufacturing.

[0003] In the tobacco industry, due to factors such as malfunctions of production equipment, changing environmental conditions during the production process, and the quality of raw materials, the finished cigarette products produced may have appearance defects, which will have an adverse impact on aspects such as the quality of cigarette products and production efficiency.

[0004] In the prior art, the detection of finished cigarette products is usually carried out by manual inspection, that is, manually checking the appearance of cigarette products during the conveying process and screening out the defective cigarette products for rejection. However, with the development of industrial technology and the increase in production requirements, the manual inspection method can no longer adapt to the fast cigarette production line, and the misdetection and missed detection rates are gradually increasing. Summary of the Invention

[0005] In view of this, the purpose of the embodiments of the present application is to provide a method for detecting cigarette defects, an electronic device, and a program product, which can improve the problems of low efficiency and incomplete detection existing in the traditional method for detecting cigarette defects.

[0006] To achieve the above technical objectives, the technical solutions adopted in the present application are as follows:

[0007] In a first aspect, an embodiment of the present application provides a method for detecting cigarette defects, the method comprising:

[0008] Obtaining cigarette images obtained by photographing the appearance of finished cigarette products at different angles;

[0009] Preprocessing the cigarette images to extract the color features and texture features of the cigarette images, and obtaining comprehensive feature parameters representing the color features and the texture features;

[0010] Normalizing the comprehensive feature parameters to obtain normalized comprehensive feature parameters;

[0011] Inputting the normalized comprehensive feature parameters into a preset defect detection model to obtain a detection result, wherein when the finished cigarette product has a defect, the detection result includes the type and location of the defect.

[0012] In combination with the first aspect, in some alternative embodiments, the cigarette image is preprocessed to extract the color features and texture features of the cigarette image, and a comprehensive feature parameter representing the color features and the texture features is obtained, including:

[0013] Obtain the first pixel values of the cigarette image on the R, G, and B color channels;

[0014] According to the first pixel values, determine the color components of the cigarette image in terms of hue, saturation, and lightness;

[0015] According to the first pixel values and the color components, determine the color feature parameters corresponding to the cigarette image, and the color feature parameters represent the color features of the cigarette image;

[0016] According to the position coordinates and gray values of each pixel point in the cigarette image, determine the probability matrix of pixel points with different gray levels appearing on the cigarette image;

[0017] According to the probability matrix, determine the texture feature parameters corresponding to the cigarette image, and the texture feature parameters represent the texture features of the cigarette image;

[0018] According to the color feature parameters and the texture feature parameters, determine the comprehensive feature parameter.

[0019] In combination with the first aspect, in some alternative embodiments, according to the first pixel values, determining the color components of the cigarette image in terms of hue, saturation, and lightness includes:

[0020] Normalize the first pixel values to obtain the normalized first pixel values;

[0021] According to the normalized first pixel values, determine the color components:

[0022] V = max(r, g, b)

[0023]

[0024] In the formula, r, g, and b represent the normalized first pixel values of the cigarette image on the R, G, and B color channels, V represents the color component of the cigarette image in terms of lightness, S represents the color component of the cigarette image in terms of saturation, and H represents the color component of the cigarette image in terms of hue.

[0025] In combination with the first aspect, in some alternative embodiments, according to the first pixel values and the color components, determining the color feature parameters corresponding to the cigarette image includes:

[0026] Determine the mean, variance, and skewness of each different first pixel value or color component in the cigarette rod image according to the color component, as the color feature parameter:

[0027]

[0028]

[0029] where P i,j represents the i-th first pixel value or color component of the j-th pixel point in the cigarette rod image, N represents the number of pixel points in the cigarette rod image, and μ i represents the mean of the i-th first pixel value or color component, and σ i represents the variance of the i-th first pixel value or color component, and s i represents the skewness of the i-th first pixel value or color component.

[0030] Combined with the first aspect, in some alternative embodiments, determine the probability matrix of the occurrence of pixel points of different gray levels on the cigarette rod image according to the position coordinates and gray values of each pixel point in the cigarette rod image, including:

[0031] Determine the probability matrix according to the coordinates and gray values of each pixel point in the cigarette rod image through the following formula:

[0032]

[0033] where p(a, b, d, θ) represents the probability matrix, x, y = 0, 1, 2, …, K - 1, K represents the coordinates of pixel points in the cigarette rod image, a, b = 0, 1, …, L - 1, L represents the number of gray levels of the cigarette rod image, Dx and Dy are displacement offsets, d represents the generation step of the probability matrix, and θ represents the generation direction of the probability matrix.

[0034] Combined with the first aspect, in some alternative embodiments, determine the texture feature parameter corresponding to the cigarette rod image according to the probability matrix, including:

[0035] Determine the angular second moment representing the uniformity of the gray level change of the image texture in the texture feature parameter according to the probability matrix:

[0036]

[0037] where ASM represents the angular second moment;

[0038] Determine the contrast representing the local change of the image in the texture feature parameter according to the probability matrix:

[0039]

[0040] In the formula, CON represents contrast;

[0041] Determine the correlation representing the gray linear relationship of the local image among the texture feature parameters according to the probability matrix:

[0042]

[0043] In the formula, CORRLN represents correlation, u 1 and u 2 and d 1 and d 2 respectively represent the mean and variance of the probability matrix in the row and column directions;

[0044] Determine the inverse difference moment representing the texture regularity degree of the image among the texture feature parameters according to the probability matrix:

[0045]

[0046] In the formula, IDM represents the inverse difference moment.

[0047] Combined with the first aspect, in some alternative embodiments, normalize the comprehensive feature parameters to obtain the normalized comprehensive feature parameters, including:

[0048] Normalize the comprehensive feature parameters according to the following formula based on the comprehensive feature parameters:

[0049]

[0050] In the formula, t * represents the normalized comprehensive feature parameter, t represents the comprehensive feature parameter, α represents the mean of the comprehensive feature parameter, and β represents the standard deviation of the comprehensive feature parameter.

[0051] Combined with the first aspect, in some alternative embodiments, before obtaining the cigarette images obtained by photographing the appearance of the finished cigarette at different angles, the method further includes:

[0052] Obtain a plurality of initial images obtained by photographing the appearance of the finished cigarette at different angles;

[0053] Preprocess the plurality of initial images to extract the color features and texture features of the plurality of initial images, and obtain initial feature parameters;

[0054] Normalize the initial feature parameters to obtain the normalized initial feature parameters;

[0055] Construct an XGBoost initial model;

[0056] Divide the normalized initial feature parameters into a training set and a test set according to a preset ratio, and label the training set and the test set to obtain a labeled training set and a labeled test set, which are used as the data set.

[0057] Train the initial XGBoost model with the data set to obtain a trained initial XGBoost model, which is used as the preset defect detection model.

[0058] In a second aspect, an embodiment of the present application further provides an electronic device, which includes a processor and a memory coupled to each other. The memory stores a computer program. When the computer program is executed by the processor, the electronic device is caused to execute the above method.

[0059] In a third aspect, an embodiment of the present application further provides a computer program product, including a computer program, which implements the above method when executed by a processor.

[0060] The invention adopting the above technical solution has the following advantages:

[0061] In the technical solution provided by the present application, first, cigarette images obtained by photographing the appearance of finished cigarettes at different angles are acquired. Then, preprocessing is performed on the cigarette images to extract the color features and texture features of the cigarette images, and comprehensive feature parameters representing the color features and texture features are obtained. Then, the comprehensive feature parameters are normalized to obtain normalized comprehensive feature parameters. Finally, the normalized comprehensive feature parameters are input into a preset defect detection model to obtain a detection result. In this way, the automatic detection of cigarettes is realized through machine vision, improving the problems of low efficiency and incomplete detection existing in the traditional cigarette defect detection method. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] The present application can be further illustrated by the non-limiting embodiments given in the drawings. It should be understood that the following drawings only show some embodiments of the present application, so they should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.

[0063] Figure 1 It is a structural block diagram of the electronic device provided by the embodiment of the present application.

[0064] Figure 2 It is a flowchart of the cigarette defect detection method provided by the embodiment of the present application.

[0065] Reference numerals: 100 - electronic device; 101 - processor; 102 - memory. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0066] The present application will be described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that in the accompanying drawings or the description of the specification, similar or identical parts are all denoted by the same reference numerals. The implementation manners not depicted or described in the accompanying drawings are in the forms known to those of ordinary skill in the art. In the description of the present application, the terms "first", "second", etc. are only used for distinguishing descriptions and cannot be construed as indicating or implying relative importance.

[0067] Please refer to Figure 1 , an electronic device 100 provided in an embodiment of the present application may include a processor 101 and a memory 102. A computer program is stored in the memory 102. When the computer program is executed by the processor 101, the electronic device 100 can execute the corresponding steps in the following cigarette defect detection method.

[0068] In this embodiment, the electronic device 100 may be a personal computer, a laptop computer, a cloud server, etc. It is used to obtain cigarette images obtained by photographing the appearance of cigarette products at different angles. Then, preprocess the cigarette images to extract the color features and texture features of the cigarette images, and obtain comprehensive feature parameters characterizing the color features and texture features. Then normalize the comprehensive feature parameters to obtain the normalized comprehensive feature parameters. Finally, input the normalized comprehensive feature parameters into a preset defect detection model to obtain a detection result.

[0069] In this embodiment, the processor 101 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor 101 may be a general-purpose processor. For example, the processor 101 may be a central processing unit (CPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application.

[0070] The memory 102 may be, but is not limited to, a random access memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, etc. In this embodiment, the memory 102 may be used to store cigarette images, comprehensive feature parameters, normalized comprehensive feature parameters, a preset defect detection model, detection results, etc. Of course, the memory 102 may also be used to store a program, and the processor 101 executes the program after receiving an execution instruction.

[0071] It is understandable that Figure 1 the structure of the electronic device 100 shown is only a schematic diagram of one structure, and the electronic device 100 may further include more Figure 1 components than shown. Figure 1 Each component shown in may be implemented by hardware, software, or a combination thereof.

[0072] Please refer to Figure 2 , this application also provides a method for detecting cigarette defects, which can be applied to the above-mentioned electronic device 100 and executed or implemented by the electronic device 100 for each step of the method. Among them, the method for detecting cigarette defects may include the following steps:

[0073] Step 210, obtaining cigarette images obtained by photographing the appearance of cigarette products at different angles;

[0074] Step 220, preprocessing the cigarette images to extract the color features and texture features of the cigarette images, and obtaining comprehensive feature parameters representing the color features and the texture features;

[0075] Step 230, normalizing the comprehensive feature parameters to obtain normalized comprehensive feature parameters;

[0076] Step 240, inputting the normalized comprehensive feature parameters into a preset defect detection model to obtain a detection result, where when there are defects in the cigarette products, the detection result includes the type and location of the defects.

[0077] In the above embodiment, first, cigarette images obtained by photographing the appearance of cigarette products at different angles are obtained. Then, the cigarette images are preprocessed to extract the color features and texture features of the cigarette images, and comprehensive feature parameters representing the color features and texture features are obtained. Then, the comprehensive feature parameters are normalized to obtain normalized comprehensive feature parameters. Finally, the normalized comprehensive feature parameters are input into a preset defect detection model to obtain a detection result. In this way, the automatic detection of cigarettes is realized through machine vision, improving the problems of low efficiency and incomplete detection existing in the traditional method for detecting cigarette defects.

[0078] The following will elaborate on each step of the method for detecting cigarette defects in detail, as follows:

[0079] Before step 210, the method may include:

[0080] Obtaining a plurality of initial images obtained by photographing the appearance of the cigarette products at different angles;

[0081] Preprocess the multiple initial images to extract the color features and texture features of the multiple initial images, obtaining initial feature parameters;

[0082] Normalize the initial feature parameters to obtain the normalized initial feature parameters;

[0083] Construct an XGBoost initial model;

[0084] Divide the normalized initial feature parameters into a training set and a test set according to a preset ratio, and label the training set and the test set to obtain the labeled training set and the labeled test set, which are used as the dataset;

[0085] Train the XGBoost initial model with the dataset to obtain the trained XGBoost initial model, which is used as the preset defect detection model.

[0086] In this embodiment, multiple initial images of finished cigarette sticks are taken at different angles, and then the color features and texture features of the initial images are extracted to obtain initial feature parameters. Then the initial feature parameters are normalized to obtain the normalized initial feature parameters. Then the XGBoost model is used as the initial structure of the defect detection model to construct an XGBoost initial model. Then the normalized initial feature parameters are divided into a training set and a test set according to a preset ratio, and the normalized initial feature parameters in the training set and the test set are labeled (that is, each feature is labeled with the corresponding defect type (which can be defect-free)) to obtain the dataset. Finally, the XGBoost initial model is trained with the dataset to obtain the trained XGBoost initial model, which is used as the above-mentioned preset defect detection model.

[0087] It can be understood that in practical applications, in order to enhance the diversity of data and ensure the generalization ability of the model, after taking multiple initial images of finished cigarette sticks, data augmentation operations such as flipping, shearing, Gaussian blurring, translation, and rotation can be performed on the multiple initial images to obtain a larger number of initial images, and subsequent feature extraction and model training are carried out.

[0088] In this embodiment, the color feature extraction and texture feature extraction can refer to step 220 below and will not be elaborated here.

[0089] In step 210, the acquisition of the cigarette image can be carried out during the real-time detection of the finished cigarette. The appearance of the finished cigarette is captured in real time by an RGB camera to obtain the cigarette image, and the cigarette image is uploaded to the processor 101 of the above-mentioned electronic device 100 in real time, facilitating the subsequent defect detection by the processor 101 based on the cigarette image. Alternatively, the acquisition of the cigarette image can also be that in the pre-test stage, the user inputs the cigarette image, stores the cigarette image in the memory 102 of the above-mentioned electronic device 100, and during the subsequent defect detection process, the processor 101 calls the cigarette image from the memory 102 based on the operation instruction initiated by the user. The acquisition method of the cigarette image is not specifically limited here.

[0090] In step 220, preprocessing the cigarette image to extract the color features and texture features of the cigarette image and obtain the comprehensive feature parameters representing the color features and the texture features may include:

[0091] Obtain the pixel values of the cigarette image on the R, G, and B color channels;

[0092] According to the first pixel value, determine the color components of the cigarette image in hue, saturation, and lightness;

[0093] According to the pixel value and the color components, determine the color feature parameters corresponding to the cigarette image, and the color feature parameters represent the color features of the cigarette image;

[0094] According to the position coordinates and gray values of each pixel point in the cigarette image, determine the probability matrix of the pixel points with different gray levels appearing on the cigarette image;

[0095] According to the probability matrix, determine the texture feature parameters corresponding to the cigarette image, and the texture feature parameters represent the texture features of the cigarette image;

[0096] According to the color feature parameters and the texture feature parameters, determine the comprehensive feature parameters.

[0097] In this embodiment, according to the first pixel value, determining the color components of the cigarette image in hue, saturation, and lightness may include:

[0098] Normalize the first pixel value to obtain the normalized first pixel value;

[0099] According to the normalized first pixel value, determine the color components:

[0100] V = max(r, g, b)

[0101]

[0102]

[0103] In the formula, r, g, and b represent the first pixel values after normalization of the cigarette image on the R, G, and B color channels, V represents the color component of the cigarette image in terms of color lightness, S represents the color component of the cigarette image in terms of saturation, and H represents the color component of the cigarette image in terms of hue.

[0104] In this embodiment, the pixel value of each pixel point in the cigarette image captured by the RGB camera is composed of the three primary colors R, G, and B. Therefore, the pixel value representation of the cigarette image can be directly obtained, and the pixel value representations of the cigarette image on the three color channels of R, G, and B are normalized to obtain the pixel values of the cigarette image on the R, G, and B color channels as described above.

[0105] In this embodiment, the cigarette image represented by the RGB color space (a three-primary color space based on R (Red), G (Green), and B (Blue)) and the HSV color space (a color space represented by hue / hue (H), saturation (S), and color lightness / brightness (V)) is not sufficient to characterize features such as the color distribution and range of the cigarette image. Therefore, by converting R, G, B, H, S, and V into their respective corresponding color feature parameters, a total of 18 feature values are denoted as feature F1 to feature F18. In this way, the color features of the cigarette image are more comprehensively characterized, and the detection ability for defects such as black spots and yellow spots on the cigarette that are reflected by color is enhanced.

[0106] Among them, determining the color feature parameters corresponding to the cigarette image according to the first pixel value and the color component may include:

[0107] Determining the mean, variance, and skewness of each different first pixel value or color component in the cigarette image as the color feature parameters according to the color component:

[0108]

[0109] In the formula, P i,j represents the i-th first pixel value or color component of the j-th pixel point in the cigarette image, N represents the number of pixel points in the cigarette image, μ i represents the mean of the i-th first pixel value or color component, σ i represents the variance of the i-th first pixel value or color component, and s i represents the skewness of the i-th first pixel value or color component.

[0110] It is understandable that, in addition to the color of the image, texture is also important information that reflects the characteristics of the image. It contains important information about the arrangement of the surface structure of the object, and has the characteristics of rotation invariance and scale invariance. In this embodiment, the probability matrix of the appearance of pixels of different gray levels on the cigarette image is first determined based on the position coordinates and grayscale values ​​of each pixel point in the cigarette image, and then the texture feature parameters corresponding to the cigarette image are determined based on the probability matrix. In this way, by comprehensively extracting the texture features in the cigarette image, the detection capability of the defects reflected by the texture, such as warping, contact, deformation, and empty heads, of the finished cigarette product is enhanced.

[0111] In this embodiment, determining the probability matrix of pixels of different gray levels appearing on the cigarette image according to the position coordinates and grayscale values ​​of each pixel in the cigarette image may include:

[0112] According to the coordinates and grayscale values ​​of each pixel in the cigarette image, the probability matrix is ​​determined by the following formula:

[0113]

[0114] Where p(a, b, d, θ) represents the probability matrix, x, y = 0, 1, 2, ..., K-1, K represents the coordinates of the pixel points in the cigarette image, a, b = 0, 1, ..., L-1, L represents the grayscale level of the cigarette image, Dx and Dy are displacement offsets, d represents the generation step of the probability matrix, and θ represents the generation direction of the probability matrix.

[0115] In this embodiment, for any two pixels at positions (x1, y1) and (x2, y2) in the cigarette image, the corresponding grayscale values ​​are a and b respectively. For a given distance d between the two pixels, four different angles (i.e., the direction θ of generating the probability matrix) can be selected, which are 0°, 45°, 90°, and 135° respectively. Then the probability matrix p(a, b, d, θ) represents the probability of the occurrence of a point with grayscale a (taking (x1, y1) as an example) and a point with grayscale b (taking (x2, y2) as an example) in the direction of a given angle θ (0°, 45°, 90°, or 135°) and a distance of d.

[0116] In this embodiment, determining the texture feature parameters corresponding to the cigarette image according to the probability matrix may include:

[0117] According to the probability matrix, the angular second-order moment of the texture feature parameter characterizing the uniformity of the image texture grayscale change is determined:

[0118]

[0119] Where ASM represents the angular second moment;

[0120] In this embodiment, the uniformity of texture grayscale change is reflected by the angular second moment. When the element values of the probability matrix are concentrated near the diagonal, the larger the value of the angular second moment, the finer the texture is characterized. Conversely, the smaller the value of the angular second moment, the coarser the texture is. In this way, the external texture characteristics of the cigarette rod finished product are reflected more carefully. When there are defects such as breakage and deformation in the cigarette rod and the texture at the defect is not obvious, the detection ability of the model for cigarette rod defects.

[0121] According to the probability matrix, determine the contrast representing the local change of the image in the texture feature parameters:

[0122]

[0123] In the formula, CON represents the contrast;

[0124] In this embodiment, the local change of the image is reflected by the contrast. Among them, the larger the contrast is, the clearer the image is, the deeper the grooves are, and the more obvious the texture effect is. In this way, the detection ability of the contrast enhancement model of the cigarette rod image for defects under different background conditions (for example, when the background brightness is different, the contrast of the cigarette rod image, that is, the clarity of the cigarette rod image is also different).

[0125] According to the probability matrix, determine the correlation representing the gray linear relationship of the local image in the texture feature parameters:

[0126]

[0127] In the formula, CORRLN represents the correlation, u 1 、u 2 、d 1 、d 2 respectively represent the mean and variance of the probability matrix in the row and column;

[0128] According to the probability matrix, determine the inverse difference moment representing the texture regularity degree of the image in the texture feature parameters:

[0129]

[0130] In the formula, IDM represents the inverse difference moment.

[0131] In this embodiment, the inverse difference moment represents the texture regularity degree of the cigarette rod image. Among them, when the internal regularity of the texture is strong, the matrix elements of the probability matrix are more concentrated on the diagonal, that is, the texture is more regular and the value of the inverse difference moment is larger. In this way, the texture regularity degree of the cigarette rod image is used as a feature to detect the defects of the cigarette rod finished product, and the classification accuracy of different defects is enhanced. For example, when different types of defects such as bending and depression appear on the appearance of the cigarette rod finished product, the texture at the defect will also show different regularity degrees.

[0132] In this embodiment, specifically, the mean values of the four eigenvalue parameters of ASM, CON, CORRLN, and IDM in four directions (0°, 45°, 90°, and 135°) are used as texture feature parameters, denoted as feature F19 to feature F22.

[0133] In this embodiment, the set of the aforementioned color feature parameters (i.e., feature F1 to feature F18) and texture feature parameters (i.e., feature F19 to feature F22) is used as the aforementioned comprehensive feature parameter. To characterize the color feature and texture feature of the cigarette rod image (i.e., the finished cigarette rod) through the comprehensive feature parameter. Facilitate subsequent defect detection of the comprehensive feature parameter through a preset defect detection model to obtain a detection result.

[0134] In step 230, normalizing the comprehensive feature parameter to obtain the normalized comprehensive feature parameter may include:

[0135] According to the comprehensive feature parameter, the comprehensive feature parameter is normalized by the following formula:

[0136]

[0137] In the formula, t * represents the normalized comprehensive feature parameter, t represents the comprehensive feature parameter, α represents the mean value of the comprehensive feature parameter, and β represents the standard deviation of the comprehensive feature parameter.

[0138] In step 240, after normalizing the comprehensive feature, the normalized comprehensive feature parameter is input into the above-mentioned preset defect detection model, and the defect type of the cigarette rod image corresponding to the normalized comprehensive feature parameter is detected through the preset defect detection model.

[0139] It should be noted that those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the above-described electronic device 100 can refer to the corresponding processes of each step in the foregoing method, and will not be elaborated herein.

[0140] The embodiment of the present application further provides a computer program product, including a computer program, and the computer program realizes the above method when executed by the processor 101.

[0141] Through the description of the above embodiments, those skilled in the art can clearly understand that this application can be implemented through hardware or by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, mobile hard disk, etc.), including several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in various implementation scenarios of this application.

[0142] In summary, the embodiments of this application provide a cigarette defect detection method, an electronic device, and a program product. In this technical solution, first, cigarette images obtained by photographing the appearance of finished cigarettes at different angles are acquired. Then, the cigarette images are preprocessed to extract the color features and texture features of the cigarette images, and comprehensive feature parameters representing the color features and texture features are obtained. Then, the comprehensive feature parameters are normalized to obtain the normalized comprehensive feature parameters. Finally, the normalized comprehensive feature parameters are input into a preset defect detection model to obtain a detection result. In this way, the automatic detection of cigarettes is realized through machine vision, improving the problems of low efficiency and incomplete detection existing in the traditional cigarette defect detection method.

[0143] In the embodiments provided by this application, it should be understood that the disclosed method can also be implemented in other ways. The method embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of the methods and computer program products according to multiple embodiments of this application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions. In addition, the functional modules in various embodiments of this application can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.

[0144] The above is only the embodiments of this application and is not used to limit the protection scope of this application. For those skilled in the art, this application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included in the protection scope of this application.

Claims

1. A cigarette defect detection method, characterized in that: The method comprises: Acquire cigarette images obtained by photographing the appearance of finished cigarettes at different angles; Preprocessing the cigarette image to extract color features and texture features of the cigarette image, and obtaining comprehensive feature parameters representing the color features and the texture features; Normalizing the comprehensive feature parameters to obtain normalized comprehensive feature parameters; The normalized comprehensive characteristic parameters are input into a preset defect detection model to obtain a detection result, wherein when the finished cigarette has defects, the detection result includes the type and location of the defect.

2. The method according to claim 1, characterized in that: Preprocessing the cigarette image to extract color features and texture features of the cigarette image, and obtaining comprehensive feature parameters characterizing the color features and the texture features, including: Obtaining a first pixel value of the cigarette image on the R, G, and B color channels; Determining the color components of the cigarette image in terms of hue, saturation and color brightness according to the first pixel value; Determine, according to the first pixel value and the color component, a color feature parameter corresponding to the cigarette image, wherein the color feature parameter represents the color feature of the cigarette image; Determine a probability matrix of pixels of different gray levels appearing on the cigarette image according to the position coordinates and grayscale values ​​of each pixel in the cigarette image; Determining, according to the probability matrix, texture feature parameters corresponding to the cigarette image, wherein the texture feature parameters represent the texture features of the cigarette image; The comprehensive feature parameter is determined according to the color feature parameter and the texture feature parameter.

3. The method according to claim 2, characterized in that Determining the color components of the cigarette image in terms of hue, saturation, and color brightness according to the first pixel value includes: Normalizing the first pixel value to obtain a normalized first pixel value; Determine the color component according to the normalized first pixel value: V=max(r,g,b) Where r, g, and b represent the normalized first pixel value of the cigarette image on the R, G, and B color channels, V represents the color component of the cigarette image in terms of color brightness, S represents the color component of the cigarette image in terms of saturation, and H represents the color component of the cigarette image in terms of hue.

4. The method according to claim 2, characterized in that: Determining a color feature parameter corresponding to the cigarette image according to the first pixel value and the color component includes: According to the color component, the mean, variance and slope of each different first pixel value or the color component in the cigarette image are determined as the color feature parameters: Where P i,j represents the i-th first pixel value or color component of the j-th pixel in the cigarette image, N represents the number of pixels in the cigarette image, μ i represents the mean of the i-th first pixel value or color component, σ i represents the variance of the i first pixel values ​​or color components, s i Represents the slope of the i-th first pixel value or color component.

5. The method according to claim 2, characterized in that: Determining a probability matrix of pixels of different gray levels appearing on the cigarette image according to the position coordinates and grayscale values ​​of each pixel in the cigarette image includes: According to the coordinates and grayscale values ​​of each pixel in the cigarette image, the probability matrix is ​​determined by the following formula: Where p(a, b, d, θ) represents the probability matrix, x, y = 0, 1, 2, ..., K-1, K represents the coordinates of the pixel points in the cigarette image, a, b = 0, 1, ..., L-1, L represents the grayscale level of the cigarette image, Dx and Dy are displacement offsets, d represents the generation step of the probability matrix, and θ represents the generation direction of the probability matrix.

6. The method according to claim 2, characterized in that Determining texture feature parameters corresponding to the cigarette image according to the probability matrix includes: According to the probability matrix, the angular second-order moment of the texture feature parameter characterizing the uniformity of the image texture grayscale change is determined: Where ASM represents the angular second moment; According to the probability matrix, the contrast representing the local change of the image in the texture feature parameter is determined: Where, CON represents contrast; According to the probability matrix, the correlation of the linear relationship of grayscale representing the local image in the texture feature parameters is determined: In the formula, CORRLN represents the correlation, u1, u2, d1, and d2 represent the mean and variance of the probability matrix in rows and columns respectively; According to the probability matrix, the inverse difference moment representing the regularity of the image texture in the texture feature parameters is determined: Where IDM stands for inverse difference moment.

7. The method according to claim 1, characterized in that , normalizing the comprehensive feature parameters to obtain normalized comprehensive feature parameters, including: According to the comprehensive characteristic parameters, the comprehensive characteristic parameters are normalized by the following formula: Where, t * represents the normalized comprehensive feature parameter, t represents the comprehensive feature parameter, α represents the mean of the comprehensive feature parameter, and β represents the standard deviation of the comprehensive feature parameter.

8. The method according to claim 1, characterized in that Before acquiring cigarette images obtained by photographing the appearance of finished cigarettes at different angles, the method further includes: Acquire multiple initial images of the appearance of the finished cigarette at different angles; Preprocessing the multiple initial images to extract color features and texture features of the multiple initial images to obtain initial feature parameters; Normalizing the initial characteristic parameters to obtain normalized initial characteristic parameters; Build the initial XGBoost model; Dividing the normalized initial feature parameters into a training set and a test set according to a preset ratio, and labeling the training set and the test set to obtain a labeled training set and a labeled test set as a data set; The XGBoost initial model is trained using the data set to obtain a trained XGBoost initial model as the preset defect detection model.

9. An electronic device, characterized in that: The electronic device comprises a processor and a memory coupled to each other, wherein the memory stores a computer program. When the computer program is executed by the processor, the electronic device executes the method according to any one of claims 1 to 8.

10. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Cigarette appearance quality detection method based on computer vision

    CN103868935A

  • Cigarette defect detection method and device

    CN116756372A

  • Cigarette appearance detection method

    CN117058089A

  • Cigarette packaging defect detection method and device, electronic equipment and storage medium

    CN117576063A

  • Stainless steel tube defect identification system based on machine learning

    CN118823472A