Intelligent detection method, medium and system for flue-cured tobacco leaves
Through intelligent detection methods and modular deep neural network models, the phenomenon of roasted green tobacco leaves is automatically detected, which solves the problems of low efficiency and poor accuracy of manual detection, and achieves efficient and accurate detection of roasted green tobacco leaves.
Patent Information
- Application Number
- CN202410888038.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-07-04
AI Technical Summary
In the existing technology, the detection of roasted green tobacco leaves relies on manual labor, which has the problems of high labor intensity, low detection efficiency, low accuracy and high cost.
An intelligent detection method is used to obtain the scene image and background reference image for background difference processing, extract the tobacco leaf area, and use the modular deep neural network model to extract the characteristics of the roasted green tobacco leaves to achieve automated detection.
It realizes automated intelligent detection, improves detection efficiency and accuracy, reduces labor costs, can match modern production lines, and the detection results are stable and reliable.
Smart Images

Figure CN118411368B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of flue-cured tobacco leaf detection, and in particular, relates to an intelligent flue-cured tobacco leaf detection method, medium and system. Background Art
[0002] Tobacco leaves are the main raw material for making cigarettes, and their quality has an important impact on the quality of cigarettes. One of the most common problems in tobacco leaf processing is the phenomenon of greening. Greening refers to the problem that tobacco leaves become darker in color, harder in texture, and weaker in aroma due to reasons such as too high baking temperature or too long baking time, which seriously affects the grade and quality of tobacco leaves. In order to ensure the quality of the final product, tobacco companies must strictly control the proportion of green-baked tobacco leaves, so the detection of green-baked tobacco leaves has become a crucial link in the leaf baking process.
[0003] At present, the tobacco industry mainly relies on manual inspection for the detection of flue-cured tobacco leaves. During the inspection of flue-cured tobacco leaves, workers need to carefully observe each leaf to determine whether it has the phenomenon of being flue-cured, and remove the flue-cured tobacco leaves from the normal leaves. This traditional manual inspection method has the following main problems:
[0004] 1. High labor intensity. Since workers need to concentrate their attention for a long time to observe each tobacco leaf, the work intensity is extremely high and they are prone to fatigue, which in turn affects the accuracy of the test.
[0005] 2. Low detection efficiency. Tobacco leaf detection is completely dependent on manual labor, and the operating efficiency cannot match the modern tobacco leaf production line, which restricts the production efficiency of the entire tobacco leaf processing.
[0006] 3. Low detection accuracy. Manual detection is subjective to a certain extent. Different workers may have different judgment criteria for flue-cured green tobacco leaves, and omissions are inevitable, resulting in the inability to guarantee detection accuracy.
[0007] 4. High cost. Manual testing requires a lot of manpower, which increases the labor cost expenditure of the enterprise. Summary of the invention
[0008] In view of this, the present invention provides an intelligent detection method, medium and system for flue-cured green tobacco leaves, which can solve the technical problems that the existing flue-cured green tobacco leaves often rely on manual detection, have high labor intensity and low detection efficiency.
[0009] The present invention is achieved in that:
[0010] A first aspect of the present invention provides an intelligent detection method for flue-cured green tobacco leaves, comprising the following steps:
[0011] S10, obtaining a scene image and a background reference image of a fixed detection scene;
[0012] S20, performing background difference processing on the background reference image and the current scene image to be detected to obtain a difference image;
[0013] S30, segmenting the difference image to obtain a foreground area and a background area;
[0014] S40, determining the optimal segmentation threshold according to the inter-class variance of the foreground area and the background area, and binarizing the difference image to obtain a binary image;
[0015] S50, counting the number and area of connected domains of the binary image, finding the connected domain with the largest area, and recording it as the largest connected domain;
[0016] S60, comparing the maximum connected domain area with a preset a priori area threshold to determine whether the current scene contains tobacco leaves to be detected;
[0017] S70, if there are tobacco leaves to be detected, input the image containing the tobacco leaf area into the pre-trained detection network model;
[0018] S80, using a preset modular structure in the detection network model to extract features of flue-cured tobacco leaves and detect the tobacco leaf area;
[0019] S90: Output the detection result and complete the detection process.
[0020] Among them, the step S20 specifically includes: normalizing the background reference image and the scene image to be detected, scaling the image pixel values to between 0 and 1; graying the normalized background reference image and the scene image to be detected, extracting the image grayscale component; comparing the grayscale image of the scene image to be detected with the grayscale image of the background reference image, and representing the difference between the two as a difference image.
[0021] Furthermore, the formula for the normalization process is:
[0022] Normalized background reference image pixel value = background reference image pixel value / 255;
[0023] Normalized pixel value of scene image to be detected = pixel value of scene image to be detected / 255;
[0024] The formula for the grayscale processing is:
[0025] Grayscale background reference image = (red component + green component + blue component) / 3;
[0026] Grayscale detection scene image = (red component + green component + blue component) / 3.
[0027] Furthermore, the adaptive threshold segmentation of the difference image to obtain the foreground area and the background area includes the following steps: taking a threshold T in the interval (0, 1); dividing the difference image into two parts, wherein the pixels less than T constitute the background area, and the pixels greater than or equal to T constitute the foreground area; calculating the number of pixels in the foreground area and the background area, and the proportion of the pixels in the whole image; calculating the grayscale mean of the foreground area and the background area; and calculating the grayscale mean of the whole image.
[0028] The method of determining the optimal segmentation threshold according to the inter-class variance of the foreground area and the background area and performing binarization processing on the difference image comprises the following steps:
[0029] The inter-class variance under each threshold T is calculated using the number of pixels in the foreground and background areas, the grayscale mean, and the grayscale mean of the entire image; the threshold T that maximizes the inter-class variance is selected as the optimal segmentation threshold T*; the pixels in the difference image that are greater than or equal to T* are assigned a value of 1, and the pixels that are less than T* are assigned a value of 0, to obtain a binary image.
[0030] The method of counting the number and area of connected domains in the binary image and finding the connected domain with the largest area comprises the following steps: using the eight-neighborhood query method to count the number of connected domains in the binary image and the area of each connected domain; selecting the connected domain with the largest area from the counted connected domains and marking it as the largest connected domain.
[0031] The method of comparing the maximum connected domain area with the prior area threshold to determine whether the current scene contains tobacco leaves to be detected includes the following steps:
[0032] A priori area threshold is introduced, and the value range of the prior area threshold is 0.05 to 0.3; the maximum connected domain area is compared with the prior area threshold, if the maximum connected domain area is greater than or equal to the prior area threshold, it is judged that the current scene contains tobacco leaves to be detected, otherwise it is judged that the current scene does not contain tobacco leaves to be detected.
[0033] The method of extracting the features of flue-cured tobacco leaves by using a modular structure in the detection network and performing flue-cured tobacco leaf detection on the tobacco leaf area comprises the following steps:
[0034] A modular network structure is constructed, wherein the modular network structure includes a series structure and a parallel structure; tobacco leaf features are extracted using the series structure, wherein the series structure includes two serial convolutions; tobacco leaf features under different receptive fields are extracted using the parallel structure, wherein the parallel structure includes two parallel convolutions; the features extracted by the series structure and the parallel structure are fused; and the fused features are used to perform roasted green detection on a tobacco leaf region in the modular network.
[0035] Among them, the first serial convolution in the series structure is a 3×3 standard convolution with a step size, and the second serial convolution is a 3×3 group convolution with a dilation rate; one parallel convolution in the parallel structure is a 3×3 standard convolution, and the other parallel convolution is a 3×3 group convolution with a dilation rate.
[0036] Among them, the step S10 specifically includes: obtaining the background image when there is no tobacco leaves in the fixed flue-cured green tobacco leaf detection scene as a background reference image; using prior knowledge to statistically analyze a large amount of tobacco leaf image data to determine the tobacco leaf image threshold used to judge whether there are tobacco leaves in the scene.
[0037] The step S20 specifically includes: normalizing the background reference image and the scene image to be detected, scaling the image pixel values to between 0 and 1; graying the normalized background reference image and the scene image to be detected, extracting the image grayscale components; comparing the grayscale image of the scene image to be detected with the grayscale image of the background reference image, and representing the difference between the two as a difference image.
[0038] The step S30 specifically includes: taking a threshold value T∈(0,1), dividing the difference image into a background area less than the threshold value T and a foreground area greater than the threshold value T; counting the number of pixels in the background area and the foreground area respectively; calculating the proportion of the background area and the foreground area in the whole image according to the ratio of the number of pixels in the background area and the foreground area to the number of pixels in the whole image; calculating the grayscale mean of the background area and the foreground area respectively; calculating the grayscale mean of the whole image according to the proportion of the background area and the foreground area in the whole image and the grayscale mean of the background area and the foreground area.
[0039] The step S40 specifically includes: calculating the inter-class variance of the background area and the foreground area respectively according to the square of the difference between the grayscale mean of the background area and the foreground area and the grayscale mean of the entire image; traversing all values of the threshold T within the value interval of the threshold T to find the threshold T* corresponding to the maximum inter-class variance; using the threshold T* as the segmentation threshold, binarizing the difference image to obtain a binary image.
[0040] The step S50 specifically includes: counting the number of connected domains of the binary image according to the eight-neighborhood query method; performing area statistics on each connected domain, finding the area with the largest area of the connected domain and marking it as a valid area.
[0041] The step S60 specifically includes: introducing a priori area threshold representing the minimum area of the tobacco leaf area; comparing the area of the effective area with the priori area threshold, and when the area of the effective area is greater than or equal to the priori area threshold, determining that there are tobacco leaves to be detected in the current scene.
[0042] The step S70 specifically includes: when it is determined that there are tobacco leaves to be detected in the current scene, marking the image containing the tobacco leaf area; inputting the marked image into the detection network, and performing roasted green detection on the tobacco leaf area.
[0043] Among them, the detection network adopts a modular structure to replace the standard convolution structure to extract the characteristics of flue-cured tobacco leaves; the modular structure includes a series structure and a parallel structure, the series structure includes two serial convolutions, which can deepen the nonlinear layer and expand the receptive field; the parallel structure includes two parallel convolutions, which can widen the nonlinear layer and extract contextual information. Specifically, the series structure specifically includes: using a 3×3 standard convolution with a step size to extract features; then using a 3×3 group convolution with a dilation rate to further extract feature information to increase the receptive field and nonlinear expression ability in a short time; the parallel structure specifically includes: one branch uses a 3×3 standard convolution to extract local information; the other branch uses a 3×3 group convolution with a dilation rate to extract local information with a larger receptive field; the feature information with different receptive fields is cascaded and filtered using a 1×1 point convolution, so that these feature information are fused to obtain contextual information.
[0044] Furthermore, the modular structure also includes: using a 3×3 standard convolution with a step size to establish a short connection between the input and the output to dynamically adjust the complexity of the modular structure and compensate for information loss; using the detection network of the modular structure to extract features of the input image containing the tobacco leaf area, and then classifying the extracted features through the fully connected layer to output the final flue-cured tobacco leaf detection result.
[0045] The step S90 specifically includes: visually displaying the detection result of the flue-cured tobacco leaves output by the detection network on a monitoring interface, or docking with a production control system to realize intelligent detection of the flue-cured tobacco leaves; wherein the detection result of the flue-cured tobacco leaves is output in the form of 0 or 1, 0 indicates that no flue-cured phenomenon is detected, and 1 indicates that the flue-cured phenomenon is detected.
[0046] Optionally, the value range of the prior tobacco leaf image threshold is 0.1~0.5, preferably 0.3.
[0047] Optionally, the value range of the prior area threshold is 0.05~0.3, preferably 0.1.
[0048] A second aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores program instructions, and when the program instructions are executed, they are used to execute the above-mentioned intelligent detection method for flue-cured green tobacco leaves.
[0049] A third aspect of the present invention provides an intelligent detection system for flue-cured green tobacco leaves, which includes the above-mentioned computer-readable storage medium.
[0050] Compared with the prior art, the beneficial effects of the intelligent detection method, medium and system for flue-cured green tobacco leaves provided by the present invention are:
[0051] 1. Automated intelligent detection completely solves the drawbacks of manual detection
[0052] By adopting the method of the present invention, the detection of flue-cured green tobacco leaves is fully automated and intelligent, without the need for manual intervention, fundamentally solving the problems of high labor intensity, low efficiency, low accuracy, high labor costs, etc. in traditional manual detection. Automated intelligent detection can not only greatly improve detection efficiency, but also eliminate the influence of human subjective factors, and ensure the objectivity and consistency of the detection results.
[0053] 2. Improve detection accuracy and reduce the risk of flue-cured tobacco leaves flowing into the
[0054] The method of the present invention can better extract the details and context features of flue-cured tobacco leaves through an innovative modular deep neural network model, thereby significantly improving the accuracy of detection. The improvement of detection accuracy can greatly reduce the risk of flue-cured tobacco leaves flowing into subsequent processing links, fundamentally ensuring the stability of the quality of the final product.
[0055] 3. Improve detection efficiency and match modern production lines
[0056] Another major advantage of the method of the present invention is that it has a fast detection speed and strong real-time performance. Through the effective scene tobacco leaf detection link, it is possible to avoid unnecessary calculations for scenes without tobacco leaves, saving a lot of computing resources. At the same time, the design of the modular network structure also improves the detection speed. According to the test, the detection speed of the method of the present invention can reach 50 tobacco leaves / second, which can fully meet the production rhythm requirements of modern tobacco leaf production lines.
[0057] 4.Automation of the testing process reduces labor costs
[0058] The method of the present invention automates and intelligentizes the entire flue-cured green tobacco leaf detection process, without the need for manual participation, and fundamentally reduces the labor cost expenditure of the enterprise. Compared with the traditional manual detection method that relies on a large amount of manpower, the method of the present invention reduces labor costs while also improving the efficiency and accuracy of detection, and has significant economic value.
[0059] 5. The detection method is stable and reliable, with strong robustness
[0060] The method of the present invention fully considers the complexity of the actual application scenario when designing, effectively eliminates background interference through image processing techniques such as background difference, and improves the robustness of the detection process; at the same time, the innovative network structure also enables the model to have strong generalization ability under different data distributions. The detection results are stable and reliable, less affected by external conditions, and can adapt well to complex and changeable production environments.
[0061] In summary, the present invention solves the technical problems that the existing flue-cured green tobacco leaves often rely on manual detection, which has high labor intensity and low detection efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0063] Figure 1 A flow chart of the method provided by the present invention;
[0064] Figure 2 This is the flow chart of the scene tobacco leaf detection algorithm;
[0065] Figure 3 This is a schematic diagram of the testing process for flue-cured green tobacco leaves;
[0066] Figure 4 It is a schematic diagram of the module structure;
[0067] Figure 5 This is a schematic diagram of the network training process;
[0068] Figure 6 This is a flow chart for intelligent detection of flue-cured green tobacco leaves;
[0069] Figure 7 is the training loss graph. DETAILED DESCRIPTION
[0070] In order to make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0071] like Figure 1 FIG. 1 is a flow chart of an intelligent detection method for flue-cured green tobacco leaves provided by the present invention. The method comprises the following steps:
[0072] S10, obtaining a scene image and a background reference image of a fixed detection scene;
[0073] S20, performing background difference processing on the background reference image and the current scene image to be detected to obtain a difference image;
[0074] S30, segmenting the difference image to obtain a foreground area and a background area;
[0075] S40, determining the optimal segmentation threshold according to the inter-class variance of the foreground area and the background area, and binarizing the difference image to obtain a binary image;
[0076] S50, counting the number and area of connected domains of the binary image, finding the connected domain with the largest area, and recording it as the largest connected domain;
[0077] S60, comparing the maximum connected domain area with a preset a priori area threshold to determine whether the current scene contains tobacco leaves to be detected;
[0078] S70, if there are tobacco leaves to be detected, input the image containing the tobacco leaf area into the pre-trained detection network model;
[0079] S80, extracting features of flue-cured tobacco leaves by using a preset modular structure in the detection network model, and detecting the tobacco leaf area;
[0080] S90: Output the detection result and complete the detection process.
[0081] The specific implementation methods of the above steps are described in detail below:
[0082] The specific implementation method of step S10 is: obtaining a background reference image of a fixed detection scene and obtaining a tobacco leaf image threshold using prior knowledge. The so-called fixed detection scene means that when performing the detection of flue-cured tobacco leaves, the position and angle of the camera remain unchanged, and the background image without tobacco leaves in the same scene is obtained as the background reference image. The background reference image will be used in subsequent steps to compare with the scene with tobacco leaves to highlight the difference between tobacco leaves and the background. At the same time, it is necessary to obtain the tobacco leaf image threshold in combination with prior knowledge. This threshold is obtained by statistically analyzing a large amount of tobacco leaf image data and is used to determine whether there are tobacco leaves in the scene. The specific value range of the prior tobacco leaf image threshold is between 0.1 and 0.5, and generally 0.3.
[0083] The specific implementation method of step S20 is: perform background difference between the background reference image and the current scene image to be detected to obtain a difference image. First, the background reference image and the scene image to be detected obtained under a fixed detection scene are normalized. Normalization is to scale the image pixel values to between 0 and 1 to facilitate subsequent calculations. Specifically, normalization can be achieved by dividing the value of each pixel by 255. After that, the color image is grayed to extract the grayscale component of the image. For a color image, the average value of the three color components of red, green and blue can be used as the grayscale value of the pixel. Next, the scene image to be detected and the background reference image are compared, and the difference between the two is represented by a difference image. Through the background difference operation, the area in the scene image that is different from the background, that is, the area where the tobacco leaves are located, can be highlighted.
[0084] The specific implementation method of step S30 is: perform adaptive threshold segmentation on the difference image to obtain the foreground area and the background area. The purpose of adaptive threshold segmentation is to separate the part with a larger value (possibly the tobacco leaf area) from the part with a smaller value (the background area) in the difference image. The specific method is to take a threshold and divide the difference image into two parts, the part less than the threshold is recorded as the background area, and the part greater than the threshold is recorded as the foreground area. Then calculate the proportion of the number of pixels in the foreground area and the background area in the whole image, as well as their grayscale mean. The grayscale mean of the whole image can be obtained by weighting the grayscale mean of the foreground area and the background area.
[0085] The specific implementation of step S40 is: according to the inter-class variance of the foreground area and the background area, determine the optimal segmentation threshold, and perform binarization on the difference image. The inter-class variance of the foreground area and the background area of the image can be calculated. In the interval from 0 to 1, traverse the entire interval with a step length of 1 / 255, calculate the inter-class variance corresponding to each threshold, and the threshold corresponding to the largest inter-class variance is the optimal segmentation threshold. Then, the difference image is segmented with this optimal segmentation threshold, and the pixel points greater than or equal to the threshold are set to 1, and the pixel points less than the threshold are set to 0, so as to obtain a binary image. The purpose of this step is to separate the possible tobacco leaf area and the background area through adaptive threshold segmentation, so as to prepare for the subsequent judgment of whether there are tobacco leaves.
[0086] The specific implementation method of step S50 is: count the number of connected domains of the binary image according to the eight-neighborhood query method, and find the connected domain with the largest area. In the binary image, the eight-neighborhood query method can be used to find all connected areas and count the number of connected domains. Each connected domain will be marked, and the nth connected domain is marked as Cn. Then, the area of each connected domain is calculated, and the connected domain with the largest area is found and marked as C*. The connected domain C* with the largest area is the effective area to be judged whether there are tobacco leaves, and other connected domains are regarded as abnormal areas. Record the area A* of the connected domain C*. The purpose of this step is to find the largest connected area from the binary image as a possible tobacco leaf area.
[0087] The specific implementation method of step S60 is: introduce a priori area threshold, compare it with the maximum connected domain area, and judge whether the current scene contains tobacco leaves to be detected. The priori area threshold represents the minimum value of the tobacco leaf area, and usually ranges from 0.05 to 0.3, and generally takes 0.1. If the maximum connected domain area A* is greater than or equal to the priori area threshold, it is considered that there are tobacco leaves to be detected in the current scene, and the area where the tobacco leaves are located is the maximum connected domain marked as C*; if the maximum connected domain area A* is less than the priori area threshold, it is considered that there are no tobacco leaves to be detected in the current scene.
[0088] The specific implementation of step S70 is: if there are tobacco leaves to be detected, the image containing the tobacco leaf area is input into the pre-trained detection network model. The previous steps determine whether there are tobacco leaves from the scene image by background difference, adaptive threshold segmentation, etc. If there are, the image containing the tobacco leaf area is input into a specially designed flue-cured tobacco leaf detection network. The input of the detection network is the image with the tobacco leaf area marked, and the output is the detection result of whether the tobacco leaf is flue-cured.
[0089] The specific implementation method of step S80 is: using a preset modular structure in the detection network model to extract the features of flue-cured tobacco leaves and detect the tobacco leaf area. The standard convolution feature extraction capability is limited. In order to better extract the features of flue-cured tobacco leaves, a modular structure is designed to replace the standard convolution. The modular structure expands the receptive field, enhances the nonlinear relationship between input and output, and can extract context information. The modular structure mainly includes a series structure and a parallel structure. The series structure contains two serial convolutions, which can deepen the nonlinear layer and expand the receptive field. First, a 3×3 standard convolution with a step size is used to extract features, followed by a 3×3 group convolution with a dilation rate to further extract features, the purpose of which is to increase the receptive field and nonlinear expression capability in a short time. The parallel structure contains two parallel convolutions, one using a 3×3 standard convolution to extract local information, and the other using a 3×3 group convolution with a dilation rate to extract larger receptive field information. The features of different receptive fields are cascaded and fused using 1×1 convolution to obtain contextual information. Finally, a 3×3 standard convolution short connection with a step size is established between the input and output to dynamically adjust the module complexity and compensate for information loss. Compared with standard convolution, this modular structure can better extract the details and contextual information of flue-cured tobacco leaves, thereby achieving more accurate flue-cured tobacco detection.
[0090] The specific implementation of step S90 is: output the detection result of flue-cured tobacco leaves to complete the detection process. In the modular detection network, the input image is first feature extracted, and then the extracted features are classified through the fully connected layer, and the final flue-cured tobacco leaf detection result is output, that is, it is determined whether the input tobacco leaf image has flue-cured leaves. The output result is usually in the form of 0 or 1, 0 means that no flue-cured leaves are detected, and 1 means that flue-cured leaves are detected. The detection result can be intuitively displayed on the monitoring interface, and can also be connected to the production control system to realize intelligent detection. The purpose of this step is to visualize the processing results of the previous steps and complete the entire flue-cured tobacco leaf intelligent detection process.
[0091] Network training is a process of parameter optimization, which mainly includes two parts: setting initial parameters and updating network parameters. The initial learning rate, number of training batches, number of model iterations, and loss function are trained and verified repeatedly to determine the optimal values. Network parameter updating is the key to model learning features, including forward propagation and error back propagation. Usually, the network parameter update stops after 1,000 iterations, outputs the final network parameters, and loads them into the detection network to complete the detection task.
[0092] In general, the technical solution first obtains the background reference image of the fixed detection scene and the image of the current scene to be detected, and obtains the difference image by background difference. Then, the difference image is segmented by adaptive threshold to obtain the foreground area and the background area, and the optimal segmentation threshold is determined according to the inter-class variance for binarization. Next, the number and area of the connected domains of the binary image are counted, and the connected domain with the largest area is found, which is compared with the preset threshold to determine whether the current scene contains the tobacco leaves to be detected. If so, the tobacco leaf area image is input into the pre-trained detection network model. A special modular structure is used in the detection network to extract tobacco leaf features, and the tobacco leaf area is subjected to green-baked detection, and the results are finally output. Compared with the existing technology, this method can automatically determine whether there are tobacco leaves to be detected, and at the same time, the modular network structure is used to enhance the expression ability of green-baked tobacco leaf features, so that more stable and effective green-baked tobacco leaf detection can be achieved.
[0093] In order to better understand the present invention, the specific implementation of the method of the present invention is described in more detail below in combination with specific formulas:
[0094] The specific implementation of step S10 is: obtaining a background reference image of a fixed detection scene and using prior knowledge to obtain tobacco leaf image threshold .
[0095] Fixed detection scene means that when detecting flue-cured tobacco leaves, the camera position, shooting angle, etc. remain unchanged, and the background image obtained is the same scene without tobacco leaves. , as the background reference image. The background reference image is used to compare with the tobacco leaf scene in the subsequent steps to highlight the difference between the tobacco leaves and the background.
[0096] At the same time, the tobacco leaf image threshold is obtained by combining prior knowledge This threshold is generally obtained through statistical analysis of a large amount of tobacco leaf image data and is used to determine whether there are tobacco leaves in the scene. Prior tobacco leaf image threshold The specific value range is 0.1~0.5, and 0.3 is generally taken.
[0097] The specific implementation of step S20 is: the background reference image And the current scene image to be detected Perform background subtraction to obtain a difference image .
[0098] Background reference image obtained in a fixed detection scene And the scene image to be detected Normalization is performed to scale the image pixel values to between 0 and 1 for easy subsequent calculations. The normalization formula is as follows:
[0099]
[0100] in represents the normalized background reference image, represents the normalized scene image to be detected, (i, j) represents the image pixel position, and M and N represent the image size.
[0101] Grayscale the color image and extract the grayscale component of the image. The formula is as follows:
[0102]
[0103] in and Respectively represent the background reference image and the grayscale image of the scene image to be detected, , , Represents the three color components of red, green and blue.
[0104] Compare the scene image to be detected with the background reference image, and use the difference between the two express:
[0105]
[0106] Through the background difference operation, the area in the scene image that is different from the background, that is, the area where the tobacco leaves are located, can be highlighted.
[0107] The specific implementation of step S30 is: Perform adaptive threshold segmentation to obtain the foreground area and background area.
[0108] The purpose of adaptive threshold segmentation is to transform the difference image The part with larger median value (probably tobacco leaf area) is separated from the part with smaller median value (background area). Take the threshold T∈(0,1) to convert the difference image It is divided into two parts, and the image part smaller than the threshold T is recorded as the background , the image part larger than T is recorded as foreground The number of pixels in the foreground area is , the number of pixels in the background area is , then there exists:
[0109]
[0110] in and Respectively represent the proportion of the foreground area and the background area to the entire image, and there is . Calculate the grayscale mean of the foreground area and the background area:
[0111]
[0112] in and Represent the grayscale mean of the foreground area and the background area respectively. The grayscale mean of the entire image can be expressed as:
[0113]
[0114] The specific implementation of step S40 is: according to the inter-class variance of the foreground area and the background area, the optimal segmentation threshold is determined, and the difference image is binarized.
[0115] The inter-class variance of the foreground and background regions of the image is expressed as:
[0116]
[0117] In the interval (0,1), the threshold T takes integer multiples of 1 / 255 to traverse the entire interval, and the maximum inter-class variance The corresponding threshold is recorded as , then is the segmentation threshold, and the image is segmented:
[0118]
[0119] in, is the binary image that needs to detect the difference between the scene image and the background reference image. In Location The pixel value at which the segmentation threshold is greater than or equal to the optimal segmentation threshold When the corresponding binary image The value at this position is 1, indicating the foreground area; otherwise, the value is 0, indicating the background area.
[0120] The specific implementation of step S50 is: according to the eight-neighborhood query method, the binary image is statistically analyzed. The number of connected domains is , the nth connected domain is marked as , its area is:
[0121]
[0122] The value range of n is , is the indicator function, when Belongs to the connected domain The value is 1 when , otherwise it is 0. Find the area with the largest connected domain area and mark it as , then the connected domain In order to determine whether there is an effective area for tobacco leaves, record the connected domain The area of the region is .
[0123] The specific implementation of step S60 is: introducing a priori area threshold , represents the minimum area value of the tobacco leaf area, usually The value range of is 0.05~0.3, and is generally 0.1. Then the following relationship exists:
[0124]
[0125] Indicates the tobacco leaf detection status of the scene. When , it indicates that there are tobacco leaves to be detected, and the area where the tobacco leaves are located is a connected domain The marked area is recorded as the marked detection tobacco leaf image; When the number of tobacco leaves is 0, it indicates that there is no tobacco leaf to be tested.
[0126] The specific implementation of step S70 is: if there is a tobacco leaf to be detected ( ), then the image containing the marked tobacco leaf area Input into the detection network for flue-cured tobacco leaf detection.
[0127] The specific implementation of step S80 is: using a modular structure in the detection network to extract the features of flue-cured tobacco leaves, and performing flue-cured detection on the tobacco leaf area. The standard convolution feature extraction capability is limited, and in order to better extract the features of flue-cured tobacco leaves, a modular structure is designed to replace the standard convolution.
[0128] The modular structure mainly includes series modules and parallel modules. The series module uses two serial convolution kernels to deepen the network nonlinearity and expand the receptive field, including:
[0129] 1) Use with step size Standard convolution kernel extracts features;
[0130] 2) Then use the expansion rate The group convolution kernel further extracts features and increases the receptive field and nonlinear expression ability.
[0131] The parallel module contains two parallel convolution kernel branches, which can widen the nonlinear layer and extract context information, including:
[0132] 1) A branch uses Standard convolution kernel extracts local information;
[0133] 2) Another branch uses a dilation rate Group convolution kernels to extract local information with a larger receptive field;
[0134] 3) Cascade the features of the two branches and use Point convolution is used for fusion to obtain context information.
[0135] In addition, the modular structure also includes: establishing a step-length Standard convolution short connections are used to dynamically adjust module complexity and compensate for information loss.
[0136] Compared with standard convolution, this modular structure can better extract the details and contextual information of flue-cured tobacco leaves, thereby achieving more accurate flue-cured tobacco leaf detection.
[0137] The specific implementation of step S90 is: output the detection result of the flue-cured tobacco leaves to complete the detection process. After extracting features, the extracted features are classified through the fully connected layer and the final detection results are output. :
[0138]
[0139] The test results are intuitively displayed on the monitoring interface, or connected to the production control system to realize intelligent detection of flue-cured tobacco leaves.
[0140] Network training is a process of parameter optimization. First, the initial learning rate is set. , the number of training batches , model iterations And the loss function Then perform forward propagation and error back propagation to adjust the network parameters Perform update iterations:
[0141]
[0142] The relevant variables are explained as follows: : Background reference image, which is the background image obtained when there is no tobacco leaf in the fixed detection scene; : Tobacco leaf image threshold, obtained by statistically analyzing a large amount of tobacco leaf image data through prior knowledge, is used to determine whether there are tobacco leaves in the scene. The value range is 0.1~0.5, and 0.3 is generally taken; : The scene image that currently needs to be detected; : The normalized background reference image is at position The pixel value at ; : The normalized scene image to be detected is at position The pixel value at ; : The row and column coordinates of the image pixel point, the value range is , ; : The size of the image, which represents the number of rows and columns of the image respectively; , , : The red, green and blue color components of the normalized background reference image; , , : After normalization, the three color components of red, green and blue of the scene image need to be detected; : Grayscale image of the background reference image; : Grayscale image of the scene image to be detected; : It is necessary to detect the difference image between the grayscale image of the scene image and the grayscale image of the background reference image; : The threshold used for adaptive threshold segmentation, the value range is (0,1); : Difference image Less than threshold background area; : Difference image Greater than threshold foreground area; : Foreground area The number of pixels; : Background area The number of pixels; : Foreground area The proportion of the whole image; : Background area The proportion of the whole image; : Foreground area The grayscale mean of ; : Background area The grayscale mean of ; : The grayscale mean of the entire image; : The inter-class variance of the foreground and background regions of the image; : When adaptive threshold segmentation is used, the optimal segmentation threshold corresponding to the maximum inter-class variance; : A binary image that needs to detect the difference between the scene image and the background reference image; : Binary image The number of connected domains; : Binary image The nth connected domain of ; : Connected domain area; : Indicator function, the value is 1 when the condition is met, otherwise it is 0; : The effective area with the largest connected domain area; : Valid area area; : Prior area threshold, indicating the minimum area value of the tobacco leaf area, ranging from 0.05 to 0.3, generally 0.1; : Scene tobacco leaf detection status, the value is 0 or 1, 1 means there is a tobacco leaf to be detected, 0 means there is no tobacco leaf; : An image containing marked tobacco leaf areas as input to the detection network; : The detection result of the flue-cured tobacco leaves output by the detection network, with a value of 0 or 1, 1 means that the flue-cured tobacco leaves are detected, and 0 means that the flue-cured tobacco leaves are not detected; : The initial learning rate during network training; : The number of training batches during network training; : The number of model iterations during network training; : The loss function used when training the network; : The set of parameters that need to be optimized during network training; : For parameters The gradient of : The final optimized parameters obtained by network training.
[0143] A second aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores program instructions, and when the program instructions are executed, they are used to execute the above-mentioned intelligent detection method for flue-cured green tobacco leaves.
[0144] A third aspect of the present invention provides an intelligent detection system for flue-cured green tobacco leaves, which includes the above-mentioned computer-readable storage medium.
[0145] Specifically, the principle of the present invention is: first, based on image processing techniques such as background difference and adaptive threshold segmentation, it is determined whether there are tobacco leaves to be detected in the current scene; for scenes with tobacco leaves, the image with the tobacco leaf area marked is input into the designed deep neural network model, and the model is used to extract the features of the flue-cured tobacco leaves, and finally the flue-cured tobacco leaves detection results are output.
[0146] Specifically, the technical solution of the present invention can be divided into two main parts: scene tobacco leaf detection and flue-cured tobacco leaf detection.
[0147] In the scene tobacco leaf detection part, we first obtain the background reference image of the fixed detection scene and use prior knowledge to obtain the tobacco leaf image threshold. The background reference image is the background image obtained when there is no tobacco leaf in the detection scene, which can reflect the inherent background characteristics of the scene. By performing background difference with the scene image to be detected, the area in the scene that is different from the background, that is, the possible tobacco leaf area, can be highlighted.
[0148] Next, the difference image obtained by background difference is segmented by adaptive threshold to separate the possible tobacco leaf area from the background area. Specifically, the number, proportion and grayscale mean of the foreground and background areas are calculated, and the optimal segmentation threshold is determined according to their inter-class variance, and the difference image is binarized. Then, the number and area of the connected domains of the binary image are counted, and the connected domain with the largest area is found as the effective area. The area of the effective area is compared with the tobacco leaf area threshold determined a priori to determine whether the area is the tobacco leaf to be detected.
[0149] The advantage of the tobacco leaf detection part of this scene is that it can effectively determine whether there are tobacco leaves in the current scene through simple image processing methods such as background difference and adaptive threshold segmentation, avoiding unnecessary green detection of scenes without tobacco leaves, thus saving computing resources. At the same time, by introducing prior knowledge (such as tobacco leaf area threshold), the accuracy of detection can be further improved.
[0150] In the part of flue-cured tobacco leaf detection, the image containing tobacco leaf area is input into the designed deep neural network model for flue-cured tobacco leaf detection. The key of this model is the use of an innovative modular structure to extract the features of flue-cured tobacco leaves.
[0151] Traditional convolutional neural networks have problems such as small receptive field and limited nonlinear expression ability when extracting target features. In order to solve this problem, the present invention designs two novel modular structures: series modules and parallel modules.
[0152] The tandem module uses two serial convolution kernels. The first convolution kernel is used for the tandem module. The first is a standard convolution kernel with a step size for preliminary feature extraction, and the second is a group convolution kernel with a dilation rate for further feature extraction and expansion of the receptive field. By using dilated convolution, a larger receptive field can be obtained with less computation, thereby extracting richer contextual information.
[0153] The parallel module contains two parallel convolution kernel branches, one branch uses a standard convolution kernel to extract local detail features, and the other branch uses a group convolution kernel with a dilation rate to extract larger scale context features. By concatenating the features of these two branches and fusing them through a 1×1 convolution kernel, the local and global feature representations of the target can be obtained simultaneously.
[0154] In addition, this modular structure also establishes a standard convolution kernel connection with a step size between the input and output to compensate for possible information loss and dynamically adjust the complexity of the module, thereby enhancing the nonlinear expression ability of the network.
[0155] In summary, compared with traditional convolution kernels, this innovative modular structure has a larger receptive field and stronger nonlinear expression ability, and can better extract the details and context features of flue-cured tobacco leaves, thereby improving the accuracy of flue-cured tobacco leaf detection. Experimental results also show that the deep neural network using this modular structure has achieved better performance than existing methods in the flue-cured tobacco leaf detection task.
[0156] The present invention also uses a standard network training strategy to optimize the model. First, a series of hyperparameters are set, such as the initial learning rate, batch size, number of iterations, etc., and then forward propagation and error back propagation are performed, and the network parameters are iteratively updated according to the training data and the loss function value until the model converges to obtain the final parameters.
[0157] In summary, the core technical solution of the present invention includes two parts: scene tobacco leaf detection and flue-cured tobacco leaf detection. The former uses simple image processing methods such as background difference to efficiently determine whether there are tobacco leaves in the scene; the latter uses an innovative modular deep neural network to effectively extract the details and context features of flue-cured tobacco leaves, thereby achieving accurate flue-cured tobacco leaf detection. The two work together to not only ensure the efficiency of detection, but also improve the accuracy and robustness of detection.
[0158] In general, the present invention proposes an innovative technical solution to the problems existing in the existing flue-cured green tobacco leaf detection technology. Its advantages are:
[0159] 1) The complete detection process can not only determine whether there are tobacco leaves to be tested in the scene, but also accurately detect the green-baking phenomenon in the tobacco leaves, which is close to the actual detection needs.
[0160] 2) The method for determining whether there are tobacco leaves to be detected in the scene is simple and efficient, reducing unnecessary computing resource usage.
[0161] 3) The innovative modular neural network structure improves the ability to express the characteristics of flue-cured tobacco leaves and enhances the accuracy of detection.
[0162] 4) The entire testing process is automated and intelligent, requiring no human involvement, thus reducing testing costs.
[0163] 5) The detection speed is fast and the stability is good, which can match the rhythm of the modern tobacco production line.
[0164] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
[0165] Two embodiments of the present invention are provided below:
[0166] Embodiment 1:
[0167] like Figure 6 As shown, the intelligent detection of flue-cured tobacco leaves includes two processes: scene tobacco leaf detection and flue-cured tobacco leaf detection. First, obtain the background reference image of the fixed detection scene and use the prior knowledge to obtain the tobacco leaf image threshold; then, combine the background reference image and the prior tobacco leaf image threshold to determine whether the current scene contains tobacco leaves to be detected. If so, mark the tobacco leaf area to be detected; next, input the image with the marked tobacco leaf area to be detected into the detection network for flue-cured tobacco leaf detection; finally, output the flue-cured tobacco leaf detection result to determine whether the tobacco leaves are flue-cured. The specific process is as follows:
[0168] 1. Scene tobacco leaf detection algorithm
[0169] When shooting images of cured tobacco leaves, there are two situations: the scene contains tobacco leaves and the scene without tobacco leaves. For the scene without tobacco leaves, there is no need to detect whether the tobacco leaves are cured. Therefore, it is necessary to first detect whether the current scene contains cured tobacco leaves, such as Figure 2 As shown in the figure, the main body of the scene tobacco leaf detection algorithm includes (1) background difference, (2) adaptive threshold segmentation, and (3) prior area threshold comparison.
[0170] (1) Background subtraction
[0171] The main purpose of background difference is to highlight the difference between tobacco leaf information and background information in the scene.
[0172] For the fixed tobacco leaf roasting detection scene, the image without tobacco leaves is recorded as , as the background reference image, assuming that the scene image to be detected is recorded as , the above images are normalized and expressed as:
[0173] ;
[0174] ;
[0175] in represents the normalized background reference image, represents the normalized scene image that needs to be detected, represents the position of the image pixel, and Indicates the image size. , and Respectively represent the red component, green component and blue component of the background reference image, , and Respectively indicate that the red component, green component and blue component of the scene image need to be detected, and the color image is grayed out, then there exists:
[0176] ;
[0177] ;
[0178] in and The table shows the grayscale image of the background reference image and the scene image to be detected. The scene image to be detected is compared with the background reference image, and the difference between the two is expressed as a difference. express:
[0179]
[0180] (2) Adaptive threshold segmentation
[0181] The purpose of adaptive threshold segmentation is to segment out the area that is different from the background reference image.
[0182] Take the threshold The difference image Divided into two parts, less than the threshold The image part is recorded as background , greater than The image part is recorded as foreground The number of pixels in the foreground area is , the number of pixels in the background area is , then there exists:
[0183] ;
[0184] ;
[0185] ;
[0186] ;
[0187] in and The sub-table shows the ratio of the foreground area and the background area to the entire image, and there is , and Represent the grayscale mean of the foreground area and the background area respectively. The grayscale mean of the entire image can be expressed as:
[0188]
[0189] The inter-class variance of the foreground and background regions of the image is expressed as:
[0190]
[0191] exist Interval, threshold Pick The integer multiples of traverse the entire interval, the largest between-class variance The corresponding threshold is recorded as , then is the segmentation threshold, and the image is segmented:
[0192] ;
[0193] It is a binary image that needs to detect the difference between the scene image and the background reference image. 0 represents the background area and 1 represents the foreground area.
[0194] (3) Comparison of prior area thresholds
[0195] Statistical binary image based on eight-neighborhood query method The number of connected domains is , No. The connected domains are marked as , whose area is:
[0196] ;
[0197] in The value range is 1, 2, 3, ... , find the area with the largest connected domain area and mark it as , then the connected domain This is the effective area to determine whether there is tobacco leaves, and other connected areas are abnormal areas. The area of the region is . Introducing the prior area threshold , represents the minimum value of the tobacco leaf area, then the following relationship exists:
[0198] ;
[0199] Indicates the tobacco leaf detection status of the scene. When the status is 1, it means there are tobacco leaves to be detected, and the area where the tobacco leaves are located is a connected domain. The marked area is recorded as a marked detected tobacco leaf image. When the state is 0, it indicates that there is no tobacco leaf to be detected.
[0200] 2. Intelligent Detection Network Algorithm for Flue-cured Tobacco Leaves
[0201] like Figure 3 As shown in the figure, the labeled detection tobacco leaf image is used as input, and the flue-cured tobacco leaf detection network structure is designed to predict whether there is flue-cured tobacco leaf.
[0202] The main body of flue-cured tobacco leaf detection is the detection network, which includes (1) the modular structure design of the detection network and (2) the parameters of the network training to obtain the detection results of flue-cured tobacco leaves.
[0203] (1) Modular structure design of detection network
[0204] like Figure 4 As shown in the figure, the feature extraction capability of standard convolution is very limited. In order to better extract the target features, a modular structure is designed to replace the standard convolution. Compared with the standard convolution, the modular structure expands the receptive field, enhances the nonlinear relationship between input and output, and can extract contextual information. The modular structure mainly includes a serial structure and a parallel structure. The serial structure contains two serial convolutions, which can deepen the nonlinear layer and expand the receptive field. First, a 3×3 standard convolution with a step size is used to extract features. Then, a 3×3 group convolution with a dilation rate is used to further extract feature information, with the aim of increasing the receptive field and nonlinear expression capability while spending as little time as possible. The parallel structure contains two parallel convolutions, which can widen the nonlinear layer and extract contextual information. One branch uses a 3×3 standard convolution to extract local information, while the other branch uses a 3×3 group convolution with a dilation rate to extract local information with a larger receptive field. Then, features with different receptive fields are cascaded and filtered using a 1×1 point convolution, so that these features are fused to obtain contextual information. Finally, to further compensate for information loss, a short connection is established between the input and output using a 3×3 standard convolution with a stride to dynamically adjust the complexity of the module.
[0205] (2) Network training
[0206] like Figure 5 As shown in the figure, network training is a process of parameter optimization, which mainly includes two parts: setting initial parameters and updating network parameters. Minor differences such as the initial learning rate, the number of training batches, the number of model iterations, and the loss function may have an adverse effect on the model training results. After repeated training and verification, we finally determined the initial parameters of the experiment; network parameter updating is the main step in learning the target characteristics of the network structure, including forward propagation and error back propagation. Forward propagation is from input through each hidden layer until the final output prediction result. Back propagation distributes the difference between the prediction result and the label to different hidden layers through the gradient chain rule to calculate the error of different hidden layers, thereby realizing network parameter update. Usually, when the number of network parameter update iterations is 1000, the parameter iteration stops and the network parameters are output.
[0207] Finally, the trained parameters are loaded into the network structure, the tobacco leaf images are detected, and the detection results of whether there are flue-cured tobacco leaves are output.
[0208] Embodiment 2:
[0209] The following is an embodiment of a specific usage scenario of the present invention. The hardware environment used in the embodiment is: the CPU is Intel (R) Xeon (R) Gold 6230 @ 2.10GHz, the memory is 64GB, and the graphics card is NVIDIA GeForce RTX 3090. The embodiment data collected 1000 flue-cured tobacco leaf images and 1000 normal tobacco leaf images, and the image size was unified to 640×480. Among them, 800 images were used for model training and 200 images were used for model testing. The test set contains 100 flue-cured tobacco leaf images and 100 normal tobacco leaf images.
[0210] First, 100 tobacco-free images are randomly selected from the 1000 normal tobacco leaf images collected to obtain the background reference image under the fixed detection scene. The tobacco leaf image threshold was obtained by comparing and statistically analyzing 1000 normal tobacco leaf images and 1000 flue-cured tobacco leaf images. The value is 0.3. Step S10 is completed.
[0211] The following is the specific implementation process of steps S20-S90:
[0212] For each image in the test dataset , implement the method of the present invention according to the following steps:
[0213] Step S20: Background reference image And the current scene image to be detected Normalize and grayscale them to get their grayscale images and Then calculate the difference image between the two .
[0214] Take a normal tobacco leaf image as an example, its background difference results are shown in Table 1:
[0215] Table 1 Background difference results of example images
[0216] Number of pixels in the foreground area Number of pixels in the background area Foreground area ratio Background area ratio Foreground area grayscale mean Background area grayscale mean The grayscale mean of the entire image 53845 259895 0.172 0.828 0.351 0.078 0.122
[0217] Step S30: Difference image Perform adaptive threshold segmentation to obtain the foreground area and background area , calculate the number of pixels, proportion, grayscale mean, etc. in each area. Some data of this process are shown in Table 2:
[0218] Table 2 Image parameter table
[0219] index value Number of pixels in the foreground area 53845 Number of pixels in the background area 259895 Foreground area ratio 0.172 Background area ratio 0.828 Foreground area grayscale mean 0.351 Background area grayscale mean 0.078 The grayscale mean of the entire image 0.122
[0220] Step S40: Determine the optimal segmentation threshold based on the inter-class variance of the foreground area and the background area , for the difference image Perform binarization processing to obtain a binary image .
[0221] Step S50: Statistical Binarization of Image The number of connected domains , calculate and sort the area of each connected domain, the largest connected domain area is .
[0222] Step S60: The maximum connected domain area With the prior area threshold For comparison, ,Therefore, it is determined that there are tobacco leaves to be detected in the current scene. .
[0223] So far, the scene tobacco leaf detection process is completed. Next, the image containing the tobacco leaf area is subjected to roasted green detection.
[0224] Step S70: The image with the tobacco leaf area marked Input to the detection network.
[0225] Step S80: The detection network adopts a modular structure, extracts tobacco leaf features with series modules and parallel modules, and performs roasted green detection through multi-layer convolution and fully connected layers.
[0226] The structure of the series and parallel modules in the detection network is as follows Figure 4 Shown:
[0227] The modules shown in series are used first The standard convolution kernel extracts features and then uses The dilated convolution kernel further extracts features and increases the receptive field. The parallel module consists of two branches: one uses The standard convolution kernel and the other one using Dilate the convolution kernel to extract local and large-scale features, and pass Convolution fusion. In addition, a Convolutional short connections to compensate for information loss.
[0228] In the detection network, 2 parallel modules and 1 series module are first used for initial feature extraction, then 3 parallel modules and 5 series modules are used for deep feature extraction, and finally two fully connected layers are used to output the baking green detection results.
[0229] Step S90: marking the image with the tobacco leaf area Make judgments through the detection network and output the final detection results , indicating that no baking phenomenon was detected in the image.
[0230] The training process of the detection network is as follows: Set the initial learning rate ,batch ,Iterations , using the cross entropy loss function for optimization. During the training process, the loss curve on the training set is as follows Figure 7 Shown:
[0231] After 1000 iterations, the training loss tended to stabilize, and the final detection accuracy on the test set was 98.5%, and the detection network training was completed.
[0232] The trained network parameters are loaded into the detection network, and the entire test set is tested according to the above steps S10-S90. The final test results are shown in Table 3:
[0233] Table 3 Test results
[0234] index Numeric Number of normal tobacco leaf images 96 Normal tobacco leaf detection accuracy 97% Number of flue-cured tobacco leaf images 98 Flue-cured tobacco leaf detection accuracy 98.98% Overall detection accuracy 98.5%
[0235] It can be seen from the experimental results that the method of the present invention can well detect whether there is a green-baked phenomenon in tobacco leaf images, with a detection accuracy of 98.5%. Especially for green-baked tobacco leaves, the detection accuracy is as high as 98.98%, which is much higher than the current level of manual detection in the industry.
Claims
1. A method for intelligent detection of flue-cured green tobacco leaves, characterized in that: The following steps are involved: S10, obtaining a scene image and a background reference image of a fixed detection scene; S20, performing background difference processing on the background reference image and the current scene image to be detected to obtain a difference image; S30, segmenting the difference image to obtain a foreground area and a background area; S40, determining the optimal segmentation threshold according to the inter-class variance of the foreground area and the background area, and binarizing the difference image to obtain a binary image; S50, counting the number and area of connected domains of the binary image, finding the connected domain with the largest area, and recording it as the largest connected domain; S60, comparing the maximum connected domain area with a preset a priori area threshold to determine whether the current scene contains tobacco leaves to be detected; S70, if there are tobacco leaves to be detected, input the image containing the tobacco leaf area into the pre-trained detection network model; S80, using a preset modular structure in the detection network model to extract features of flue-cured tobacco leaves and detect the tobacco leaf area; specifically, constructing a modular network structure, the modular network structure includes a series structure and a parallel structure; using the series structure to extract tobacco leaf features, the series structure includes two serial convolutions; using the parallel structure to extract tobacco leaf features under different receptive fields, the parallel structure includes two parallel convolutions; fusing the features extracted by the series structure and the parallel structure; using the fused features to perform flue-cured tobacco leaf area detection in the modular network; S90: Output the detection result and complete the detection process.
2. The intelligent detection method for flue-cured tobacco leaves according to claim 1, characterized in that: The step S20 specifically includes: normalizing the background reference image and the scene image to be detected, scaling the image pixel values to between 0 and 1; graying the normalized background reference image and the scene image to be detected, extracting the image grayscale components; comparing the grayscale image of the scene image to be detected with the grayscale image of the background reference image, and representing the difference between the two as a difference image.
3. The intelligent detection method for flue-cured tobacco leaves according to claim 2, characterized in that: The formula for the normalization process is: Normalized background reference image pixel value = background reference image pixel value / 255; Normalized pixel value of scene image to be detected = pixel value of scene image to be detected / 255; The formula for the grayscale processing is: Grayscale background reference image = (red component + green component + blue component) / 3; Grayscale detection scene image = (red component + green component + blue component) / 3.
4. The intelligent detection method for flue-cured tobacco leaves according to claim 2, characterized in that: The method performs adaptive threshold segmentation on a difference image to obtain a foreground area and a background area, comprising the following steps: taking a threshold T in the interval (0, 1); dividing the difference image into two parts, wherein pixels less than T constitute a background area, and pixels greater than or equal to T constitute a foreground area; calculating the number of pixels in the foreground area and the background area, and the proportion of the pixels in the entire image; calculating the grayscale mean of the foreground area and the background area; and calculating the grayscale mean of the entire image.
5. The intelligent detection method for flue-cured tobacco leaves according to claim 1, characterized in that: The method of determining the optimal segmentation threshold according to the inter-class variance of the foreground area and the background area and performing binarization processing on the difference image comprises the following steps: The inter-class variance under each threshold T is calculated using the number of pixels in the foreground and background areas, the grayscale mean, and the grayscale mean of the entire image; the threshold T that maximizes the inter-class variance is selected as the optimal segmentation threshold T*; the pixels in the difference image that are greater than or equal to T* are assigned a value of 1, and the pixels that are less than T* are assigned a value of 0, to obtain a binary image.
6. The intelligent detection method for flue-cured tobacco leaves according to claim 1, characterized in that: The method of counting the number and area of connected domains of a binary image and finding the connected domain with the largest area comprises the following steps: using an eight-neighborhood query method to count the number of connected domains in the binary image and the area of each connected domain; selecting the connected domain with the largest area from the counted connected domains and marking it as the largest connected domain.
7. The intelligent detection method for flue-cured green tobacco leaves according to claim 1, characterized in that: The method of comparing the maximum connected domain area with the prior area threshold to determine whether the current scene contains the tobacco leaf to be detected includes the following steps: A priori area threshold is introduced, and the value range of the prior area threshold is 0.05 to 0.3; the maximum connected domain area is compared with the prior area threshold, if the maximum connected domain area is greater than or equal to the prior area threshold, it is judged that the current scene contains tobacco leaves to be detected, otherwise it is judged that the current scene does not contain tobacco leaves to be detected.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program instructions, and when the program instructions are executed, they are used to execute the intelligent detection method for flue-cured tobacco leaves according to any one of claims 1 to 7.
9. An intelligent detection system for flue-cured green tobacco leaves, characterized in that: Contains the computer-readable storage medium of claim 8.
