Tea detection and classification method and system based on image recognition
By using prior data on tea leaf shape and topological constraint data on buds and leaves for constrained contour completion and construction of heterogeneous topological graphs of buds and leaves, the problems of morphological restoration and structural recognition in occluded scenes in tea leaf image detection are solved, thereby improving classification accuracy and reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- RIZHAO CHUNMING MACHINERY MFG
- Filing Date
- 2026-05-13
- Publication Date
- 2026-06-19
AI Technical Summary
Existing tea image detection and classification methods are inaccurate in segmentation under adhesion and occlusion scenarios, and cannot accurately recover the outline and bud and leaf structure of the underlying tea leaves. They also lack morphological constraints and bud and leaf topology guidance, resulting in low classification reliability.
By acquiring tea leaf images, foreground and instance segmentation are performed to identify occlusion hierarchy. Constrained contour completion is carried out using prior tea leaf shape data and bud and leaf topological constraint data to construct a heterogeneous topological map of buds and leaves. Topological consistency, structural integrity and occlusion correction features are generated to achieve comprehensive tea leaf classification.
It significantly improves the accuracy and structural integrity of tea leaf morphology restoration in occluded scenarios, enhances classification accuracy and reliability, and provides an interpretable, multi-dimensional detection and classification scheme.
Smart Images

Figure CN122244563A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of tea detection and classification technology, specifically to a tea detection and classification method and system based on image recognition. Background Technology
[0002] With the development of image recognition technology and computer vision algorithms, automatic tea detection and classification methods are gradually being applied in food processing, intelligent sorting, and quality control. Traditional tea detection methods rely on human experience or simple image processing algorithms to characterize the morphology, color, and bud / leaf structure of individual tea leaves. In recent years, deep learning methods such as convolutional neural networks (CNNs), instance segmentation models, and end-to-end classification models have been gradually introduced into tea detection tasks. Through feature extraction and end-to-end training, tea grade identification and structural analysis are achieved, significantly improving processing efficiency and automation levels. Simultaneously, the application of multi-source, multi-angle acquisition, and data augmentation technologies has improved the system's robustness in complex environments, providing a feasible technical path for tea sorting and online detection.
[0003] However, existing technologies still have significant limitations in scenarios involving tea leaf adhesion, occlusion, and complex stacking. On the one hand, traditional image processing methods and end-to-end deep learning models struggle to accurately segment overlapping tea leaf individuals, and their ability to reconstruct the contours of occluded instances in the lower layers and restore the bud and leaf structures is insufficient, leading to a significant decrease in the accuracy of grade classification and structure recognition. On the other hand, existing methods lack constraints on the natural morphology and physiological topology of tea leaves, relying solely on pixel-level or texture-level features. This fails to ensure that the completed contours match the actual bud and leaf connection rules, easily resulting in misalignment of bud tips, midribs, or tea stems, further affecting the reliability of comprehensive classification features.
[0004] Furthermore, existing methods cannot quantify and correct the impact of occlusion on classification decisions in cases of severe occlusion or stacking, leading to a decrease in the reliability of classification results. To address these shortcomings, this invention proposes a tea detection and classification method based on occlusion hierarchy recognition, constrained contour completion, and bud-leaf heterogeneous topology analysis. This method achieves accurate contour restoration of occluded tea leaves, complete identification of bud-leaf structures, and generation of occlusion correction features, thereby significantly improving classification accuracy and structural integrity in complex scenarios. It solves the problem that existing technologies cannot simultaneously address morphological restoration, structural recognition, and classification reliability. Summary of the Invention
[0005] In view of the above-mentioned problems, the present invention is proposed.
[0006] Therefore, the technical problem solved by this invention is that existing tea image detection and classification methods have the following problems: inaccurate segmentation of tea leaves that are stuck together and occluded, insufficient ability to complete the outline and bud and leaf structure of the lower layer of occluded tea leaves, lack of morphological constraints and bud and leaf topology guidance leading to low comprehensive classification reliability, and how to achieve accurate completion of the outline of occluded tea leaves, complete recognition of bud and leaf structure and generation of reliable comprehensive classification features.
[0007] To solve the above-mentioned technical problems, the present invention provides the following technical solution: In a first aspect, embodiments of the present invention provide a tea detection and classification method based on image recognition, comprising the following steps: S1: Obtain the tea leaf image to be detected, and perform foreground segmentation and instance segmentation on the tea leaf image to be detected to obtain multiple tea leaf candidate instances; S2: Perform adhesion and occlusion recognition on the multiple tea candidate instances to determine the occlusion hierarchy relationship between each tea candidate instance; S3: Based on the occlusion hierarchy, determine the candidate tea leaf instances with occlusion and their contour regions to be filled, and based on the preset tea leaf shape prior data and bud and leaf topological constraint data, perform constrained contour filling on the contour regions to be filled to obtain reconstructed tea leaf instances. S4: Perform structural region identification on the reconstructed tea leaf instance to obtain the bud tip region, leaf region, tea stem region, and main vein region; S5: Based on the spatial connection relationship between the bud tip region, leaf region, tea stem region and main vein region, construct a bud-leaf heterogeneous topology map, and generate topological consistency features, structural integrity features and occlusion correction features based on the bud-leaf heterogeneous topology map. S6: Generate a comprehensive tea classification feature based on the topological consistency feature, the structural integrity feature, and the occlusion correction feature, and output the tea detection and classification result based on the comprehensive tea classification feature.
[0008] As a preferred embodiment of the image recognition-based tea detection and classification method of the present invention, step S1 specifically includes: The image of the tea leaves to be detected is subjected to illumination equalization and background separation to obtain the foreground region of the tea leaves; The foreground region of the tea leaves is segmented and its contours are extracted to obtain multiple candidate tea leaf instances and their corresponding candidate contours.
[0009] As a preferred embodiment of the image recognition-based tea detection and classification method of the present invention, step S2 specifically includes: Based on the candidate contours corresponding to each tea candidate instance, determine the contour overlap relationship, boundary interruption relationship, and region coverage relationship between adjacent tea candidate instances; Based on the contour overlap relationship, the boundary interruption relationship, and the region coverage relationship, determine the adhesion and occlusion status of each tea candidate instance, and distinguish between upper occluded instances and lower occluded instances. Based on the distinction between the upper-layer occluded instance and the lower-layer occluded instance, the occlusion hierarchy relationship between each tea candidate instance is determined.
[0010] As a preferred embodiment of the image recognition-based tea detection and classification method of the present invention, the preset tea shape prior data and bud / leaf topological constraint data include: The prior data on tea shape includes the outline morphology of the tea leaves, the length-to-width ratio of the leaves, the distribution of the curvature of the leaf margins, the direction of the main vein extension, and the connection position of the tea stem. The bud and leaf topological constraint data includes the connection relationship between the bud tip and the leaf, the connection relationship between the leaf and the tea stem, and the directional correspondence between the midrib and the leaf. The tea leaf shape prior data and the bud and leaf topological constraint data are both pre-constructed based on standard tea leaf samples.
[0011] As a preferred embodiment of the image recognition-based tea detection and classification method of the present invention, the step of performing constrained contour completion on the region to be completed based on preset tea shape prior data and bud and leaf topological constraint data to obtain a reconstructed tea instance includes: Contour completion energy function is constructed, which includes leaf margin continuity constraint term, midrib direction continuity constraint term, tea leaf shape prior constraint term, and bud-leaf topological consistency constraint term; With the goal of minimizing the contour completion energy function, constrained contour completion is performed on the contour region to be completed to obtain a reconstructed tea instance that conforms to the prior data of tea shape and the topological constraint data of bud and leaf.
[0012] As a preferred embodiment of the image recognition-based tea detection and classification method of the present invention, step S4 specifically includes: For the reconstructed tea leaf instance and the unoccluded tea leaf candidate instance, the outline skeleton, main vein direction and local structural endpoints of the instance are extracted respectively. The bud tip region is determined based on the endpoints of the local structure, the leaf region is determined based on the area enclosed by the outline skeleton, the tea stem region is determined based on the slender connecting structure connected to the leaf region, and the main vein region is determined based on the linear texture direction of the main vein.
[0013] As a preferred embodiment of the image recognition-based tea detection and classification method of the present invention, step S5 specifically includes: For each tea instance, the identified bud tip region, leaf region, tea stem region, and main vein region are used as heterogeneous nodes. Based on the spatial connection relationship between each region, topological connection edges between nodes are constructed to form the bud and leaf heterogeneous topological graph of the corresponding tea instance. Based on the node connection relationships of the bud-leaf heterogeneous topology graph and the preset bud-leaf topology constraint data, a topology consistency feature is generated. Based on the node coverage of the heterogeneous topology graph of buds and leaves and the preset prior data of tea leaf shape, structural integrity features are generated. Based on the occlusion state and occlusion hierarchy of the tea leaf instances corresponding to the heterogeneous topology of the buds and leaves, occlusion correction features are generated.
[0014] As a preferred embodiment of the image recognition-based tea detection and classification method of the present invention, step S6 specifically includes: The topological consistency feature, structural integrity feature, and occlusion correction feature are weighted and fused to generate a comprehensive tea classification feature; The comprehensive classification features of tea are matched with preset classification rules to obtain tea grade classification results, structural anomaly detection results, and integrity assessment results. The tea grade classification results, structural anomaly detection results, and integrity assessment results are combined to output the final tea detection and classification results.
[0015] Secondly, embodiments of the present invention provide a tea detection and classification system based on image recognition, comprising: Image acquisition and instance segmentation module: acquires the tea image to be detected, performs foreground segmentation and instance segmentation on the tea image to be detected, and obtains multiple tea candidate instances; Occlusion recognition module: performs adhesion occlusion recognition on the multiple tea candidate instances and determines the occlusion hierarchy relationship between each tea candidate instance; Contour completion module: Based on the occlusion hierarchy, determine the candidate tea leaf instances with occlusion and their contour regions to be completed, and based on the preset tea leaf shape prior data and bud and leaf topological constraint data, perform constrained contour completion on the contour regions to be completed to obtain reconstructed tea leaf instances; Structural Region Recognition Module: Performs structural region recognition on the reconstructed tea leaf instance to obtain the bud tip region, leaf region, tea stem region, and main vein region; Topology analysis module: Based on the spatial connectivity between the bud tip region, leaf region, tea stem region and main vein region, construct a heterogeneous topology map of bud and leaf, and generate topological consistency features, structural integrity features and occlusion correction features based on the heterogeneous topology map of bud and leaf; Comprehensive classification module: Generates comprehensive tea classification features based on the topological consistency feature, the structural integrity feature, and the occlusion correction feature, and outputs tea detection and classification results based on the comprehensive tea classification features.
[0016] The beneficial effects of this invention are as follows: By introducing a constrained contour completion mechanism based on prior data of tea shape and topological constraint data of buds and leaves, the four constraints of leaf edge continuity, main vein direction continuity, tea morphology conformity, and bud-leaf topological consistency are synergistically optimized in the energy function. This ensures that the completed tea contour has structural compliance on the basis of visual rationality, significantly improving the accuracy of morphological restoration in occluded scenarios. By constructing a heterogeneous topological graph of buds and leaves, the structural regions of tea and their spatial connections are transformed into computable graph features. The generated topological consistency features, structural integrity features, and occlusion correction features directly correspond to the core judgment factors in tea grade evaluation, realizing a paradigm upgrade from texture classification to structural reasoning. Through adaptive weight fusion based on occlusion correction features and matching with preset classification rules, the credibility contribution of each feature is dynamically balanced in the classification decision, and the grade classification results, structural anomaly detection results, and integrity evaluation results are output simultaneously. This provides an interpretable and traceable full-dimensional detection and classification scheme for automated sorting, quality grading, and process optimization of tea. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein: Figure 1 The first embodiment of the present invention provides an overall flowchart of a tea detection and classification method based on image recognition; Figure 2 This is a module connection diagram of a tea detection and classification system based on image recognition, provided for the third embodiment of the present invention. Detailed Implementation
[0018] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of the present invention.
[0019] Example 1, referring to Figure 1 This invention provides a tea detection and classification method based on image recognition, as one embodiment of the present invention.
[0020] S1: Obtain the tea leaf image to be detected, and perform foreground segmentation and instance segmentation on the tea leaf image to obtain multiple tea leaf candidate instances.
[0021] The image of the tea leaves to be detected is subjected to illumination equalization and background separation to obtain the foreground region of the tea leaves; The foreground region of the tea leaves is segmented and its contours are extracted to obtain multiple candidate tea leaf instances and their corresponding candidate contours.
[0022] Step S1 provides standardized and interference-resistant basic input data for the entire image recognition-based tea detection and classification method. The core is to strictly follow the process defined in the claims to complete the compliant acquisition, standardized preprocessing and individual tea target segmentation of the tea images to be detected, and finally output the tea candidate instances and corresponding candidate contours that meet the requirements of subsequent adhesion and occlusion recognition and contour completion. The specific implementation process is carried out in its entirety according to the following process.
[0023] It should be noted that the first step is to acquire the image of the tea leaves to be inspected. The core of this operation is to collect a recognizable digital image containing the tea leaves. This is suitable for two main application scenarios: online inspection in industrial production lines and offline static inspection in laboratories. In online scenarios, an industrial area scan camera with a ring shadowless light source is used for acquisition. In offline scenarios, a digital camera or high-definition scanning equipment can be used for acquisition. The acquired image can be a two-dimensional color image or a grayscale image. The resolution of a single image is limited to the range of 1024×768 pixels to 4000×3000 pixels. It should also be noted that within this resolution range, a resolution lower than 1024×768 pixels will result in the loss of key morphological details such as the leaf edges and main veins, while a resolution higher than 4000×3000 pixels will significantly increase the amount of computational work and reduce detection efficiency. The preferred resolution is no less than 1920×1080 pixels, which can balance detail recognition and computational efficiency. During online data acquisition, the camera is fixed at a height of 30 to 50 centimeters above the tea delivery plane. Below 30 centimeters, a single image may not be able to cover the entire detection area, while above 50 centimeters, the edge details of the tea leaves will be blurred. This ensures that the acquired image can completely cover all tea leaves within the detection area.
[0024] Furthermore, illumination equalization processing is performed on the acquired tea leaf images to be detected. The core function of this operation is to eliminate the differences in brightness caused by ambient light fluctuations, local reflections from the tea leaves, and shadow occlusion during image acquisition, avoiding misjudgments in subsequent foreground segmentation and contour extraction, and providing a uniform brightness basis for subsequent tea leaf edge recognition. In specific implementation, two methods can be used: adaptive histogram equalization or local brightness correction. The brightness value of each pixel in the tea leaf image to be detected is uniformly adjusted to adjust the brightness distribution of the entire image to a uniform state. It should be noted that the uniform state here has a clear quantitative definition standard: the average brightness difference between any two 100×100 pixel local areas in the image does not exceed 15 gray levels. If the brightness difference of any local area exceeds this range, the brightness adjustment operation is repeated until the entire image meets the brightness uniformity requirement. It should also be noted that the single adjustment range of local brightness is limited to within ±30% of the original image brightness value. Exceeding this range will lead to excessive image enhancement, artifacts, and damage to the true morphological characteristics of the tea leaves. After completing the illumination equalization process, the overall contrast of the image is effectively enhanced, and the clarity of the tea outline in the original shadow area is improved. The quantitative standard for the improvement in clarity is: in the processed image, the gray-scale difference between the two sides of the tea boundary is increased by at least 20% compared to before processing, where the gray-scale difference refers to the difference between the average gray-scale values of 5 pixels on each side of the boundary.
[0025] Furthermore, a background separation operation is performed on the tea leaf image to be detected after the illumination equalization processing is completed to obtain the tea leaf foreground region. The core function of this operation is to accurately separate the tea leaf target in the tea leaf image from non-tea leaf background regions such as the conveyor belt, detection tray, and environmental shadows, and eliminate the interference of background regions on subsequent individual tea leaf identification and adhesion determination. In practical implementation, two methods can be selected based on the detection scenario: background subtraction or color space thresholding. Both methods have clear quantitative execution standards: The first is background subtraction, which first compares the pre-collected blank background image without tea leaves with the image of tea leaves to be detected at the pixel level. Areas where the difference between the pixel gray value and the corresponding position gray value of the blank background is less than 20 gray levels are determined as background areas, and areas where the difference is greater than or equal to 20 gray levels are determined as initial foreground areas. The second is color space thresholding, which converts the RGB color image to the HSV color space and uses the numerical differences in hue and saturation channels between tea leaves and background to set a dual-channel joint threshold to complete the segmentation. The hue value distribution range of green tea leaves is 60 to 180 degrees, and the saturation value is not less than 30 (range of 0 to 255). The saturation value of gray / black conveyor belt background is usually less than 30, thus distinguishing foreground and background pixels. It should also be noted that after the initial foreground region is determined, morphological smoothing processing needs to be performed on the initial foreground region to eliminate isolated noise in the region and break the weak connection between the shadow and the main body of the tea leaves. The number of morphological smoothing operations is limited to 1 to 3 times. More than 3 operations will cause the loss of details of the tea leaf edge contour, while less than 1 operation will not effectively eliminate isolated noise in the image, and finally obtain a complete and interference-free tea leaf foreground region.
[0026] Furthermore, instance segmentation is performed on the obtained tea foreground region. The core function of this operation is to independently separate multiple stacked and adjacent tea leaves in the foreground region, generating a unique recognition region for each tea leaf, providing independent individual units for subsequent adhesion and occlusion level determination. In specific implementation, either a deep learning-based instance segmentation model or a traditional method based on connected component analysis can be used. If a deep learning model is used, a pre-annotated instance segmentation network is required to classify and recognize the tea foreground region pixel by pixel, assigning a unique integer recognition number to each independent tea leaf, and generating a candidate tea leaf instance for each individual. This model is pre-trained using no fewer than 10,000 manually annotated tea leaf images, with no fewer than 5 annotated tea leaves per training image, ensuring that the trained model achieves an accuracy of no less than 95% in segmenting adhered and adjacent tea leaves. If a traditional method is used, edge detection and connected component analysis can be used to label the closed contours of the tea foreground region one by one, assigning a unique recognition number to each independent closed contour, and generating a candidate tea leaf instance accordingly. It should also be noted that the instance segmentation here must ensure that tightly stacked and partially overlapping tea leaves can be separated independently, so as to avoid multiple tea leaves being merged into the same instance, thus providing an independent individual basis for the adhesion and occlusion recognition in the subsequent step S2.
[0027] Furthermore, a contour extraction operation is performed on each tea candidate instance with a unique identification number to obtain the candidate contour corresponding to each tea candidate instance. The core function of this operation is to extract the corresponding outer edge contour for each tea candidate instance, providing core basic data for the contour overlap and boundary interruption determination in the subsequent step S2. In specific implementation, edge pixels are continuously extracted along the outer edge of the identification area of each tea candidate instance in a clockwise direction to form a closed pixel sequence, which is the candidate contour of the corresponding tea candidate instance. It should also be noted that during the contour extraction process, scattered edge fragments with a length of less than 10 pixels are removed to avoid generating invalid contours due to local noise, ensuring that each candidate contour obtained in the end is the complete closed outer edge of the corresponding tea individual. It should be noted that the term "tea leaf candidate instance" is used here because in the case of stacked and adhered scenes, some extracted instances may have abnormal situations such as overlapping contours and broken boundaries. They cannot be used as the final complete tea leaf unit and need to be processed for adhesion and occlusion recognition and contour completion in subsequent steps. Therefore, they are called "candidates". For tea leaf candidate instances with clear contours and no overlap with other instances, their candidate contours are the real contours of the individual tea leaf and can be directly used for subsequent structural region recognition.
[0028] Furthermore, after completing all the above operations, multiple tea candidate instances with unique identification numbers and corresponding complete closed candidate contours can be obtained. This provides complete, accurate, and standardized input data for the subsequent adhesion and occlusion recognition and occlusion hierarchy determination operations in step S2, ensuring that the contour completion and feature extraction operations for adhesion and occlusion scenarios can be executed stably.
[0029] S2: Perform adhesion and occlusion recognition on the multiple tea candidate instances to determine the occlusion hierarchy relationship between each tea candidate instance.
[0030] Based on the candidate contours corresponding to each tea candidate instance, determine the contour overlap relationship, boundary interruption relationship, and region coverage relationship between adjacent tea candidate instances; Based on the contour overlap relationship, the boundary interruption relationship, and the region coverage relationship, determine the adhesion and occlusion status of each tea candidate instance, and distinguish between upper occluded instances and lower occluded instances. Based on the distinction between the upper-layer occluded instance and the lower-layer occluded instance, the occlusion hierarchy relationship between each tea candidate instance is determined.
[0031] The preset tea leaf shape prior data and bud / leaf topological constraint data include: The prior data on tea shape includes the outline morphology of the tea leaves, the length-to-width ratio of the leaves, the distribution of the curvature of the leaf margins, the direction of the main vein extension, and the connection position of the tea stem. The bud and leaf topological constraint data includes the connection relationship between the bud tip and the leaf, the connection relationship between the leaf and the tea stem, and the directional correspondence between the midrib and the leaf. The tea leaf shape prior data and the bud and leaf topological constraint data are both pre-constructed based on standard tea leaf samples.
[0032] It should be noted that step S2 follows the output of step S1. The core task is to identify the adhesion and occlusion of multiple tea candidate instances obtained in S1, accurately determine the stacking and occlusion relationship between individual tea leaves, and finally output the occlusion hierarchy relationship between each tea candidate instance. This provides the core judgment basis for the localization of the contour region to be filled and the execution of constrained contour completion in the subsequent step S3.
[0033] The core process of step S2 is as follows: Identify the adhesion and occlusion of the multiple tea candidate instances to determine the occlusion hierarchy among them. Specifically, this includes determining the contour overlap, boundary interruption, and region coverage relationships between adjacent tea candidate instances based on their corresponding candidate contours; determining the adhesion and occlusion state of each tea candidate instance based on the contour overlap, boundary interruption, and region coverage relationships, and distinguishing between upper-layer occluded instances and lower-layer occluded instances; and determining the occlusion hierarchy among the tea candidate instances based on the distinction between the upper-layer occluded instances and the lower-layer occluded instances. The specific implementation process of this step is as follows.
[0034] Furthermore, the first step is to extract the associated features of adjacent tea candidate instances. The core is to determine the three major associations between adjacent tea candidate instances based on the closed candidate contours corresponding to each tea candidate instance, so as to provide a quantitative basis for subsequent adhesion and occlusion state determination.
[0035] The first category is contour overlap, which refers to the overlapping and covering relationship between the regions enclosed by the candidate contours of two adjacent tea candidate instances in planar space. In specific implementation, the overlapping area of the regions enclosed by the two adjacent candidate contours is calculated, as well as the proportion of the overlapping area to the total area enclosed by the contour of a single candidate instance. When the proportion of the overlapping area to the total area of any candidate instance is ≥5%, it is determined that there is a valid contour overlap relationship between the two instances. It should also be noted that the 5% threshold here is the lower limit for determining effective adhesion. Overlapping areas below 5% are mostly invalid overlaps caused by image noise and jagged edges, and do not need to be included in the adhesion occlusion determination range, which can avoid misjudgment.
[0036] The second category is boundary interruption relationships, which refers to the abnormal situation where the contour lines are discontinuous or the endpoints abruptly change on the closed candidate contour of a single tea leaf candidate instance. In specific implementation, the slope of the coordinate change of two adjacent contour pixels is calculated along the clockwise pixel sequence of the candidate contour. When the slope change of three or more consecutive pixels exceeds 45 degrees and the contour has a non-closed breakpoint, it is determined that there is a boundary interruption at that position. It should also be noted that when the number of boundary interruption points on a single candidate contour is ≥2, it is determined that the instance has a valid boundary interruption relationship, which completely matches the real morphological features of the contour break after the tea leaf is occluded.
[0037] The third category is region coverage relationship, which refers to the pixel-level coverage relationship between two candidate tea leaf instances with overlapping contours within the overlapping area. In specific implementation, the continuity of the contours of the two instances in the overlapping area is determined based on the pixel grayscale and texture continuity features within the overlapping area. Instances whose contour lines can completely pass through the overlapping area without interruption are determined to have a region coverage relationship with the other instance. It should also be noted that the region coverage relationship is the core basis for distinguishing between upper and lower occluded instances. The covering one is the upper instance, and the covered one is the lower instance.
[0038] Furthermore, based on the aforementioned determined contour overlap, boundary interruption, and region coverage relationships, the adhesion and occlusion status of each tea leaf candidate instance is comprehensively determined, and upper-layer occluded instances are distinguished from lower-layer occluded instances. It should be noted that the adhesion and occlusion status is divided into three categories: unoccluded state, upper-layer occluded state, and lower-layer occluded state. Specific determination rules are set with clear quantitative standards; the final state can only be confirmed if two or more correlation relationships are matched simultaneously, avoiding misjudgments caused by single feature anomalies and ensuring that the state determination accuracy is no less than 98%. When a tea leaf candidate instance has no effective contour overlap relationship or no boundary interruption relationship, it is directly determined to be an unoccluded state and does not belong to the upper occluded instance or the lower occluded instance. When a tea leaf candidate instance has a valid contour overlap relationship with other instances, and there is a region coverage relationship with the overlapping instances and no valid boundary interruption relationship with itself, it is determined to be an upper-layer occlusion state, corresponding to an upper-layer occlusion instance. When a tea leaf candidate instance has a valid contour overlap with other instances, is covered by the region of other instances, and has a valid boundary interruption relationship, it is determined to be in a state of occlusion of the lower layer, corresponding to an occluded instance of the lower layer.
[0039] Furthermore, based on the distinction between upper-layer occluded instances and lower-layer occluded instances, the occlusion hierarchy among the candidate tea leaf instances is determined. It should be noted that the occlusion hierarchy is quantified using integer hierarchy numbers; the smaller the hierarchy number, the higher the instance is in the stacking structure and the lower the degree of occlusion. The specific hierarchy division rules are as follows: Unoccluded tea candidate instances, and tea candidate instances that are only occluded instances at the upper level and have no occluded features, are defined with an occlusion level of 0, which is the topmost unoccluded instance. The occlusion level of a lower-level occluded instance that is occluded by a level 0 instance is defined as level 1; the occlusion level of a lower-level occluded instance that is occluded by a level 1 instance is defined as level 2; and so on, with the level number increasing with the occlusion depth. The maximum occlusion level for candidate tea leaves in a single image is 3. It should also be noted that in actual industrial inspection scenarios, the proportion of cases where the tea leaf stacking depth exceeds 3 layers is less than 2%, and instances with more than 3 layers do not have enough identifiable effective morphological features to complete the effective contour. Therefore, the maximum level is limited to 3. Instances exceeding 3 layers are not included in the subsequent contour completion and classification process to avoid invalid calculations.
[0040] Furthermore, after completing all the above operations, the corresponding adhesion and occlusion status and occlusion level number can be matched for each tea candidate instance, forming a complete occlusion level relationship between each tea candidate instance. This provides accurate and quantitative core judgment basis for the subsequent step S3, which involves locating occluded tea candidate instances, delineating the contour region to be completed, and performing constrained contour completion. For occluded lower-layer instances, their corresponding occlusion level number, boundary break point position, and overlapping area range will be directly used as core input parameters for subsequent contour completion.
[0041] S3: Based on the occlusion hierarchy, determine the candidate tea leaf instances with occlusion and their contour regions to be filled, and based on the preset tea leaf shape prior data and bud and leaf topological constraint data, perform constrained contour filling on the contour regions to be filled to obtain reconstructed tea leaf instances.
[0042] Based on preset tea leaf shape prior data and bud / leaf topological constraint data, constrained contour completion is performed on the region to be completed to obtain a reconstructed tea leaf instance, including: Contour completion energy function is constructed, which includes leaf margin continuity constraint term, midrib direction continuity constraint term, tea leaf shape prior constraint term, and bud-leaf topological consistency constraint term; With the goal of minimizing the contour completion energy function, constrained contour completion is performed on the contour region to be completed to obtain a reconstructed tea instance that conforms to the prior data of tea shape and the topological constraint data of bud and leaf.
[0043] It should be noted that step S3, following the output of step S2, is a key innovative step in this invention that addresses the core pain point of low morphological reconstruction accuracy in scenarios where tea leaves are adhered and occluded. The core task is to determine the occluded tea leaf candidate instances based on the occlusion hierarchy relationship output in S2, and to lock their regions to be filled in. Then, based on preset tea leaf shape prior data and bud / leaf topological constraint data, constrained contour completion is performed on the regions to be filled in, ultimately outputting a reconstructed tea leaf instance with a complete contour. This reconstructed tea leaf instance will replace the original tea leaf candidate instance and serve as the input object for the subsequent structural region recognition step S4.
[0044] The core process of step S3 is as follows: Based on the occlusion hierarchy, candidate tea leaf instances with occlusion and their contour regions to be completed are determined. Then, based on preset tea leaf shape prior data and bud / leaf topological constraint data, constrained contour completion is performed on the contour regions to be completed to obtain reconstructed tea leaf instances. Specifically, this includes constructing a contour completion energy function, which includes leaf edge continuity constraint terms, main vein direction continuity constraint terms, tea leaf shape prior constraint terms, and bud / leaf topological consistency constraint terms. With the goal of minimizing the contour completion energy function, constrained contour completion is performed on the contour regions to be completed to obtain reconstructed tea leaf instances that conform to the tea leaf shape prior data and the bud / leaf topological constraint data. The specific implementation process of this step is executed completely according to the following flow.
[0045] First, the occluded tea candidate instances and their outline regions to be completed are determined. It should be noted that in the occlusion hierarchy output in step S2, each tea candidate instance is labeled with an occlusion hierarchy number. Instances with an occlusion hierarchy number of 0 are unoccluded instances or instances occluded at the upper level; their outlines are complete and do not require completion. Instances with an occlusion hierarchy number of 1 or higher are instances occluded at the lower level; their candidate outlines contain boundary breaks and missing regions due to being covered by upper-level instances, requiring outline completion. Specifically, all tea candidate instances in the occlusion hierarchy are traversed, and instances with an occlusion hierarchy number greater than or equal to 1 are marked as occluded tea candidate instances. For each occluded tea candidate instance, the outline region to be completed is delineated based on the boundary break point positions, outline overlap relationships, and region coverage relationships determined in step S2. It should be noted that the region to be filled in refers to the missing part of the candidate contour of the instance that needs to be repaired. Its spatial location is determined by the start and end positions defined by the boundary break point, and its upper limit is defined by the boundary of the overlapping area between the instance and the upper occluded instance.
[0046] Furthermore, after determining the region to be completed, the core constraints of this step are clarified—pre-defined tea shape prior data and bud-leaf topological constraint data. Both types of data are pre-constructed based on standard tea samples, providing specific biological morphological constraints for contour completion and avoiding invalid results generated by general completion methods that do not conform to the true shape of tea. It should be noted that the tea shape prior data includes the tea contour shape, leaf length-to-width ratio, leaf margin curvature distribution, midrib extension direction, and stem connection position; the bud-leaf topological constraint data includes the connection relationship between the bud tip and the leaf, the connection relationship between the leaf and the stem, and the directional correspondence between the midrib and the leaf. The construction process for these two types of data is as follows: select no fewer than 10,000 unobstructed, complete tea standard samples of the target detection category; extract the morphological features and topological structure of each sample through manual annotation; and obtain the corresponding shape prior data and topological constraint data through statistical analysis to ensure that the constraint rules completely match the true shape of the target tea category. The core idea of constrained contour completion is to transform the contour completion problem into an energy function minimization problem. By constructing an energy function with multiple constraint terms, the completed contour not only satisfies the edge continuity of the image itself, but also conforms to the morphological characteristics and bud and leaf structure rules of tea leaves.
[0047] Furthermore, a contour completion energy function is constructed, which is composed of a weighted sum of four constraint terms, and its mathematical expression is as follows:
[0048] It should be noted that the characters in the above formula are interpreted as follows: The completed contour curve to be solved, i.e. the contour segment to be generated in the region to be completed; Complete the outline The smaller the total energy value, the better the completed contour meets the various constraints, and the higher the completion accuracy. : Leaf edge continuity constraint term, used to measure the degree of smooth connection between the completed contour and the original contour at the break point; Main vein direction continuity constraint term, used to measure the consistency between the main vein direction within the completed contour area and the main vein direction in the visible part; : Tea shape prior constraint, used to measure the degree of conformity between the overall shape of the completed outline and the preset tea shape prior data; : Bud and leaf topology consistency constraint term, used to measure whether the completed structural region satisfies the connection relationship defined by the preset bud and leaf topology constraint data; , , , : These are the weight coefficients of the four constraint terms, satisfying The weighting coefficients are strongly correlated with the occlusion level number of the instance to be completed. The deeper the occlusion level, the higher the weight of the tea shape prior constraint and the bud and leaf topology consistency constraint, so as to ensure that the completion result still conforms to the real shape and structural rules of tea when there is severe occlusion.
[0049] Leaf edge continuity constraint This setting ensures a smooth transition between the completed contour and the original visible contour at break points, preventing abrupt inflection points or breaks in the completed contour. It should be noted that the starting break point of the region to be completed is set to... The termination point is The original visible outline is in The tangent direction at that point is ,exist The tangent direction at that point is Complete the outline The tangent directions at the two endpoints are respectively and Based on this, and considering the consistency of curvature changes at adjacent points on the profile, the mathematical expression for the leaf edge continuity constraint is:
[0050] in, To complete the number of discrete points on the contour, To complete the outline, the first The curvature values at discrete points. The first two terms of the formula ensure that the tangent direction of the completed contour is consistent with that of the original contour at the endpoints, and the last term constrains the smoothness of the curvature change along the completed contour. Together, these three terms ensure the visual continuity of the leaf edge and match the natural growth characteristics of tea leaves.
[0051] Main vein direction continuity constraint term This parameter ensures that the direction of the main vein within the completed outline area is consistent with the direction of the visible main vein, conforming to the natural growth pattern of tea leaves where the main vein extends unidirectionally along the central axis of the leaf. It should be noted that the direction vector of the visible main vein is set as... The estimated value of the main vein direction for each candidate contour point within the completed contour region is... Then the mathematical expression for this constraint term is:
[0052] in, This refers to the number of discrete points within the completed area that participate in estimating the direction of the main vein. The smaller this value, the more consistent the direction of the main vein within the completed area is with the visible main vein, which can effectively avoid abnormal morphology such as bending or deviation of the main vein after completion.
[0053] Prior constraints on tea leaf shape This step ensures that the overall shape of the completed outline conforms to the typical morphological characteristics of the target tea variety, thereby preventing invalid results generated by general completion methods that do not resemble tea leaves. It should be noted that, assuming the preset tea shape prior data includes a leaf length-to-width ratio range of [range missing] for this tea variety... The leaf margin curvature distribution curve is ,in Let be the arc length parameter along the contour. The mathematical expression for this constraint term is:
[0054] in: To complete the aspect ratio of the tea leaves in the tea leaf example, The aspect ratio deviation penalty function has the following rule: when Falling When within range, ;when When outside the range, , for Deviation or The nearest boundary value; To complete the contour in arc length The curvature value at that point, The standard curvature value of the preset leaf edge curvature distribution curve at the corresponding arc length position; and Let be the weight coefficients of the two items, satisfying ,in The range of values is – , The range of values is – The smaller this value, the closer the completed outline is to the standard shape of that tea variety.
[0055] Bud and leaf topological consistency constraint This item ensures that the completed structural region conforms to the inherent connection rules of the physiological structure of tea buds and leaves, avoiding completion results that do not conform to biological characteristics, such as misalignment of the bud tip and tea stem, or separation of the midrib and leaf. It should be noted that the preset bud and leaf topological constraint data defines three sets of core connection rules: Rule 1 requires the bud tip region to be adjacent to and spatially connected to the leaf region; Rule 2 requires the leaf region to be connected to the tea stem region through a slender connection structure; Rule 3 requires the direction of the midrib region to be consistent with the long axis direction of the leaf region. The mathematical expression for this constraint item is:
[0056] in, This is the rule satisfaction determination function; when the corresponding connection rule is satisfied by the currently completed contour... When satisfied, When not satisfied, ; , , The penalty coefficients for each set of rules, summing to 1, are the core connection rule's corresponding penalty coefficients. , The values are all no less than The smaller this value, the more the completed structure conforms to the natural topological rules of tea buds and leaves.
[0057] Furthermore, minimizing the contour completion energy function The objective is to perform constrained contour completion on the region to be completed. Specifically, the optimal completed contour is searched in the feasible solution space of the region to be completed. , making The goal is to reach the global minimum. The solution process can be implemented using the graph cut method, gradient descent method, or dynamic programming method. The graph cut method, which is preferred due to its suitability for real-time industrial inspection requirements, can quickly find the global optimal solution for multiple constraints. When the energy function converges to a stable state, or when the number of iterations reaches the preset maximum number of iterations, the current contour is output as the optimal completed contour; the preset maximum number of iterations ranges from 100 to 500. This optimal completed contour is then stitched together with the original visible contour to form a complete closed tea leaf contour.
[0058] Furthermore, the completed tea leaf outline is verified for compliance. The shape features and topological relationships of the completed tea leaf instance are compared with the preset tea leaf shape prior data and bud and leaf topological constraint data. If the deviation between the two does not exceed 10%, it is considered to meet the compliance requirements, and the completed instance is marked as a reconstructed tea leaf instance. If the deviation exceeds 10%, the weight coefficients of the corresponding constraint terms in the energy function are adjusted, and the constrained outline completion is re-executed until the compliance requirements are met or the preset maximum number of iterations is reached.
[0059] After completing all the above operations, the optimal completed contour is merged with the original visible contour to obtain a reconstructed tea leaf instance with a complete contour. For tea leaf candidate instances with an occlusion level of 0, since their contours are already complete, no completion operation is required, and their original contours and region masks can be directly retained as another type of input object for the subsequent step S4 structural region recognition. The reconstructed tea leaf instances and the tea leaf candidate instances with an occlusion level of 0 will jointly serve as input objects for the subsequent step S4 structural region recognition, providing complete and accurate morphological data for the precise identification of the bud tip region, leaf region, tea stem region, and main vein region.
[0060] S4: Perform structural region identification on the reconstructed tea leaf instance to obtain the bud tip region, leaf region, tea stem region and main vein region.
[0061] For the reconstructed tea leaf instance and the unoccluded tea leaf candidate instance, the outline skeleton, main vein direction and local structural endpoints of the instance are extracted respectively. The bud tip region is determined based on the endpoints of the local structure, the leaf region is determined based on the area enclosed by the outline skeleton, the tea stem region is determined based on the slender connecting structure connected to the leaf region, and the main vein region is determined based on the linear texture direction of the main vein.
[0062] Step S4 follows the output of step S3. Its core task is to perform refined physiological structural analysis on the reconstructed tea leaf instance output in step S3 and the tea leaf candidate instances identified as unoccluded with an occlusion level of 0 in step S2. This involves accurately identifying four core structures: the bud tip region, leaf region, stem region, and midrib region. This provides precise structural data for the subsequent construction of the bud-leaf heterogeneous topology map and extraction of topological features in step S5. The core process of step S4 in the claims is as follows: Structural region identification is performed on the reconstructed tea leaf instance to obtain the bud tip region, leaf region, stem region, and midrib region. Specifically, this includes extracting the outline skeleton, midrib direction, and local structural endpoints of the reconstructed tea leaf instance and the unoccluded tea leaf candidate instances, respectively. The bud tip region is determined based on the local structural endpoints; the leaf region is determined based on the area enclosed by the outline skeleton; the stem region is determined based on the slender connecting structures connected to the leaf region; and the midrib region is determined based on the linear texture direction of the midrib direction. The specific implementation process of this step is executed completely according to the following flow.
[0063] Furthermore, the scope of this step should be clearly defined. It should be noted that the processing objects in this step are divided into two categories: the first category consists of the reconstructed tea leaf instances that have undergone contour completion and morphological restoration in step S3, corresponding to the lower-layer occluded instances with occlusion levels of 1, 2, and 3 in step S2; the second category consists of candidate tea leaf instances determined to be unoccluded in step S2 with an occlusion level of 0, including independent tea leaf instances without any stacking, and complete tea leaf instances that are only occluded at the upper layer. Both types of instances possess complete closed candidate contours, which can be directly used for structural feature extraction and recognition of the bud tip region, leaf region, tea stem region, and main vein region. This step achieves accurate segmentation of the entire region based on the complete closed tea leaf contours, unlike step S3 which only targets the structural pre-identification of the visible region.
[0064] Furthermore, for each tea leaf instance to be processed, a core structural feature extraction operation is performed to extract the instance's outline skeleton, main vein direction, and local structural endpoints, providing a quantitative basis for the subsequent identification of the four major structural regions.
[0065] It should be noted that the first type of core feature is the contour skeleton of the instance. The contour skeleton is the set of central axes of the region surrounded by the candidate contour of the tea instance. It can accurately represent the overall shape and branch structure of the tea. In specific implementation, the Zhang-Suen thinning algorithm is used to extract the skeleton. This algorithm can generate a central skeleton with a single pixel width and maintain the topological connectivity of the contour. It should also be noted that after the skeleton is extracted, a burr removal operation needs to be performed to remove scattered skeleton branches with a length of less than 5 pixels. Here, 5 pixels is the threshold for judging invalid burrs. Branches with a length lower than this are mostly invalid structures caused by jagged contour edges. Removing them can avoid interference with the subsequent recognition of the main vein and endpoints, and finally obtain a smooth and continuous contour skeleton of the tea instance.
[0066] The second core feature is the main vein direction of the instance. The main vein is the core central axis of the tea leaf instance, corresponding to the longest continuous main branch in the contour skeleton. In specific implementation, the pixel length of all continuous branches in the contour skeleton is counted, and the longest continuous branch is determined as the main vein skeleton. The length of the main vein skeleton accounts for no less than 60% of the total length of the entire contour skeleton. The 60% threshold here is determined based on the preset tea leaf shape prior data, which is consistent with the natural growth characteristic of the main vein of tea leaves running through the main body of the leaf. Then, the pixel coordinates of the main vein skeleton are linearly fitted by the least squares method to obtain the extension direction angle of the main vein, which is the main vein direction of the instance, in degrees. This is completely consistent with the definition of the main vein direction used in the main vein direction continuity constraint term in step S3.
[0067] The third core feature is the local structural endpoint of the instance. An endpoint refers to a pixel in the contour skeleton that has only one adjacent pixel, corresponding to the top and bottom of the tea leaf structure. In practice, all pixels in the contour skeleton are traversed to filter out all endpoints that meet the conditions. Then, based on the spatial position of the endpoint and the curvature features of the corresponding candidate contour, the endpoints are divided into two categories: bud tip points and tea stem endpoints. Among them, the bud tip point is the endpoint located at the outermost convex position of the tea leaf contour and the corresponding contour curvature value is more than twice the preset leaf edge curvature average value. The tea stem endpoint is the endpoint located at the base of the tea leaf contour and extends in the opposite direction to the main vein. It should also be noted that the number of valid endpoints in a single complete tea leaf instance is 2, corresponding to 1 bud tip point and 1 tea stem endpoint respectively. If the number of endpoints obtained by filtering exceeds 2, invalid endpoints with curvature values lower than the leaf edge curvature average value are removed to ensure that only 1 set of valid endpoints is retained in the end.
[0068] Furthermore, based on the extracted contour skeleton, main vein direction, and local structure endpoints, the four major structural regions are accurately identified. The specific implementation process is as follows: It should be noted that, firstly, the bud tip region is determined based on the bud tip point in the local structural endpoints. The bud tip region is the apical structural region where the tea bud tip is located. In specific implementation, a circular recognition region is constructed with the bud tip point as the center and 1 / 10 of the width of the minimum bounding rectangle of the candidate outline of the tea instance as the radius. Then, combined with the closed range of the tea outline, the candidate bud tip region is cropped to obtain the bud tip region. It should also be noted that the bud tip region must meet two quantitative verification criteria: first, the bud tip region must have a continuous spatial adjacency relationship with the leaf region obtained later, without any breaks; second, the area of the bud tip region accounts for no more than 10% of the total area of the entire tea instance. This proportion threshold is determined based on the preset tea shape prior data and conforms to the natural size characteristics of the tea bud tip, thus obtaining an accurate bud tip region.
[0069] The leaf region is determined based on the area enclosed by the outline skeleton. The leaf region is the main structural area of the tea leaf and is the core component of the entire tea leaf instance. In specific implementation, the main vein branch of the outline skeleton is used as the central axis. The complete closed outline enclosed area covered by the main vein branch is taken. After removing the identified bud tip area and the subsequently identified tea stem area, the main leaf area is obtained. It should also be noted that the leaf region must meet the quantitative verification standard: the area of the leaf region should account for no less than 70% of the total area of the entire tea leaf instance. This ratio threshold is determined based on the preset tea leaf shape prior data and conforms to the natural characteristics of tea leaves as the main structure. At the same time, the aspect ratio of the leaf region should fall within the range of the leaf aspect ratio specified by the preset tea leaf shape prior data to ensure that the recognition result conforms to the morphological characteristics of the target tea category.
[0070] The tea stem region is determined based on the slender connecting structure that connects to the leaf region. The tea stem region is the slender basal structure that connects the main body of the leaf to the tea plant. In practice, starting from the end point of the tea stem, the outline is extended towards the leaf region. Slender structural regions that are directly connected to the base of the leaf region and have an aspect ratio of ≥5:1 are selected as candidate tea stem regions. It should also be noted that the aspect ratio of ≥5:1 is a quantitative criterion for the "slender structure" of the tea stem. This threshold is determined based on the preset tea shape prior data and can accurately distinguish the tea stem from the main body structure of the leaf. At the same time, the tea stem region must have a unique connection path with the leaf region, without branches or breaks, to obtain the accurate tea stem region.
[0071] The main vein region is determined based on the linear texture direction of the main vein. The main vein region is the central linear texture region that runs through the main body of the leaf. In practice, the extracted main vein skeleton is used as the central axis, and the main vein extends symmetrically to both sides in a direction perpendicular to the main vein direction. The total width of the extension does not exceed 1 / 8 of the maximum width of the leaf region, and the extension range does not exceed the closed boundary of the leaf region. The resulting strip-shaped linear region is the main vein region. It should also be noted that the main vein region must meet two quantitative verification standards: First, the main vein region must run through the entire leaf region along the main vein direction, with one end adjacent to the bud tip region and the other end adjacent to the tea stem region; second, the extension direction of the main vein region deviates from the pre-extracted main vein direction by no more than 5 degrees to ensure that the identification result conforms to the natural growth characteristics of the main vein of tea.
[0072] Furthermore, after identifying the four major structural regions, a bud-leaf topological compliance verification is performed to ensure that the identification results conform to the preset bud-leaf topological constraints. It should be noted that the core criteria for compliance verification are: the bud tip region is located at the top of the leaf region, the tea stem region is located at the base of the leaf region, the midrib region penetrates the leaf region and connects the bud tip region and the tea stem region, and the spatial connection relationship of the four major structural regions fully conforms to the preset bud-leaf topological constraints. If the verification fails, the structural feature extraction and region identification operations are re-executed until the compliance requirements are met.
[0073] Furthermore, after completing all the above operations, each tea instance can generate a bud tip region, leaf region, tea stem region, and main vein region with unique spatial coordinates, area attributes, and adjacency relationships. The spatial connection relationships and morphological attributes of the four major structural regions will directly serve as the core input data for the construction of the heterogeneous topology map of buds and leaves and the extraction of topological features in the subsequent step S5, providing accurate structural support for the generation of comprehensive tea classification features.
[0074] S5: Based on the spatial connection relationship between the bud tip region, leaf region, tea stem region and main vein region, construct a bud-leaf heterogeneous topology map, and generate topological consistency features, structural integrity features and occlusion correction features based on the bud-leaf heterogeneous topology map.
[0075] For each tea instance, the identified bud tip region, leaf region, tea stem region, and main vein region are used as heterogeneous nodes. Based on the spatial connection relationship between each region, topological connection edges between nodes are constructed to form the bud and leaf heterogeneous topological graph of the corresponding tea instance. Based on the node connection relationships of the bud-leaf heterogeneous topology graph and the preset bud-leaf topology constraint data, a topology consistency feature is generated. Based on the node coverage of the heterogeneous topology graph of buds and leaves and the preset prior data of tea leaf shape, structural integrity features are generated. Based on the occlusion state and occlusion hierarchy of the tea leaf instances corresponding to the heterogeneous topology of the buds and leaves, occlusion correction features are generated.
[0076] It should be noted that step S5 follows the output of step S4. The core task is to construct a heterogeneous topology map of buds and leaves based on the bud tip region, leaf region, tea stem region, and midrib region to characterize the physiological structure of tea leaves. Subsequently, three core features are extracted based on this topology map. These features have strong discriminative power and resistance to occlusion, providing a basis for the tea grade and category classification in step S6.
[0077] The specific implementation process for this step is carried out in its entirety according to the following procedure: First, we need to clarify the processing object and basic input data for this step. It should be noted that the processing object for this step is all tea leaf instances for which the four major structural regions were identified in step S4, including the reconstructed tea leaf instances output in step S3, and the candidate tea leaf instances determined to be unoccluded and with an occlusion level of 0 in step S2. The basic input data for this step is completely consistent with the output results of the preceding steps S1-S4, with no terminological or logical discrepancies. Specifically, it includes: the spatial coordinates, area attributes, and adjacency relationships of the bud tip region, leaf region, stem region, and main vein region corresponding to each tea leaf instance; the occlusion level number and adhesion occlusion state corresponding to the instance; and the preset bud and leaf topological constraint data and tea leaf shape prior data.
[0078] Furthermore, for each tea leaf instance, a heterogeneous topological graph of buds and leaves is constructed, transforming the physiological structure of the tea leaves into quantifiable and computationally computable graph structure data. It should be noted that the heterogeneous topological graph of buds and leaves is a directed weighted graph, consisting of a set of heterogeneous nodes and a set of topological connecting edges. The specific construction process is as follows: First, a heterogeneous node set was constructed. The bud tip region, leaf region, stem region, and midrib region identified by S4 were designated as four independent heterogeneous node types. Each node corresponds to a unique type label and attribute information: bud tip nodes correspond to type label 0, with attributes including the center coordinates, area, and convergence direction of the bud tip region; leaf nodes correspond to type label 1, with attributes including the contour coordinates, total area, aspect ratio, and minimum bounding rectangle parameter of the leaf region; stem nodes correspond to type label 2, with attributes including the central axis, length, aspect ratio, and base coordinates of the stem region; and midrib nodes correspond to type label 3, with attributes including the extension direction, length, and penetration range of the midrib region. The heterogeneous node set for a single complete tea leaf instance is fixed at four nodes, corresponding to the four structural regions respectively. The number and type of nodes perfectly match the natural physiological structure of tea leaves, avoiding redundant nodes from interfering with subsequent feature extraction.
[0079] Second, the topological connection edge set is constructed. Based on the spatial connection relationships of the regions corresponding to each heterogeneous node, directed connection edges between nodes are constructed. The existence of connection edges is determined by spatial adjacency quantification. The specific rule is as follows: calculate the total number of adjacent pixels in the regions corresponding to two nodes. When the proportion of adjacent pixels to the total number of pixels in the smaller region is ≥5%, it is determined that there is a valid topological connection edge between the two nodes. Here, the 5% threshold is the lower limit for determining valid adjacency. Adjacencies below this proportion are mostly caused by edge errors in region recognition and do not belong to the real physiological structure connection, which can avoid the misjudgment of invalid connections. The topological connection edges are directed edges, and the direction strictly follows the natural growth direction of tea leaves, specifically from the tea stem node to the leaf node, from the leaf node to the bud tip node, from the tea stem node to the main vein node, and from the main vein node to the bud tip node. The weight of the directed edge is positively correlated with the adjacency degree of the regions corresponding to the two nodes. The higher the adjacency degree, the closer the weight is to 1.
[0080] Third, the final generation of the heterogeneous topology graph of buds and leaves is completed. The heterogeneous node set and topological connection edge set constructed above are combined to form the heterogeneous topology graph of buds and leaves corresponding to a single tea leaf instance. It should be noted that this topology graph fully represents the type, attributes, and spatial connections of the four major structural regions of the tea leaf, transforming the original morphological features based on image pixels into topological graph features with structural invariance. This effectively resists feature interference caused by changes in tea leaf posture and local occlusion, which is the core innovation of this invention that distinguishes it from existing pixel-level feature extraction methods.
[0081] Furthermore, based on the node connectivity of the generated heterogeneous bud and leaf topology graph, and combined with pre-defined bud and leaf topology constraint data, a topology consistency feature is generated. It should be noted that the topology consistency feature is used to quantify the degree of matching between the actual bud and leaf structural connectivity of tea instances and the natural physiological topological rules of tea. It is the core discriminant feature distinguishing between intact tea leaves and damaged or deformed tea leaves. The value range is fixed at 0-1; the closer the value is to 1, the higher the topology consistency and the more the structural connectivity conforms to the natural growth rules of tea.
[0082] The specific calculation rules for the topology consistency feature are as follows: First, the preset bud and leaf topology constraint data specifies four standard connection relationships corresponding to the natural structure of tea leaves: tea stem-leaf, leaf-bud tip, tea stem-main vein, and main vein-bud tip, which serve as the matching benchmark. Second, the number of valid connection edges that completely match the standard connection relationships in the actual heterogeneous topology graph of buds and leaves is counted, and the ratio of the number of matching edges to the total number of standard edges is used as the basic matching degree. Third, the average angular deviation between the actual direction of the directed edge in the actual topology graph and the standard direction of natural growth of tea leaves is calculated, and the ratio of 1 to 90 degrees is used as the directional consistency coefficient. Finally, the basic matching degree and the directional consistency coefficient are multiplied to obtain the basic value of the topology consistency feature. It should be noted that if there are redundant connection edges in the actual topology graph that are not part of the standard connection relationships, 0.2 is deducted from the basic value of the topology consistency feature for each redundant edge, down to a minimum of 0, to avoid misclassifying abnormally structured tea leaves as normal samples.
[0083] Furthermore, based on the node coverage of the generated heterogeneous topology graph of buds and leaves, and combined with pre-set prior data on tea leaf shape, structural integrity features are generated. It should be noted that structural integrity features are used to quantify the degree to which the morphology and size of each structural region of a tea leaf instance matches the standard tea leaf sample. This is the core feature for distinguishing between complete and defective tea leaves. The value range is fixed at 0-1; the closer the value is to 1, the higher the structural integrity, and the more the tea leaf morphology conforms to the prior requirements of the standard sample.
[0084] The structural integrity feature is obtained by weighted summation of four sub-features: bud tip, leaf, stem, and midrib. The sum of the weight coefficients of the four features is 1. Among them, the weight of the leaf structure feature is no less than 0.4, which is consistent with the characteristic that tea leaves are the core identification subject. The weight coefficients of the other features are determined based on pre-set tea shape prior data. The specific calculation rules of the four structural integrity sub-features are as follows: First, the structural integrity of the bud tip is calculated as the ratio of the actual bud tip area to the standard bud tip area in the pre-set tea shape prior data. The ratio is up to 1, and areas exceeding the standard area are counted as 1. Second, the blade structural integrity sub-characteristic is obtained by multiplying two parameters. The first parameter is the ratio of the actual blade area to the standard blade area, with a maximum of 1. Areas exceeding the standard area are counted as 1. The second parameter is 1 minus the relative deviation between the actual blade length-width ratio and the median of the standard blade length-width ratio. The higher the relative deviation, the lower the value of this parameter. Third, the structural integrity of the tea stem is a sub-characteristic, calculated by the ratio of the axial length of the actual tea stem area to the preset standard tea stem length. The ratio is up to 1, and any length exceeding the standard length is counted as 1. Fourth, the integrity of the main vein structure is a sub-characteristic, calculated as the ratio of the axial length of the actual main vein area to the axial length of the blade area. The standard requires that the main vein length be no less than 90% of the blade length. If the standard is met, it is counted as 1; otherwise, it is counted as the actual ratio.
[0085] Furthermore, based on the occlusion state and occlusion hierarchy of tea leaf instances corresponding to the heterogeneous topology of buds and leaves, occlusion correction features are generated. It should be noted that these occlusion correction features are used to quantitatively characterize the degree of occlusion of tea leaf instances, providing a basis for correcting feature weight allocation in subsequent classification steps. This addresses the problem of decreased classification accuracy caused by structural feature distortion in occluded scenarios. The value range is fixed at 0-1; the closer the value is to 1, the more severe the occlusion, requiring a higher degree of correction to the weight of the structural integrity feature.
[0086] The specific calculation rules for the occlusion correction feature are as follows: First, two core calculation parameters are determined. The first is the occlusion level number corresponding to the tea instance, which comes from the output of step S2. The occlusion level number of an unoccluded instance is 0, and the higher the occlusion level, the larger the value. The second is the occlusion area ratio of the tea instance, that is, the proportion of the area occluded by the upper-layer instance to the total area of the tea instance, which comes from the contour overlap relationship calculation result of step S2. Second, multiply the occlusion level number by 0.5 and the occlusion area ratio by 0.3, sum the two, add 1, take the reciprocal of the value, and finally subtract the reciprocal from 1 to obtain the occlusion correction feature value. It should be noted that for tea instances in an unoccluded state, the occlusion correction feature value is 0, and no weight correction is required for the classification features. The reconstructed occlusion correction feature of the tea instance will be directly used in the subsequent classification judgment in step S6 to balance the interference of occlusion on the classification results.
[0087] Furthermore, after generating the three core features, feature compliance verification is performed. It should be noted that the verification criteria are: the values of the topology consistency feature, structural integrity feature, and occlusion correction feature must all fall within the specified range of 0-1, with no outliers; if outlier feature values are found that exceed the range, the bud-leaf heterogeneous topology graph construction and feature calculation operations are re-executed until the compliance requirements are met.
[0088] Furthermore, after completing all the above operations, a corresponding bud-leaf heterogeneous topology map can be generated for each tea instance, along with three core classification features: topological consistency feature, structural integrity feature, and occlusion correction feature. These features and topology map data will directly serve as the core input for the subsequent step S6 tea classification and recognition, providing feature support with strong anti-occlusion capabilities and high discriminative power for accurate identification of tea categories and grades.
[0089] S6: Generate a comprehensive tea classification feature based on the topological consistency feature, the structural integrity feature, and the occlusion correction feature, and output the tea detection and classification result based on the comprehensive tea classification feature.
[0090] The topological consistency feature, structural integrity feature, and occlusion correction feature are weighted and fused to generate a comprehensive tea classification feature; The comprehensive classification features of tea are matched with preset classification rules to obtain tea grade classification results, structural anomaly detection results, and integrity assessment results. The tea grade classification results, structural anomaly detection results, and integrity assessment results are combined to output the final tea detection and classification results.
[0091] Step S6 follows the output of step S5 and is the final execution step of the tea detection method of this invention. Its core task is to generate comprehensive tea classification features based on the topological consistency features, structural integrity features, and occlusion correction features generated in S5, and then match these features according to preset classification rules to output the final tea detection classification result, achieving full-dimensional detection of tea grade, structural state, and integrity.
[0092] The core process of step S6 is as follows: Based on the topology consistency feature, the structural integrity feature, and the occlusion correction feature, a comprehensive tea classification feature is generated, and the tea detection and classification result is output according to the comprehensive tea classification feature. Specifically, this includes weighted fusion of the topology consistency feature, structural integrity feature, and occlusion correction feature to generate the comprehensive tea classification feature; matching the comprehensive tea classification feature with preset classification rules to obtain the tea grade classification result, structural anomaly detection result, and integrity assessment result; and combining the tea grade classification result, structural anomaly detection result, and integrity assessment result to output the final tea detection and classification result. The specific implementation process of this step is executed completely according to the following flow.
[0093] Furthermore, we must first clarify the processing object and basic input data for this step. It should be noted that the processing object for this step is all the individual tea leaf instances for which feature extraction was completed in step S5, including unoccluded complete tea leaf instances and reconstructed tea leaf instances after contour completion. The basic input data for this step is completely consistent with the output results of the preceding steps S1 to S5, with no terminological or logical discrepancies. Specifically, it includes: the topological consistency features, structural integrity features, and occlusion correction features corresponding to each tea leaf instance, the occlusion level number corresponding to that instance, and the preset classification rules.
[0094] Furthermore, the three core features are weighted and fused to generate a comprehensive tea classification feature. It should be noted that this comprehensive tea classification feature is a single-valued quantitative feature, with a fixed value range of 0-1. The closer the value is to 1, the higher the overall quality of the tea, the more complete its structure, and the stronger the feature reliability. The core logic of the weighted fusion is to dynamically adjust the weights of each feature item based on the occlusion correction feature, solving the classification bias problem caused by structural feature distortion in occluded scenarios, fully echoing the core inventive purpose of this invention for detecting adhered and occluded tea leaves.
[0095] The specific weighted fusion rules are as follows: the sum of the weight coefficients of the three features is always 1, and the weight allocation is strongly bound to the occlusion state of the instance. For unoccluded instances with an occlusion correction feature value of 0, the credibility of the topology consistency feature and the structural integrity feature is equivalent, and they are allocated according to a preset basic weight—in the preferred embodiment, the weight of the topology consistency feature is 0.4, the weight of the structural integrity feature is 0.4, and the weight of the occlusion correction feature is 0.2, and their values are simultaneously retained as credibility reference labels. For reconstructed tea instances with an occlusion correction feature value greater than 0, the weights are dynamically adjusted according to the occlusion correction feature value—the higher the occlusion correction feature value, the more severe the occlusion experienced by the instance, and the lower the credibility of the structural recognition of the completed part. Therefore, in the comprehensive classification, the weight of the structural integrity feature is gradually reduced, and the weight of the topology consistency feature is simultaneously increased, and the weight of the occlusion correction feature is adjusted smoothly and synchronously with the degree of occlusion.
[0096] It should be noted that the core rule for dynamic weight adjustment is as follows: the sum of the weights of the three features always remains 1; for every 0.1 increase in the occlusion correction feature value, the weight of the structural integrity feature decreases by no more than 0.05, and the weight of the topology consistency feature increases by no more than 0.05, ensuring smooth and continuous weight adjustment without abrupt changes. The topology consistency feature reflects the degree of matching between the bud-leaf structure connection relationship and the preset topology rules, and has a strong resistance to occlusion interference—even if some regions are filled in, as long as the connection relationship between buds and leaves is not destroyed, its value can still maintain a high level. The structural integrity feature, on the other hand, directly depends on the morphological integrity of each structural region and is more sensitive to completion errors. Therefore, in cases of severe occlusion, the topology consistency feature should be prioritized for classification.
[0097] Furthermore, after determining the fusion weights, the topological consistency feature value, structural integrity feature value, and occlusion correction feature value are weighted and summed according to their respective current weights to obtain the basic value of the comprehensive tea classification feature. If the calculation result exceeds the range of 0-1, it is counted as 1 if it exceeds the upper limit and as 0 if it is below the lower limit, ensuring that the final comprehensive tea classification feature always falls within the compliant value range.
[0098] Furthermore, the generated comprehensive tea classification features, combined with single-feature thresholds, are matched item by item with preset classification rules to generate three sub-results: tea grade classification results, structural anomaly detection results, and integrity assessment results. It should be noted that the preset classification rules are classification criteria pre-constructed based on standard tea samples. The construction method is as follows: standard tea samples of the target detection category are selected, and the topological consistency features and structural integrity features of each sample are extracted according to the processing flow of steps S1 to S5 above. Statistical analysis is used to determine the feature value range corresponding to each grade, forming the grade classification threshold, structural anomaly detection threshold, and integrity assessment threshold. The rule thresholds are completely homologous to the preset tea shape prior data and bud / leaf topological constraint data, ensuring that the classification rules match the industry standards of the target tea category.
[0099] The specific matching rules for the three types of sub-results are as follows: First, the tea grade classification results are matched. The comprehensive classification feature value of the tea is compared with the preset grade classification threshold. In a preferred embodiment, the grade classification threshold is set with three level intervals: a comprehensive classification feature value of not less than 0.85 is classified as Special Grade, not less than 0.65 but less than 0.85 is classified as Grade 1, and less than 0.65 is classified as Grade 2. The grade corresponding to the interval in which the comprehensive classification feature value of the tea falls is output as the tea grade classification result. It should be noted that the numerical intervals for grade division can be adjusted according to the industry standards and enterprise acceptance rules of the target tea category to adapt to different testing scenario requirements.
[0100] Second, the structural anomaly detection results are matched. The topology consistency feature value and structural integrity feature value are compared with the preset structural anomaly judgment threshold. In a preferred embodiment, when the topology consistency feature value is lower than 0.3 or the structural integrity feature value is lower than 0.4, the tea instance is judged to have a structural anomaly, and the structural anomaly detection result is marked as abnormal; otherwise, it is marked as normal. It should be noted that the reason for setting the threshold of the topology consistency feature value relatively low here is that some high-grade teas may have shorter tea stems due to the picking method, and there may be reasonable deviations in the connection edges between tea stems and leaves in the topology diagram, but the main structure of the buds and leaves is still intact. It is not appropriate to judge it as abnormal solely because of the deviation in the connection of tea stems.
[0101] Third, the integrity assessment results are matched. The structural integrity feature value is compared with a preset integrity assessment threshold. In a preferred embodiment, the integrity assessment threshold is set with three levels: a structural integrity feature value of not less than 0.75 is assessed as intact, not less than 0.45 but less than 0.75 is assessed as slightly damaged, and less than 0.45 is assessed as significantly damaged. The assessment conclusion corresponding to the range in which the structural integrity feature value falls is output as the integrity assessment result.
[0102] It should also be noted that for reconstructed tea instances with high occlusion correction feature values, their topological consistency and structural integrity features may be lower than their true values due to errors introduced during the completion process. In this case, the results of grade classification and integrity assessment should be comprehensively considered in conjunction with the occlusion correction feature—if the occlusion correction feature value exceeds 0.5, an occlusion correction mark should be added to both the structural anomaly detection results and the integrity assessment results, indicating that the classification conclusion of this instance is affected by occlusion factors and its reliability is somewhat reduced. This marking information can be used for subsequent manual review or quality traceability.
[0103] After matching the above three sub-results, the tea grade classification result, structural anomaly detection result, and integrity assessment result are combined to output the final tea detection and classification result. It should be noted that the final tea detection and classification result is a structured data record containing the unique identifier of the tea instance, the grade classification result, the structural anomaly detection result, the integrity assessment result, and the occlusion correction feature value. If the instance is determined to have occlusion in step S2, the result data also includes its occlusion level number and occlusion correction mark. This data record can be directly output to the sorting execution mechanism, quality management system, or manual verification terminal, providing clear technical basis for automated tea sorting, quality grading, and process optimization.
[0104] After completing all the above operations, the system can output tea detection and classification results for each tea instance, including grade, structural anomaly, and integrity assessment. This completes the entire closed loop from original image acquisition to classification decision, enabling intelligent and high-precision detection and classification of tea in scenarios with adhesion and occlusion.
[0105] Example 2 is the second embodiment of the present invention, which differs from the previous embodiment in that: If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art or the current technical solution, can be embodied in the form of a software product. This current computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0106] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.
[0107] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0108] Example 3, referring to Figure 2 As an embodiment of the present invention, a tea detection and classification system based on image recognition is provided, which includes an image acquisition and instance segmentation module, an occlusion recognition module, a contour completion module, a structural region recognition module, a topology analysis module, and a comprehensive classification module; Image acquisition and instance segmentation module: acquires the tea image to be detected, performs foreground segmentation and instance segmentation on the tea image to be detected, and obtains multiple tea candidate instances; Occlusion recognition module: performs adhesion occlusion recognition on the multiple tea candidate instances and determines the occlusion hierarchy relationship between each tea candidate instance; Contour completion module: Based on the occlusion hierarchy, determine the candidate tea leaf instances with occlusion and their contour regions to be completed, and based on the preset tea leaf shape prior data and bud and leaf topological constraint data, perform constrained contour completion on the contour regions to be completed to obtain reconstructed tea leaf instances; Structural Region Recognition Module: Performs structural region recognition on the reconstructed tea leaf instance to obtain the bud tip region, leaf region, tea stem region, and main vein region; Topology analysis module: Based on the spatial connectivity between the bud tip region, leaf region, tea stem region and main vein region, construct a heterogeneous topology map of bud and leaf, and generate topological consistency features, structural integrity features and occlusion correction features based on the heterogeneous topology map of bud and leaf; Comprehensive classification module: Generates comprehensive tea classification features based on the topological consistency feature, the structural integrity feature, and the occlusion correction feature, and outputs tea detection and classification results based on the comprehensive tea classification features.
[0109] Example 4 is an embodiment of the present invention, which provides a tea detection and classification method based on image recognition. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through economic benefit calculation and simulation / comparative experiments.
[0110] This embodiment designed a set of comparative experiments to verify the accuracy advantage of the method of the present invention in classifying tea grades under adhesion and occlusion scenarios. West Lake Longjing tea was selected as the test object. This variety of tea has a flat and smooth appearance with buds and leaves in clusters. In industrial sorting, it often piles up due to uneven spreading, making it an ideal sample for testing the occlusion handling capability.
[0111] In the experimental preparation phase, a 5-megapixel industrial area array camera was fixedly mounted above the tea sorting production line, with the lens optical axis perpendicular to the conveyor belt plane and the shooting distance set at 40 cm. A ring-shaped LED shadowless lamp with a color temperature of 5500K was used as the light source, and the illuminance uniformity was controlled within 12% of the center illuminance to eliminate brightness fluctuations during conveyor belt movement. The conveyor belt ran at a speed of 0.3 meters per second, and the camera continuously acquired images at a rate of 10 frames per second, accumulating 1200 images of the tea leaves to be inspected. All images had a resolution of 2448 x 2048 pixels, covering complete tea leaves, fragments, tea stems, and scenes with varying degrees of stacking and adhesion. After acquisition, three evaluation experts holding national tea taster professional qualification certificates graded each identifiable tea leaf in each image according to the national standard GB / T 23776. The grading results served as the true value benchmark for the experiment. Finally, 900 images containing stacked occlusion scenes were selected and grouped. 450 images were used as the control group of the prior art, and the other 450 images were used as the experimental group of the method of this invention. The statistical characteristics of the two groups of images in terms of tea quantity, grade distribution and occlusion degree were basically the same to ensure the fairness of the comparison.
[0112] The control group's processing flow was as follows: after performing conventional Gaussian filtering to denoise the images to be detected, they were directly fed into a standard YOLOv8 instance segmentation model to complete individual tea leaf detection, extracting the texture and color features of each instance, and outputting the grade classification results through a trained ResNet classifier. The experimental group followed the complete technical chain of the present invention, namely, sequentially completing illumination equalization and background separation, three-layer relationship recognition of adhesion and occlusion, constrained contour completion based on energy functions, fine segmentation of the four major structural regions, construction of heterogeneous topology maps of buds and leaves, and generation of three features, finally outputting the grade results through adaptive weight fusion and matching with preset classification rules. Both experiments were run on the same computing platform configured with an Intel Core i9 processor and an NVIDIA RTX 4090 graphics card to ensure a consistent hardware environment. Key data recorded are shown in Table 1. Table 1: Experimental Data Recording Table
[0113] Through systematic analysis of the data in the above tables, the following conclusions can be drawn.
[0114] First, in unobstructed scenarios, the performance of the control and experimental groups was similar across all metrics, with a classification accuracy difference of no more than 1.2 percentage points. This result verifies that the method of this invention has good compatibility under normal conditions, and the added contour completion and topology analysis steps did not negatively impact the recognition of complete tea leaves. The processing time per image in the experimental group was approximately 182 to 188 milliseconds, which is higher than the control group's approximately 110 to 114 milliseconds, but still within the acceptable time window for industrial online detection, and it resulted in a significant performance improvement in subsequent occluded scenarios.
[0115] Secondly, the advantages of the method of this invention become apparent in scenarios with mild to moderate occlusion. The accuracy rate of the classification of premium tea leaves in the control group plummeted to 78.2%, while that in the experimental group remained at 91.7%, a difference of 13.5 percentage points. The core reasons for this gap can be explained by three indicators: First, the contour completion morphology deviation of the control group was as high as 34.7%, indicating that the existing technology, without the guidance of tea-specific prior knowledge, has serious distortions in the contour restoration of the occluded area, and is prone to incorrectly splicing the edges of the upper tea leaves to the lower tea leaves, or completing broken bud tips as smooth arcs; Second, the bud and leaf structure recognition integrity rate of the experimental group reached 93.2%, significantly higher than the 81.5% of the control group, indicating that the constrained contour completion not only repaired the visual contour, but also reconstructed the correct structural connection relationship, so that the subsequent bud tips, leaves, tea stems and main vein areas can be accurately separated; Third, the mean value of the topological consistency feature of the experimental group was 0.915, much higher than the 0.724 of the control group, proving that the completion result guided by the topological constraint of buds and leaves is highly consistent with the physiological connection rules of natural buds and leaves in structure, while the unconstrained completion result is prone to topological anomalies such as misalignment of bud tips and tea stems, and deviation of the main vein.
[0116] Furthermore, in scenarios with severe occlusion, the control group could no longer provide effective data. When the occlusion level reached level 3, the identifiable area of the occluded instance was less than 35% of the complete area. Existing instance segmentation models struggled to classify it as an independent target, resulting in many occluded tea leaves being incorrectly merged or discarded. In contrast, the method of this invention, in step S2, used paired detection of boundary breakpoints and step-by-step derivation of occlusion levels to pinpoint the locations of these severely occluded instances. Through the α3 and α4 weight synchronization enhancement mechanism in step S3, prioritizing tea leaf shape priors and bud / leaf topological constraints during the completion process, it ultimately achieved a classification accuracy of 85.3% for premium tea and 78.7% for first-grade tea. The mean occlusion correction feature of the experimental group increased smoothly with the severity of occlusion, from 0.136 for mild occlusion to 0.491 for severe occlusion. This feature continued to play a role in the adaptive weight fusion in step S6, effectively reducing the interference of completion errors on classification decisions.
[0117] In summary, this comparative experiment demonstrates the beneficial effects of the present invention's technical solution from three dimensions. In terms of morphological restoration, constrained contour completion reduces contour morphological deviation in occluded scenarios by more than 20 percentage points, ensuring that the completion results possess structural compliance while maintaining visual reasonableness. In terms of structural recognition, the construction of the bud-leaf heterogeneous topology map elevates tea grading from traditional texture classification to a structural reasoning level. Topological indicators such as bud-leaf connection integrity, angle matching degree, and quantity matching degree directly correspond to core evaluation factors in national evaluation standards, such as "bud-leaf cluster formation and uniformity." In terms of credibility control, occlusion correction features, as quantitative proxy indicators of completion quality, dynamically adjust the contribution weight of each feature in the final classification, forming a complete closed loop from occlusion recognition to result output.
[0118] 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 it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A tea leaf detection and classification method based on image recognition, characterized in that, include: S1: Obtain the tea leaf image to be detected, and perform foreground segmentation and instance segmentation on the tea leaf image to be detected to obtain multiple tea leaf candidate instances; S2: Perform adhesion and occlusion recognition on the multiple tea candidate instances to determine the occlusion hierarchy relationship between each tea candidate instance; S3: Based on the occlusion hierarchy, determine the candidate tea leaf instances with occlusion and their contour regions to be filled, and based on the preset tea leaf shape prior data and bud and leaf topological constraint data, perform constrained contour filling on the contour regions to be filled to obtain reconstructed tea leaf instances. S4: Perform structural region identification on the reconstructed tea leaf instance to obtain the bud tip region, leaf region, tea stem region, and main vein region; S5: Based on the spatial connection relationship between the bud tip region, leaf region, tea stem region and main vein region, construct a bud-leaf heterogeneous topology map, and generate topological consistency features, structural integrity features and occlusion correction features based on the bud-leaf heterogeneous topology map. S6: Generate a comprehensive tea classification feature based on the topological consistency feature, the structural integrity feature, and the occlusion correction feature, and output the tea detection and classification result based on the comprehensive tea classification feature.
2. The tea leaf detection and classification method based on image recognition as described in claim 1, characterized in that, Step S1 specifically includes: The image of the tea leaves to be detected is subjected to illumination equalization and background separation to obtain the foreground region of the tea leaves; The foreground region of the tea leaves is segmented and its contours are extracted to obtain multiple candidate tea leaf instances and their corresponding candidate contours.
3. The tea leaf detection and classification method based on image recognition as described in claim 2, characterized in that, Step S2 specifically includes: Based on the candidate contours corresponding to each tea candidate instance, determine the contour overlap relationship, boundary interruption relationship, and region coverage relationship between adjacent tea candidate instances; Based on the contour overlap relationship, the boundary interruption relationship, and the region coverage relationship, determine the adhesion and occlusion status of each tea candidate instance, and distinguish between upper occluded instances and lower occluded instances. Based on the distinction between the upper-layer occluded instance and the lower-layer occluded instance, the occlusion hierarchy relationship between each tea candidate instance is determined.
4. The tea leaf detection and classification method based on image recognition as described in claim 3, characterized in that, The preset tea leaf shape prior data and bud / leaf topological constraint data include: The prior data on tea shape includes the outline morphology of the tea leaves, the length-to-width ratio of the leaves, the distribution of the curvature of the leaf margins, the direction of the main vein extension, and the connection position of the tea stem. The bud and leaf topological constraint data includes the connection relationship between the bud tip and the leaf, the connection relationship between the leaf and the tea stem, and the directional correspondence between the midrib and the leaf. The tea leaf shape prior data and the bud and leaf topological constraint data are both pre-constructed based on standard tea leaf samples.
5. The tea leaf detection and classification method based on image recognition as described in claim 4, characterized in that, Based on preset tea leaf shape prior data and bud / leaf topological constraint data, constrained contour completion is performed on the region to be completed to obtain a reconstructed tea leaf instance, including: Contour completion energy function is constructed, which includes leaf margin continuity constraint term, midrib direction continuity constraint term, tea leaf shape prior constraint term, and bud-leaf topological consistency constraint term; With the goal of minimizing the contour completion energy function, constrained contour completion is performed on the contour region to be completed to obtain a reconstructed tea instance that conforms to the prior data of tea shape and the topological constraint data of bud and leaf.
6. The tea leaf detection and classification method based on image recognition as described in claim 5, characterized in that, Step S4 specifically includes: For the reconstructed tea leaf instance and the unoccluded tea leaf candidate instance, the outline skeleton, main vein direction and local structural endpoints of the instance are extracted respectively. The bud tip region is determined based on the endpoints of the local structure, the leaf region is determined based on the area enclosed by the outline skeleton, the tea stem region is determined based on the slender connecting structure connected to the leaf region, and the main vein region is determined based on the linear texture direction of the main vein.
7. The tea leaf detection and classification method based on image recognition as described in claim 6, characterized in that, Step S5 specifically includes: For each tea instance, the identified bud tip region, leaf region, tea stem region, and main vein region are used as heterogeneous nodes. Based on the spatial connection relationship between each region, topological connection edges between nodes are constructed to form the bud and leaf heterogeneous topological graph of the corresponding tea instance. Based on the node connection relationships of the bud-leaf heterogeneous topology graph and the preset bud-leaf topology constraint data, a topology consistency feature is generated. Based on the node coverage of the heterogeneous topology graph of buds and leaves and the preset prior data of tea leaf shape, structural integrity features are generated. Based on the occlusion state and occlusion hierarchy of the tea leaf instances corresponding to the heterogeneous topology of the buds and leaves, occlusion correction features are generated.
8. The tea leaf detection and classification method based on image recognition as described in claim 7, characterized in that, Step S6 specifically includes: The topological consistency feature, structural integrity feature, and occlusion correction feature are weighted and fused to generate a comprehensive tea classification feature; The comprehensive classification features of tea are matched with preset classification rules to obtain tea grade classification results, structural anomaly detection results, and integrity assessment results; The tea grade classification results, structural anomaly detection results, and integrity assessment results are combined to output the final tea detection and classification results.
9. A tea detection and classification system based on image recognition, used to implement the tea detection and classification method based on image recognition as described in any one of claims 1 to 8, characterized in that, include: Image acquisition and instance segmentation module: acquires the tea image to be detected, performs foreground segmentation and instance segmentation on the tea image to be detected, and obtains multiple tea candidate instances; Occlusion recognition module: performs adhesion occlusion recognition on the multiple tea candidate instances and determines the occlusion hierarchy relationship between each tea candidate instance; Contour completion module: Based on the occlusion hierarchy, determine the candidate tea leaf instances with occlusion and their contour regions to be completed, and based on the preset tea leaf shape prior data and bud and leaf topological constraint data, perform constrained contour completion on the contour regions to be completed to obtain reconstructed tea leaf instances; Structural Region Recognition Module: Performs structural region recognition on the reconstructed tea leaf instance to obtain the bud tip region, leaf region, tea stem region, and main vein region; Topology analysis module: Based on the spatial connectivity between the bud tip region, leaf region, tea stem region and main vein region, construct a heterogeneous topology map of bud and leaf, and generate topological consistency features, structural integrity features and occlusion correction features based on the heterogeneous topology map of bud and leaf; Comprehensive classification module: Generates comprehensive tea classification features based on the topological consistency feature, the structural integrity feature, and the occlusion correction feature, and outputs tea detection and classification results based on the comprehensive tea classification features.