CN117058089A - Cigarette appearance detection method - Google Patents
Cigarette appearance detection method Download PDFInfo
- Publication number
- CN117058089A CN117058089A CN202311007394.9A CN202311007394A CN117058089A CN 117058089 A CN117058089 A CN 117058089A CN 202311007394 A CN202311007394 A CN 202311007394A CN 117058089 A CN117058089 A CN 117058089A
- Authority
- CN
- China
- Prior art keywords
- cigarette
- image
- appearance
- color
- adaboost
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 235000019504 cigarettes Nutrition 0.000 title claims abstract description 186
- 238000001514 detection method Methods 0.000 title claims abstract description 33
- 238000012545 processing Methods 0.000 claims abstract description 17
- 238000012549 training Methods 0.000 claims abstract description 10
- 239000013598 vector Substances 0.000 claims description 60
- 238000000605 extraction Methods 0.000 claims description 23
- 238000004458 analytical method Methods 0.000 claims description 22
- 238000000034 method Methods 0.000 claims description 16
- 238000012706 support-vector machine Methods 0.000 claims description 12
- 238000007781 pre-processing Methods 0.000 claims description 7
- 238000001228 spectrum Methods 0.000 claims description 6
- 238000012360 testing method Methods 0.000 claims description 5
- 230000009286 beneficial effect Effects 0.000 claims description 4
- 239000003086 colorant Substances 0.000 claims description 3
- 238000003708 edge detection Methods 0.000 claims description 3
- 238000005259 measurement Methods 0.000 claims description 3
- 238000010606 normalization Methods 0.000 claims description 3
- 238000012216 screening Methods 0.000 claims description 3
- 230000002194 synthesizing effect Effects 0.000 claims description 3
- 230000000007 visual effect Effects 0.000 claims description 3
- 238000012800 visualization Methods 0.000 claims description 3
- 230000006870 function Effects 0.000 description 13
- 238000011160 research Methods 0.000 description 8
- 241000208125 Nicotiana Species 0.000 description 4
- 235000002637 Nicotiana tabacum Nutrition 0.000 description 4
- 238000013461 design Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 238000002474 experimental method Methods 0.000 description 3
- 238000004519 manufacturing process Methods 0.000 description 3
- 230000007547 defect Effects 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000010801 machine learning Methods 0.000 description 2
- 238000002591 computed tomography Methods 0.000 description 1
- 238000013527 convolutional neural network Methods 0.000 description 1
- 230000002950 deficient Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000008030 elimination Effects 0.000 description 1
- 238000003379 elimination reaction Methods 0.000 description 1
- 238000003384 imaging method Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 239000000523 sample Substances 0.000 description 1
- 239000000779 smoke Substances 0.000 description 1
- 238000003325 tomography Methods 0.000 description 1
- 238000011179 visual inspection Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
- G06T7/0004—Industrial image inspection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/54—Extraction of image or video features relating to texture
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/56—Extraction of image or video features relating to colour
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/764—Arrangements for image or video recognition or understanding using pattern recognition or machine learning using classification, e.g. of video objects
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/30—Computing systems specially adapted for manufacturing
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Multimedia (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Artificial Intelligence (AREA)
- Health & Medical Sciences (AREA)
- Quality & Reliability (AREA)
- Computing Systems (AREA)
- Databases & Information Systems (AREA)
- Evolutionary Computation (AREA)
- General Health & Medical Sciences (AREA)
- Medical Informatics (AREA)
- Software Systems (AREA)
- Image Analysis (AREA)
Abstract
The cigarette appearance detection method comprises the following steps: processing the image of the appearance of the cigarette; extracting image features of the appearance of the cigarettes; training Adaboost for classification recognition; identifying the appearance image of the cigarettes shot at high speed, judging the appearance image to be a qualified cigarette or a disqualified cigarette, and then removing the disqualified cigarette through a removing device; adaboost is adopted to classify and identify the appearance of the cigarettes, and a strong classifier is constructed by combining a plurality of weak classifiers, so that the classification accuracy can be improved.
Description
Technical Field
The application relates to the field of cigarette manufacturing, in particular to a cigarette appearance detection method, and particularly relates to a cigarette appearance detection method based on OpenCV-Python and Adaboost.
Background
The tobacco industry is an important national industry in China, and has strict requirements on the quality and safety of products. Consumer demands for consistency and quality of cigarette appearance are increasing, traditional cigarette appearance detection usually depends on manual visual inspection, and the method has the problems of subjectivity, time consumption, high cost and the like. With the rapid development of related technologies such as computer vision, image processing, machine learning and the like, a new research direction and a new solution are provided for cigarette appearance detection. The wide application of the technologies enables the appearance detection of cigarettes to be more feasible and accurate, and provides more choices for tobacco enterprises.
A cigarette is a consumer product, and its appearance quality is directly related to the quality of the product and the user's experience. By researching and developing a reliable appearance detection method, possible defects or anomalies such as breakage, foreign matters and the like in the cigarette products are detected and identified, the appearance of the cigarettes is ensured to meet the standard, production enterprises are helped to take corrective measures in time, the number of defective products is reduced, the quality risk and the return rate are reduced, and therefore the product quality is improved, the user satisfaction is enhanced, and the product competitiveness of the enterprises is improved. Therefore, the research of the cigarette appearance detection method has important significance for tobacco enterprises, consumers and the whole industry.
Zhang Yuehua the machine vision is fused with the cigarette detection device using a machine vision deployment system plan.
Lijing, yang Shuai et al establish an online detection method for cigarette overlap inclusion based on a machine vision technology, realize online detection and elimination of the cigarette overlap inclusion defect in the cigarette production process, solve the problem of low accuracy of cigarette appearance detection and the like, effectively improve the cigarette appearance recognition efficiency and improve the cigarette product quality. Panting, cai Peiliang et al design a high-speed packagine machine mould box internal cigarette detection device based on vision imaging technique, effectively solve mechanical probe type cigarette and detect the problem of false detection and missed detection, improved product quality, reduced waste smoke consumption, improved equipment effective operation rate. Wang Liang and Wang Tian et al design a 3D-mu CT scanning and reconstruction method suitable for detecting long objects such as cigarettes, and the method can realize high-quality microscopic tomography on cigarettes and can obtain relatively complete topological structure and porosity characteristic quantity of tobacco shreds. Zhang Qin, wang Mingzhu et al design a special-shaped cigarette packet based on X-ray and lack a detecting system, have obtained better effect. Zhong, Z, zeng, Z et al explored a cigarette quality detection technique based on acoustic methods. By using the sound sensor to record sound characteristics of cigarettes produced in the transportation, production and use processes, sound parameters related to the quality of the cigarettes are extracted, and an acoustic model is established to classify and identify the appearance quality of the cigarettes by using signal processing and machine learning algorithms. Experimental results show that the cigarette quality detection technology based on the acoustic method has good accuracy and feasibility, and can effectively detect defects and anomalies of cigarettes. Cui Yunyue the cigarette appearance quality detection algorithm based on machine learning and the cigarette appearance detection algorithm based on convolutional neural network are researched, classification effect comparison is carried out on the two algorithms, system architecture design and installation are carried out on a cigarette appearance quality detection system, practical application test is carried out, and the test effect is good.
In summary, a certain research foundation exists for the cigarette appearance detection method, some research results which can be used for reference are obtained, but the implementation of most of the cigarette appearance detection methods is based on the existing software, which may cause dependence on specific environments and limit portability and expansibility of the method. In addition, python, a popular programming language, has a rich library and tool ecosystem, and can provide a wide range of support and resources. Furthermore, the problem is to adopt Adaboost to classify and identify the appearance of the cigarettes, the Adaboost is a self-adaptive learning method, and a strong classifier is constructed by combining a plurality of weak classifiers, so that the classification accuracy can be improved. Therefore, the application performs corresponding exploratory research and experiments on the aspect so as to provide a new thought and reference for the research on the method for detecting the appearance quality of the cigarettes.
Disclosure of Invention
The application aims to provide a cigarette appearance detection method, in particular to a method for detecting the appearance of a cigarette based on OpenCV-Python and Adaboost.
In order to achieve the above object, the present application adopts the following technical scheme:
the application relates to a cigarette appearance detection method, which comprises the following steps: it comprises the following steps:
image processing of cigarette appearance
(a) Image acquisition
Selecting an environment with sufficient and uniform light, aligning a cigarette with a high-pixel digital camera, keeping the cigarette centered in the image and free of shielding to obtain an image with rich definition and detail, collecting images with multiple angles and distances to capture cigarette appearance images with different characteristics of the cigarette appearance, and repeating the steps to collect multiple cigarette appearance images to increase the accuracy and reliability of feature extraction;
(b) Image preprocessing
I, picking up cigarette images
Converting the cigarette appearance image into a gray image by using a cv2.cvtColor () function of OpenCV, performing edge detection by using cv2.canny () of OpenCV, searching the outline by using cv2.findContours () of OpenCV, screening the largest outline by using cv2.drawContours () of OpenCV, creating a blank image for drawing the outline, finally intercepting the cigarette image by using cv2.boundingRect () of OpenCV and displaying the result, and picking out the shape, outline and characteristics of the cigarette to obtain the cigarette image so as to reduce background interference, so that the shape analysis, the length measurement, the classification and the identification are easier;
(II) resizing the image
Reading the cigarette image, designating the size of the target image, performing image scaling by using a bilinear interpolation algorithm of a cv2.resize () function of OpenCV, and then displaying the scaled cigarette image;
(III) removing noise
Removing noise in the cigarette image by using a cv2.Gaussian Blur () Gaussian filter of OpenCV to improve the image quality and definition; the clear and interference-free cigarette images are ensured by adjusting the size of the images and removing noise, and the preprocessing operation is beneficial to improving the accuracy and stability of the subsequent feature extraction and classification;
(II) extracting image characteristics of cigarette appearance
Extracting relevant color features and texture features from the cigarette images through analysis, converting the color features and the texture features into feature vectors processed by a computer so as to facilitate the analysis, classification and processing of subsequent cigarettes, and combining the extracted color features and texture features into one feature vector;
(c) Color feature extraction
Converting the cigarette image of step (iii) using the cvtColor function in OpenCV to include: the color of the cigarette is more accurately described by the converted HSV color space, namely three channels of hue, saturation and brightness, so that the subsequent color feature extraction and analysis are facilitated;
(d) Performing dimension reduction on the color characteristics by using a wavelet packet analysis method, and reducing the color characteristic data to 24 dimensions to obtain a cigarette color characteristic vector;
(e) Texture feature extraction
Extracting cigarette texture features from the cigarette image in the step (III) by using a local binary pattern (Local Binary Patterns, LBP), and calculating by an LBP algorithm based on gray differences among local pixel points to obtain a cigarette texture feature vector;
(f) Synthetic feature vector
Synthesizing the cigarette color feature vector obtained in the step (d) and the cigarette texture feature vector obtained in the step (e) into a feature vector;
(III) training Adaboost for Classification recognition
The Adaboost consists of three basic classifiers which are a linear kernel function support vector machine, a polynomial kernel function support vector machine and an RBF kernel function support vector machine respectively, the Adaboost is constructed into a strong classifier through the three basic classifiers, the Adaboost is trained by using the plurality of feature vectors and corresponding result labels in the step (g), the trained Adaboost is obtained through multiple iterations, and the feature vectors are input into the trained Adaboost to obtain qualified cigarettes and classification identification of unqualified cigarettes;
fourth, identifying the appearance image of the cigarettes shot at high speed
Shooting cigarettes in a cigarette making machine by using the step (a) to obtain a cigarette appearance image, then processing the cigarette appearance image according to the steps (b) to (f) to obtain a feature vector, inputting the feature vector into a trained Adaboost, classifying the feature vector by the Adaboost, judging the feature vector as a qualified cigarette or a unqualified cigarette, and then rejecting the unqualified cigarette by a rejecting device.
The application discloses a cigarette appearance detection method, which comprises the following steps: in the step (c), the color value of each pixel point in the cigarette image is recalculated to be a combination of hue, saturation and brightness, the histogram of each color channel is calculated, the distribution situation of different color values in the image is counted, the distribution situation of each color channel in the cigarette appearance is obtained by analyzing the histogram, the characteristics of relevant colors are extracted, the characteristics are used for identifying and classifying the cigarettes, and the steps of extracting the color characteristics of the cigarette appearance are realized by using a Python and OpenCV library:
1) Importing an OpenCV library;
2) Reading the image and converting the image into HSV color space;
3) Calculating a histogram of the color channel, and carrying out normalization processing on the histogram to ensure that the features have consistent scales;
4) And a visual histogram.
The application discloses a cigarette appearance detection method, which comprises the following steps: in the step (e), the image texture feature extraction is implemented by using Python and OpenCV libraries, and the step of implementing the extraction of the cigarette appearance texture feature includes:
<1>, loading an image;
<2>, defining GLCM parameters;
<3>, calculating GLCM;
<4>, extracting texture features;
<5>, visualization histogram;
<6>, print characteristic value;
<7>, statistical data results.
The application discloses a cigarette appearance detection method, which comprises the following steps: in the step (d), the wavelet packet analysis method is to perform dimension reduction processing on the signal based on the wavelet packet of Python, and the specific steps are as follows:
1, extracting the energy characteristic of each wavelet packet node;
2, calculating energy spectrum;
3, reading an image;
5, converting the color space into HSV;
5, calculating the histogram of each color channel;
6, normalized histogram;
7, carrying out wavelet packet analysis and extracting energy characteristics and energy spectrum;
8, drawing an image, a histogram and a wavelet packet energy spectrogram histogram;
9, combining energy features into feature vectors.
The application discloses a cigarette appearance detection method, which comprises the following steps: the plurality of feature vectors is at least 80 feature vectors.
The application discloses a cigarette appearance detection method, which comprises the following steps: the step of training the plurality of feature vectors and the corresponding result labels by Adaboost comprises the following steps:
(1) Inputting a feature vector and a corresponding result label;
(2) Performing minimum-maximum scaling on the feature vector;
(3) Creating a support vector machine classifier object;
(4) Creating an Adaboost classifier;
(5) Training an Adaboost classifier;
(6) Predicting on the test set;
(7) Calculating the accuracy of the strong classifier;
(8) And visualizing the result.
The innovation points of the cigarette appearance detection method are as follows:
1. all experimental procedures were completed by knocking the code in Python without reliance on other software.
2. The small Bao Bo analysis is applied to the extraction and dimension reduction of the appearance color features of the cigarettes.
3. And using the support vector sum Adaboost for classifying and identifying the appearance of the cigarettes.
4. And taking the support vector products of three different cores as a base classifier, and forming a strong classifier through an Adaboost algorithm.
The cigarette appearance detection method has the following beneficial effects:
according to the application, the method for detecting the appearance of the cigarette is realized based on OpenCV-Python and Adaboost, the realization based on OpenCV and Python has the advantages of autonomy and flexibility, and the algorithm, flow and function can be customized and adjusted according to specific requirements. In addition, python, a popular programming language, has a rich library and tool ecosystem, and can provide a wide range of support and resources. Furthermore, the application adopts Adaboost to classify and identify the appearance of the cigarettes, the Adaboost is a self-adaptive learning method, and a strong classifier is constructed by combining a plurality of weak classifiers, so that the classification accuracy can be improved. Therefore, the application performs corresponding exploratory research and experiments on the aspect so as to provide a new thought and reference for the research on the method for detecting the appearance quality of the cigarettes.
Drawings
FIG. 1 is a flow chart of a method for detecting the appearance of a cigarette according to the present application;
FIG. 2 is a flow chart of image preprocessing;
fig. 3 is a flow chart of image feature extraction for a cigarette appearance.
Detailed Description
The cigarette appearance detection method comprises the following steps:
image processing of cigarette appearance
(a) Image acquisition
Selecting an environment with sufficient and uniform light, aligning a cigarette with a high-pixel digital camera, keeping the cigarette centered in the image and free of shielding to obtain an image with rich definition and detail, collecting images with multiple angles and distances to capture cigarette appearance images with different characteristics of the cigarette appearance, and repeating the steps to collect multiple cigarette appearance images to increase the accuracy and reliability of feature extraction;
(b) Image preprocessing
I, picking up cigarette images
Converting the cigarette appearance image into a gray image by using a cv2.cvtColor () function of OpenCV, performing edge detection by using cv2.canny () of OpenCV, searching the outline by using cv2.findContours () of OpenCV, screening the largest outline by using cv2.drawContours () of OpenCV, creating a blank image for drawing the outline, finally intercepting the cigarette image by using cv2.boundingRect () of OpenCV and displaying the result, and picking out the shape, outline and characteristics of the cigarette to obtain the cigarette image so as to reduce background interference, so that the shape analysis, the length measurement, the classification and the identification are easier;
(II) resizing the image
Reading the cigarette image, designating the size of the target image, performing image scaling by using a bilinear interpolation algorithm of a cv2.resize () function of OpenCV, and then displaying the scaled cigarette image;
(III) removing noise
Removing noise in the cigarette image by using a cv2.Gaussian Blur () Gaussian filter of OpenCV to improve the image quality and definition; the clear and interference-free cigarette images are ensured by adjusting the size of the images and removing noise, and the preprocessing operation is beneficial to improving the accuracy and stability of the subsequent feature extraction and classification;
(II) extracting image characteristics of cigarette appearance
Extracting relevant color features and texture features from the cigarette images through analysis, converting the color features and the texture features into feature vectors processed by a computer so as to facilitate the analysis, classification and processing of subsequent cigarettes, and combining the extracted color features and texture features into one feature vector;
(d) Color feature extraction
Converting the cigarette image of step (iii) using the cvtColor function in OpenCV to include: the color of the cigarette is more accurately described by the converted HSV color space, namely three channels of hue, saturation and brightness, so that the subsequent color feature extraction and analysis are facilitated;
(e) Performing dimension reduction on the color characteristics by using a wavelet packet analysis method, and reducing the color characteristic data to 24 dimensions to obtain a cigarette color characteristic vector;
(f) Texture feature extraction
Extracting cigarette texture features from the cigarette image in the step (III) by using a local binary pattern (Local Binary Patterns, LBP), and calculating by an LBP algorithm based on gray differences among local pixel points to obtain a cigarette texture feature vector;
(g) Feature vector
Synthesizing the cigarette color feature vector obtained in the step (e) and the cigarette texture feature vector obtained in the step (f) into a feature vector;
(III) training Adaboost for Classification recognition
The Adaboost consists of three basic classifiers which are a linear kernel function support vector machine, a polynomial kernel function support vector machine and an RBF kernel function support vector machine respectively, the Adaboost is constructed into a strong classifier through the three basic classifiers, the Adaboost is trained by the at least 80 feature vectors and corresponding result labels in the step (g), the trained Adaboost is obtained through multiple iterations, and the feature vectors are input into the trained Adaboost to obtain qualified cigarettes and classification identification of unqualified cigarettes;
fourth, identifying the appearance image of the cigarettes shot at high speed
Shooting cigarettes in a cigarette making machine by using the step (a) to obtain a cigarette appearance image, then processing the cigarette appearance image according to the steps (b) to (g) to obtain a feature vector, inputting the feature vector into a trained Adaboost, classifying the feature vector by the Adaboost, judging the feature vector as a qualified cigarette or a unqualified cigarette, and then rejecting the unqualified cigarette by a rejecting device.
In the step (c), the color value of each pixel point in the cigarette image is recalculated to be a combination of hue, saturation and brightness, the histogram of each color channel is calculated, the distribution situation of different color values in the image is counted, the distribution situation of each color channel in the cigarette appearance is obtained by analyzing the histogram, the characteristics of relevant colors are extracted, the characteristics are used for identifying and classifying the cigarettes, and the steps of extracting the color characteristics of the cigarette appearance are realized by using a Python and OpenCV library:
1) Importing an OpenCV library;
2) Reading the image and converting the image into HSV color space;
3) Calculating a histogram of the color channel, and carrying out normalization processing on the histogram to ensure that the features have consistent scales;
4) And a visual histogram.
In the step (e), the image texture feature extraction is implemented by using Python and OpenCV libraries, and the step of implementing the extraction of the cigarette appearance texture feature includes:
<1>, loading an image;
<2>, defining GLCM parameters;
<3>, calculating GLCM;
<4>, extracting texture features;
<5>, visualization histogram;
<6>, print characteristic value;
<7>, statistical data results.
In the step (d), the wavelet packet analysis method is to perform dimension reduction processing on the signal based on the wavelet packet of Python, and the specific steps are as follows:
1, extracting the energy characteristic of each wavelet packet node;
2, calculating energy spectrum;
3, reading an image;
4, converting color space into HSV;
5, calculating the histogram of each color channel;
6, normalized histogram;
7, carrying out wavelet packet analysis and extracting energy characteristics and energy spectrum;
8, drawing an image, a histogram and a wavelet packet energy spectrogram histogram;
9, combining energy features into feature vectors.
In step (four), the step of training the plurality of feature vectors and the corresponding result labels with Adaboost includes:
(1) Inputting a feature vector and a corresponding result label;
(2) Performing minimum-maximum scaling on the feature vector;
(3) Creating a support vector machine classifier object;
(4) Creating an Adaboost classifier;
(5) Training an Adaboost classifier;
(6) Predicting on the test set;
(7) Calculating the accuracy of the strong classifier;
(8) And visualizing the result.
It will be evident to those skilled in the art that the application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein.
Claims (6)
1. A cigarette appearance detection method is characterized in that: it comprises the following steps:
image processing of cigarette appearance
(a) Image acquisition
Selecting an environment with sufficient and uniform light, aligning a cigarette with a high-pixel digital camera, keeping the cigarette centered in the image and free of shielding to obtain an image with rich definition and detail, collecting images with multiple angles and distances to capture cigarette appearance images with different characteristics of the cigarette appearance, and repeating the steps to collect multiple cigarette appearance images to increase the accuracy and reliability of feature extraction;
(b) Image preprocessing
I, picking up cigarette images
Converting the cigarette appearance image into a gray image by using a cv2.cvtColor () function of OpenCV, performing edge detection by using cv2.canny () of OpenCV, searching the outline by using cv2.findContours () of OpenCV, screening the largest outline by using cv2.drawContours () of OpenCV, creating a blank image for drawing the outline, finally intercepting the cigarette image by using cv2.boundingRect () of OpenCV and displaying the result, and picking out the shape, outline and characteristics of the cigarette to obtain the cigarette image so as to reduce background interference, so that the shape analysis, the length measurement, the classification and the identification are easier;
(II) resizing the image
Reading the cigarette image, designating the size of the target image, performing image scaling by using a bilinear interpolation algorithm of a cv2.resize () function of OpenCV, and then displaying the scaled cigarette image;
(III) removing noise
Removing noise in the cigarette image by using a cv2.Gaussian Blur () Gaussian filter of OpenCV to improve the image quality and definition; the clear and interference-free cigarette images are ensured by adjusting the size of the images and removing noise, and the preprocessing operation is beneficial to improving the accuracy and stability of the subsequent feature extraction and classification;
(II) extracting image characteristics of cigarette appearance
Extracting relevant color features and texture features from the cigarette images through analysis, converting the color features and the texture features into feature vectors processed by a computer so as to facilitate the analysis, classification and processing of subsequent cigarettes, and combining the extracted color features and texture features into one feature vector;
(c) Color feature extraction
Converting the cigarette image of step (iii) using the cvtColor function in OpenCV to include: the color of the cigarette is more accurately described by the converted HSV color space, namely three channels of hue, saturation and brightness, so that the subsequent color feature extraction and analysis are facilitated;
(d) Performing dimension reduction on the color characteristics by using a wavelet packet analysis method, and reducing the color characteristic data to 24 dimensions to obtain a cigarette color characteristic vector;
(e) Texture feature extraction
Extracting cigarette texture features from the cigarette image in the step (III) by using a local binary pattern (Local Binary Patterns, LBP), and calculating by an LBP algorithm based on gray differences among local pixel points to obtain a cigarette texture feature vector;
(f) Synthetic feature vector
Synthesizing the cigarette color feature vector obtained in the step (d) and the cigarette texture feature vector obtained in the step (e) into a feature vector;
(III) training Adaboost for Classification recognition
The Adaboost consists of three basic classifiers which are a linear kernel function support vector machine, a polynomial kernel function support vector machine and an RBF kernel function support vector machine respectively, the Adaboost is constructed into a strong classifier through the three basic classifiers, the Adaboost is trained by using the plurality of feature vectors and corresponding result labels in the step (g), the trained Adaboost is obtained through multiple iterations, and the feature vectors are input into the trained Adaboost to obtain qualified cigarettes and classification identification of unqualified cigarettes;
fourth, identifying the appearance image of the cigarettes shot at high speed
Shooting cigarettes in a cigarette making machine by using the step (a) to obtain a cigarette appearance image, then processing the cigarette appearance image according to the steps (b) to (f) to obtain a feature vector, inputting the feature vector into a trained Adaboost, classifying the feature vector by the Adaboost, judging the feature vector as a qualified cigarette or a unqualified cigarette, and then rejecting the unqualified cigarette by a rejecting device.
2. The method for detecting the appearance of a cigarette according to claim 1, wherein: in the step (c), the color value of each pixel point in the cigarette image is recalculated to be a combination of hue, saturation and brightness, the histogram of each color channel is calculated, the distribution situation of different color values in the image is counted, the distribution situation of each color channel in the cigarette appearance is obtained by analyzing the histogram, the characteristics of relevant colors are extracted, the characteristics are used for identifying and classifying the cigarettes, and the steps of extracting the color characteristics of the cigarette appearance are realized by using a Python and OpenCV library:
1) Importing an OpenCV library;
2) Reading the image and converting the image into HSV color space;
3) Calculating a histogram of the color channel, and carrying out normalization processing on the histogram to ensure that the features have consistent scales;
4) And a visual histogram.
3. A method of detecting the appearance of a cigarette as in claim 2 wherein: in the step (e), the image texture feature extraction is implemented by using Python and OpenCV libraries, and the step of implementing the extraction of the cigarette appearance texture feature includes:
<1>, loading an image;
<2>, defining GLCM parameters;
<3>, calculating GLCM;
<4>, extracting texture features;
<5>, visualization histogram;
<6>, print characteristic value;
<7>, statistical data results.
4. A method of detecting the appearance of a cigarette as in claim 3 wherein: in the step (d), the wavelet packet analysis method is to perform dimension reduction processing on the signal based on the wavelet packet of Python, and the specific steps are as follows:
1, extracting the energy characteristic of each wavelet packet node;
2, calculating energy spectrum;
3, reading an image;
4, converting color space into HSV;
5, calculating the histogram of each color channel;
6, normalized histogram;
7, carrying out wavelet packet analysis and extracting energy characteristics and energy spectrum;
8, drawing an image, a histogram and a wavelet packet energy spectrogram histogram;
9, combining energy features into feature vectors.
5. The method for detecting the appearance of a cigarette according to claim 4, wherein: the plurality of feature vectors is at least 80 feature vectors.
6. The method for detecting the appearance of a cigarette according to claim 5, wherein: the step of training the plurality of feature vectors and the corresponding result labels by Adaboost comprises the following steps:
(1) Inputting a feature vector and a corresponding result label;
(2) Performing minimum-maximum scaling on the feature vector;
(3) Creating a support vector machine classifier object;
(4) Creating an Adaboost classifier;
(5) Training an Adaboost classifier;
(6) Predicting on the test set;
(7) Calculating the accuracy of the strong classifier;
(8) And visualizing the result.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311007394.9A CN117058089A (en) | 2023-08-10 | 2023-08-10 | Cigarette appearance detection method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311007394.9A CN117058089A (en) | 2023-08-10 | 2023-08-10 | Cigarette appearance detection method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117058089A true CN117058089A (en) | 2023-11-14 |
Family
ID=88665673
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311007394.9A Pending CN117058089A (en) | 2023-08-10 | 2023-08-10 | Cigarette appearance detection method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117058089A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118096775A (en) * | 2024-04-29 | 2024-05-28 | 红云红河烟草(集团)有限责任公司 | Multi-dimensional characterization and digital feature evaluation method and device for appearance quality of cigarettes |
-
2023
- 2023-08-10 CN CN202311007394.9A patent/CN117058089A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118096775A (en) * | 2024-04-29 | 2024-05-28 | 红云红河烟草(集团)有限责任公司 | Multi-dimensional characterization and digital feature evaluation method and device for appearance quality of cigarettes |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111862064B (en) | Silver wire surface flaw identification method based on deep learning | |
CN110148130B (en) | Method and device for detecting part defects | |
CN114549522A (en) | Textile quality detection method based on target detection | |
CN113592845A (en) | Defect detection method and device for battery coating and storage medium | |
CN111815564B (en) | Method and device for detecting silk ingots and silk ingot sorting system | |
CN106610969A (en) | Multimodal information-based video content auditing system and method | |
CN112862770B (en) | Defect analysis and diagnosis system, method and device based on artificial intelligence | |
Wang et al. | Surface defects detection using non-convex total variation regularized RPCA with kernelization | |
CN111369516A (en) | Transformer bushing heating defect detection method based on infrared image recognition | |
CN111160451A (en) | Flexible material detection method and storage medium thereof | |
CN117058089A (en) | Cigarette appearance detection method | |
Wah et al. | Analysis on feature extraction and classification of rice kernels for Myanmar rice using image processing techniques | |
CN109584206B (en) | Method for synthesizing training sample of neural network in part surface flaw detection | |
CN115147363A (en) | Image defect detection and classification method and system based on deep learning algorithm | |
CN116434206A (en) | Cotton quality character detection method based on machine vision technology | |
CN116559111A (en) | Sorghum variety identification method based on hyperspectral imaging technology | |
Li et al. | DDR-Unet: A High Accuracy and Efficient Ore Image Segmentation Method | |
CN107025439B (en) | Lip region feature extraction and normalization method based on depth data | |
CN112858311A (en) | Rice phenotype monitoring system and method based on machine vision technology | |
CN112614113A (en) | Strip steel defect detection method based on deep learning | |
Huang et al. | Mango surface defect detection based on HALCON | |
CN114662594B (en) | Target feature recognition analysis system | |
JP2007018176A (en) | Learning device, learning method, learning program, recording medium, and device and method for pattern recognition | |
CN115131355A (en) | Intelligent method for detecting abnormality of waterproof cloth by using data of electronic equipment | |
CN115082449A (en) | Electronic component defect detection method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |