A method for detecting the width of cut tobacco and its application
Through deep learning and image processing technology, combined with deep network model and Hough linear detection method, efficient and accurate detection of tobacco width is achieved, solving the problems of low manual detection efficiency and poor accuracy in the existing technology, and realizing online accurate identification and efficient measurement.
Patent Information
- Application Number
- CN202211556354.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-06
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-12-06
AI Technical Summary
In the prior art, the width detection of tobacco wire relies on manual sampling and sampling, with small sample size, low detection efficiency, high cost and large errors, making it difficult to meet the high-precision requirements of the tobacco industry.
Deep learning and image processing technology are used to train the tobacco image dataset through deep network models, combining mask cutting, graying, edge detection and Hough linear detection to achieve accurate measurement of the tobacco width.
It realizes online accurate identification of tobacco width, improves detection efficiency by 100,000 times, and reaches 1 micron level, meets the tobacco industry standards, and saves manpower and time costs.
Smart Images

Figure CN115810136B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of artificial intelligence, and particularly relates to a method, device and storage medium for detecting the width of cut tobacco. Background Art
[0002] In the cut tobacco production line, the cutting process is one of the most important parts of the cigarette manufacturing process. And the width of cut tobacco is an important parameter in this process. The qualified rate of the cutting width will affect the processability strength, filling rate and material loss of the cut tobacco. In the requirements of the tobacco industry standard, the width tolerance shall not exceed 0.1 mm. At present, the detection of the cutting width of tobacco leaves in the tobacco industry basically relies on manual sampling and spot-checking during the process, and uses auxiliary detection methods such as projectors and off-line detection equipment. The disadvantages of this detection method are as follows: first, the sample size of manual sampling is small, and it cannot truly reflect the qualified rate of the real-time cutting width during the process; second, the detection efficiency is low, and it requires a large amount of human and time costs; third, there are errors in manually judging the cutting width, and it is easily affected by the personnel level during the implementation of the detection standard. Summary of the Invention
[0003] The present invention is proposed to solve the above-mentioned deficiencies existing in the prior art, and provides a method for detecting the width of cut tobacco and its application, in order to achieve accurate detection of the width of cut tobacco, thereby improving the detection efficiency and accuracy of the width of cut tobacco.
[0004] The method for detecting the width of cut tobacco according to the present invention is characterized by including:[[]]
[0005] Step 1: Obtain a cut tobacco image data set, input it into a deep network model for training to obtain a target detection model; input the cut tobacco image to be detected into the target detection model to obtain the cut tobacco recognition frame and its coordinate information of the cut tobacco image;
[0006] Step 2: Use mask matte to process the coordinate information of the cut tobacco recognition frame in the cut tobacco image, so as to obtain several cut tobacco recognition frames of the cut tobacco image;
[0007] Step 3: Gray-scale process the images within several cut tobacco recognition frames to obtain several gray-scale images;
[0008] Step 4: Perform quality enhancement processing on the gray-scale images to obtain gray-scale images after quality enhancement;
[0009] Step 5: Perform binarization processing on the gray-scale images after quality enhancement to obtain binarized cut tobacco images;
[0010] Step 6: Use opening operation to eliminate noise from the binarized cut tobacco images, and then perform skeleton extraction on the binarized cut tobacco images after noise elimination to obtain image skeletons;
[0011] Step 7: Extract the contour of the image skeleton to obtain a cut tobacco contour image, and then crop the cut tobacco contour image according to the image skeleton to eliminate the head and tail parts of the image skeleton, thereby obtaining a cut tobacco main body contour image;
[0012] Step 8: Detect the cut tobacco main body contour image to obtain the contour coordinate information on both sides of the cut tobacco main body contour image. Consider the coordinate information on both sides as two curves, calculate the distance between the two curves and take the average value to obtain the cut tobacco width.
[0013] The feature of a cut tobacco width detection method according to the present invention also lies in that the binarization process in Step 5 is to perform binarization on the grayscale image through an adaptive threshold method to obtain a preliminary binarized image, and then use the maximum connected domain filtering algorithm to eliminate the binarized regions that do not meet the length threshold in the preliminary binarized image, and retain the binarized regions that meet the length threshold, thereby obtaining a binarized cut tobacco image.
[0014] The said Step 8 includes:
[0015] Step 8.1: Use the Hough line detection method to determine whether each pixel point on the cut tobacco main body contour image is respectively on both sides of the cut tobacco. If so, retain the corresponding pixel point; otherwise, delete the corresponding pixel point;
[0016] Step 8.2: Fit the pixel points retained on both sides of the cut tobacco into two curves;
[0017] Step 8.3: Select any point on each of the two curves, denoted as pixel point A(a1, b1, c1) and B(a2, b2, c2); Denote the tangents of pixel point A(a1, b1, c1) and B(a2, b2, c2) to the two curves as L1 and L2 respectively;
[0018] Step 8.4: After converting the tangents L1 and L2 into the vector space respectively, the vectors (X1, Y1, Z1) of tangent L1 and the vector (X2, Y2, Z2) of tangent L2 are obtained correspondingly;
[0019] Step 8.5: Calculate the inclination angles θ1 and θ2 of L1 and L2 in the vector space;
[0020] Step 8.6: If θ1 = θ2, it means L1∥L2; and execute Step 8.7; otherwise, it means L1 and L2 are not parallel, and return to Step 8.3;
[0021] Step 8.7: Continue to traverse the curve where L2 is located until all the straight lines parallel to L1 in the curve where L2 is located are selected, and the intersection points of all the tangent lines parallel to the straight line L1 in the curve where L2 is located and the curve where they are located are obtained, denoted as Q1, Q2, Q3...Q vand connect the intersection points Q1, Q2, Q3...Q v to point A respectively, obtaining multiple straight lines, denoted as D1, D2, D3...D v ; denote D1, D2, D3...D v with the inclination angles to L1 as γ1, γ2, γ3...γ v ; select the maximum value from γ1, γ2, γ3...γ v and denote it as γ max ; denote the straight line D max corresponding to γ max ; denote the intersection point corresponding to D max as Q max ; the curve tangent line parallel to L1 corresponding to Q max is denoted as L max ; where, v represents the number of intersection points, Q v represents the v-th intersection point, D v represents the v-th straight line, and γ v represents the v-th inclination angle;
[0022] Step 8.8, calculate the distance d between L1 and L max ;
[0023] Step 8.9, obtain the distances of the parallel lines that meet the requirements of Step 8.7 between all the measured pixel points of the two curves according to the process of Step 8.3 - Step 8.8, and take the average value as the width of the cut tobacco on the cut tobacco main body contour image.
[0024] An electronic device according to the present invention includes a memory and a processor, characterized in that the memory is used to store a program for supporting the processor to execute the cut tobacco width detection method, and the processor is configured to execute the program stored in the memory.
[0025] A computer-readable storage medium according to the present invention, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, it executes the steps of the cut tobacco width detection method.
[0026] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0027] The on-line detection method for the width of cut tobacco of the present invention realizes on-line accurate identification and measurement of the width of cut tobacco; this method effectively improves the efficiency and accuracy of cut tobacco width detection, and its one-time detection time is only 10 milliseconds, which is more than 100,000 times that of manual detection efficiency; it realizes pixel-level detection, and the accuracy reaches 1 micron, which is 100 times that of the tobacco industry standard, greatly saving the labor and time costs of cut tobacco detection. Description of the Drawings
[0028] Figure 1Flowchart for implementing a method for detecting the width of cut tobacco provided by an embodiment of the present invention;
[0029] Figure 2 Schematic diagram of the result obtained by processing the cut tobacco image provided by an embodiment of the present invention through a target detection model trained by the YOLO V4 deep network model;
[0030] Figure 3 Schematic diagram of the result obtained by the Hough line detection method provided by an embodiment of the present invention;
[0031] Figure 4 Schematic diagram of the process of extracting the image skeleton provided by an embodiment of the present invention;
[0032] Figure 5 Schematic diagram of the principle of cut tobacco width detection provided by an embodiment of the present invention. Detailed implementation manners
[0033] In this embodiment, to solve the problem of detecting the width of cut tobacco in the cut tobacco section of the current tobacco industry, a method for detecting the width of cut tobacco is proposed. As Figure 1 shown, it includes:
[0034] Step 1: Obtain 1000 cut tobacco images at the production site to form a cut tobacco image dataset, thereby establishing a sample library. After labeling the cut tobacco image samples in the sample library through the labellmg software, input them into the YOLO V4 deep network model for training to learn the contour shape of the cut tobacco and obtain a target detection model;
[0035] As Figure 2 shown, input the cut tobacco image to be detected into the target detection model, and output the cut tobacco recognition frame of the cut tobacco image and its coordinate information;
[0036] Step 2: Use mask-based image cropping to process the coordinate information of the cut tobacco recognition frame in the cut tobacco image, thereby obtaining several cut tobacco recognition frames of the cut tobacco image;
[0037] Step 3: Grayscale the images within several cut tobacco recognition frames through the RGB color channels to obtain several grayscale images;
[0038] Step 4: Perform quality enhancement processing on the grayscale images through Gaussian filtering and bilateral filtering respectively to achieve the purposes of smoothing the edges of the cut tobacco image and sharpening the edges of the image, thereby obtaining the grayscale images after quality enhancement;
[0039] Step 5: Perform binarization processing on the grayscale images after quality enhancement to obtain binarized cut tobacco images;
[0040] The binarization process in the specific implementation is to perform adaptive thresholding on the grayscale image to obtain a preliminary binarized image, and then use the largest connected component filtering algorithm to eliminate the binarized regions in the preliminary binarized image that do not meet the length threshold, and retain the binarized regions that meet the length threshold, so as to obtain the binarized cut tobacco image.
[0041] Step 6, as Figure 4 shown, perform noise elimination on the binarized cut tobacco image using morphological opening operation, and then perform skeleton extraction on the binarized cut tobacco image after noise elimination to obtain the image skeleton;
[0042] Step 7, as Figure 4 shown, perform edge detection and contour extraction on the image skeleton through the Canny operator to obtain the cut tobacco contour image, and then crop the cut tobacco contour image according to the image skeleton to eliminate the head and tail parts of the image skeleton and retain the main body part of the cut tobacco, so as to obtain the main body contour image of the cut tobacco;
[0043] Step 8, as Figure 5 shown, detect the main body contour image of the cut tobacco to obtain the contour coordinate information on both sides of the main body contour image of the cut tobacco. Treat the coordinate information on both sides as two curves, calculate the distance between the two curves and take the average value to obtain the width of the cut tobacco.
[0044] Step 8.1, as Figure 3 shown, use the Hough line detection method to determine whether each pixel point on the main body contour image of the cut tobacco is on both sides of the cut tobacco respectively. If so, retain the corresponding pixel point and put the coordinates on both sides into two lists respectively. Otherwise, delete the corresponding pixel point;
[0045] Step 8.2, Fit the pixel points retained on both sides of the cut tobacco into two curves;
[0046] Step 8.3, Select any point on each of the two curves respectively, denoted as pixel point A(a1, b1, c1) and B(a2, b2, c2); Extend pixel point A(a1, b1, c1) and B(a2, b2, c2) to straight lines tangent to the two curves on both sides respectively, denoted as L1 and L2;
[0047] Step 8.4, After converting the tangent lines L1 and L2 into the vector space respectively, the vectors (X1, Y1, Z1) of the tangent line L1 and the vector (X2, Y2, Z2) of the tangent line L2 are obtained correspondingly;
[0048] Step 8.5, Calculate the inclination angles and of L1 and L2 in the vector space. Let the normal vector of the vector space be n=(o, p, q), where m1 represents the inclination angle of L1 with the vector space; m2 represents the inclination angle of L2 with the vector space;
[0049] Step 8.6: If θ1 = θ2, it indicates that L1∥L2, and proceed to Step 8.7; otherwise, it indicates that L1 and L2 are not parallel, and return to Step 8.3 to continue traversing the pixel points of one of the curves on both sides of the cut tobacco until two parallel lines are selected.
[0050] Step 8.7: Continue traversing the curve where L2 is located until all the lines parallel to L1 in the curve where L2 is located are selected, and obtain the intersection points of all the tangent lines parallel to the straight line L1 in this curve with the curve, denoted as Q1, Q2, Q3...Q v , and connect the intersection points Q1, Q2, Q3...Q v to point A respectively to obtain multiple straight lines, denoted as D1, D2, D3...D v , and denote D1, D2, D3...D v with the inclination angles to L1 as γ1, γ2, γ3...γ v , select the maximum value from γ1, γ2, γ3...γ v and denote it as γ max , and denote the straight line D max corresponding to γ max , D max the corresponding intersection point is denoted as Q max , Q max the corresponding curve tangent line parallel to L1 is denoted as L max ; where, v represents the number of intersection points, Q v represents the v-th intersection point, D v represents the v-th straight line, and γ v represents the v-th inclination angle;
[0051] Step 8.8: Calculate the distance d between L1 and L max according to the straight line equations (vector representation) of the parallel line group.
[0052] Step 8.9: Then point A moves 20 pixel points along the curve where it is located, and point B continuously traverses and selects tangent lines on the curve where it is located until a tangent line parallel to the tangent line L1 of point A and meeting the requirements of Step 8.7 is obtained. Thus, according to the process of Step 8.3 - Step 8.8, the distance between the parallel tangent lines that meet the requirements of Step 8.7 among the measured pixel points of the two curves is obtained, and the average value is taken as the cut tobacco width on the cut tobacco main body contour image.
[0053] In this embodiment, an electronic device includes a memory and a processor. The memory is used to store a program that supports the processor to execute the above cut tobacco width detection method, and the processor is configured to execute the program stored in the memory.
[0054] In this embodiment, a computer-readable storage medium stores a computer program thereon, and when the computer program is run by a processor, it executes the steps of the above-mentioned cut tobacco width detection method.
Claims
1. A method for detecting the width of cut tobacco, characterized in that, Including: Step 1: Obtain a dataset of cut tobacco images, input it into a deep network model for training to obtain an object detection model; input the cut tobacco image to be detected into the object detection model to obtain the cut tobacco recognition frame of the cut tobacco image and its coordinate information. Step 2: Use mask matting to process the coordinate information of the cut tobacco recognition frame in the cut tobacco image, so as to obtain several cut tobacco recognition frames of the cut tobacco image. Step 3: Gray-scale the images within several cut tobacco recognition frames to obtain several gray-scale images. Step 4: Perform quality enhancement processing on the gray-scale images to obtain gray-scale images after quality enhancement. Step 5: Perform binarization processing on the gray-scale images after quality enhancement to obtain binarized cut tobacco images. Step 6: Use opening operation to eliminate noise from the binarized cut tobacco images, and then perform skeleton extraction on the binarized cut tobacco images after noise elimination to obtain an image skeleton. Step 7: Extract the contour of the image skeleton to obtain a cut tobacco contour image, and then crop the cut tobacco contour image according to the image skeleton to eliminate the head and tail parts of the image skeleton, so as to obtain a cut tobacco main body contour image. Step 8: Detect the cut tobacco main body contour image to obtain the coordinate information of the two side contours of the cut tobacco main body contour image. Regard the two side coordinate information as two curves, calculate the distance between the two curves and take the average value to obtain the cut tobacco width. Step 8.1: Use the Hough line detection method to determine whether each pixel point on the cut tobacco main body contour image is respectively on both sides of the cut tobacco. If so, retain the corresponding pixel point; otherwise, delete the corresponding pixel point. Step 8.2: Fit the pixel points retained on both sides of the cut tobacco into two curves. Step 8.3: Select any point on each of the two curves, denoted as pixel point A ( , , ) and B( , , ); Denote the tangents of the two curves passing through pixel point A ( , , ) and B( , , ) as and ; Step 8.4, after converting the tangent lines and into the vector space respectively, the vectors of the tangent line are obtained as ( , , ) and the vectors of the tangent line are ( , , ); Step 8.5, calculate and the inclination angle in the vector space and ; Step 8.6, if = , it means that ∥ ; And execute step 8.7; otherwise, it means and are not parallel, and return to step 8.3; Step 8.
7. Continue to traverse the curve where it is located until all the straight lines parallel to in the curve where it is located are selected, and the intersections of all the tangent straight lines parallel to the straight line in the curve where it is located and the curve are obtained, denoted as , , ... , and connect the intersections , , ... to point A respectively to obtain multiple straight lines, denoted as , , ... , denote , , ... and has an inclination angle of , , ... , select , , ... the maximum value among them is denoted as , denote the corresponding straight line , denote the corresponding intersection point is denoted as , the corresponding curve tangent line parallel to is denoted as ; where, v represents the number of intersection points, represents the v-th intersection point, represents the v-th straight line, represents the v-th inclination angle; Step 8.8, calculate and the distance d therebetween; Step 8.9: Obtain the distance between the parallel lines that meet the requirements of Step 8.7 among all the measured pixel points of the two curves according to the process of Step 8.3 - Step 8.8 and take the average value as the cut tobacco width on the cut tobacco main body contour image.
2. The method for detecting the width of cut tobacco according to claim 1, characterized in that The binarization processing in Step 5 is to perform binarization on the gray-scale image through an adaptive threshold method to obtain a preliminary binarized image, and then use the maximum connected component filtering algorithm to eliminate the binarized regions that do not meet the length threshold in the preliminary binarized image, and retain the binarized regions that meet the length threshold, so as to obtain a binarized cut tobacco image.
3. An electronic device, comprising a memory and a processor, characterized in that, The memory is used to store a program for supporting the processor to execute the cut tobacco width detection method described in Claim 1, and the processor is configured to execute the program stored in the memory.
4. A computer-readable storage medium, on which a computer program is stored, characterized in that, When the computer program is run by the processor, it executes the steps of the cut tobacco width detection method described in Claim 1.
Citation Information
Patent Citations
Novel method for measuring width of cut tobacco based on machine vision detection technology
CN110345874A
Hairline contour locating method and device, and computer readable storage medium
WO2019165604A1