Grain impurity weight estimation method and system based on instance segmentation and sequence deduplication
Patent Information
- Application Number
- CN202611019494.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-09
- Publication Date
- 2026-10-09
AI Technical Summary
[0004]本发明旨在解决现有粮食杂质视觉检测方法存在准确性较差的问题,提出一种基于实例分割与序列去重的粮食杂质估重方法及系统
[0057]本发明的有益效果是:本发明提供的基于实例分割与序列去重的粮食杂质估重方法及系统,通过实例分割掩膜替代水平矩形框对颗粒进行定位,能够更精确地刻画斜向杂质的真实轮廓,有效避免了背景区域引入的面积偏差,从而提高了投影面积标定与重量估算精度;通过时序图像序列中基于外接框重叠程度和/或中心距离的跨帧关联与轨迹合并,将同一物理颗粒的多个重复检出归并为唯一目标,能够有效消除飞拍场景下的重复计数问题,进一步提高了杂质估重的准确性;通过基于物理投影面积绝对值并结合质量赋值模型估算各目标的单粒质量,并根据输出类别分别汇总得到每类颗粒的估计总质量,能够直接输出与粮检业务系统对接的各品类质量报表,无需人工换算或二次称重;同时,按输出类别统计各目标的颗粒数量并汇总得到每类颗粒的总数,可直接替代人工计数环节,进一步提高检测效率;此外,对于置信度偏低但未被直接丢弃的检测结果,通过门控机制将其归为未知杂质,既避免了低置信度结果直接入账造成的误检风险,又为后续分析和模型优化保留了追溯信息。
Smart Images

Figure CN122888313A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of grain impurity detection technology, specifically to a method and system for estimating the weight of grain impurities based on instance segmentation and sequence deduplication. Background Technology
[0002] Grain impurity testing is a crucial quality control step in grain procurement, warehousing inspection, and weighing in processing lines. According to current grain inspection standards and warehousing operation requirements, impurities are typically categorized into large impurities, small impurities (side-by-side impurities), fine impurities, and light impurities. Inspection reports must specify the mass or percentage of each type of impurity, as well as the net grain content. Currently, the primary method for this testing is manual sorting and weighing, with some units supplementing with mechanical sieving. However, this process is time-consuming, labor-intensive, and the test results are significantly influenced by the operator's experience.
[0003] With the development of machine vision technology, some solutions have attempted to introduce image recognition technology into grain impurity detection, but the following shortcomings still exist: Existing vision solutions mostly use horizontal rectangular boxes to locate the detection target. For impurities such as wheat stalks and straw placed at an angle, the horizontal box will include a large background area, leading to a large deviation in area estimation and affecting the accuracy of subsequent weight estimation. In production line aerial photography scenarios using a linear feeder and a high-speed camera for continuous shooting, the same physical particle may appear in multiple consecutive frames. Existing solutions count each frame independently, resulting in the same particle being detected repeatedly, causing significantly higher particle counts and estimated weights. Furthermore, the output of existing solutions is mostly particle quantity or category labels, which is disconnected from the quality reports required by the grain inspection business system. The quality of each category of impurities still needs to be manually calculated or obtained through secondary weighing. For detection results with low prediction confidence during instance segmentation model inference, existing solutions either discard them directly, causing missed detections, or include them directly, causing false detections, lacking a reasonable processing mechanism. Summary of the Invention
[0004] This invention aims to solve the problem of poor accuracy in existing visual detection methods for grain impurities, and proposes a method and system for estimating the weight of grain impurities based on instance segmentation and sequence deduplication.
[0005] The technical solution adopted by the present invention to solve the above-mentioned technical problems is as follows:
[0006] In a first aspect, the present invention provides a method for estimating the weight of grain impurities based on instance segmentation and sequence deduplication, the method comprising:
[0007] The input image of the grain sample is obtained, which contains multiple physical particles, namely grain particles or impurity particles; the input image is a single photograph of a static sample plate, or a time-series image sequence extracted frame by frame after continuous shooting of the flat-ballistic discharge flow from a fixed position.
[0008] A region of interest is determined on the input image as the geometric range for subsequent instance segmentation; if the region of interest cannot be located, the entire input image is used as the region of interest.
[0009] The cropped image of the region of interest is fed into the instance segmentation model to obtain a set of detected instances, which contains multiple detected instances; each detected instance outputs at least: predicted category, prediction confidence, instance segmentation mask, and bounding box.
[0010] For each detection instance in the detection instance set, the mask pixel area is calculated using the instance segmentation mask; the mask pixel area is converted into the absolute value of the physical projection area based on the pixel equivalent obtained by camera plane calibration.
[0011] For each detection instance in the detection instance set, the output category of the detection instance is determined based on the predicted category and the predicted confidence level, combined with the confidence level threshold set for each impurity category; wherein, when the predicted category is an impurity category and the predicted confidence level is lower than the confidence level threshold for that impurity category, the output is an unknown impurity;
[0012] If the input image is a temporal image sequence, then based on the degree of overlap and / or center distance between the bounding boxes of the detection instances in consecutive frames, the detection instances of the same physical particle appearing across frames are associated with the same trajectory, and the detection instance with the largest absolute value of physical projection area is retained as the representative of the trajectory within each trajectory; then, for the representative bounding boxes of all archived trajectories, spatial merging is performed based on the degree of overlap and / or center distance between the bounding boxes, and multiple trajectories belonging to the same physical particle are grouped into the same merge group;
[0013] If the input image is a single photograph, spatial merging is performed directly based on the degree of overlap and / or center distance between the bounding boxes of the detection instances, and multiple detection instances belonging to the same physical particle are grouped into the same merging group.
[0014] Within each merge group, the detection instance with the largest absolute value of physical projected area is selected as the representative of the merge group, forming a unique target set. Each target in the unique target set corresponds to a physical particle.
[0015] For each target in the unique target set, the estimated single-particle mass is determined based on the absolute value of the physical projected area and a pre-established mass assignment model. Based on the corresponding output category, the number of particles and the estimated total mass for each output category are obtained respectively.
[0016] Further, determining the region of interest on the input image specifically includes:
[0017] When the input image is a time-series image sequence, the flying backlight mode is adopted, and the effective imaging area of the backlight panel is pre-calibrated as a fixed region of interest, or the bright field area is automatically extracted by binarizing the backlight image and then used as the region of interest after the aspect ratio and the ratio of width and height to the whole image are verified.
[0018] When the input image is a single photo of a static sample plate, the static sample plate mode is adopted. The grayscale binarization of the input image is used to extract the plate surface. After morphological operations to remove noise, candidate regions are selected according to the contour area ratio and shape. The bounding rectangle of the largest contour is taken and expanded as the region of interest.
[0019] The aspect ratio and width-to-height ratio of the region of interest obtained by localization to the whole image are verified. If the aspect ratio or width-to-height ratio of the region of interest to the whole image does not meet the preset verification rules, the localization is determined to be a failure, and the whole input image is used as the region of interest.
[0020] Furthermore, the output category of the detection instance is determined according to the following rules:
[0021] When the predicted category is a grain category, the grain category is output directly; when the predicted category is an impurity category and the prediction confidence is not lower than the confidence threshold of the impurity category, the impurity category is output; when the predicted category is an impurity category and the prediction confidence is lower than the confidence threshold of the impurity category, the unknown impurity is output.
[0022] Furthermore, the formula for calculating the area of the mask pixels is as follows:
[0023] ;
[0024] in, Indicates the sequence number of the detected instance. Indicates the first The mask pixel area of each detection instance, Indicates the first Instance segmentation mask for each detection instance, This is a set radix operator, representing the counting of foreground pixels within the mask.
[0025] Furthermore, the calibration formula for the pixel equivalent is:
[0026] ;
[0027] The conversion formula for the absolute value of the physical projected area is as follows:
[0028] ;
[0029] in, Represents pixel equivalent. This indicates the pixel length of the calibration reference object on the image plane. Indicates the physical length of the calibration reference object. Indicates the first The absolute value of the physical projected area of each detection instance. Indicates the first The mask pixel area of each detection instance.
[0030] Furthermore, the overlap between the bounding boxes of consecutive inter-frame detection instances is measured using the intersection-union ratio (IUGR):
[0031] ;
[0032] in, Indicates the sequence number of the detection instance in the current frame. Indicates the trajectory number. Indicates the current frame number The outer frame of a detection instance Indicates the first The outer bounding box representing the trajectory. Indicates the current frame number The outer frame of a detection instance With the The outer bounding box representing the trajectory The crossover ratio between them This represents the area calculation operator. To represent the intersection of sets, Represents the union of sets;
[0033] When associating detected instances of the same physical particle appearing across frames to the same trajectory, the criteria for trajectory association are as follows:
[0034] or ;
[0035] in, This represents the preset crossover-union ratio (CUI) threshold. Indicates the current frame number The outer frame center of the first detection instance is related to the first... The trajectories represent the Euclidean distance between the centers of the bounding boxes. This represents the preset center distance coefficient. Indicates the current frame number The outer frame of a detection instance The length of the diagonal.
[0036] Furthermore, the quality assignment model adopts a linear form, as follows:
[0037] ;
[0038] in, Indicates the first Estimated single-grain mass for each target This indicates the output category number. Indicates the output category The quality assignment slope coefficient, Indicates the first The absolute value of the physical projected area of a target. Indicates the output category The quality-assigned intercept, the slope coefficient With intercept The results were obtained through least squares fitting, where each output category corresponds to an independent set of values. and .
[0039] Furthermore, the formula for calculating the estimated total mass is as follows:
[0040] ;
[0041] in, This indicates the output category number. Indicates the output category The estimated total mass, Indicates the first unique target set. The output category of each target Indicates the first Estimated single-grain mass of each target.
[0042] Furthermore, the method also includes an accuracy judgment step for the quality assignment model:
[0043] Using the true values of the number of calibrated grains and the true value of the total calibrated mass for each output category collected in the calibration batch, the deviation index of the estimated single grain mass relative to the true single grain mass of that category is calculated:
[0044] ;
[0045] in, This indicates the output category number. Indicates the output category Deviation index, Represents a unique target set. Indicates the first Estimated single-grain mass for each target Indicates the first The output category of each target Indicates the first The target belongs to the output category. , Indicates the output category The median estimated single-grain mass of all targets. Indicates the output category The true value of the calibrated total mass. Indicates the output category The true value of the calibration particle number.
[0046] Secondly, the present invention provides a grain impurity estimation system based on instance segmentation and sequence deduplication, for implementing the grain impurity estimation method based on instance segmentation and sequence deduplication as described in the first aspect, the system comprising:
[0047] The image acquisition unit is used to acquire an input image of a grain sample. The input image contains multiple physical particles, which are grain particles or impurity particles. The input image is a single photograph of a static sample plate or a time-series image sequence extracted frame by frame after continuous shooting of a flat-ballistic discharge flow from a fixed position.
[0048] A region of interest localization unit is used to determine a region of interest on the input image as the geometric range for subsequent instance segmentation; if the region of interest localization fails, the entire input image is used as the region of interest.
[0049] The instance segmentation inference unit is used to feed the cropped image of the region of interest into the instance segmentation model to obtain a set of detected instances, which contains multiple detected instances; each detected instance outputs at least: predicted category, predicted confidence, instance segmentation mask, and bounding box.
[0050] The projected area calculation unit is used to calculate the mask pixel area for each detection instance in the detection instance set using the instance segmentation mask; and to convert the mask pixel area into the absolute value of the physical projected area based on the pixel equivalent obtained by camera plane calibration.
[0051] The confidence gating unit is used to determine the output category of each detection instance in the detection instance set based on the predicted category and the predicted confidence, and in combination with the confidence threshold set for each impurity category.
[0052] The deduplication and merging unit is used for:
[0053] If the input image is a temporal image sequence, then based on the degree of overlap and / or center distance between the bounding boxes of the detection instances in consecutive frames, the detection instances of the same physical particle appearing across frames are associated with the same trajectory, and the detection instance with the largest absolute value of physical projection area is retained as the representative of the trajectory within each trajectory; then, for the representative bounding boxes of all archived trajectories, spatial merging is performed based on the degree of overlap and / or center distance between the bounding boxes, and multiple trajectories belonging to the same physical particle are grouped into the same merge group;
[0054] If the input image is a single photograph, spatial merging is performed directly based on the degree of overlap and / or center distance between the bounding boxes of the detection instances, and multiple detection instances belonging to the same physical particle are grouped into the same merging group.
[0055] Within each merge group, the detection instance with the largest absolute value of physical projected area is selected as the representative of the merge group, forming a unique target set. Each target in the unique target set corresponds to a physical particle.
[0056] The weight estimation calculation unit is used to determine the estimated single-particle mass for each target in the unique target set based on the absolute value of the physical projected area and a pre-established mass assignment model, and to obtain the number of particles and the estimated total mass for each output category according to the corresponding output category.
[0057] The beneficial effects of this invention are as follows: The grain impurity weight estimation method and system based on instance segmentation and sequence deduplication provided by this invention, by replacing the horizontal rectangular box with an instance segmentation mask to locate particles, can more accurately depict the true contour of oblique impurities, effectively avoiding the area deviation introduced by the background area, thereby improving the accuracy of projection area calibration and weight estimation; by cross-frame association and trajectory merging based on the degree of overlap of bounding boxes and / or center distance in the temporal image sequence, multiple duplicate detections of the same physical particle are merged into a single target, which can effectively eliminate the duplicate counting problem in aerial photography scenarios, further improving the accuracy of impurity weight estimation; by using physical projection... The system estimates the individual grain mass of each target by combining the absolute area value with a quality assignment model, and summarizes the estimated total mass of each type of grain according to the output category. It can directly output quality reports for each category that are integrated with the grain inspection business system, without the need for manual conversion or secondary weighing. At the same time, it counts the number of grains of each target according to the output category and summarizes the total number of grains of each category, which can directly replace the manual counting process and further improve the detection efficiency. In addition, for test results with low confidence but not directly discarded, a gating mechanism is used to classify them as unknown impurities. This avoids the risk of false detection caused by directly recording low confidence results and retains traceability information for subsequent analysis and model optimization. Attached Figure Description
[0058] Figure 1 A flowchart illustrating the grain impurity estimation method based on instance segmentation and sequence deduplication provided in this embodiment;
[0059] Figure 2 This is a schematic diagram of image acquisition and hardware deployment in the flying photography mode provided in the embodiment;
[0060] Figure 3 A schematic diagram of the region of interest localization process provided in the static sample disk mode for an embodiment;
[0061] Figure 4 A schematic diagram of an example segmentation mask and bounding box provided for an embodiment;
[0062] Figure 5 This is a schematic diagram of the confidence gating process provided in the embodiment;
[0063] Figure 6 A schematic diagram of the deduplication and merging process provided in this embodiment;
[0064] Figure 7 A schematic diagram of fitting the mass assignment model for large impurities provided in the embodiment;
[0065] Figure 8 This is a schematic diagram of the structure of a grain impurity estimation system based on instance segmentation and sequence deduplication provided in an embodiment. Detailed Implementation
[0066] Because existing visual detection methods for grain impurities mostly use horizontal rectangular frames to locate the detection target, and in continuous shooting scenarios on the production line, the same physical particle appearing in multiple consecutive frames of images is repeatedly detected, resulting in poor accuracy of the particle count and weight estimation results.
[0067] Based on this, the technical solution of the present invention is proposed. In this invention, an input image containing grain particles and impurity particles is first acquired. The region of interest is determined, cropped, and fed into an instance segmentation model to obtain the predicted category, prediction confidence, instance segmentation mask, and bounding box for each detected instance. Then, the pixel area of the instance segmentation mask is calculated, and combined with the pixel equivalent of the camera calibration, it is converted into the absolute value of the physical projection area, which serves as the area benchmark for subsequent weight estimation. At the same time, each detected instance is gated based on the predicted category and prediction confidence, and the final category of each detected instance is output. For time-series image sequences, the same physical particle that appears repeatedly across frames is associated with the same trajectory based on the degree of overlap of the bounding boxes and / or the center distance between the detected instances in consecutive frames, and the archived trajectories are spatially merged. For a single image, spatial merging is performed directly based on the bounding boxes, and multiple detected instances belonging to the same physical particle are merged into a unique target to form a unique target set. Finally, for each target in the unique target set, its estimated single-grain mass is determined based on the absolute value of the physical projection area and a pre-established mass assignment model, and then summarized according to the output category to obtain the number of particles and the estimated total mass corresponding to each output category.
[0068] The technical solutions in this embodiment will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0069] Figure 1A flowchart illustrating a method for estimating grain impurities based on instance segmentation and sequence deduplication is shown. Please refer to [link / reference]. Figure 1 The method includes the following steps:
[0070] Step 1, Image Acquisition:
[0071] The input image of the grain sample is obtained. The input image contains multiple physical particles, which are grain particles or impurity particles. The input image is a single photograph of a static sample plate or a time-series image sequence extracted frame by frame after continuous shooting of the flat-ballistic discharge flow from a fixed position.
[0072] Specifically, this step involves acquiring an input image of the grain sample. This input image contains multiple physical particles, which fall into two main categories: grain particles and impurity particles. Impurity particles are further categorized into large impurities, small impurities, fine impurities, and light impurities.
[0073] There are two scenarios regarding the source of the input image:
[0074] The first type is a single photograph of a static sample tray, suitable for static testing in laboratory or sampling scenarios.
[0075] The second type is a sequence of images taken by drone in online inspection scenarios on production lines. Please refer to [link / reference]. Figure 2 The hardware deployment for this scenario is as follows: a linear feeder discharges grains at a uniform speed, causing them to fall in a flat, parabolic trajectory; a backlight is positioned on one side of the material drop path, providing uniform backlighting to highlight the edges of the grains; an aperture-type surface light is mounted at the front of the camera lens, with a central aperture that does not obstruct the view and surrounding positive fill light to reduce surface shadows; a global shutter industrial camera is fixedly mounted on the other side of the material drop path, directly opposite the backlight, to continuously capture images of the grains during their fall. Subsequently, frames are extracted from the images captured by the camera to obtain a time-series image sequence, which serves as the input image.
[0076] Step 2: Locating the Region of Interest:
[0077] A region of interest is determined on the input image as the geometric range for subsequent instance segmentation; if the region of interest cannot be located, the entire input image is used as the region of interest.
[0078] In this embodiment, determining the region of interest on the input image specifically includes:
[0079] When the input image is a time-series image sequence, the flying backlight mode is adopted, and the effective imaging area of the backlight panel is pre-calibrated as a fixed region of interest, or the bright field area is automatically extracted by binarizing the backlight image and then used as the region of interest after the aspect ratio and the ratio of width and height to the whole image are verified.
[0080] When the input image is a single photo of a static sample plate, the static sample plate mode is adopted. The grayscale binarization of the input image is used to extract the plate surface. After morphological operations to remove noise, candidate regions are selected according to the contour area ratio and shape. The bounding rectangle of the largest contour is taken and expanded as the region of interest.
[0081] The aspect ratio and width-to-height ratio of the region of interest obtained by localization to the whole image are verified. If the aspect ratio or width-to-height ratio of the region of interest to the whole image does not meet the preset verification rules, the localization is determined to be a failure, and the whole input image is used as the region of interest.
[0082] Specifically, this step determines the region of interest (ROI) on the input image to limit the detection range of subsequent instance segmentation, focusing the processing on the effective areas where particles may appear, avoiding interference from background areas, and reducing computational load.
[0083] The method for determining the region of interest is divided into two modes depending on the source of the input image.
[0084] In the backlight shooting mode, the input image is a time-series image sequence. At this time, the effective imaging area of the backlight panel is pre-calibrated as a fixed region of interest; or, the backlight image is binarized, the bright field area is automatically extracted as a candidate region of interest, and then the width and height ratio of the region to the whole image and the aspect ratio are verified. If the verification is successful, it is taken as the region of interest.
[0085] In static sample tray mode, the input image is a single photograph. Please refer to [link / reference]. Figure 3 The specific process for locating the region of interest in this mode includes:
[0086] First, the input image is converted to grayscale and binarized using an adaptive threshold. Then, morphological denoising is performed, with two closing operations and one opening operation executed sequentially. The structuring element size is 7×7 pixels to eliminate interference from disk textures and tiny specks on contour extraction. Next, all contours are extracted and preliminarily filtered. The filtering criteria are that the contour area accounts for 10% to 95% of the total image area, and the number of contour vertices is between 4 and 8, to exclude interference areas that are too small, too large, or irregularly shaped. Among the selected candidate regions, the contour with the largest area is selected, and its bounding rectangle is expanded outward by 2% to generate a candidate region of interest. The width and height ratios of this region to the total image and its aspect ratio are then verified. Regions that pass the verification are designated as regions of interest.
[0087] The process involves validating the proportions of the candidate region of interest (ROI) to the entire image, including its width and height, as well as its aspect ratio. The validation rules are: the width must be at least 30% of the entire image, the height must be at least 30% of the entire image, and the aspect ratio must be between 0.45 and 2.2. If all three criteria are met, the validation passes, and the region is output as the final ROI.
[0088] For both modes described above, if the aspect ratio or width-to-height ratio of the candidate region of interest to the entire image does not conform to the above verification rules, the localization is deemed a failure. In this case, the localization result is no longer used; instead, the entire input image is directly used as the region of interest to ensure that subsequent instance segmentation can proceed normally. Through the localization and verification fallback mechanism of the above two modes, it is possible to adaptively accommodate both aerial photography and static sample disk detection conditions.
[0089] Step 3, Instance Segmentation Reasoning:
[0090] The cropped image of the region of interest is fed into the instance segmentation model to obtain a set of detected instances, which contains multiple detected instances; each detected instance outputs at least: predicted category, prediction confidence, instance segmentation mask, and bounding box.
[0091] Specifically, this step feeds the cropped image of the region of interest obtained in step 2 into the instance segmentation model, which performs pixel-level recognition and localization of each physical particle in the cropped image and outputs a set of detected instances.
[0092] The instance segmentation model employs a lightweight segmentation network structure (such as the segmentation version of the YOLO series), optimized with TensorRT or FP16 and deployed on edge inference devices. This model can achieve real-time inference while maintaining high detection accuracy, with an inference speed on the order of 2 milliseconds per frame, matching the high-speed image acquisition pace in aerial photography.
[0093] This instance segmentation model has been trained to recognize grain particles and various impurities, predicting categories that include at least grains (such as wheat), large impurities, small impurities, fine impurities, and light impurities. After performing inference on the cropped image, the model outputs a set of detected instances for the current frame. This set contains multiple detected instances, each corresponding to a physical particle in the image.
[0094] For each detection instance, the model outputs at least the following four pieces of information:
[0095] Predicted category: This indicates the category to which the model determines the instance belongs. It can be any one of the five categories mentioned above.
[0096] Prediction confidence score represents the degree of confidence the model has in the predicted category. It ranges from 0 to 1, with a higher confidence score indicating a greater certainty about the classification result.
[0097] An instance segmentation mask represents the pixel-level foreground region of an instance in an image. This means that each pixel is labeled with whether it belongs to the instance, thereby accurately depicting the true outline of the particles and providing a basis for subsequent area calculations.
[0098] The bounding box represents the smallest bounding rectangle of this instance, which is used for position matching during trajectory association and spatial merging in subsequent steps.
[0099] Please refer to the instance segmentation mask and bounding box. Figure 4 .
[0100] Step 4: Calculate the projected area:
[0101] For each detection instance in the detection instance set, the mask pixel area is calculated using the instance segmentation mask; the mask pixel area is converted into the absolute value of the physical projection area based on the pixel equivalent obtained by camera plane calibration.
[0102] In this embodiment, the formula for calculating the area of the mask pixels is:
[0103] ;
[0104] in, Indicates the sequence number of the detected instance. Indicates the first The mask pixel area of each detection instance, Indicates the first Instance segmentation mask for each detection instance, This is a set radix operator, representing the counting of foreground pixels within the mask.
[0105] The formula for determining the pixel equivalent is:
[0106] ;
[0107] The conversion formula for the absolute value of the physical projected area is as follows:
[0108] ;
[0109] in, Represents pixel equivalent. This indicates the pixel length of the calibration reference object on the image plane. Indicates the physical length of the calibration reference object. Indicates the first The absolute value of the physical projected area of each detection instance. Indicates the first The mask pixel area of each detection instance.
[0110] Specifically, this step calculates the absolute value of the physical projected area for each detection instance obtained in step 3, which serves as the basis for subsequent weight estimation.
[0111] The calculation process is divided into two stages: first, the mask pixel area is calculated from the pixel domain, and then the pixel area is converted into physical area.
[0112] During the pixel domain calculation phase, for each detected instance, the total number of foreground pixels covered by its instance segmentation mask is counted, i.e., the number of pixels belonging to that instance within the mask. This count value is the mask pixel area for that instance. Instance segmentation masks are used instead of bounding boxes for area calculation because masks can accurately fit the true contours of particles, avoiding the inclusion of background areas surrounding the particles in the area calculation. This is especially true for irregularly shaped impurities such as obliquely placed straw or stalks, where mask area calculations offer higher accuracy compared to bounding box area calculations.
[0113] During the physical conversion stage, the mask pixel area is converted into the absolute value of the physical projected area, in square millimeters. Before the conversion, the camera needs to be calibrated in a plane to obtain the pixel equivalent, that is, the physical side length corresponding to each pixel. During calibration, a reference object with known physical dimensions (such as a checkerboard calibration board) is placed at the imaging plane position. The pixel length occupied by the reference object on the image plane is measured through image processing. The pixel equivalent is obtained by dividing the physical length of the reference object by the pixel length, in millimeters per pixel.
[0114] After obtaining the pixel equivalent, multiplying the mask pixel area by the square of the pixel equivalent yields the absolute value of the physical projected area of the instance. This absolute value of the physical projected area serves as the basis for subsequent quality assignment model establishment and weight estimation calculations. All targets are converted using a unified calibration coefficient, ensuring the comparability and reproducibility of area measurements across different devices or working distances.
[0115] Step 5, Confidence Gating:
[0116] For each detection instance in the set of detection instances, the output category of the detection instance is determined based on the predicted category and the predicted confidence level, combined with the confidence level threshold set for each impurity category; wherein, when the predicted category is an impurity category and the predicted confidence level is lower than the confidence level threshold of the impurity category, the output is an unknown impurity.
[0117] In this embodiment, the output category of the detection instance is determined according to the following rules:
[0118] When the predicted category is a grain category, the grain category is output directly; when the predicted category is an impurity category and the prediction confidence is not lower than the confidence threshold of the impurity category, the impurity category is output; when the predicted category is an impurity category and the prediction confidence is lower than the confidence threshold of the impurity category, the unknown impurity is output.
[0119] Specifically, this step performs gating processing on each detection instance obtained in step 3 based on its predicted category and prediction confidence to determine the final output category of the detection instance to be written into the output result.
[0120] For detection results with high prediction confidence, the predicted category of the instance segmentation model is directly used as the output category. For detection results with low prediction confidence, directly discarding them would result in information loss, while directly accepting them carries the risk of false detection. Therefore, this embodiment sets confidence thresholds for different impurity categories, forming a classification gating mechanism that allows categories with different recognition difficulties to be judged using different levels of strictness.
[0121] The specific rules are as follows:
[0122] When the predicted category is a grain category (such as wheat), that grain category is output directly. As the main component of the sample, the confidence level of the grain category is usually high, and the impact of false detections of grain on the final calculation of impurity content is relatively controllable. Therefore, the grain category is directly gated without setting a confidence threshold limit.
[0123] When the predicted category is a certain impurity category and the prediction confidence is not lower than the confidence threshold corresponding to that impurity category, the output is that impurity category.
[0124] When the predicted category is a certain impurity category, but the prediction confidence is lower than the confidence threshold corresponding to that impurity category, it is determined that the confidence of the detection result is insufficient to determine its specific impurity type. In this case, the original predicted category of the instance segmentation model is not used, but the output category of the detected instance is classified as an unknown impurity.
[0125] In practical applications, the confidence thresholds for different impurity categories can be set separately according to the specific scenario and accuracy requirements. Please refer to [link / reference]. Figure 5 For example, the threshold for large impurities can be set to 0.70, small impurities to 0.60, fine impurities to 0.55, and light impurities to 0.50. When the instance segmentation model predicts a detected instance as a large impurity but the confidence level is only 0.65, the detected instance will be classified as an unknown impurity. This classification gating mechanism can control the risk of false detections while retaining low-confidence results for subsequent analysis, avoiding missed detections caused by direct discarding. For detected instances classified as unknown impurities, their original predicted category is retained in the internal data so that the original prediction information can be traced during subsequent data analysis or model optimization, but in the official output results, it is only recorded as an unknown impurity.
[0126] Step 6: Deduplication and Merging:
[0127] If the input image is a temporal image sequence, then based on the degree of overlap and / or center distance between the bounding boxes of the detection instances in consecutive frames, the detection instances of the same physical particle appearing across frames are associated with the same trajectory, and the detection instance with the largest absolute value of physical projection area is retained as the representative of the trajectory within each trajectory; then, for the representative bounding boxes of all archived trajectories, spatial merging is performed based on the degree of overlap and / or center distance between the bounding boxes, and multiple trajectories belonging to the same physical particle are grouped into the same merge group;
[0128] If the input image is a single photograph, spatial merging is performed directly based on the degree of overlap and / or center distance between the bounding boxes of the detection instances, and multiple detection instances belonging to the same physical particle are grouped into the same merging group.
[0129] Within each merge group, the detection instance with the largest absolute value of physical projected area is selected as the representative of that merge group, forming a unique target set. Each target in the unique target set corresponds to a physical particle.
[0130] In this embodiment, the overlap between the bounding boxes of consecutive inter-frame detection instances is measured using the intersection-union ratio (IUGR):
[0131] ;
[0132] in, Indicates the sequence number of the detection instance in the current frame. Indicates the trajectory number. Indicates the current frame number The outer frame of a detection instance Indicates the first The outer bounding box representing the trajectory. Indicates the current frame number The outer frame of a detection instance With the The outer bounding box representing the trajectory The crossover ratio between them This represents the area calculation operator. To represent the intersection of sets, Represents the union of sets;
[0133] When associating detected instances of the same physical particle appearing across frames to the same trajectory, the criteria for trajectory association are as follows:
[0134] or ;
[0135] in, This represents the preset crossover-union ratio (CUI) threshold. Indicates the current frame number The outer frame center of the first detection instance is related to the first... The trajectories represent the Euclidean distance between the centers of the bounding boxes. This represents the preset center distance coefficient. Indicates the current frame number The outer frame of a detection instance The length of the diagonal.
[0136] Specifically, this step performs deduplication and merging on the detection instances obtained in step 3, grouping multiple detection instances belonging to the same physical particle into a single target to form a unique target set. This step is divided into two processing methods depending on the source of the input image.
[0137] Please see Figure 6 For time-series image sequences, grain particles fall in a projectile trajectory after being uniformly discharged from a linear feeder. In multiple consecutive frames, the same physical particle may appear at different positions in different frames. If each frame is processed independently, the same particle will be detected and counted repeatedly, leading to a significant overestimation of the particle count and weight estimate. Therefore, this embodiment uses trajectory association and spatial merging to remove duplicates.
[0138] Specifically, the trajectory association is as follows:
[0139] The bounding boxes of consecutively detected instances are matched to associate multiple instances of the same physical particle appearing across frames with the same trajectory. The trajectory association is determined based on at least one of two conditions: intersection-over-union (IoU) and center distance.
[0140] The intersection-union ratio (CIU) is the ratio of the intersection area to the union area of two bounding boxes, ranging from 0 to 1. A higher CIU indicates a greater degree of overlap between the two bounding boxes. The CIU is calculated between the bounding box of the current frame detection instance and the bounding box representing the existing trajectory. If the CIU is not lower than a preset threshold, it is determined that the two bounding boxes correspond to the same physical particle.
[0141] The center distance condition serves as a supplement to the intersection-over-union (IoU) condition. When particles move at high speeds or the interval between adjacent frames is large, the bounding boxes of the same particle in adjacent frames may only partially overlap or even not overlap at all, potentially causing the IoU to fall below a threshold and resulting in matching failure. In this case, the Euclidean distance between the center of the bounding box of the detected instance in the current frame and the center of the bounding box representing the trajectory is calculated. If this distance does not exceed the diagonal length of the bounding box of the detected instance in the current frame multiplied by a preset coefficient, then both are determined to correspond to the same physical particle. The center distance condition effectively handles the correlation problem when particle displacement is large between frames, improving the robustness of trajectory correlation.
[0142] If any of the above conditions are met, the detection instance of the current frame is associated with the trajectory. Within each trajectory, the detection instance with the largest absolute value of its physical projection area is always retained as the representative of that trajectory to ensure that the trajectory representative always has the most complete contour information. If the detection instance of the current frame does not meet any of the above conditions with any existing trajectory, a new trajectory is created for it. Trajectories that fail to match any detection instance for more than a preset number of frames (default 10 frames) are considered terminated, archived, and will not participate in subsequent matching.
[0143] The specifics of spatial merging are:
[0144] After trajectory association is completed, due to particle tumbling or bounding box jitter, the same physical particle may still correspond to multiple trajectories. For representative bounding boxes of all archived trajectories, spatial merging is performed again based on the intersection-union ratio (IU) and center distance between bounding boxes, grouping multiple trajectories belonging to the same physical particle into the same merge group. The judgment criteria used in this step are the same as those used in trajectory association, namely, the IU is not lower than a threshold or the center distance does not exceed the diagonal length multiplied by a coefficient.
[0145] For a single image, there is no issue of duplicate detection across frames, so trajectory association is unnecessary. However, the same physical particle will not generate multiple detection instances in a static image, making the deduplication and merging logic relatively simple. If the instance segmentation model generates multiple overlapping detection instances of the same physical particle in the same image, spatial merging is performed directly based on the intersection-union ratio and center distance between the bounding boxes of the detection instances. This groups multiple detection instances belonging to the same physical particle into the same merge group, avoiding duplicate detection.
[0146] In both modes, the detection instance with the largest absolute value of physical projected area is selected as the representative of each merging group. Ultimately, the representatives of all merging groups constitute a unique target set, in which each target uniquely corresponds to a physical particle. This eliminates cross-frame duplicate detection and spatial redundancy detection, providing an accurate particle granularity basis for subsequent repetition calculations.
[0147] Step 7, Weight estimation calculation:
[0148] For each target in the unique target set, the estimated single-particle mass is determined based on the absolute value of the physical projected area and a pre-established mass assignment model. Based on the corresponding output category, the number of particles and the estimated total mass for each output category are obtained respectively.
[0149] In this embodiment, the quality assignment model adopts a linear form, as follows:
[0150] ;
[0151] in, Indicates the first Estimated single-grain mass for each target This indicates the output category number. Indicates the output category The quality assignment slope coefficient, Indicates the first The absolute value of the physical projected area of a target. Indicates the output category The quality-assigned intercept, the slope coefficient With intercept The results were obtained through least squares fitting, where each output category corresponds to an independent set of values. and .
[0152] The formula for calculating the estimated total mass is as follows:
[0153] ;
[0154] in, This indicates the output category number. Indicates the output category The estimated total mass, Indicates the first unique target set. The output category of each target Indicates the first Estimated single-grain mass of each target.
[0155] This step uses the unique target set obtained in step 6 to perform weight estimation. For each target in the set, its individual mass is estimated based on the absolute value of its physical projected area using a pre-established mass assignment model. Then, the estimated total mass is obtained by summing the results according to the output category.
[0156] The mass assignment model establishes a correspondence between the absolute value of the physical projected area and the mass of a single grain. The basic idea is that for physical particles of the same category, there is a positive correlation between their projected area and mass; the larger the area, the greater the mass. An independent area-mass model is established for each type of particle in the grain sample (including various grain categories and various impurity categories).
[0157] Please see Figure 7 Each category's mass assignment model adopts a linear form. During fitting, sample data of that category from the calibration batch are used, including the absolute value of the physical projected area of each sample and its corresponding true single-grain mass. The slope and intercept that minimize the fitting error are solved using the least squares fitting method, thus obtaining the area-mass relationship for that category.
[0158] Taking a certain impurity category as an example, if the slope obtained by fitting is 0.08 and the intercept is 0.5, and the absolute value of the physical projected area of a certain target is 25 square millimeters, then its estimated single particle mass is 0.08×25+0.5=2.5 milligrams.
[0159] In application, the absolute value of the physical projected area of each target in the unique target set is substituted into the mass assignment model corresponding to its output category to obtain the estimated single-grain mass of that target. After obtaining the estimated single-grain mass of each target, they are summarized by output category: the estimated single-grain masses of all targets belonging to the same output category are added together to obtain the estimated total mass of that category. For example, the estimated total mass of all hybrid targets is obtained by adding the single-grain masses of all hybrid targets; the estimated total mass of wheat is obtained by adding the single-grain masses of all wheat targets.
[0160] Through the above calculations, the estimated total mass corresponding to each output category is obtained, which can be directly used to generate quality reports for each category that interface with the grain inspection business system, without the need for manual conversion or secondary weighing. In addition, during the aggregation process, the number of targets belonging to the same output category can also be counted simultaneously to obtain the number of particles corresponding to each output category, which serves as auxiliary reference information.
[0161] In this embodiment, the method further includes an accuracy determination step for the quality assignment model:
[0162] Using the true values of the number of calibrated grains and the true value of the total calibrated mass for each output category collected in the calibration batch, the deviation index of the estimated single grain mass relative to the true single grain mass of that category is calculated:
[0163] ;
[0164] in, This indicates the output category number. Indicates the output category Deviation index, Represents a unique target set. Indicates the first Estimated single-grain mass for each target Indicates the first The output category of each target Indicates the first The target belongs to the output category. , Indicates the output category The median estimated single-grain mass of all targets. Indicates the output category The true value of the calibrated total mass. Indicates the output category The true value of the calibration particle number.
[0165] Specifically, following step 7, this method also includes an accuracy assessment step for the quality assignment model. This step is independent of the real-time inference process on the production line and belongs to the calibration and verification stage. It is used to evaluate the estimation accuracy of the quality assignment model used in step 7.
[0166] For each output category, independent validation is performed. The validation process utilizes the calibration data for that category from the calibration batch, including the true values of the calibration particle count and the true value of the calibration total mass. The true value of the calibration particle count is the actual total number of particles of that category in the calibration batch, and the true value of the calibration total mass is the actual total mass of that category in the calibration batch; both are known true values.
[0167] For a given output category, during verification, the estimated individual particle mass of all targets in that category is first obtained, and the median is calculated to obtain the median estimated individual particle mass for that category. Then, this median value is compared to the average true individual particle mass for that category. The average true individual particle mass is obtained by dividing the true total mass of the calibration by the true number of calibration particles, reflecting the true average individual particle mass of that type in the calibration batch. This ratio is the deviation index for that category.
[0168] When the deviation index is close to 1, it indicates that the estimated median single grain mass of this category is basically consistent with the true average single grain mass, the estimation result of the mass assignment model matches the calibration true value well, and the accuracy of the mass assignment model is high. When the deviation index deviates significantly from 1, it indicates that there is a systematic bias in the estimation of the mass assignment model, and the mass assignment model needs to be reviewed or recalibrated.
[0169] Taking a certain impurity category as an example, if the true value of the total mass of this category is 10 grams and the true value of the number of particles is 100, then the average true single particle mass is 0.10 grams. If the median estimated single particle mass of all targets in this category is 0.098 grams, then the deviation index is 0.098 divided by 0.10, which equals 0.98, close to 1, indicating that the mass assignment model for this category has high accuracy.
[0170] This accuracy assessment step can be used for quality assignment model calibration and verification before shipment, as well as for periodic verification, to ensure the reliability of weight estimation results during long-term use.
[0171] In summary, the grain impurity weight estimation method based on instance segmentation and sequence deduplication provided in this embodiment utilizes dual-mode ROI adaptive positioning (using both aerial photography with backlighting and static sample trays) to be compatible with both online production line inspection and laboratory sampling. It replaces horizontal rectangular boxes with instance segmentation masks for area calculation, accurately matching the true contours of oblique impurities and avoiding area deviations introduced by background areas. A category-based confidence gating mechanism classifies low-confidence impurities as unknown impurities, controlling the risk of false detection while retaining original prediction information for subsequent traceability analysis. A two-level deduplication strategy involving trajectory association and spatial merging effectively eliminates the problem of repeated counting of the same physical particle across frames in aerial photography scenarios. A calibration and mass assignment model based on the absolute value of the physical projected area ensures comparability of area measurements between different devices, achieving reproducible quantitative weight estimation. Finally, the estimated total mass for each category is summarized according to the output category, directly connecting to the quality reports required by the grain inspection business system without manual conversion or secondary weighing, realizing automated weight estimation from image acquisition to category quality output.
[0172] Based on the above technical solutions, this embodiment also proposes a grain impurity estimation system based on instance segmentation and sequence deduplication, used to implement the grain impurity estimation method based on instance segmentation and sequence deduplication as described in the embodiment. Please refer to [link to relevant documentation]. Figure 8 The system includes:
[0173] The image acquisition unit is used to acquire an input image of a grain sample. The input image contains multiple physical particles, which are grain particles or impurity particles. The input image is a single photograph of a static sample plate or a time-series image sequence extracted frame by frame after continuous shooting of a flat-ballistic discharge flow from a fixed position.
[0174] A region of interest localization unit is used to determine a region of interest on the input image as the geometric range for subsequent instance segmentation; if the region of interest localization fails, the entire input image is used as the region of interest.
[0175] The instance segmentation inference unit is used to feed the cropped image of the region of interest into the instance segmentation model to obtain a set of detected instances, which contains multiple detected instances; each detected instance outputs at least: predicted category, predicted confidence, instance segmentation mask, and bounding box.
[0176] The projected area calculation unit is used to calculate the mask pixel area for each detection instance in the detection instance set using the instance segmentation mask; and to convert the mask pixel area into the absolute value of the physical projected area based on the pixel equivalent obtained by camera plane calibration.
[0177] The confidence gating unit is used to determine the output category of each detection instance in the detection instance set based on the predicted category and the predicted confidence, and in combination with the confidence threshold set for each impurity category.
[0178] The deduplication and merging unit is used for:
[0179] If the input image is a temporal image sequence, then based on the degree of overlap and / or center distance between the bounding boxes of the detection instances in consecutive frames, the detection instances of the same physical particle appearing across frames are associated with the same trajectory, and the detection instance with the largest absolute value of physical projection area is retained as the representative of the trajectory within each trajectory; then, for the representative bounding boxes of all archived trajectories, spatial merging is performed based on the degree of overlap and / or center distance between the bounding boxes, and multiple trajectories belonging to the same physical particle are grouped into the same merge group;
[0180] If the input image is a single photograph, spatial merging is performed directly based on the degree of overlap and / or center distance between the bounding boxes of the detection instances, and multiple detection instances belonging to the same physical particle are grouped into the same merging group.
[0181] Within each merge group, the detection instance with the largest absolute value of physical projected area is selected as the representative of the merge group, forming a unique target set. Each target in the unique target set corresponds to a physical particle.
[0182] The weight estimation calculation unit is used to determine the estimated single-particle mass for each target in the unique target set based on the absolute value of the physical projected area and a pre-established mass assignment model, and to obtain the number of particles and the estimated total mass for each output category according to the corresponding output category.
[0183] It is understood that the grain impurity estimation system based on instance segmentation and sequence deduplication described in this embodiment is a system for implementing the grain impurity estimation method based on instance segmentation and sequence deduplication described in the embodiment. As the system disclosed in the embodiment corresponds to the method disclosed in the embodiment, the description is relatively simple. For relevant parts, please refer to the description of the method. It will not be repeated here.
Claims
1. A method for estimating grain impurities based on instance segmentation and sequence deduplication, characterized in that, The method includes: The input image of the grain sample is obtained, which contains multiple physical particles, namely grain particles or impurity particles; the input image is a single photograph of a static sample plate, or a time-series image sequence extracted frame by frame after continuous shooting of the flat-ballistic discharge flow from a fixed position. A region of interest is determined on the input image as the geometric range for subsequent instance segmentation; if the region of interest cannot be located, the entire input image is used as the region of interest. The cropped image of the region of interest is fed into the instance segmentation model to obtain a set of detected instances, which contains multiple detected instances; each detected instance outputs at least: predicted category, prediction confidence, instance segmentation mask, and bounding box. For each detection instance in the detection instance set, the mask pixel area is calculated using the instance segmentation mask; the mask pixel area is converted into the absolute value of the physical projection area based on the pixel equivalent obtained by camera plane calibration. For each detection instance in the detection instance set, the output category of the detection instance is determined based on the predicted category and the predicted confidence level, combined with the confidence level threshold set for each impurity category; wherein, when the predicted category is an impurity category and the predicted confidence level is lower than the confidence level threshold for that impurity category, the output is an unknown impurity; If the input image is a temporal image sequence, then based on the degree of overlap and / or center distance between the bounding boxes of the detection instances in consecutive frames, the detection instances of the same physical particle appearing across frames are associated with the same trajectory, and the detection instance with the largest absolute value of physical projection area is retained as the representative of the trajectory within each trajectory; then, for the representative bounding boxes of all archived trajectories, spatial merging is performed based on the degree of overlap and / or center distance between the bounding boxes, and multiple trajectories belonging to the same physical particle are grouped into the same merge group; If the input image is a single photograph, spatial merging is performed directly based on the degree of overlap and / or center distance between the bounding boxes of the detection instances, and multiple detection instances belonging to the same physical particle are grouped into the same merging group. Within each merge group, the detection instance with the largest absolute value of physical projected area is selected as the representative of the merge group, forming a unique target set. Each target in the unique target set corresponds to a physical particle. For each target in the unique target set, the estimated single-particle mass is determined based on the absolute value of the physical projected area and a pre-established mass assignment model. Based on the corresponding output category, the number of particles and the estimated total mass for each output category are obtained respectively.
2. The method for estimating grain impurities based on instance segmentation and sequence deduplication according to claim 1, characterized in that, Determining the region of interest on the input image specifically includes: When the input image is a time-series image sequence, the flying backlight mode is adopted, and the effective imaging area of the backlight panel is pre-calibrated as a fixed region of interest, or the bright field area is automatically extracted by binarizing the backlight image and then used as the region of interest after the aspect ratio and the ratio of width and height to the whole image are verified. When the input image is a single photo of a static sample plate, the static sample plate mode is adopted. The grayscale binarization of the input image is used to extract the plate surface. After morphological operations to remove noise, candidate regions are selected according to the contour area ratio and shape. The bounding rectangle of the largest contour is taken and expanded as the region of interest. The aspect ratio and width-to-height ratio of the region of interest obtained by localization to the whole image are verified. If the aspect ratio or width-to-height ratio of the region of interest to the whole image does not meet the preset verification rules, the localization is determined to be a failure, and the whole input image is used as the region of interest.
3. The method for estimating grain impurities based on instance segmentation and sequence deduplication according to claim 1, characterized in that, The output category of the detection instance is determined according to the following rules: When the predicted category is a grain category, the grain category is output directly; when the predicted category is an impurity category and the prediction confidence is not lower than the confidence threshold of the impurity category, the impurity category is output; when the predicted category is an impurity category and the prediction confidence is lower than the confidence threshold of the impurity category, the unknown impurity is output.
4. The method for estimating grain impurities based on instance segmentation and sequence deduplication according to claim 1, characterized in that, The formula for calculating the area of the mask pixels is: ; in, Indicates the sequence number of the detected instance. Indicates the first The mask pixel area of each detection instance, Indicates the first Instance segmentation mask for each detection instance, This is a set radix operator, representing the counting of foreground pixels within the mask.
5. The method for estimating grain impurities based on instance segmentation and sequence deduplication according to claim 1, characterized in that, The formula for determining the pixel equivalent is: ; The conversion formula for the absolute value of the physical projected area is as follows: ; in, Represents pixel equivalent. This indicates the pixel length of the calibration reference object on the image plane. Indicates the physical length of the calibration reference object. Indicates the first The absolute value of the physical projected area of each detection instance. Indicates the first The mask pixel area of each detection instance.
6. The method for estimating grain impurities based on instance segmentation and sequence deduplication according to claim 1, characterized in that, The degree of overlap between the bounding boxes of consecutive inter-frame detection instances is measured using the intersection-over-union ratio (IoU). ; in, Indicates the sequence number of the detection instance in the current frame. Indicates the trajectory number. Indicates the current frame number The outer frame of a detection instance Indicates the first The outer bounding box representing the trajectory. Indicates the current frame number The outer frame of a detection instance With the The outer bounding box representing the trajectory The crossover ratio between them This represents the area calculation operator. To represent the intersection of sets, Represents the union of sets; When associating detected instances of the same physical particle appearing across frames to the same trajectory, the criteria for trajectory association are as follows: or ; in, This represents the preset crossover-union ratio (CUI) threshold. Indicates the current frame number The outer frame center of the first detection instance is related to the first... The trajectories represent the Euclidean distance between the centers of the bounding boxes. This represents the preset center distance coefficient. Indicates the current frame number The outer frame of a detection instance The length of the diagonal.
7. The method for estimating grain impurities based on instance segmentation and sequence deduplication according to claim 1, characterized in that, The quality assignment model adopts a linear form, as follows: ; in, Indicates the first Estimated single-grain mass for each target This indicates the output category number. Indicates the output category The quality assignment slope coefficient, Indicates the first The absolute value of the physical projected area of a target. Indicates the output category The quality-assigned intercept, the slope coefficient With intercept The results were obtained through least squares fitting, where each output category corresponds to an independent set of values. and .
8. The method for estimating grain impurities based on instance segmentation and sequence deduplication according to claim 1, characterized in that, The formula for calculating the estimated total mass is as follows: ; in, This indicates the output category number. Indicates the output category The estimated total mass, Indicates the first unique target set. The output category of each target Indicates the first Estimated single-grain mass of each target.
9. The method for estimating grain impurities based on instance segmentation and sequence deduplication according to claim 1, characterized in that, The method also includes an accuracy judgment step for the quality assignment model: Using the true values of the number of calibrated grains and the true value of the total calibrated mass for each output category collected in the calibration batch, the deviation index of the estimated single grain mass relative to the true single grain mass of that category is calculated: ; in, This indicates the output category number. Indicates the output category Deviation index, Represents a unique target set. Indicates the first Estimated single-grain mass for each target Indicates the first The output category of each target Indicates the first The target belongs to the output category. , Indicates the output category The median estimated single-grain mass of all targets. Indicates the output category The true value of the calibrated total mass. Indicates the output category The true value of the calibration particle number.
10. A grain impurity estimation system based on instance segmentation and sequence deduplication, characterized in that, The system is used to implement the grain impurity estimation method based on instance segmentation and sequence deduplication as described in any one of claims 1 to 9, the system comprising: The image acquisition unit is used to acquire an input image of a grain sample. The input image contains multiple physical particles, which are grain particles or impurity particles. The input image is a single photograph of a static sample plate or a time-series image sequence extracted frame by frame after continuous shooting of a flat-ballistic discharge flow from a fixed position. A region of interest localization unit is used to determine a region of interest on the input image as the geometric range for subsequent instance segmentation; if the region of interest localization fails, the entire input image is used as the region of interest. The instance segmentation inference unit is used to feed the cropped image of the region of interest into the instance segmentation model to obtain a set of detected instances, which contains multiple detected instances; each detected instance outputs at least: predicted category, predicted confidence, instance segmentation mask, and bounding box. The projected area calculation unit is used to calculate the mask pixel area for each detection instance in the detection instance set using the instance segmentation mask; and to convert the mask pixel area into the absolute value of the physical projected area based on the pixel equivalent obtained by camera plane calibration. The confidence gating unit is used to determine the output category of each detection instance in the detection instance set based on the predicted category and the predicted confidence, and in combination with the confidence threshold set for each impurity category. The deduplication and merging unit is used for: If the input image is a temporal image sequence, then based on the degree of overlap and / or center distance between the bounding boxes of the detection instances in consecutive frames, the detection instances of the same physical particle appearing across frames are associated with the same trajectory, and the detection instance with the largest absolute value of physical projection area is retained as the representative of the trajectory within each trajectory; then, for the representative bounding boxes of all archived trajectories, spatial merging is performed based on the degree of overlap and / or center distance between the bounding boxes, and multiple trajectories belonging to the same physical particle are grouped into the same merge group; If the input image is a single photograph, spatial merging is performed directly based on the degree of overlap and / or center distance between the bounding boxes of the detection instances, and multiple detection instances belonging to the same physical particle are grouped into the same merging group. Within each merge group, the detection instance with the largest absolute value of physical projected area is selected as the representative of the merge group, forming a unique target set. Each target in the unique target set corresponds to a physical particle. The weight estimation calculation unit is used to determine the estimated single-particle mass for each target in the unique target set based on the absolute value of the physical projected area and a pre-established mass assignment model, and to obtain the number of particles and the estimated total mass for each output category according to the corresponding output category.