Tobacco width detection method, system, terminal and storage medium
By performing linear detection and binarization of tobacco thread pictures, screening and calculating the distance value of parallel straight line groups, the problem of low efficiency of tobacco thread width detection in the prior art is solved, and the rapid and accurate detection of tobacco thread width is achieved.
Patent Information
- Application Number
- CN202111229548.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-21
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2041-10-21
AI Technical Summary
In the prior art, the detection efficiency of tobacco width is low and relies on manual sampling, resulting in low detection efficiency and affecting the quality of cigarettes.
By obtaining the tobacco strips after being cut, performing straight line detection and binarization processing, filtering out straight lines that meet the preset length threshold, and calculating the distance value of the parallel straight line group to determine the width of the tobacco strips and improving detection efficiency.
It realizes the rapid accuracy of tobacco width detection, reduces detection errors, and improves detection efficiency and accuracy.
Smart Images

Figure CN113989355B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of tobacco detection, and in particular to a tobacco width detection method, system, terminal and storage medium. Background Art
[0002] Cut tobacco refers to tobacco products that are made by cutting tobacco leaves into shreds, granules, sheets, powder or other shapes, adding auxiliary materials, fermenting, storing, and then selling or smoking without rolling. In the cigarette processing process, the width of cut tobacco is an important indicator affecting the quality of cigarettes. Tobacco with unqualified width affects the filling effect and combustion quality of cigarettes. Therefore, in the cigarette processing process, it is necessary to detect the width of cut tobacco. The earlier detection method was to manually measure the width of cut tobacco through manual sampling. The inventors found that the detection efficiency of detecting the width of cut tobacco through manual sampling was low. Summary of the invention
[0003] The present application provides a tobacco width detection method, system, terminal and storage medium, which have the characteristics of improving the tobacco width detection efficiency.
[0004] The first purpose of this application is to provide a method for detecting tobacco width.
[0005] The above-mentioned application objective 1 of the present application is achieved through the following technical solutions:
[0006] A method for detecting tobacco width, comprising:
[0007] Get pictures of tobacco on the conveyor belt after cutting;
[0008] After performing straight line detection on the tobacco image, multiple straight lines and the length value of each straight line are obtained;
[0009] Compare the straight line length value of each straight line with the preset length threshold to obtain multiple remaining straight lines. If the straight line length value of a straight line is greater than the preset length threshold, the straight line is retained; if the straight line length value of a straight line is less than the preset length threshold, the straight line is removed;
[0010] After performing line detection on the remaining lines, a plurality of parallel line groups are obtained, wherein the parallel line group includes two mutually parallel lines;
[0011] The distance value between two mutually parallel straight lines is calculated based on the parallel straight line group, and the distance value is the tobacco width value.
[0012] By adopting the above technical solution, multiple straight lines in the tobacco shreds image and the length value of each straight line are first obtained, and then the length value is compared with the preset length threshold to obtain the remaining straight lines; in the tobacco shreds image, if a certain tobacco shred blocks another tobacco shred, then the straight lines less than the preset length threshold are removed, and the remaining ones are the straight lines representing the complete tobacco shreds; then the distance between the two parallel straight lines is detected, and the distance is the tobacco shreds width value; in this way, the detection efficiency of the tobacco shreds width is improved.
[0013] In a preferred example, the present application can be further configured as follows: the step of obtaining the picture of the tobacco shreds on the conveyor belt after cutting includes obtaining the picture of the tobacco shreds by a camera device, wherein the camera device is located above the conveyor belt, and the camera device takes pictures in a vertical downward direction.
[0014] By adopting the above technical solution, the possibility of tobacco being larger near and smaller far away in the picture is reduced.
[0015] In a preferred example, the present application can be further configured as follows: after obtaining the image of the shredded tobacco on the conveyor belt after cutting, the image of the shredded tobacco is binarized.
[0016] By adopting the above technical solution, a binary image of the tobacco picture is obtained, which is convenient for straight line detection.
[0017] In a preferred example, the present application can be further configured as follows: the step of obtaining a plurality of parallel straight line groups after performing straight line detection on the plurality of remaining straight lines comprises:
[0018] Calculate the line equation of each remaining line based on the line detection;
[0019] Obtain the slope of each remaining line from the equation of the line;
[0020] The slopes of the remaining straight lines are judged, and if the slopes of the two remaining straight lines are equal, the two remaining straight lines are divided into a parallel straight line group.
[0021] By adopting the above technical solution, whether two straight lines are parallel is determined according to the slope of each straight line. If they are parallel, the two straight lines are divided into one group. In this way, it is convenient to calculate the distance between the straight lines.
[0022] In a preferred example, the present application may be further configured as follows: the step of calculating the distance value between two mutually parallel straight lines based on the parallel straight line group includes obtaining the distance value between the two mutually parallel straight lines based on image recognition.
[0023] By adopting the above technical solution, the distance value between two mutually parallel straight lines can be obtained by performing image recognition on each parallel straight line group, thereby improving recognition efficiency.
[0024] In a preferred example, the present application may be further configured as follows: after calculating the distance between two adjacent straight lines to obtain a distance value, an average value of multiple distance values is calculated to obtain an average value of tobacco shred width.
[0025] By adopting the above technical solution, the calculated average value of tobacco shred width can further reflect the width of this batch of tobacco shreds, thereby improving the detection efficiency of tobacco shred width.
[0026] The second purpose of this application is to provide a tobacco width detection system.
[0027] The second application objective of the present application is achieved through the following technical solutions:
[0028] A tobacco width detection method system, comprising:
[0029] An acquisition module is used to acquire the image of the tobacco on the conveyor belt after cutting;
[0030] A detection module, used to detect straight lines on the tobacco image and obtain multiple straight lines and the length value of each straight line;
[0031] A comparison module, used for comparing the straight line length value of each straight line with a preset length threshold to obtain a plurality of remaining straight lines;
[0032] A measuring module, used for obtaining a plurality of parallel straight line groups after performing straight line detection on the remaining straight lines;
[0033] The calculation module is used to calculate the distance value between two mutually parallel straight lines according to the parallel straight line group.
[0034] In a preferred example, the present application can be further configured as follows: it also includes a processing module; the processing module is used to perform binarization processing on the tobacco cut image.
[0035] The third purpose of this application is to provide a smart terminal.
[0036] The third application objective of this application is achieved through the following technical solutions:
[0037] An intelligent terminal comprises a memory and a processor, wherein the memory stores computer program instructions of the above-mentioned tobacco shred width detection method which can be loaded and executed by the processor.
[0038] The fourth object of this application is to provide a computer medium capable of storing corresponding programs.
[0039] The fourth application objective of this application is achieved through the following technical solutions:
[0040] A computer-readable storage medium stores a computer program that can be loaded by a processor and execute any of the above-mentioned tobacco width detection methods.
[0041] In summary, the present application includes at least one of the following beneficial technical effects:
[0042] By performing straight line detection on the tobacco image, multiple straight lines in the image and the length value of each straight line are obtained. Then, after judging the length value, the straight line representing the complete tobacco in the image is left. Then, the slope of each straight line is judged to obtain parallel straight lines. The distance between the two straight lines is calculated, and the distance value obtained is the tobacco width value. In this way, the efficiency of tobacco width detection is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a flow chart of a tobacco width detection method in an embodiment of the present application.
[0044] Figure 2 It is a structural schematic diagram of a tobacco width detection system in an embodiment of the present application.
[0045] Explanation of the accompanying drawings: 1. Acquisition module; 2. Processing module; 3. Detection module; 4. Comparison module; 5. Measurement module; 6. Calculation module. DETAILED DESCRIPTION
[0046] This specific embodiment is merely an explanation of the present application and is not a limitation of the present application. After reading this specification, those skilled in the art may make modifications to the present embodiment without any creative contribution as needed. However, as long as it is within the scope of the claims of the present application, it shall be protected by the patent law.
[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0048] The embodiments of the present application are further described in detail below in conjunction with the drawings in the specification.
[0049] In the process of tobacco processing, the tobacco needs to be cut into shreds first, and then the cut tobacco is transported to the next stage via a conveyor belt. The tobacco width detection method provided in the embodiment of the present application is to sample and detect the tobacco during the transmission stage, and finally obtain the width of the tobacco by screening, detecting and calculating the tobacco in the photographed tobacco picture, and then judge the quality of this batch of tobacco based on the width of the tobacco.
[0050] The present application provides a tobacco shred width detection method, which is applied to cut tobacco shreds. The main process of the method is described as follows.
[0051] like Figure 1 As shown:
[0052] Step S101: obtaining a picture of the tobacco shreds on the conveyor belt after being cut.
[0053] To obtain tobacco pictures, a camera or other shooting device can be used to shoot tobacco pictures. However, during the shooting process, errors may occur, such that the image in the picture is smaller when far away and larger when near due to the shooting angle, which may lead to errors in the detection of the width of the tobacco. To solve the above problem, the shooting device in the embodiment of the present application adopts a dual telecentric lens and a high-resolution area array camera. The area array camera is set above the conveyor belt, and then the lens of the area array camera is aimed at the conveyor belt at a vertical downward angle, so that the tobacco in the image taken by the area array camera is of real size, and the situation of smaller when far away and larger when near will not appear. The use of the area array camera improves the detection efficiency and accuracy of tobacco width detection.
[0054] After obtaining the tobacco image, the contour extraction algorithm is used to extract the contour of the tobacco image, and then the tobacco image is filtered, that is, the tobacco image is binarized; the binarization of the image is to set the grayscale value of the pixel points on the image to 0 or 255, that is, the entire image presents an obvious visual effect of only black and white; a binary image is a digital image in which each pixel has only two possible values.
[0055] Step S102: performing straight line detection on the tobacco image to obtain a plurality of straight lines and a straight line length value of each straight line.
[0056] After obtaining the binary image of the tobacco cut picture, performing Hough transform line detection on the binary image of the tobacco cut picture can obtain multiple straight lines in the image and the straight line length value of each straight line.
[0057] Hough transform is one of the basic methods for identifying geometric shapes from images in image processing. It is widely used and has many improved algorithms. It is mainly used to separate geometric shapes with certain common features from images, such as straight lines, circles, etc. The most basic Hough transform is to detect straight lines from black and white images. Therefore, in order to detect tobacco images, the tobacco images must be binarized to turn them into black and white images, and then straight lines are detected from the tobacco images based on the Hough transform. After the straight lines are detected, each straight line is measured to obtain the straight line length value. The length of each straight line can be measured through image recognition, which is a commonly used technical means in related fields and will not be repeated here.
[0058] Step S103: Compare the straight line length value of each straight line with a preset length threshold to obtain a plurality of remaining straight lines.
[0059] In the embodiment of the present application, if the straight line length value of a straight line is greater than a preset length threshold, the straight line is retained; if the straight line length value of a straight line is less than the preset length threshold, the straight line is removed.
[0060] In the above manner, straight lines that can represent complete tobacco can be screened out from the tobacco picture; when the area array camera takes a picture of tobacco, the tobacco is randomly placed on the conveyor belt. In this case, the picture taken will show that one tobacco shred blocks another tobacco shred. Then, when the picture is detected using the Hough transform, straight lines of varying lengths will appear; and in step S101, the tobacco picture is contour extracted and binarized, avoiding the following two situations: the first is that Hough transform straight line detection is performed on the complete tobacco in the picture, and then countless straight lines are detected, resulting in the inability to detect the width of the tobacco; the second is that the picture is not binarized, resulting in the inability to perform straight line detection on the tobacco picture using the Hough transform.
[0061] Therefore, after steps S101 and S102, the straight lines in the obtained tobacco cut image are all the contour lines of the tobacco cut, and then the shorter straight lines among these straight lines are removed, and the remaining straight lines are all straight lines that can represent the complete tobacco cut.
[0062] Step S104: performing line detection on the remaining lines to obtain a plurality of parallel line groups.
[0063] In the embodiment of the present application, the parallel straight line group includes two straight lines that are parallel to each other.
[0064] In step S103, a plurality of remaining straight lines are obtained, and all of the remaining straight lines are straight lines that can represent complete tobacco shreds. Then, parallel straight lines are found among the remaining straight lines, and two parallel straight lines represent two long sides of a complete tobacco shred.
[0065] In the embodiment of the present application, the step of obtaining a plurality of parallel straight line groups after performing straight line detection on the plurality of remaining straight lines comprises:
[0066] 1. Calculate the line equation of each remaining line based on line detection.
[0067] 2. Obtain the slope of each remaining line based on the equation of the line.
[0068] 3. Determine the slopes of the remaining straight lines. If the slopes of the two remaining straight lines are equal, divide the two remaining straight lines into a parallel straight line group.
[0069] First, the linear equation of each remaining straight line is obtained according to the Hough transform straight line detection, and then the slope of each straight line can be obtained according to the straight line equation. If the slopes of two straight lines are the same, it means that the two straight lines are parallel. Then the two parallel straight lines are divided into a parallel straight line group, that is, each parallel straight line group corresponds to a complete tobacco shred.
[0070] Step S105: Calculate the distance between two parallel straight lines according to the parallel straight line group.
[0071] Among them, the calculated distance value is the width value of each tobacco shred; in the embodiment of the present application, the distance value between two parallel straight lines can be calculated by image recognition; the above process is a commonly used technical means in the relevant field and will not be repeated here.
[0072] After obtaining the width value of each tobacco shred, since the method adopted in this application is random sampling and tobacco testing, the width value of the tobacco shred can be calculated; the average value of multiple tobacco shred width values is calculated to obtain the average tobacco shred width value, and the average tobacco shred width value can reflect the width value of this batch of tobacco shreds, and then the quality of this batch of tobacco shreds can be judged by the average tobacco shred width value.
[0073] By executing the above steps S101-S105 in coordination, the width value of the tobacco shreds and the average width value of the tobacco shreds can be calculated quickly and accurately, and then the quality of this batch of tobacco shreds can be obtained, thereby improving the efficiency and accuracy of tobacco shreds width detection.
[0074] The present application also provides a tobacco width detection system, such as Figure 2 As shown, a tobacco width detection system includes an acquisition module 1, which is used to acquire a tobacco image on a conveyor belt after cutting; a processing module 2, which is used to perform binarization processing on the tobacco image; a detection module 3, which is used to perform straight line detection on the tobacco image to obtain multiple straight lines and a straight line length value of each straight line; a comparison module 4, which is used to compare the straight line length value of each straight line with a preset length threshold to obtain multiple remaining straight lines; a measurement module 5, which is used to perform straight line detection on the remaining straight lines to obtain multiple parallel straight line groups; and a calculation module 6, which is used to calculate the distance value between two mutually parallel straight lines according to the parallel straight line groups.
[0075] In order to better execute the program of the above method, the present application also provides an intelligent terminal, which includes a memory and a processor.
[0076] The memory may be used to store instructions, programs, codes, code sets or instruction sets. The memory may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function, and instructions for implementing the above-mentioned tobacco width detection method, etc.; the data storage area may store data involved in the above-mentioned tobacco width detection method, etc.
[0077] The processor may include one or more processing cores. The processor calls the data stored in the memory by running or executing the instructions, programs, code sets or instruction sets stored in the memory, performs various functions of the present application and processes data. The processor may be at least one of a special purpose integrated circuit, a digital signal processor, a digital signal processing device, a programmable logic device, a field programmable gate array, a central processing unit, a controller, a microcontroller and a microprocessor. It is understandable that for different devices, the electronic device used to implement the above-mentioned processor function can also be other, and the embodiments of the present application are not specifically limited.
[0078] The present application also provides a computer-readable storage medium, for example, including: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes. The computer-readable storage medium stores a computer program that can be loaded by a processor and execute the above-mentioned tobacco width detection method.
[0079] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the aforementioned disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present application (but not limited to) by each other to form a technical solution.
Claims
1. A method for detecting tobacco width, characterized in that: include: Get pictures of tobacco on the conveyor belt after cutting; After performing straight line detection on the tobacco image, multiple straight lines and the length value of each straight line are obtained; Compare the straight line length value of each straight line with the preset length threshold to obtain multiple remaining straight lines. If the straight line length value of a straight line is greater than the preset length threshold, the straight line is retained; if the straight line length value of a straight line is less than the preset length threshold, the straight line is removed; After performing line detection on the remaining lines, a plurality of parallel line groups are obtained, wherein the parallel line group includes two mutually parallel lines; The distance between two mutually parallel straight lines is calculated based on the parallel straight line group, and the distance is the width of the tobacco; The steps of obtaining a plurality of parallel straight line groups after performing straight line detection on the plurality of remaining straight lines include: Calculate the line equation of each remaining line based on the line detection; Obtain the slope of each remaining line from the equation of the line; The slopes of the remaining straight lines are judged. If the slopes of the two remaining straight lines are equal, the two remaining straight lines are divided into a parallel straight line group. The step of calculating the distance value between two mutually parallel straight lines according to the parallel straight line group includes obtaining the distance value between the two mutually parallel straight lines according to image recognition; After calculating the distance between two adjacent straight lines to obtain a distance value, an average value of the multiple distance values is calculated to obtain an average value of the tobacco shred width.
2. The tobacco shred width detection method according to claim 1, characterized in that: The step of obtaining the picture of the tobacco shreds on the conveyor belt after cutting includes obtaining the picture of the tobacco shreds by a photographing device, wherein the photographing device is located above the conveyor belt and the photographing device photographs the picture in a vertical downward direction.
3. The tobacco shred width detection method according to claim 1, characterized in that: After obtaining the image of the tobacco on the conveyor belt after cutting, the image of the tobacco is binarized.
4. A tobacco width detection system, characterized in that: include: An acquisition module (1) is used to acquire an image of the tobacco shreds on the conveyor belt after being cut; A detection module (3) is used to perform straight line detection on the tobacco image to obtain a plurality of straight lines and a straight line length value of each straight line; A comparison module (4) is used to compare the straight line length value of each straight line with a preset length threshold to obtain a plurality of remaining straight lines; if the straight line length value of a straight line is greater than the preset length threshold, the straight line is retained; if the straight line length value of a straight line is less than the preset length threshold, the straight line is removed; A measuring module (5) is used to perform straight line detection on the remaining straight lines to obtain a plurality of parallel straight line groups, wherein the parallel straight line groups include two straight lines that are parallel to each other; The steps of obtaining a plurality of parallel straight line groups after performing straight line detection on the plurality of remaining straight lines include: Calculate the line equation of each remaining line based on the line detection; Obtain the slope of each remaining line from the equation of the line; The slopes of the remaining straight lines are judged. If the slopes of the two remaining straight lines are equal, the two remaining straight lines are divided into a parallel straight line group. A calculation module (6) is used to calculate the distance value between two mutually parallel straight lines according to the parallel straight line group, and the distance value is the tobacco width value; The step of calculating the distance value between two mutually parallel straight lines according to the parallel straight line group includes obtaining the distance value between the two mutually parallel straight lines according to image recognition; After calculating the distance between two adjacent straight lines to obtain a distance value, an average value of the multiple distance values is calculated to obtain an average value of the tobacco shred width.
5. The tobacco width detection system according to claim 4, characterized in that: It also includes a processing module (2); the processing module (2) is used to perform binarization processing on the tobacco cut image.
6. An intelligent terminal, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer program instructions that can be loaded by the processor and execute any one of the methods according to claims 1 to 3.
7. A computer-readable storage medium, characterized in that: A computer program is stored which can be loaded by a processor and executes the method according to any one of claims 1 to 3.
