Real-time tobacco leaf classification method and system based on machine learning
By using the XGBoost model and feature extraction technology based on machine learning, the problems of large errors and long time consumption in manual tobacco leaf inspection are solved, realizing efficient automatic classification and rapid identification of tobacco leaves, and improving the real-time performance and model flexibility of tobacco leaf inspection.
Patent Information
- Application Number
- CN202511130492.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-13
- Publication Date
- 2025-11-14
AI Technical Summary
Existing technologies rely on manual visual inspection of tobacco leaf quality, which suffers from problems such as large detection errors, long processing times, and difficulty in real-time performance and flexible deployment. In particular, deep CNN models have high computational and energy consumption.
By employing the XGBoost model based on machine learning, combined with features such as the XGBoost classification model, HOG, and gradient histogram, tobacco leaf images are acquired in real time, preprocessed, stitched together, and multi-type feature extraction is performed to achieve automatic classification of tobacco leaf grades.
It improves the standardization and recognition speed of tobacco leaf classification, reduces model size and computing power consumption, supports incremental learning, and enhances the flexible deployment capability of the model.
Smart Images

Figure CN120953705A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of tobacco leaf grading and classification technology, specifically involving a real-time tobacco leaf classification method and system based on machine learning. Background Technology
[0002] my country is a major producer and consumer of tobacco leaves. Before the production of finished cigarettes, the raw tobacco leaves must first be tested and classified (graded). The quality of the tobacco leaves determines the purity and quality of the produced cigarettes, and also relates to the market positioning of that type of cigarette. Therefore, the testing and classification of raw tobacco leaves is crucial. Classification parameters for tobacco leaves include maturity. Generally, mature tobacco leaves are a relatively uniform orange-yellow, golden-yellow, or dark brown color, which is reflected in the presence of maturity spots (yellow spots). Furthermore, mold and insect holes significantly reduce the quality evaluation of the tobacco leaves.
[0003] Existing detection methods rely on the vision of professionals, who manually examine distinguishing features such as color, texture, shape, and main vein to classify tobacco leaves based on long-term prior experience. Manual inspection is constrained by personnel quality and environmental conditions (such as lighting). Long hours of manual inspection can also lead to mental exhaustion for inspectors, further reducing the accuracy of the detection.
[0004] To address the drawbacks of manual sorting, automated tobacco leaf part classification technology based on machine vision and image processing has been widely researched and applied in recent years. These technologies typically use industrial cameras to acquire tobacco leaf images, extract features such as morphology, color, and texture through image analysis, and use pattern recognition algorithms (such as Support Vector Machine (SVM), Random Forest, and early Convolutional Neural Networks (CNN)) for classification. However, these algorithms usually have complex model structures and a huge number of parameters (such as using deep CNN models). Such models often require a huge amount of computation and energy consumption during classification, are time-consuming, lack real-time performance, and are not conducive to flexible deployment. Summary of the Invention
[0005] This application provides a real-time tobacco leaf classification method and system based on machine learning to solve or partially solve the problems mentioned in the background art.
[0006] This application provides a real-time tobacco leaf classification method based on machine learning, including the following steps: S1: real-time acquisition of images of the detection station, determining whether the tobacco leaves on the detection station are in a detectable state, if so, proceeding to step S2; S2: Acquire the left and right images of the tobacco leaves on the detection platform, and perform image preprocessing and stitching fusion; S3: Extract multiple types of features from the fused image to obtain a combined feature vector; S4: Input the combined feature vector into the pre-trained XGBoost classification model and output the tobacco leaf grade classification result; In step S2, the left and right images of the tobacco leaves refer to the images of the tobacco leaves captured by two cameras that are set above the detection platform and symmetrically arranged on the left and right sides of the center line of the detection platform.
[0007] Preferably, in step S1, the method for determining whether the tobacco leaves are in a detectable state is as follows: The system detects the inter-frame differences in the images from the detection station and the range of the hand area in the images in real time. When the inter-frame differences are less than a preset threshold Q and the hand area in the image is less than a preset ratio Rate, the tobacco leaves are determined to be in a detectable state. The preset threshold Q and the preset ratio Rate are both set to 5%.
[0008] Preferably, in step S2, the image preprocessing method is as follows: S201: Calculate the difference map between the green and blue channels of the color image, and perform threshold segmentation using the OTSU algorithm; S202: Perform morphological closing operations on the image to smooth the edges; S203: Extract the largest connected region in the image as the tobacco leaf region image.
[0009] Preferably, the images of the tobacco leaf regions of the left and right tobacco leaves are subjected to SIFT feature matching according to the overlapping areas, and the images are stitched and fused according to the SIFT feature matching results. The method for stitching and fusing the images is as follows: When there are ≥10 SIFT matching point pairs, homography transformation is used for splicing. When SIFT fails, weighted fusion is used: For the weight function, Let x be the starting coordinates of the merged region in the x-direction. Let x be the end coordinate of the merged region in the x-direction.
[0010] Preferably, the stitched images are standardized, and the specific method is as follows: S221: Calculate the image centroid using the image moment method: in, Let p+q be the p-th order moment of the image; S222: Calculate the principal direction angle using PCA (Principal Component Analysis): Covariance matrix calculation: Wherein, the central moment is: Main direction angle: ; S223: Rotational correction based on affine transformation centered on the centroid: Rotation matrix: Transformation formula: ; S224: Scale to the preset standard size.
[0011] Preferably, in step S3, the multiple types of features include HOG features, width ratio features, local gradient length histogram and local brightness histogram features, overall brightness histogram features, and HSV color features; In step S3, the extracted feature values are Z-score standardized and then combined into feature vectors.
[0012] Preferably, the training method for the XGBoost classification model is as follows: S401: Obtain sample data, standardize the Z-score of the feature vector in the sample data, and divide the standardized sample data into training set and test set in an 8:2 ratio; S402: The XGBoost model is trained and optimized using grid search and five-fold cross-validation to determine the optimal parameter combination.
[0013] Preferably, the optimal parameter combination is: n_estimators - Number of trees: 200; learning_rate - learning rate: 0.1; max_depth - Maximum tree depth: 4; min_child_weight - the sum of the weights of the smallest leaf node samples: 5; Minimum value of the Gamma-loss function: 0.2; The penalty coefficient for reg_alpha -L1 regularization is 0.5. reg_lambda -L2 regularization penalty coefficient: 0.5; colsample_bytree - Percentage of columns randomly sampled from each tree: 0.7; Subsample - the proportion of random sampling per tree: 0.7; In the XGBoost model, the multi:softmax loss function is used to solve multi-class classification problems.
[0014] This application also provides a real-time tobacco leaf classification system based on machine learning, including: an image acquisition module, a detection and judgment module, an image stitching module, a multi-feature extraction module, and a classification model. The functions of each module are as follows: The image acquisition module acquires real-time images of the testing platform, which are obtained by two cameras positioned above the testing platform and symmetrically arranged along the center line of the testing platform. The detection and judgment module determines whether the tobacco leaves on the detection table are in a detectable state based on the image on the detection table. The image stitching module acquires the left and right images of the tobacco leaves on the detection platform through the image acquisition module when the tobacco leaves on the detection platform are in an detectable state, and performs preprocessing and stitching fusion on the images; The multi-feature extraction module performs multi-type feature extraction on the fused image to obtain a combined feature vector. The classification model is a pre-trained XGBoost model. It takes a combined feature vector as input and outputs the classification result of tobacco leaf grade.
[0015] Compared with the prior art, the beneficial effects of this application are as follows: This application uses the XGBoost model based on machine learning to automatically classify tobacco leaves, avoiding errors from manual classification and improving the standardization of tobacco leaf classification. At the same time, by separating detectable state judgment, feature extraction and model training, it supports incremental learning, reduces model size and computational cost, and is conducive to improving model recognition speed and flexible model deployment. Furthermore, by selecting the XGBoost model and features with moderate computational complexity such as HOG and gradient histogram, the model size is further reduced. Attached Figure Description
[0016] The present application will be further described below with reference to the accompanying drawings and embodiments.
[0017] Figure 1 This is a schematic diagram of the method flow of this application. Figure 2 This is a schematic diagram of the image stitching mechanism of this application. Figure 3 This is a schematic diagram of the system composition of this application. Figure 4 This is a schematic diagram illustrating the tobacco leaf processing implementation of this application. Detailed Implementation
[0018] The specification and claims use certain terms to refer to specific components. Those skilled in the art will understand that hardware manufacturers may use different names to refer to the same component. This specification and claims do not distinguish components based on differences in name, but rather on differences in function. The term "comprising" throughout the specification and claims is an open-ended term and should be interpreted as "comprising but not limited to." "Approximately" means that within an acceptable margin of error, those skilled in the art can solve the technical problem and substantially achieve the technical effect within a certain margin of error.
[0019] In the description of this application, it should be understood that the terms "upper", "lower", "front", "back", "left", "right", "horizontal", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application.
[0020] In this application, unless otherwise expressly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection between two components. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.
[0021] Example 1 like Figures 1 to 2 As shown, this application provides a real-time tobacco leaf classification method based on machine learning, including the following steps: S1: Acquire images of the detection station in real time and determine whether the tobacco leaves on the detection station are in a detectable state. If so, proceed to step S2. S2: Acquire the left and right images of the tobacco leaves on the detection platform, and perform image preprocessing and stitching fusion; S3: Extract multiple types of features from the fused image to obtain a combined feature vector; S4: Input the combined feature vector into the pre-trained XGBoost classification model and output the tobacco leaf grade classification result.
[0022] This application utilizes image recognition technology to extract image features for tobacco leaf grading, and then uses a pre-trained XGBoost classification model to automatically judge the image features and output tobacco leaf grade classification results. The classification results have high accuracy, small fluctuations, and high consistency, thus improving classification efficiency.
[0023] Specifically, the classification results of tobacco leaf grades are represented by the part of the tobacco leaf on the plant and a number, such as upper grade 1, upper grade 2, upper grade 3, middle grade 1, etc. The smaller the number, the higher the quality of the tobacco leaf.
[0024] During the growth process, tobacco plants are usually "topped" (removing the apical growing point) to promote leaf development. Then, based on the position of the leaves on the plant, they are roughly divided into upper tobacco leaves, middle tobacco leaves, and lower tobacco leaves from top to bottom. Due to the longer exposure to sunlight and the characteristics of nutrient accumulation, the thickness, color, leaf shape, nicotine and nitrogen compound content of each part of the tobacco leaves are different. Their combustibility and aroma characteristics are significantly different, and their economic value and proportion in the formulation of various cigarette products are also different.
[0025] Specifically, in step S1, the method for determining whether the tobacco leaves are in a detectable state is as follows: The system detects the inter-frame differences in the images from the detection station and the range of the hand area in the images in real time. When the inter-frame difference is less than a preset threshold Q and the hand area in the image is less than a preset ratio Rate, the tobacco leaf is determined to be in a detectable state.
[0026] Among them, the detection of inter-frame differences can use the absolute frame difference method to calculate the absolute difference between corresponding pixels in two adjacent frames. Preferably, the accumulated frame difference method is used to perform a logical "AND" operation on the inter-frame pixel differences of N consecutive frames (N is greater than or equal to 3). If all differences are less than a preset threshold Q, the detection condition is satisfied. By "accumulating" the differences of multiple frames, the feature of "continuous change" (motion state) is amplified, while the instantaneous differences caused by accidental noise operation are suppressed, thus enhancing robustness. The range detection of the hand area in the image can be judged by the range of the HSV color space. In the HSV space, the hue (H) of skin color is usually distributed within a specific range, while saturation (S) and brightness (V) can help filter noise and lighting effects.
[0027] Typically, both the preset threshold and the preset ratio are set to 5%.
[0028] Specifically, in step S2, the left and right images of the tobacco leaf refer to the images of the tobacco leaf captured by two cameras positioned symmetrically on either side of the center line of the detection platform, such as... Figure 4 As shown, the tobacco leaf images on both sides of the image are left and right images of the same tobacco leaf taken by two cameras respectively.
[0029] In step S2, the image preprocessing method is as follows: S201: Calculate the difference map between the green and blue channels of the color image, and perform threshold segmentation using the OTSU algorithm; S202: Perform morphological closing operations on the image to smooth the edges; S203: Extract the largest connected region in the image as the tobacco leaf region image.
[0030] In the difference map between the green and blue channels, green objects appear brighter and blue objects appear darker. The OTSU algorithm determines an optimal threshold by maximizing the inter-class variance to separate the foreground and background in the image. In step S202, the morphological closing operation uses an elliptical kernel with a kernel size of 15×15 pixels and performs two closing operations to ensure smooth edges.
[0031] After preprocessing the left and right images of tobacco leaves to extract the tobacco leaf region images, the extracted images are stitched and fused. Specifically, SIFT feature matching is performed on the overlapping areas of the left and right tobacco leaf region images. The images are stitched and fused according to the SIFT feature matching results. Weighted fusion stitching is selected as a means after SIFT feature matching fails to avoid affecting subsequent image stitching.
[0032] The specific method for SIFT feature matching is as follows: S211: Construct a scale space and use Gaussian blur to generate a multi-scale space: In the formula, For Gaussian blur, I(x,y) is the original image, G(x,y,σ) is the Gaussian kernel, and σ is the standard deviation; S212: Subtract the Gaussian blurred images of adjacent scales to obtain the DoG image: In the formula, k is the scaling factor; S213: In the 3×3×3 neighborhood (3 adjacent scales, 3×3 pixels per scale) of the DoG image, determine whether the current point is a local extremum (brighter or darker than all 26 surrounding points). If it is an extremum, mark it as a candidate keypoint. S214: Generate a 128-dimensional feature vector for each keypoint, making it rotation invariant, and calculate the gradient magnitude and direction: ; S215: Set the SIFT feature matching strategy. First, use the nearest neighbor distance ratio to filter matching point pairs. Where descriptor1-NN1 is the nearest neighbor distance, and descriptor1-NN2 is the second nearest neighbor distance. The nearest neighbor distance is the distance between the nearest descriptors to the descriptor to be matched in another image, and the second nearest neighbor distance is the distance between the second nearest descriptors to the descriptor to be matched in another image.
[0033] The method for stitching and merging images is as follows: When there are ≥10 SIFT matching point pairs, homography transformation is used for splicing. When SIFT fails, weighted fusion is used: Let be the weighting function, where Let x be the starting coordinates of the merged region in the x-direction. Let x be the end coordinate of the merged region in the x-direction.
[0034] When the number of matching point pairs is greater than 4, the homography transformation matrix H can be solved. The homography matrix H describes the correspondence between the common parts of two images (two images must have overlapping areas to find the number of matching points). The homography matrix H between two images is calculated by reliable matching point pairs. The calculation method can be the DLT algorithm. After solving H, the source image is mapped to the coordinate system of the target image through H to determine the size of the stitched image and fill in the pixels. After obtaining the matching point pairs, erroneous matching point pairs can be removed by RANSAC.
[0035] Preferably, the stitched images are standardized, and the specific method is as follows: S221: Calculate the image centroid using the image moment method: in, Let p+q be the p-th order moment of the image; S222: Calculate the principal direction angle using PCA (Principal Component Analysis): Covariance matrix calculation: Wherein, the central moment is: Main direction angle: ; S223: Rotational correction based on affine transformation centered on the centroid: Rotation matrix: Transformation formula: ; S224: Scale to the preset standard size.
[0036] Standardization of images helps improve the speed of feature extraction, thereby improving the overall classification speed. Typically, in step S224, the preset standard size is 1000×750 pixels.
[0037] In step S3, the multiple types of features include HOG (Histogram of Oriented Gradients) features, aspect ratio features, local gradient length histogram and local brightness histogram features, overall brightness histogram features, and HSV color features.
[0038] The specific method for HOG feature extraction is as follows: To balance speed and the quality of feature extraction, the orientations were set to 12. Since a signed gradient (0-360 degrees) is required to extract tobacco leaf texture information, each bin covers a range of 30 degrees, and the cell size was chosen to be 64*36 pixels. Calculate the gradients in the x and y directions using the Sobel operator: ; Calculate the gradient magnitude and direction: .
[0039] The method for extracting width ratio features is as follows: 50 sampling points are evenly selected along the main direction of the tobacco leaf tip. At each sampling point, the width of the tobacco leaf perpendicular to the main direction is measured. The width value at each position is divided by the length of the tobacco leaf in the main direction to obtain the aspect ratio.
[0040] To collect information around the veins of tobacco leaves, a ROI foreground region of 1 / 6 width above and below the main direction was selected. Within the ROI mask region, the brightness histogram and gradient length histogram were calculated.
[0041] The calculation method for the local gradient length histogram is as follows: Gradient calculation: , , For Sobel operators; Gradient magnitude: ; Set global gradient magnitude limits, with the maximum gradient magnitude as the upper limit and the minimum value as the lower limit based on the existing data, to bring the magnitudes into the same range, and divide the entire gradient magnitude range into 16 equal-width intervals.
[0042] The method for calculating local brightness histograms is as follows: The tobacco leaf image is converted to grayscale, and then a 128-bin histogram is plotted for the entire foreground grayscale image. 128-bin means that the brightness value range [0, 255] of the grayscale histogram is evenly divided into 128 parts.
[0043] HSV color features include hue ring statistical features and saturation and brightness statistical features, and the specific extraction methods are as follows: S301: Convert the image to the HSV color space; S302: Separate the HSV channels and calculate the mean, standard deviation and mode of each channel separately; S303: Normalize the H channel to [0,1) and convert it to radians, as follows: set up Calculate Cartesian coordinates Then calculate the average angle. Circular standard deviation Sum of numbers; S304: Normalizes the S and V channels to [0,1), calculates the mean, standard deviation, and mode. .
[0044] The mean, standard deviation, and mode mentioned here refer to each channel, namely hue (H channel), saturation (S channel), and lightness (V channel). In a color image in HSV space, each pixel is represented by three values (H, S, V), and the mean is the average of all H values among all pixels in the image.
[0045] After extracting features from each type of image, the features are arranged according to a preset order, i.e., a set of discrete groups is used to characterize the combined features of tobacco leaves.
[0046] For example, the aspect ratio: taking 50 key points along the length of the leaf, calculating the local aspect ratio (or shape factor) at each point, yields 50 discrete values. These 50 numbers represent the characteristics of leaf shape variation. These 50 numbers are treated as a row vector; each row represents the leaf shape feature of a tobacco leaf, and the 50 numbers represent a 50-dimensional feature. Another example is the local brightness histogram feature; the brightness histogram... Figure 1Generally, based on a grayscale image, it is divided into 128 equal parts. The value of each part is the number of pixels in each brightness range. If only the aspect ratio feature and the local brightness histogram feature are extracted, the combined feature vector can be represented as (a1, a2, ... a50, b1, b2, ..., b128), where a1 to a50 are the aspect ratio feature values and b1 to b128 are the local brightness histogram feature values, which is a 178-dimensional vector.
[0047] In step S3, the extracted feature matrix is Z-score standardized to ensure that each feature has the same scale. The standardized matrix is then input into the XGBoost model to obtain the classification result.
[0048] Specifically, the training method for the XGBoost model is as follows: S401: Obtain sample data, standardize the Z-score of the feature vector in the sample data, and divide the standardized sample data into training set and test set in an 8:2 ratio; S402: The XGBoost model is trained and optimized using grid search and five-fold cross-validation to determine the optimal parameter combination.
[0049] Preferably, the optimal parameter combination is: n_estimators (number of trees): 200; learning_rate: 0.1; max_depth (maximum tree depth): 4; min_child_weight (minimum sum of weights of leaf node samples): 5; gamma (minimum value of the loss function): 0.2; reg_alpha (L1 regularization penalty coefficient): 0.5; reg_lambda (L2 regularization penalty coefficient): 0.5; colsample_bytree (percentage of columns randomly sampled from each tree): 0.7; subsample (the proportion of random sampling per tree): 0.7.
[0050] Specifically, in the XGBoost model, the loss function used is multi:softmax to solve the multi-class classification problem.
[0051] Example 2 like Figure 3As shown, based on Embodiment 1 above, this embodiment provides a real-time tobacco leaf classification system based on machine learning, including: an image acquisition module, a detection and judgment module, an image stitching module, a multi-feature extraction module, and a classification model. The functions of each module are as follows: The image acquisition module acquires real-time images of the testing platform, which are obtained by two cameras positioned above the testing platform and symmetrically arranged along the center line of the testing platform. The detection and judgment module determines whether the tobacco leaves on the detection table are in a detectable state based on the image on the detection table. The image stitching module acquires the left and right images of the tobacco leaves on the detection platform through the image acquisition module when the tobacco leaves on the detection platform are in an detectable state, and performs preprocessing and stitching fusion on the images; The multi-feature extraction module performs multi-type feature extraction on the fused image to obtain a combined feature vector. The classification model is a pre-trained XGBoost model. It takes a combined feature vector as input and outputs the classification result of tobacco leaf grade.
[0052] The embodiments of this application have been described in detail above with reference to the accompanying drawings. However, this application is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of this application.
Claims
1. A real-time tobacco leaf classification method based on machine learning, characterized in that, Includes the following steps: S1: Acquire images of the detection station in real time and determine whether the tobacco leaves on the detection station are in a detectable state. If so, proceed to step S2. S2: Acquire the left and right images of the tobacco leaves on the detection platform, and perform image preprocessing and stitching fusion; S3: Extract multiple types of features from the fused image to obtain a combined feature vector; S4: Input the combined feature vector into the pre-trained XGBoost classification model and output the tobacco leaf grade classification result; In step S1, the method for determining whether the tobacco leaves are in a detectable state is as follows: The system detects the inter-frame differences in the images from the detection station and the range of the hand area in the images in real time. When the inter-frame differences are less than a preset threshold Q and the hand area in the image is less than a preset ratio Rate, the tobacco leaves are determined to be in a detectable state. In step S2, the left and right images of the tobacco leaves refer to the images of the tobacco leaves captured by two cameras that are set above the detection platform and symmetrically arranged on the left and right sides of the center line of the detection platform.
2. The real-time tobacco leaf classification method based on machine learning according to claim 1, characterized in that: The preset threshold Q and the preset ratio Rate are both set to 5%.
3. The real-time tobacco leaf classification method based on machine learning according to claim 1, characterized in that: In step S2, the image preprocessing method is as follows: S201: Calculate the difference map between the green and blue channels of the color image, and perform threshold segmentation using the OTSU algorithm; S202: Perform morphological closing operations on the image to smooth the edges; S203: Extract the largest connected region in the image as the tobacco leaf region image.
4. The real-time tobacco leaf classification method based on machine learning according to claim 3, characterized in that: The images of the tobacco leaf regions on the left and right sides are subjected to SIFT feature matching based on the overlapping areas. The images are then stitched and fused together based on the SIFT feature matching results. The method for stitching and fusing the images is as follows: When there are ≥10 SIFT matching point pairs, homography transformation is used for splicing. When SIFT fails, weighted fusion is used: For the weight function, Let x be the starting coordinates of the merged region in the x-direction. This represents the end coordinate of the merged region in the x-direction.
5. The real-time tobacco leaf classification method based on machine learning according to claim 4, characterized in that: The stitched images are then standardized using the following method: S221: Calculate the image centroid using the image moment method: in, Let p+q be the p-th order moment of the image; S222: Calculate the principal direction angle using PCA (Principal Component Analysis): Covariance matrix calculation: Wherein, the central moment is: Main direction angle: ; S223: Rotational correction based on affine transformation centered on the centroid. Rotation matrix: Transformation formula: ; S224: Scale to the preset standard size.
6. The real-time tobacco leaf classification method based on machine learning according to claim 1, 4, or 5, characterized in that: In step S3, the multiple types of features include HOG features, width ratio features, local gradient length histogram and local brightness histogram features, overall brightness histogram features, and HSV color features. In step S3, the extracted feature values are Z-score standardized and then combined into feature vectors.
7. The real-time tobacco leaf classification method based on machine learning according to claim 1, characterized in that: The training method for the XGBoost classification model is as follows: S401: Obtain sample data, standardize the Z-score of the feature vector in the sample data, and divide the standardized sample data into training set and test set in an 8:2 ratio; S402: The XGBoost model is trained and optimized using grid search and five-fold cross-validation to determine the optimal parameter combination.
8. The real-time tobacco leaf classification method based on machine learning according to claim 1, characterized in that: The optimal parameter combination is: n_estimators - Number of trees: 200; learning_rate - learning rate: 0.1; max_depth - Maximum tree depth: 4; min_child_weight - the sum of the weights of the smallest leaf node samples: 5; Minimum value of the Gamma-loss function: 0.2; The penalty coefficient for reg_alpha -L1 regularization is 0.
5. reg_lambda -L2 regularization penalty coefficient: 0.5; colsample_bytree - Percentage of columns randomly sampled from each tree: 0.7; Subsample - the proportion of random sampling per tree: 0.7; In the XGBoost model, the multi:softmax loss function is used to solve multi-class classification problems.
9. A real-time tobacco leaf classification system based on machine learning, characterized in that, include: The system comprises an image acquisition module, a detection and judgment module, an image stitching module, a multi-feature extraction module, and a classification model. The functions of each module are as follows: The image acquisition module acquires real-time images of the testing platform, which are obtained by two cameras positioned above the testing platform and symmetrically arranged along the center line of the testing platform. The detection and judgment module determines whether the tobacco leaves on the detection table are in a detectable state based on the image on the detection table. The image stitching module acquires the left and right images of the tobacco leaves on the detection platform through the image acquisition module when the tobacco leaves on the detection platform are in an detectable state, and performs preprocessing and stitching fusion on the images; The multi-feature extraction module performs multi-type feature extraction on the fused image to obtain a combined feature vector. The classification model is a pre-trained XGBoost model. It takes a combined feature vector as input and outputs the classification result of tobacco leaf grade.