Disclosure of Invention
The application provides a tobacco width detection method, a tobacco width detection system, a terminal and a storage medium, which have the characteristic of improving the tobacco width detection efficiency.
The application aims at providing a tobacco shred width detection method.
The first object of the present application is achieved by the following technical solutions:
a tobacco width detection method, comprising:
Acquiring cut tobacco pictures on a conveyor belt after shredding;
the method comprises the steps of performing linear detection on tobacco shred pictures to obtain a plurality of straight lines and a linear length value of each straight line;
comparing the linear length value of each straight line with a preset length threshold value to obtain a plurality of residual straight lines, and if the linear length value of a certain straight line is larger than the preset length threshold value, reserving the straight line; if the length value of a certain straight line is smaller than a preset length threshold value, the straight line is removed;
The method comprises the steps of carrying out straight line detection on the remaining straight lines to obtain a plurality of parallel straight line groups, wherein each parallel straight line group comprises two mutually parallel straight lines;
And calculating according to the parallel straight line group to obtain a distance value between two mutually parallel straight lines, wherein the distance value is the tobacco shred width value.
By adopting the technical scheme, a plurality of straight lines in the cut tobacco picture and the length value of each straight line are obtained, and then the length value is compared with a preset length threshold value to obtain the remaining straight lines; in the photographed tobacco picture, if one tobacco shred covers the other tobacco shred, removing the straight line smaller than the preset length threshold value, and leaving the straight line representing the complete tobacco shred; then detecting the distance between two parallel straight lines, wherein the distance is the tobacco shred width value; in this way, the detection efficiency of the tobacco shred width is improved.
The present application may be further configured in a preferred example to: the step of obtaining the cut tobacco picture on the conveyor belt after shredding comprises the steps of obtaining the cut tobacco picture through a shooting device, wherein the shooting device is located above the conveyor belt, and the shooting device shoots the picture along the vertical downward direction.
By adopting the technical scheme, the possibility of the appearance of the near-large and far-small cut tobacco in the picture is reduced.
The present application may be further configured in a preferred example to: after the cut tobacco pictures on the conveyor belt after shredding are obtained, binarization processing is carried out on the cut tobacco pictures.
By adopting the technical scheme, the binarized image of the cut tobacco picture is obtained, so that the straight line detection is convenient.
The present application may be further configured in a preferred example to: the step of obtaining a plurality of parallel straight line groups after the straight line detection of the plurality of residual straight lines comprises the following steps:
calculating a linear equation of each residual straight line according to the straight line detection;
Obtaining the slope of each residual straight line according to a straight line equation;
And judging the slopes of the residual straight lines, and dividing the two residual straight lines into a parallel straight line group if the slopes of the two residual straight lines are equal.
By adopting the technical scheme, whether the two straight lines are parallel or not is judged according to the slope of each straight line, and if the two straight lines are parallel, the two straight lines are divided into a group, so that the distance between the straight lines is convenient to calculate.
The present application may be further configured in a preferred example to: the step of calculating the distance value between two parallel straight lines according to the parallel straight line group comprises the step of obtaining the distance value between two parallel straight lines according to image recognition.
By adopting the technical scheme, the distance value between two mutually parallel straight lines can be obtained by carrying out image recognition on each parallel straight line group, and the recognition efficiency is improved.
The present application may be further configured in a preferred example to: after the distance between two adjacent straight lines is calculated to obtain a distance value, the average value of the distance values is calculated to obtain the average value of the tobacco shred width.
By adopting the technical scheme, the calculated average value of the tobacco shred widths can further reflect the widths of the batch of tobacco shreds, and the detection efficiency of the tobacco shred widths is improved.
The application aims at providing a tobacco shred width detection system.
The second object of the present application is achieved by the following technical solutions:
a tobacco width detection method system, comprising:
The acquisition module is used for acquiring cut tobacco pictures on the conveyor belt after shredding;
The detection module is used for detecting the straight lines of the tobacco shred pictures to obtain a plurality of straight lines and straight line length values of each straight line;
The comparison module is used for comparing the linear length value of each straight line with a preset length threshold value to obtain a plurality of residual straight lines;
the measuring module is used for carrying out linear detection on the residual straight lines to obtain a plurality of parallel straight line groups;
and the calculation module is used for calculating and obtaining a distance value between two mutually parallel straight lines according to the parallel straight line group.
The present application may be further configured in a preferred example to: the system also comprises a processing module; the processing module is used for carrying out binarization processing on the cut tobacco pictures.
The application aims at providing an intelligent terminal.
The third object of the present application is achieved by the following technical solutions:
An intelligent terminal comprises a memory and a processor, wherein the memory stores computer program instructions of the tobacco width detection method which can be loaded and executed by the processor.
A fourth object of the present application is to provide a computer medium capable of storing a corresponding program.
The fourth object of the present application is achieved by the following technical solutions:
a computer-readable storage medium storing a computer program loadable by a processor and performing any one of the above tobacco width detection methods.
In summary, the present application includes at least one of the following beneficial technical effects:
The method comprises the steps of obtaining a plurality of straight lines in a cut tobacco picture and length values of the straight lines after the straight lines are detected, then judging the length values, leaving the straight lines representing the complete cut tobacco in the picture, then judging slopes of the straight lines to obtain the straight lines parallel to each other, calculating the distance between the two straight lines, wherein the obtained distance value is the cut tobacco width value, and in this way, the cut tobacco width detection efficiency is improved.
Detailed Description
The present embodiment is only for explanation of the present application and is not to be construed as limiting the present application, and modifications to the present embodiment, which may not creatively contribute to the present application as required, are within the scope of the claims of the present application as far as they are protected by patent law.
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Embodiments of the application are described in further detail below with reference to the drawings.
In the tobacco shred processing process, tobacco shreds are required to be shredded firstly, then the shredded tobacco shreds are transported to the next stage through a conveyor belt, the tobacco shred width detection method provided by the embodiment of the application is characterized in that in the conveying stage, the tobacco shreds in a shot tobacco shred picture are subjected to sampling detection, screening, detection and calculation, the width of the tobacco shreds is finally obtained, and then the quality of the batch of tobacco shreds is judged according to the width of the tobacco shreds.
The application provides a tobacco shred width detection method which is applied to shredded tobacco shreds, and the main flow of the method is described as follows.
As shown in fig. 1:
Step S101: and obtaining cut tobacco pictures on the conveyor belt after shredding.
The obtained cut tobacco pictures can be shot through shooting devices such as cameras, but errors which are far, small and big due to imaging in the pictures in shooting angles easily occur in the shooting process, so that the detection of the cut tobacco width is caused; in order to solve the problems, the shooting device in the embodiment of the application adopts a double telecentric lens and a high-resolution area array camera; arranging an area array camera above a conveyor belt, and aligning a lens of the area array camera to the conveyor belt along a vertical downward angle, so that tobacco shreds in images shot by the area array camera are all of real size and cannot be far small and near large; the detection efficiency and the detection accuracy of the tobacco shred width detection are improved by using the area array camera.
After the cut tobacco picture is obtained, contour extraction is carried out on the cut tobacco picture by utilizing a contour extraction algorithm, and then the cut tobacco picture is filtered, namely binarization processing is carried out on the cut tobacco picture; binarization of an image, namely setting the gray value of a pixel point on the image to be 0 or 255, namely displaying the whole image with obvious visual effects of only black and white; a binary image is a digital image with only two possible values per pixel.
Step S102: and (3) detecting the straight lines of the tobacco shred pictures to obtain a plurality of straight lines and straight line length values of each straight line.
After the binarized image of the cut tobacco picture is obtained, the line length values of a plurality of lines and each line in the image can be obtained by carrying out Hough transformation line detection on the binarized image of the cut tobacco picture.
Hough transform is one of the basic methods for identifying geometric shapes from images in image processing, and has wide application and many improved algorithms; the method is mainly used for separating geometric shapes with certain same characteristics, such as straight lines, circles and the like, from the images; the most basic Hough transform is to detect straight lines from black-and-white images; therefore, in order to detect the cut tobacco picture, binarization processing is carried out on the cut tobacco picture to change the cut tobacco picture into a black-and-white image, and then a straight line is detected from the cut tobacco picture according to Hough transformation; after detecting the straight lines, measuring each straight line to obtain the length value of the straight line; the length measurement mode of each straight line can be an image recognition mode, which is a common technical means in the related field and is not described herein.
Step S103: and comparing the linear length value of each linear with a preset length threshold value to obtain a plurality of residual linear.
In the embodiment of the application, if the length value of a straight line is larger than a preset length threshold value, the straight line is reserved; and if the length value of the straight line of a certain straight line is smaller than the preset length threshold value, removing the straight line.
Through the mode, the straight line which can represent the complete tobacco shred can be screened from the tobacco shred pictures; when an area array camera shoots tobacco shred photos, the tobacco shreds are randomly placed on a conveyor belt, and when the photo shot at the moment can be used for shielding one tobacco shred from the other tobacco shred, a straight line with different lengths can appear when the photo is detected by using Hough transformation; in step S101, contour extraction and binarization processing are performed on the cut tobacco picture, so that the following two situations are avoided, firstly, hough transformation straight line detection is performed on the complete cut tobacco on the picture, and then countless straight lines are detected, so that the width detection of the cut tobacco cannot be realized; the second is that the picture is not subjected to binarization processing, so that the cut tobacco picture cannot be subjected to straight line detection by using Hough transformation.
Therefore, after steps S101 and S102, the straight lines in the obtained cut tobacco pictures are contour straight lines of the cut tobacco, and then the shorter straight lines in the straight lines are removed, and the remaining straight lines are straight lines capable of representing the complete cut tobacco.
Step S104: and carrying out straight line detection on the remaining straight lines to obtain a plurality of parallel straight line groups.
In an embodiment of the present application, the parallel straight line group includes two straight lines parallel to each other.
In step S103, a plurality of remaining straight lines are obtained, and the remaining straight lines are all straight lines capable of representing the complete tobacco shreds; then the straight lines parallel to each other are found among the remaining straight lines, and then the two straight lines parallel to each other represent two long sides of one complete tobacco shred.
The steps of obtaining a plurality of parallel straight line groups after the straight line detection of the plurality of residual straight lines in the embodiment of the application comprise the following steps:
1. and calculating a linear equation of each residual straight line according to the straight line detection.
2. And obtaining the slope of each residual straight line according to the straight line equation.
3. And judging the slopes of the residual straight lines, and dividing the two residual straight lines into a parallel straight line group if the slopes of the two residual straight lines are equal.
Firstly, detecting according to Hough transformation straight lines to obtain a straight line equation of each remaining straight line, obtaining the slope of each straight line according to the straight line equation, if the slopes of the two straight lines are the same, indicating that the two straight lines are parallel, and dividing the two parallel straight lines into a parallel straight line group, namely, each parallel straight line group corresponds to one complete cut tobacco.
Step S105: and calculating according to the parallel straight line group to obtain a distance value between two mutually parallel straight lines.
The calculated distance value is the width value of each cut tobacco; in the embodiment of the application, the distance value between two mutually parallel straight lines can be calculated in an image recognition mode; the above process is a common technical means in the related field, and is not described herein.
After the width value of each cut tobacco is obtained, the cut tobacco is detected by adopting random sampling, so that the width value of the cut tobacco can be calculated; and (3) taking an average value of the plurality of tobacco shred width values to obtain a tobacco shred width average value, wherein the tobacco shred width average value can reflect the width value of the batch of tobacco shreds, and further the quality of the batch of tobacco shreds can be judged through the tobacco shred width average value.
By the cooperation execution of the steps S101-S105, the width value of the tobacco shreds and the average width value of the tobacco shreds can be rapidly and accurately calculated, so that the quality of the batch of tobacco shreds can be obtained, and the efficiency and the accuracy of tobacco shred width detection are improved.
The application also provides a tobacco shred width detection system, as shown in fig. 2, which comprises an acquisition module 1 for acquiring tobacco shred pictures on a shredded conveyor belt; the processing module 2 is used for carrying out binarization processing on the cut tobacco pictures; the detection module 3 is used for detecting the straight lines of the tobacco shred pictures to obtain a plurality of straight lines and straight line length values of each straight line; the comparison module 4 is used for comparing the length value of the straight line of each straight line with a preset length threshold value to obtain a plurality of residual straight lines; the measuring module 5 is used for carrying out linear detection on the residual straight lines to obtain a plurality of parallel straight line groups; and the calculating module 6 is used for calculating and obtaining the distance value between two mutually parallel straight lines according to the parallel straight line group.
In order to better execute the program of the method, the application also provides an intelligent terminal, which comprises a memory and a processor.
Wherein the memory may be used to store instructions, programs, code, sets of codes, or sets of instructions. The memory may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function, instructions for implementing the above-described tobacco width detection method, and the like; the data storage area may store data and the like related to the tobacco width detection method.
The processor may include one or more processing cores. The processor performs the various functions of the application and processes the data by executing or executing instructions, programs, code sets, or instruction sets stored in memory, calling data stored in memory. The processor may be at least one of an application specific 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 will be appreciated that the electronics for implementing the above-described processor functions may be other for different devices, and embodiments of the present application are not particularly limited.
The present application also provides a computer-readable storage medium, for example, comprising: a U-disk, a removable hard disk, a Read Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes. The computer readable storage medium stores a computer program that can be loaded by a processor and that performs the tobacco width detection method described above.
The above description is only illustrative of the preferred embodiments of the present application and the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in the present application is not limited to the specific combinations of technical features described above, but also covers other technical features which may be formed by any combination of the technical features described above or their equivalents without departing from the spirit of the disclosure. Such as the above-mentioned features and the technical features disclosed in the present application (but not limited to) having similar functions are replaced with each other.