Intelligent tobacco leaf grading method and device based on machine vision
Through intelligent grading methods based on machine vision, the part type and quality information in tobacco leaf images are identified and analyzed, and the subjectivity and inconsistency caused by the reliance on labor on tobacco leaf grading in the prior art are solved, efficient and accurate automated grading is achieved, and labor costs are reduced.
Patent Information
- Application Number
- CN202510255999.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-05
- Publication Date
- 2025-06-20
AI Technical Summary
In the prior art, the grading of tobacco leaves depends on manual judgment, and there are problems such as strong subjectivity, high inconsistency, low accuracy and efficiency, and high labor costs.
Using an intelligent grading method based on machine vision, we collect tobacco leaf images, use machine vision algorithms to identify the tobacco leaf part type and quality information, and compare it with the preset tobacco leaf grade classification table to automatically determine the grading results of the tobacco leaf.
The automation and accuracy of tobacco leaf grading have been improved, manual intervention has been reduced, grading efficiency has been improved, and labor costs have been reduced.
Smart Images

Figure CN120182691A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of tobacco leaf grading, and in particular, to an intelligent grading method and device for tobacco leaves based on machine vision. Background Art
[0002] Flue-cured tobacco leaves (hereinafter referred to as tobacco leaves) are an important part of the global tobacco industry, and their quality directly affects the quality of the final tobacco products. Grading tobacco leaves is a key process that determines their commercial value and final use.
[0003] In the related art, grading tobacco leaves mainly depends on the feelings of sorting workers' eyes, hands, etc. for judgment, which has strong subjectivity and inconsistency. Moreover, due to individual perception differences, even experienced workers may have differences in grading results, resulting in low accuracy and efficiency of grading tobacco leaves manually and high labor costs.
[0004] Therefore, how to quickly and accurately grade tobacco leaves while reducing labor costs is an urgent problem to be solved at present. Summary of the Invention
[0005] In view of the problems existing in the prior art, an embodiment of the present invention provides an intelligent grading method and device for tobacco leaves based on machine vision.
[0006] The present invention provides an intelligent grading method for tobacco leaves based on machine vision, including: Collecting an image of tobacco leaves to be graded; Based on a machine vision algorithm, identifying the tobacco leaf part corresponding to the image of the tobacco leaves to be graded to obtain the type of the tobacco leaf part corresponding to the image of the tobacco leaves to be graded; performing quality analysis on the image of the tobacco leaves to be graded to determine the tobacco leaf quality information corresponding to the image of the tobacco leaves to be graded; the tobacco leaf quality information is used to reflect the quality of the tobacco leaves in the image of the tobacco leaves to be graded; Comparing the type of the tobacco leaf part and the tobacco leaf quality information with a plurality of tobacco leaf grade information in a preset tobacco leaf grade classification table, and determining the grade corresponding to the target tobacco leaf grade information in the preset tobacco leaf grade classification table as the grading result of the image of the tobacco leaves to be graded; the preset tobacco leaf part type and the preset tobacco leaf quality information in the target tobacco leaf grade information are respectively the same as the type of the tobacco leaf part and the tobacco leaf quality information corresponding to the image of the tobacco leaves to be graded.
[0007] Optionally, the identifying the tobacco leaf part corresponding to the image of the tobacco leaves to be graded to obtain the type of the tobacco leaf part corresponding to the image of the tobacco leaves to be graded includes: Input the to-be-graded tobacco leaf image into a tobacco leaf position recognition model to obtain the tobacco leaf position type output by the tobacco leaf position recognition model; the tobacco leaf position type includes any one of the following: upper tobacco leaf, middle tobacco leaf, and lower tobacco leaf; Among them, the tobacco leaf position recognition model is trained based on multiple first tobacco leaf image samples, and each part of each first tobacco leaf image sample is labeled with a corresponding position type label; The tobacco leaf position recognition model is a YOLOv8 model, and an Explicit Visual Center (EVC) module is deployed in the YOLOv8 model. The EVC module is used to capture the long-range dependence relationship of the entire length of the to-be-graded tobacco leaf image and the local corner region information, so that the tobacco leaf position recognition model determines the position type based on the long-range dependence relationship and the local corner region information.
[0008] Optionally, the quality information includes at least one of the following: the specification information of the tobacco leaf, the color information of the tobacco leaf, and the morphological information of the tobacco leaf; Performing quality analysis on the to-be-graded tobacco leaf image to determine the tobacco leaf quality information corresponding to the to-be-graded tobacco leaf image includes at least one of the following: Based on an object detection algorithm, determining the specification information and the color information; Input the to-be-graded tobacco leaf image into a tobacco leaf morphology recognition model to obtain the morphological information shown by the tobacco leaf morphology recognition model; among them, the tobacco leaf morphology recognition model is trained based on multiple second tobacco leaf image samples, and each second tobacco leaf image sample is labeled with a corresponding morphological information label; the tobacco leaf morphology recognition model is a YOLOv8 model, and an EVC module is deployed in the YOLOv8 model. The EVC module is used to capture the long-range dependence relationship of the entire length of the to-be-graded tobacco leaf image and the local corner region information, so that the tobacco leaf morphology recognition model determines the morphological information based on the long-range dependence relationship and the local corner region information.
[0009] Optionally, the specification information includes the length and width of the tobacco leaf; The determining the specification information and the color information based on the object detection algorithm includes: Based on the object detection algorithm, determining the pixel point coordinates corresponding to the contour boundary of the tobacco leaf in the to-be-graded tobacco leaf image; Based on each of the pixel point coordinates, determining the distance between the two pixel points with the farthest vertical coordinate interval as the length, and the distance between the two pixel points with the farthest horizontal coordinate interval as the width; Based on the color space information of the tobacco leaf area surrounded by the contour boundary, determining the color information.
[0010] Optionally, the color space information includes any one of HSV color space information and Lab color space information; Determining the color information based on the standard color space conversion information of the tobacco leaf area surrounded by the contour boundary includes: Determining the color information based on any one of the HSV color space information and the Lab color space information.
[0011] Optionally, the morphological information includes at least one of the following: The maturity of the tobacco leaf; The leaf structure of the tobacco leaf; The identity of the tobacco leaf, which is used to represent the thickness of the tobacco leaf; The oil content of the tobacco leaf; The damage information of the tobacco leaf, and the damage information includes at least one of the following: the degree of insect bite, the degree of mildew, and the degree of mutilation.
[0012] The present invention also provides a tobacco leaf intelligent grading device based on machine vision, including: An acquisition module, which is used to acquire an image of the tobacco leaf to be graded; A part recognition and quality analysis module, which is used to recognize the tobacco leaf part corresponding to the image of the tobacco leaf to be graded based on a machine vision algorithm, and obtain the type of the tobacco leaf part corresponding to the image of the tobacco leaf to be graded; perform quality analysis on the image of the tobacco leaf to be graded, and determine the tobacco leaf quality information corresponding to the image of the tobacco leaf to be graded; the tobacco leaf quality information is used to reflect the quality of the tobacco leaf in the image of the tobacco leaf to be graded; A grading module, which is used to compare the tobacco leaf part type and the tobacco leaf quality information with multiple tobacco leaf grade information in a preset tobacco leaf grade classification table, and determine the grade corresponding to the target tobacco leaf grade information in the preset tobacco leaf grade classification table as the grading result of the image of the tobacco leaf to be graded; the preset tobacco leaf part type and the preset tobacco leaf quality information in the target tobacco leaf grade information are the same as the tobacco leaf part type and the tobacco leaf quality information corresponding to the image of the tobacco leaf to be graded, respectively.
[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the machine vision-based tobacco leaf intelligent grading method as described in any one of the above.
[0014] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the machine vision-based tobacco leaf intelligent grading method as described in any one of the above.
[0015] The present invention also provides a computer program product, including a computer program, which when executed by a processor, implements the machine vision-based intelligent tobacco leaf grading method as described in any one of the above.
[0016] The machine vision-based intelligent tobacco leaf grading method and device provided by the present invention collect images of tobacco leaves to be graded, and then, based on machine vision algorithms, identify the parts of the tobacco leaves corresponding to the images of tobacco leaves to be graded and analyze the quality. It can automatically and accurately analyze the part types and quality information of the tobacco leaves in the images of tobacco leaves to be graded. Compare the tobacco leaf part types and tobacco leaf quality information with multiple tobacco leaf grade information in a preset tobacco leaf grade classification table, and determine the grade corresponding to the target tobacco leaf grade information as the grading result of the image of tobacco leaves to be graded. Among them, the preset tobacco leaf part type and preset tobacco leaf quality information in the target tobacco leaf grade information are respectively the same as the tobacco leaf part type and tobacco leaf quality information corresponding to the image of tobacco leaves to be graded. Through the above method, the grade corresponding to the image of tobacco leaves to be graded can be automatically identified, improving the accuracy and efficiency of tobacco leaf grading. At the same time, no manual intervention is required during the entire tobacco leaf grade identification process, reducing labor costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0018] Figure 1 is one of the flow diagrams of the machine vision-based intelligent tobacco leaf grading method provided by the present invention; Figure 2 is another flow diagram of the machine vision-based intelligent tobacco leaf grading method provided by the present invention; Figure 3 is the structural diagram of the machine vision-based intelligent tobacco leaf grading device provided by the present invention; Figure 4 is the structural diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0019] To make the objectives, technical solutions, and advantages of the present invention clearer, the following will clearly and completely describe the technical solutions in the present invention with reference to the accompanying drawings in the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.
[0020] The following will describe the intelligent tobacco leaf grading method and device based on machine vision of the present invention Figure 1 - Figure 2 in conjunction with Figure 1 - Figure 2 .
[0021] Figure 1 FIG. 7 is one of the flow schematic diagrams of the intelligent tobacco leaf grading method based on machine vision provided by the present invention, which specifically includes the following steps 101 to 103: Step 101, collect the tobacco leaf image to be graded.
[0022] First of all, it should be noted that the execution subject of the present invention can be any electronic device capable of realizing intelligent tobacco leaf grading based on machine vision, such as any one of a smart phone, a smart watch, a desktop computer, a laptop computer, etc.
[0023] The embodiment of the present invention aims to accurately and quickly grade the tobacco leaves in the tobacco leaf image to be graded based on the machine vision algorithm, and reduce the labor cost.
[0024] The tobacco leaf image to be graded can be collected in real time by the execution subject, or the tobacco leaf image to be graded that needs to be processed can be collected from the database.
[0025] Step 102, based on the machine vision algorithm, identify the tobacco leaf part corresponding to the tobacco leaf image to be graded, and obtain the tobacco leaf part type corresponding to the tobacco leaf image to be graded; perform quality analysis on the tobacco leaf image to be graded, and determine the tobacco leaf quality information corresponding to the tobacco leaf image to be graded; the tobacco leaf quality information is used to reflect the quality of the tobacco leaves in the tobacco leaf image to be graded.
[0026] In the embodiment of the present invention, the machine vision algorithm refers to various algorithms for image processing and pattern recognition. This algorithm can enable the machine to have the ability to "see". By simulating the human eye vision system, the machine can identify, detect and understand the information in the image, and is widely used in fields such as image recognition and image detection. Machine vision algorithms such as: image segmentation algorithm, feature extraction algorithm, target detection algorithm, etc. The quality information may include at least one or a combination of the following: disability (insect bite, mildew, mutilation), maturity, leaf structure, identity, oil content, chroma, color, specification information (length, width).
[0027] By using the machine vision algorithm to perform tobacco leaf part identification and quality analysis on the tobacco leaf image to be graded, the true form and quality of the tobacco leaves in the tobacco leaf image to be graded can be obtained, thereby providing a reliable data basis for subsequent tobacco leaf grading.
[0028] Step 103: Compare the tobacco leaf part type and the tobacco leaf quality information with multiple tobacco leaf grade information in a preset tobacco leaf grade classification table, and determine the grade corresponding to the target tobacco leaf grade information in the preset tobacco leaf grade classification table as the grading result of the tobacco leaf image to be graded; the preset tobacco leaf part type and the preset tobacco leaf quality information in the target tobacco leaf grade information are the same as the tobacco leaf part type and the tobacco leaf quality information corresponding to the tobacco leaf image to be graded, respectively.
[0029] In practical applications, there can be one or more preset tobacco leaf grade classification tables. When there is one preset tobacco leaf grade classification table, there are multiple tobacco leaf grade information in the tobacco leaf grade classification table, and each tobacco leaf grade information includes a preset tobacco leaf part type and a preset tobacco leaf quality information. By comparing the tobacco leaf part type and the tobacco leaf quality information obtained by the machine vision algorithm with each tobacco leaf grade information, the grading result can be obtained.
[0030] When there are multiple preset tobacco leaf grade classification tables, for example, there is a first preset tobacco leaf grade classification table including multiple preset tobacco leaf part types; there are multiple second preset tobacco leaf grade classification tables including multiple preset tobacco leaf quality information; among them, one preset tobacco leaf part type has an association relationship with multiple second preset tobacco leaf grade classification tables.
[0031] In practical applications, first compare the tobacco leaf part type obtained by the machine vision algorithm with each preset tobacco leaf part type in the first preset tobacco leaf grade classification table, and take the first tobacco leaf grade corresponding to the target preset tobacco leaf part type as the grade corresponding to the tobacco leaf part of the tobacco leaf image to be graded; among them, the target preset tobacco leaf part type is the same as the tobacco leaf part type obtained by the machine vision algorithm.
[0032] Then, compare the tobacco leaf quality information obtained by the machine vision algorithm with multiple preset tobacco leaf quality information in each second preset tobacco leaf grade classification table having an association relationship with the target preset tobacco leaf part type, and take the second tobacco leaf grade corresponding to the target preset tobacco leaf quality information as the grade corresponding to the tobacco leaf quality information of the tobacco leaf image to be graded; among them, the target preset tobacco leaf quality information is the same as the tobacco leaf quality information obtained by the machine vision algorithm.
[0033] Finally, take the first tobacco leaf grade and the second tobacco leaf grade as the final target tobacco leaf grade information and use it as the grading result of the tobacco leaf image to be graded.
[0034] The intelligent tobacco leaf grading method and device based on machine vision provided by the present invention collect the tobacco leaf images to be graded, and then, based on the machine vision algorithm, identify the tobacco leaf parts corresponding to the tobacco leaf images to be graded and analyze the quality, so as to automatically and accurately analyze the part types of the tobacco leaves and the tobacco leaf quality information in the tobacco leaf images to be graded; compare the tobacco leaf part types and the tobacco leaf quality information with multiple tobacco leaf grade information in the preset tobacco leaf grade classification table, and determine the grade corresponding to the target tobacco leaf grade information as the grading result of the tobacco leaf image to be graded; wherein, the preset tobacco leaf part type and the preset tobacco leaf quality information in the target tobacco leaf grade information are respectively the same as the tobacco leaf part type and the tobacco leaf quality information corresponding to the tobacco leaf image to be graded. Through the above method, the grade corresponding to the tobacco leaf image to be graded can be automatically identified, the accuracy and efficiency of tobacco leaf grading are improved, and at the same time, no manual intervention is required in the whole tobacco leaf grade identification process, reducing the labor cost.
[0035] Optionally, the identification of the tobacco leaf parts corresponding to the tobacco leaf image to be graded to obtain the tobacco leaf part type corresponding to the tobacco leaf image to be graded can be specifically implemented through the following steps: Input the tobacco leaf image to be graded into the tobacco leaf part identification model, and obtain the tobacco leaf part type output by the tobacco leaf part identification model; the tobacco leaf part type includes any one of the following: upper tobacco leaf, middle tobacco leaf, and lower tobacco leaf. In practical applications, the upper tobacco leaf is represented by "B"; the middle tobacco leaf is represented by "C"; the lower tobacco leaf is represented by "X".
[0036] Wherein, the tobacco leaf part identification model is trained based on multiple first tobacco leaf image samples, and each part of each first tobacco leaf image sample is labeled with a corresponding part type label; The tobacco leaf part identification model is a YOLOv8 model, and an explicit vision center EVC module is deployed in the YOLOv8 model. The EVC module is used to capture the long-distance dependence relationship of the entire length and the local corner area information of the tobacco leaf image to be graded, so that the tobacco leaf part identification model determines the part type based on the long-distance dependence relationship of the entire length and the local corner area information.
[0037] In the embodiment of the present invention, the "long-distance dependence relationship of the entire length" refers to: the dependence relationship between the target pixel in the tobacco leaf image to be graded and the pixels far away from it. The "local corner area information" refers to: the detailed information of a specific corner area in the tobacco leaf image to be graded, including detailed features such as the texture, edge, and color change of the image.
[0038] In the above embodiments, by deploying the EVC module in the tobacco leaf position recognition model, the long-range global dependencies and local corner region information can be combined, which helps to adjust the shallow features of tobacco leaf position recognition, enabling the entire tobacco leaf position recognition model to not only capture the long-range global dependencies but also effectively obtain a comprehensive and discriminative feature representation, thereby improving the accuracy of the tobacco leaf position recognition model.
[0039] Optionally, the quality information includes at least one of the following: the specification information of the tobacco leaf, the color information of the tobacco leaf, and the morphological information of the tobacco leaf. The quality analysis of the tobacco leaf image to be graded to determine the tobacco leaf quality information corresponding to the tobacco leaf image to be graded includes at least one of the following: Based on the object detection algorithm, determine the specification information and the color information. Input the tobacco leaf image to be graded into the tobacco leaf morphology recognition model to obtain the morphological information shown by the tobacco leaf morphology recognition model; wherein, the tobacco leaf morphology recognition model is trained based on a plurality of second tobacco leaf image samples, and each second tobacco leaf image sample is labeled with a corresponding morphological information label; the tobacco leaf morphology recognition model is a YOLOv8 model, and an EVC module is deployed in the YOLOv8 model, and the EVC module is used to capture the long-range global dependencies and local corner region information of the tobacco leaf image to be graded, so that the tobacco leaf morphology recognition model determines the morphological information based on the long-range global dependencies and the local corner region information.
[0040] It should be noted that the object detection algorithm can be, for example, the YOLO model, the SingleShot MultiBox Detector (SSD) algorithm, the CenterNet algorithm, etc., to determine the specification information and color information of the tobacco leaf.
[0041] In the embodiments of the present invention, the EVC module deployed in the tobacco leaf morphology recognition model is similar to the EVC module deployed in the above-mentioned tobacco leaf position recognition model, and will not be elaborated here.
[0042] Optionally, the morphological information includes at least one of the following: a) The maturity of the tobacco leaf; for example, including mature, false mature, etc.
[0043] b) The leaf structure of the tobacco leaf; for example, including tight, coefficient, etc.
[0044] c) The identity of the tobacco leaf, which is used to represent the thickness of the tobacco leaf; for example, including thin, slightly thin, medium, thick, slightly thick, etc.
[0045] d) The oil content of the tobacco leaves; for example, including having oil content, slightly having oil content, less oil content, more oil content, etc.
[0046] e) The damage information of the tobacco leaves, and the damage information includes at least one of the following: the degree of insect bite, the degree of mildew, and the degree of mutilation.
[0047] Optionally, the specification information includes the length and width of the tobacco leaves; Based on the target detection algorithm, determining the specification information and the color information is specifically implemented through the following steps: Step 1), Based on the target detection algorithm, determining the pixel point coordinates corresponding to the contour boundary of the tobacco leaves in the tobacco leaf image to be graded.
[0048] Step 2), Based on each of the pixel point coordinates, determining the distance between the two pixel points with the farthest vertical coordinate interval as the length, and the distance between the two pixel points with the farthest horizontal coordinate interval as the width.
[0049] For example, if the pixel point coordinates of the two pixel points with the farthest vertical coordinate interval are (x1, y1) and (x2, y2) respectively, then the length is the absolute value of the difference between y2 and y1. If the pixel point coordinates of the two pixel points with the farthest horizontal coordinate interval are (x3, y3) and (x4, y4) respectively, then the width is the absolute value of the difference between x4 and x3.
[0050] Step 3), Based on the color space information of the tobacco leaf area surrounded by the contour boundary, determining the color information.
[0051] Optionally, the color space information includes any one of hue, saturation, value (Hue, Saturation, Value, HSV) color space information and Lab color space information.
[0052] Among them, the HSV color space means that each color is represented by hue (Hue, H), saturation (Saturation, S), and value (Value, V). The HSV color space is also called the HSV color space model.
[0053] Lab consists of a luminance channel and two color channels. In the Lab color space, each color is represented by three numbers L, a, and b. The meanings of each component are: L represents luminance; a represents the component from green to red; b represents the component from blue to yellow.
[0054] Determining the color information based on the standard color space conversion information of the tobacco leaf area surrounded by the contour boundary includes: Determine the color information based on any one of the HSV color space information and the Lab color space information.
[0055] In practical applications, the color information of tobacco leaves can be determined based on the H value in the HSV color space, or the L, a, and b values in the Lab color space.
[0056] In another implementation, the color information of tobacco leaves can also be determined based on the R value, G value, and B value in the RGB information.
[0057] Optionally, compare the tobacco leaf part type and the tobacco leaf quality information with multiple tobacco leaf grade information in a preset tobacco leaf grade classification table, and determine the grade corresponding to the target tobacco leaf grade information as the grading result of the tobacco leaf image to be graded. Specifically, it can be implemented in the following ways: Method 1: Compare the tobacco leaf part type, the specification information, the color information, and the morphological information with each tobacco leaf grade information in the preset tobacco leaf grade classification table; each tobacco leaf grade information includes a preset tobacco leaf part type, preset specification information, preset color information, and preset morphological information; determine the grade corresponding to the target tobacco leaf grade information as the grading result.
[0058] For example, in the tobacco leaf image to be graded, the tobacco leaf part type is the lower part; the specification information is: length 40 cm, width 20 cm; the color information is: orange; the morphological information is: the maturity of the tobacco leaf is mature, the leaf structure is loose, the identity is slightly thin, the oil content is slightly present, the degree of insect bite is slightly present, the degree of mildew is none, and the degree of mutilation is medium. Then compare the above data of the tobacco leaf image to be graded with each tobacco leaf grade information in the preset tobacco leaf grade classification table, and determine the target tobacco leaf grade information in the preset tobacco leaf grade classification table. The preset tobacco leaf part type, preset specification information, preset color information, and preset morphological information in the target tobacco leaf grade information are the same as the data of the tobacco leaf image to be graded.
[0059] The grade corresponding to the target tobacco leaf grade information is, for example: X2F, where X indicates that the preset tobacco leaf part type is the lower part of the tobacco leaf, 2 indicates that the grade corresponding to the preset specification information and the morphological information is level 2, and F indicates orange. Therefore, the final grading result of the tobacco leaf image to be graded is "X2F".
[0060] In practical applications, even if the specification information, color information, and morphological information are the same, if the part type of the tobacco leaf is different, the final grading result will also be different. In view of the above situation, the embodiments of the present invention provide another way to determine the grading result of the tobacco leaf image to be graded. See Method 2 below for details.
[0061] Method 2: Step 1), compare the tobacco leaf part type with multiple first tobacco leaf grade information in the first preset tobacco leaf grade classification table, and determine the first grade corresponding to the first target tobacco leaf grade information as the first classification result corresponding to the tobacco leaf part type; the preset tobacco leaf part type in the first target tobacco leaf grade information is the same as the tobacco leaf part type; each first tobacco leaf grade information has an association relationship with multiple second preset tobacco leaf grade classification tables, the second preset tobacco leaf grade classification table includes multiple second tobacco leaf grade information, and each second tobacco leaf grade information includes preset specification information, preset color information and preset morphological information; Step 2), compare the specification information, the color information and the morphological information with each of the second preset tobacco leaf grade classification tables having an association relationship with the first target tobacco leaf grade information, and determine the second grade corresponding to the second target tobacco leaf grade information as the second classification result corresponding to the tobacco leaf quality information; the preset specification information, preset color information and preset morphological information in the second target tobacco leaf grade information are the same as the specification information, the preset color information and the preset morphological information.
[0062] Step 3), determine the first classification result and the second classification result as the classification result of the tobacco leaf image to be classified.
[0063] For example, there are 3 first tobacco leaf grade information in the first preset tobacco leaf grade classification table: the preset tobacco leaf part type in the 1st first tobacco leaf grade information is: upper tobacco leaf, and the corresponding first grade is "B"; the preset tobacco leaf part type in the 2nd first tobacco leaf grade information is: middle tobacco leaf, and the corresponding first grade is "C"; the preset tobacco leaf part type in the 3rd first tobacco leaf grade information is: lower tobacco leaf, and the corresponding first grade is "X".
[0064] Compare the tobacco leaf part type corresponding to the tobacco leaf image to be classified with 3 first tobacco leaf grade information, and determine the 2nd first tobacco leaf grade information as the first target tobacco leaf grade information, and the corresponding first grade is "C".
[0065] Then, compare the specification information, color information and morphological information corresponding to the tobacco leaf image to be classified with the second preset tobacco leaf grade classification table having an association relationship with the "2nd first tobacco leaf grade information", and determine the second target tobacco leaf grade information, including: the preset specification information is length 50cm, width 30cm; the preset color information is brown; the preset morphological information is: no insect bite, no mildew, no defect. The second grade corresponding to the second target tobacco leaf grade information is 1L, where L indicates that the preset color information is brown.
[0066] Finally, combining the "first grade" and the "second grade", the classification result of the tobacco leaf image to be classified is C1L.
[0067] Figure 2 It is the second flow schematic diagram of the intelligent tobacco leaf grading method based on machine vision provided by the present invention, specifically including the following steps 201 to 210: Step 201, collect the tobacco leaf image to be graded.
[0068] Step 202, input the tobacco leaf image to be graded into the tobacco leaf position recognition model to obtain the tobacco leaf position type output by the tobacco leaf position recognition model; wherein, the tobacco leaf position type includes any one of the following: upper tobacco leaf, middle tobacco leaf, and lower tobacco leaf.
[0069] Step 203, based on the target detection algorithm, determine the pixel point coordinates corresponding to the contour boundary of the tobacco leaf in the tobacco leaf image to be graded.
[0070] Step 204, based on each pixel point coordinate, determine the distance between the two pixel points with the farthest vertical coordinate interval as the length of the tobacco leaf, and the distance between the two pixel points with the farthest horizontal coordinate interval as the width of the tobacco leaf; the length and width are the specification information of the tobacco leaf in the tobacco leaf image to be graded.
[0071] Step 205, obtain any one of the HSV color space information and the Lab color space information in the color space information of the tobacco leaf area surrounded by the contour boundary.
[0072] Step 206, based on any one of the HSV color space information and the Lab color space information, determine the color information of the tobacco leaf.
[0073] Step 207, input the tobacco leaf image to be graded into the tobacco leaf morphology recognition model to obtain the morphology information shown by the tobacco leaf morphology recognition model; wherein, the morphology information includes at least one of the following: the maturity of the tobacco leaf, the leaf structure of the tobacco leaf, the identity of the tobacco leaf, the oil content of the tobacco leaf, and the disability information of the tobacco leaf.
[0074] Step 208, compare the tobacco leaf position type with multiple first tobacco leaf grade information in the first preset tobacco leaf grade classification table, and determine the first grade corresponding to the first target tobacco leaf grade information as the first grading result corresponding to the tobacco leaf position type; the preset tobacco leaf position type in the first target tobacco leaf grade information is the same as the tobacco leaf position type; each first tobacco leaf grade information has an association relationship with multiple second preset tobacco leaf grade classification tables, the second preset tobacco leaf grade classification table includes multiple second tobacco leaf grade information, and each second tobacco leaf grade information includes preset specification information, preset color information, and preset morphology information; Step 209: Compare the specification information, color information, and morphological information with each second preset tobacco leaf grade classification table having an associated relationship with the first target tobacco leaf grade information, and determine the second grade corresponding to the second target tobacco leaf grade information as the second classification result corresponding to the tobacco leaf quality information; the preset specification information, preset color information, and preset morphological information in the second target tobacco leaf grade information are the same as the specification information, preset color information, and preset morphological information.
[0075] Step 210: Determine the first classification result and the second classification result as the classification result of the tobacco leaf image to be classified.
[0076] It should be noted that after obtaining the tobacco leaf position type, specification information, color information, and morphological information, in addition to implementing the above steps 208-210 to achieve tobacco leaf grading, the present invention also provides another implementation method for tobacco leaf grading, which can be specifically implemented through the following steps: Compare the tobacco leaf position type, specification information, color information, and morphological information with each tobacco leaf grade information in the preset tobacco leaf grade classification table; each tobacco leaf grade information includes a preset tobacco leaf position type, preset specification information, preset color information, and preset morphological information; determine the grade corresponding to the target tobacco leaf grade information as the classification result of the tobacco leaf image to be classified.
[0077] Next, the tobacco leaf intelligent grading device 300 based on machine vision provided by the present invention will be described. The tobacco leaf intelligent grading device 300 described below can be mutually corresponding and referenced with the tobacco leaf intelligent grading method described above. The tobacco leaf intelligent grading device 300 based on machine vision specifically includes the following modules: The acquisition module 301 is used to acquire the tobacco leaf image to be classified; The position recognition and quality analysis module 302 is used to recognize the tobacco leaf position corresponding to the tobacco leaf image to be classified based on a machine vision algorithm, and obtain the tobacco leaf position type corresponding to the tobacco leaf image to be classified; perform quality analysis on the tobacco leaf image to be classified, and determine the tobacco leaf quality information corresponding to the tobacco leaf image to be classified; the tobacco leaf quality information is used to reflect the quality of the tobacco leaf in the tobacco leaf image to be classified. The grading module 303 is used to compare the tobacco leaf position type and the tobacco leaf quality information with multiple tobacco leaf grade information in the preset tobacco leaf grade classification table, and determine the grade corresponding to the target tobacco leaf grade information in the preset tobacco leaf grade classification table as the classification result of the tobacco leaf image to be classified; the preset tobacco leaf position type and preset tobacco leaf quality information in the target tobacco leaf grade information are the same as the tobacco leaf position type and the tobacco leaf quality information corresponding to the tobacco leaf image to be classified, respectively.
[0078] The intelligent tobacco leaf grading device based on machine vision provided by the present invention collects the images of tobacco leaves to be graded, and then, based on the machine vision algorithm, identifies the tobacco leaf parts corresponding to the images of tobacco leaves to be graded and analyzes the quality, so as to automatically and accurately analyze the part types of tobacco leaves and the tobacco leaf quality information in the images of tobacco leaves to be graded; compare the tobacco leaf part types and the tobacco leaf quality information with multiple tobacco leaf grade information in the preset tobacco leaf grade classification table, and determine the grade corresponding to the target tobacco leaf grade information as the grading result of the images of tobacco leaves to be graded; wherein, the preset tobacco leaf part type and the preset tobacco leaf quality information in the target tobacco leaf grade information are respectively the same as the tobacco leaf part type and the tobacco leaf quality information corresponding to the images of tobacco leaves to be graded. Through the above method, the grade corresponding to the images of tobacco leaves to be graded can be automatically identified, the accuracy and efficiency of tobacco leaf grading are improved, and at the same time, no manual intervention is required during the whole tobacco leaf grade identification process, reducing the labor cost.
[0079] Optionally, the part identification and quality analysis module 302 is further configured to: Input the images of tobacco leaves to be graded into the tobacco leaf part identification model, and obtain the tobacco leaf part type output by the tobacco leaf part identification model; the tobacco leaf part type includes any one of the following: the upper part of the tobacco leaf, the middle part of the tobacco leaf, and the lower part of the tobacco leaf; Wherein, the tobacco leaf part identification model is trained based on multiple first tobacco leaf image samples, and each part of each first tobacco leaf image sample is labeled with a corresponding part type label; The tobacco leaf part identification model is a YOLOv8 model, and an explicit vision center EVC module is deployed in the YOLOv8 model. The EVC module is used to capture the long-distance dependence relationship and local corner area information of the whole image of the tobacco leaves to be graded, so that the tobacco leaf part identification model determines the part type based on the long-distance dependence relationship and the local corner area information.
[0080] Optionally, the quality information includes at least one of the following: the specification information of the tobacco leaf, the color information of the tobacco leaf, and the morphological information of the tobacco leaf; Optionally, the part identification and quality analysis module 302 is further configured to perform at least one of the following: Determine the specification information and the color information based on the target detection algorithm; Input the tobacco leaf image to be graded into the tobacco leaf morphology recognition model to obtain the morphology information shown by the tobacco leaf morphology recognition model; wherein, the tobacco leaf morphology recognition model is trained based on a plurality of second tobacco leaf image samples, and each second tobacco leaf image sample is labeled with a corresponding morphology information label; the tobacco leaf morphology recognition model is a YOLOv8 model, and an EVC module is deployed in the YOLOv8 model, and the EVC module is used to capture the long-distance dependence and local corner region information of the entire length of the tobacco leaf image to be graded, so that the tobacco leaf morphology recognition model determines the morphology information based on the long-distance dependence and the local corner region information.
[0081] Optionally, the specification information includes the length and width of the tobacco leaf; The part recognition and quality analysis module 302 is further configured to: Based on the object detection algorithm, determine the pixel point coordinates corresponding to the contour boundary of the tobacco leaf in the tobacco leaf image to be graded; Based on each of the pixel point coordinates, determine the distance between the two pixel points with the farthest vertical coordinate interval as the length, and the distance between the two pixel points with the farthest horizontal coordinate interval as the width; Based on the color space information of the tobacco leaf area surrounded by the contour boundary, determine the color information.
[0082] Optionally, the part recognition and quality analysis module 302 is further configured to: Based on any one of the HSV color space information and the Lab color space information, determine the color information.
[0083] Optionally, the morphology information includes at least one of the following: The maturity of the tobacco leaf; The leaf structure of the tobacco leaf; The identity of the tobacco leaf, which is used to represent the thickness of the tobacco leaf; The oil content of the tobacco leaf; The disability information of the tobacco leaf, and the disability information includes at least one of the following: the degree of insect bite, the degree of mildew, and the degree of mutilation.
[0084] Figure 4 Illustrated is a schematic diagram of the physical structure of an electronic device, such as Figure 4As shown in the figure, the electronic device may include: a processor 410, a communications interface 420, a memory 430, and a communication bus 440. Among them, the processor 410, the communications interface 420, and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logical instructions in the memory 430 to execute the intelligent grading method for tobacco leaves based on machine vision. The method includes: collecting an image of the tobacco leaves to be graded; identifying the tobacco leaf part corresponding to the image of the tobacco leaves to be graded based on a machine vision algorithm to obtain the type of the tobacco leaf part corresponding to the image of the tobacco leaves to be graded; performing quality analysis on the image of the tobacco leaves to be graded to determine the tobacco leaf quality information corresponding to the image of the tobacco leaves to be graded; the tobacco leaf quality information is used to reflect the quality of the tobacco leaves in the image of the tobacco leaves to be graded; comparing the type of the tobacco leaf part and the tobacco leaf quality information with multiple tobacco leaf grade information in a preset tobacco leaf grade classification table, and determining the grade corresponding to the target tobacco leaf grade information in the preset tobacco leaf grade classification table as the grading result of the image of the tobacco leaves to be graded; the preset tobacco leaf part type and the preset tobacco leaf quality information in the target tobacco leaf grade information are the same as the type of the tobacco leaf part and the tobacco leaf quality information corresponding to the image of the tobacco leaves to be graded, respectively.
[0085] In addition, when the logical instructions in the above-mentioned memory 430 are implemented in the form of software functional units and sold or used as independent products, they may be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, may be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs, Read-Only Memories), random access memories (RAMs, Random Access Memories), magnetic disks, or optical discs that can store program codes.
[0086] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the machine vision-based intelligent tobacco leaf grading method provided by the above-mentioned various methods. The method includes: collecting an image of the tobacco leaf to be graded; based on a machine vision algorithm, identifying the tobacco leaf part corresponding to the image of the tobacco leaf to be graded to obtain the type of the tobacco leaf part corresponding to the image of the tobacco leaf to be graded; performing quality analysis on the image of the tobacco leaf to be graded to determine the tobacco leaf quality information corresponding to the image of the tobacco leaf to be graded; the tobacco leaf quality information is used to reflect the quality of the tobacco leaf in the image of the tobacco leaf to be graded; comparing the type of the tobacco leaf part and the tobacco leaf quality information with multiple tobacco leaf grade information in a preset tobacco leaf grade classification table, and determining the grade corresponding to the target tobacco leaf grade information in the preset tobacco leaf grade classification table as the grading result of the image of the tobacco leaf to be graded; the preset tobacco leaf part type and the preset tobacco leaf quality information in the target tobacco leaf grade information are respectively the same as the type of the tobacco leaf part and the tobacco leaf quality information corresponding to the image of the tobacco leaf to be graded.
[0087] On another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is implemented to execute the machine vision-based intelligent tobacco leaf grading method provided by the above-mentioned various methods. The method includes: collecting an image of the tobacco leaf to be graded; based on a machine vision algorithm, identifying the tobacco leaf part corresponding to the image of the tobacco leaf to be graded to obtain the type of the tobacco leaf part corresponding to the image of the tobacco leaf to be graded; performing quality analysis on the image of the tobacco leaf to be graded to determine the tobacco leaf quality information corresponding to the image of the tobacco leaf to be graded; the tobacco leaf quality information is used to reflect the quality of the tobacco leaf in the image of the tobacco leaf to be graded; comparing the type of the tobacco leaf part and the tobacco leaf quality information with multiple tobacco leaf grade information in a preset tobacco leaf grade classification table, and determining the grade corresponding to the target tobacco leaf grade information in the preset tobacco leaf grade classification table as the grading result of the image of the tobacco leaf to be graded; the preset tobacco leaf part type and the preset tobacco leaf quality information in the target tobacco leaf grade information are respectively the same as the type of the tobacco leaf part and the tobacco leaf quality information corresponding to the image of the tobacco leaf to be graded.
[0088] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative labor.
[0089] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0090] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A tobacco leaf intelligent grading method based on machine vision, characterized in that: include: Collect images of tobacco leaves to be graded; Based on a machine vision algorithm, the tobacco leaf part corresponding to the tobacco leaf image to be graded is identified to obtain the type of the tobacco leaf part corresponding to the tobacco leaf image to be graded; Performing quality analysis on the tobacco leaf image to be graded to determine tobacco leaf quality information corresponding to the tobacco leaf image to be graded; The tobacco leaf quality information is used to reflect the quality of the tobacco leaves in the tobacco leaf image to be graded; The tobacco leaf part type and the tobacco leaf quality information are compared with multiple tobacco leaf grade information in a preset tobacco leaf grade classification table, and the grade corresponding to the target tobacco leaf grade information in the preset tobacco leaf grade classification table is determined as the grading result of the tobacco leaf image to be graded; the preset tobacco leaf part type and the preset tobacco leaf quality information in the target tobacco leaf grade information are respectively the same as the tobacco leaf part type and the tobacco leaf quality information corresponding to the tobacco leaf image to be graded.
2. The tobacco leaf intelligent grading method based on machine vision according to claim 1 is characterized in that: The step of identifying the tobacco leaf part corresponding to the tobacco leaf image to be graded to obtain the type of the tobacco leaf part corresponding to the tobacco leaf image to be graded includes: Inputting the tobacco leaf image to be classified into a tobacco leaf part recognition model to obtain the tobacco leaf part type output by the tobacco leaf part recognition model; the tobacco leaf part type includes any one of the following: the upper part of the tobacco leaf, the middle part of the tobacco leaf, and the lower part of the tobacco leaf; The tobacco leaf part recognition model is obtained by training based on a plurality of first tobacco leaf image samples, and each part of each first tobacco leaf image sample is annotated with a corresponding part type label; The tobacco leaf part recognition model is a YOLOv8 model, in which an explicit visual center EVC module is deployed. The EVC module is used to capture the global long-distance dependencies and local corner area information of the tobacco leaf image to be classified, so that the tobacco leaf part recognition model determines the part type based on the global long-distance dependencies and the local corner area information.
3. The tobacco leaf intelligent grading method based on machine vision according to claim 1 is characterized in that: The quality information includes at least one of the following: specification information of the tobacco leaves, color information of the tobacco leaves, and morphological information of the tobacco leaves; The step of performing quality analysis on the image of the tobacco leaves to be graded to determine the tobacco leaf quality information corresponding to the image of the tobacco leaves to be graded includes at least one of the following: Determining the specification information and the color information based on a target detection algorithm; The tobacco leaf image to be classified is input into a tobacco leaf morphology recognition model to obtain the morphology information shown by the tobacco leaf morphology recognition model; wherein the tobacco leaf morphology recognition model is trained based on multiple second tobacco leaf image samples, and each second tobacco leaf image sample is annotated with a corresponding morphology information label; the tobacco leaf morphology recognition model is a YOLOv8 model, and an EVC module is deployed in the YOLOv8 model, and the EVC module is used to capture the global long-distance dependency and local corner area information of the tobacco leaf image to be classified, so that the tobacco leaf morphology recognition model determines the morphology information based on the global long-distance dependency and the local corner area information.
4. The tobacco leaf intelligent grading method based on machine vision according to claim 3 is characterized in that: The specification information includes the length and width of the tobacco leaf; The determining the specification information and the color information based on the target detection algorithm includes: Based on the target detection algorithm, determining the pixel coordinates corresponding to the contour boundary of the tobacco leaves in the image of the tobacco leaves to be classified; Based on the coordinates of each pixel point, determine the distance between the two pixel points with the farthest vertical coordinate interval as the length, and the distance between the two pixel points with the farthest horizontal coordinate interval as the width; The color information is determined based on the color space information of the tobacco leaf area surrounded by the contour boundary.
5. The method for intelligent tobacco grading based on machine vision according to claim 4, characterized in that: The color space information includes any one of HSV color space information and Lab color space information; The determining of the color information based on the standard color space conversion information of the tobacco leaf area surrounded by the contour boundary includes: The color information is determined based on any one of the HSV color space information and the Lab color space information.
6. The tobacco leaf intelligent grading method based on machine vision according to any one of claims 3 to 5, characterized in that: The morphology information includes at least one of the following: the maturity of the tobacco leaves; The leaf structure of the tobacco leaf; The identity of the tobacco leaf is used to indicate the thickness of the tobacco leaf; Oil content of the tobacco leaves; The damage information of the tobacco leaves includes at least one of the following: the degree of insect bites, the degree of mold and the degree of defect.
7. A tobacco leaf intelligent grading device based on machine vision, characterized in that: include: A collection module, used for collecting images of tobacco leaves to be graded; A part recognition and quality analysis module is used to recognize the tobacco leaf part corresponding to the tobacco leaf image to be graded based on a machine vision algorithm, and obtain the type of tobacco leaf part corresponding to the tobacco leaf image to be graded; Performing quality analysis on the tobacco leaf image to be graded to determine tobacco leaf quality information corresponding to the tobacco leaf image to be graded; The tobacco leaf quality information is used to reflect the quality of the tobacco leaves in the tobacco leaf image to be graded; A grading module is used to compare the tobacco leaf part type and the tobacco leaf quality information with multiple tobacco leaf grade information in a preset tobacco leaf grade classification table, and determine the grade corresponding to the target tobacco leaf grade information in the preset tobacco leaf grade classification table as the grading result of the tobacco leaf image to be graded; the preset tobacco leaf part type and preset tobacco leaf quality information in the target tobacco leaf grade information are respectively the same as the tobacco leaf part type and the tobacco leaf quality information corresponding to the tobacco leaf image to be graded.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the machine vision-based intelligent tobacco grading method as described in any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the machine vision-based intelligent tobacco grading method as described in any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the machine vision-based intelligent tobacco grading method as described in any one of claims 1 to 6 is implemented.