A rapid detection system for pesticide residues in grain

By acquiring images of pesticide residue detection reagents for grains using portable devices, performing image correction and feature extraction, and combining dynamic calibration curves and quality analysis models, the problem of insufficient accuracy and reliability in grain pesticide residue detection has been solved, achieving rapid and accurate detection results.

CN122109081APending Publication Date: 2026-05-29黑龙江省粮食质量安全监测和技术中心
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
黑龙江省粮食质量安全监测和技术中心
Filing Date
2026-02-09
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing technologies for detecting pesticide residues in grains have poor accuracy, insufficient universality and reliability of results, are easily affected by shooting conditions, and rely on static models.

Method used

Portable devices are used to acquire images of the reaction area of ​​pesticide residue detection reagents for grains. Standardized sub-image sets are identified through image segmentation, optical correction parameters are calculated for image correction, high-dimensional visual feature vectors are extracted, and pesticide residues are estimated and anomalies are determined by combining dynamic calibration curves and pre-trained quality analysis models to generate a test report.

Benefits of technology

It enables rapid and accurate detection of pesticide residues in grains under complex conditions, improving the accuracy and confidence of detection results and transforming smartphones into intelligent optical analyzers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122109081A_ABST
    Figure CN122109081A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of pesticide detection, and particularly relates to a rapid detection system for pesticide residues in grain. A portable device such as a mobile phone is used to collect an image of a reaction area of a detection reagent, and a standardized sub-image set of a sample detection area, an environmental reference area and a concentration reference area is obtained by segmentation. After the environmental reference correction image, the concentration reference area data is fitted to generate a dynamic calibration curve and calculate the goodness of fit. A high-dimensional visual feature vector of the sample area is extracted, a pre-trained model is input in combination with the calibration curve, and an estimated concentration of pesticide residues and an abnormality determination result are obtained. Finally, the overall confidence is calculated by comprehensively considering multiple indexes, and a standard detection report is generated according to a threshold value. The present application can realize rapid and accurate detection of pesticide residues in grain in a complex scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of pesticide detection technology, and in particular to a rapid detection system for pesticide residues in grains. Background Technology

[0002] Existing technologies have emerged that utilize smartphones equipped with AI algorithms to analyze the results of pesticide testing reagents for grains. However, these solutions often rely on threshold comparisons of a single color channel for preliminary detection, as exemplified by the solution disclosed in CN118501073A. Nevertheless, this technology lacks an environmental reference correction mechanism, is susceptible to interference from shooting conditions, depends on static models, has a limited feature analysis dimension, and lacks a system for judging the analysis results, leading to poor detection accuracy and insufficient universality and reliability of the results. Summary of the Invention

[0003] This invention addresses the technical problems of poor detection accuracy, insufficient universality and reliability of results in existing technologies by providing a rapid detection system for pesticide residues in grains.

[0004] The technical solution of the present invention to solve the above-mentioned technical problems is as follows:

[0005] This invention provides a rapid detection system for pesticide residues in grains, comprising:

[0006] The image acquisition module is used to acquire the reaction area image and pesticide residue concentration gradient of the food pesticide residue detection reagent based on a portable device, and to identify a standardized sub-image set from the reaction area image. The standardized sub-image set includes a sample detection area image, an environmental reference area image, and a food pesticide concentration reference area image.

[0007] The image correction module is used to calculate the optical correction parameters of the portable device based on the environmental reference area image, and apply the optical correction parameters to correct the sample detection area image and the grain pesticide concentration reference area image respectively, so as to obtain the corrected image data.

[0008] The fitting evaluation module is used to extract the basic feature values ​​of the corrected image data of the pesticide concentration reference area of ​​the grain, and combine it with the pesticide residue concentration gradient of the grain to fit and generate the dynamic calibration curve of this detection, and calculate the goodness of fit.

[0009] The feature extraction module is used to extract high-dimensional visual feature vectors from the corrected image data of the sample detection area image and calculate the high-dimensional visual feature vector matching degree.

[0010] The residue estimation module is used to input the high-dimensional visual feature vector and the dynamic calibration curve into a pre-trained quality analysis model to obtain the estimated pesticide residue concentration of the sample to be tested and the anomaly judgment result of this test.

[0011] The confidence assessment module is used to calculate the overall confidence level of this detection based on the goodness of fit of the dynamic calibration curve, the matching degree of the high-dimensional visual feature vector, and the anomaly determination result.

[0012] The report generation module is used to generate a test report based on the estimated concentration of pesticide residues and the overall confidence level.

[0013] Optionally, the reaction area image and pesticide residue concentration gradient of the food pesticide residue detection reagent are acquired based on a portable device, and a standardized sub-image set is identified from the reaction area image, including:

[0014] Activate the image acquisition module of the portable device to capture the original image of the grain pesticide residue detection reagent;

[0015] The reaction area image and the pesticide residue concentration gradient of the grain were extracted from the original image;

[0016] Based on the image segmentation algorithm, the sample detection area image, the environmental reference area image, and the grain pesticide concentration reference area image are segmented from the reaction area image;

[0017] After performing image alignment processing on the sample detection area image, the environmental reference area image, and the grain pesticide concentration reference area image, the standardized sub-image set is obtained.

[0018] The process of segmenting the sample detection area image, the environmental reference area image, and the grain pesticide concentration reference area image from the reaction area image includes:

[0019] Read the actual captured pixel values ​​of multiple preset standard grayscale color blocks in the reaction area image;

[0020] Read the actual captured pixel values ​​of multiple preset standard color blocks in the reaction area image.

[0021] Specifically, based on the environmental reference area image, optical correction parameters for the portable device are calculated, and these parameters are applied to correct the sample detection area image and the grain pesticide concentration reference area image, respectively, to obtain corrected image data, including:

[0022] Obtain the theoretical reference pixel value of the standard grayscale color block under a standard D65 light source;

[0023] Establish a non-linear color mapping relationship from the actual captured pixel value to the theoretical reference pixel value;

[0024] A color lookup table is generated based on the nonlinear color mapping relationship;

[0025] Configure the optical correction parameters of the portable device based on the color lookup table;

[0026] The optical correction parameters are applied to correct the image of the sample detection area and the image of the grain pesticide concentration reference area, respectively, to obtain the corrected image data.

[0027] Optionally, based on the corrected image data of the grain pesticide concentration reference area, its basic feature values ​​are extracted, and combined with the grain pesticide residue concentration gradient, a dynamic calibration curve for this detection is fitted and generated, and the goodness of fit is calculated, including:

[0028] In the corrected image data of the pesticide concentration reference area for grain, reaction region sub-blocks corresponding to different known concentration levels are identified;

[0029] Calculate the average pixel intensity value of each known concentration level reaction region sub-block in a specific color channel determined after optical correction, and use the average pixel intensity value as the basic feature value corresponding to that concentration level;

[0030] A fitting function is constructed using the gradient of pesticide residue concentrations in the grain as the independent variable and the corresponding basic feature value as the dependent variable.

[0031] Generate the dynamic calibration curve used to describe the response relationship between pesticide residue concentration gradient and basic characteristic value in grain;

[0032] The determination coefficient of the dynamic calibration curve is calculated as the goodness of fit for evaluating the reliability of the calibration.

[0033] The calculation of the determination coefficient of the dynamic calibration curve includes:

[0034] Calculate the predicted feature value corresponding to each concentration gradient based on the dynamic calibration curve;

[0035] Calculate the total sum of squares of the deviations between the actual measured fundamental characteristic values ​​and their average values, and the sum of squares of the residuals between the predicted characteristic values ​​and the actual measured fundamental characteristic values;

[0036] The determination coefficient is calculated as follows: determination coefficient = 1 - (the sum of squares of the residuals / the sum of squares of the total deviations).

[0037] Optionally, a high-dimensional visual feature vector is extracted from the corrected image data of the sample detection area image, and the high-dimensional visual feature vector matching degree is calculated, including:

[0038] A high-dimensional visual feature vector is extracted from the corrected image data of the sample detection area image. The high-dimensional visual feature vector includes color statistical features, texture complexity features, and spatial morphology features.

[0039] The color statistical features include the mean, standard deviation, skewness, and kurtosis of pixel values ​​calculated on multiple channels of the color space; the texture complexity features are texture histogram features calculated through local binary mode; and the spatial morphology features are the area, perimeter, and circularity of the reaction region.

[0040] Obtain pre-constructed standard positive sample feature libraries and standard negative sample feature libraries;

[0041] Calculate the similarity between the high-dimensional visual feature vector and the closest standard positive feature vector in the standard positive sample feature library and the standard negative sample feature library, as well as the similarity between the high-dimensional visual feature vector and the closest standard negative feature vector. The higher similarity value between the two is taken as the matching degree of the high-dimensional visual feature vector.

[0042] Optionally, the high-dimensional visual feature vector and the dynamic calibration curve are input together into a pre-trained quality analysis model to obtain the estimated pesticide residue concentration of the sample to be tested and the anomaly judgment result of this test, including:

[0043] Obtain a training sample set, which includes multiple sample data collected in different portable devices and environments with different pesticide types and concentrations. Each sample data also includes the corresponding high-dimensional visual feature vector, the dynamic calibration curve, and labels for real pesticide concentration values ​​and abnormal reactions.

[0044] The quality analysis model is built based on a multi-task neural network model, which includes a pesticide residue estimation branch and an anomaly detection branch.

[0045] The multi-task neural network model is trained based on the training sample set until convergence.

[0046] The high-dimensional visual feature vector of the sample to be tested is concatenated with the dynamic calibration curve and then input into the pre-trained quality analysis model to simultaneously obtain the estimated concentration value of pesticide residues and the anomaly judgment result.

[0047] Optionally, based on the goodness of fit of the dynamic calibration curve, the matching degree of the high-dimensional visual feature vector, and the anomaly determination result, the overall confidence level of this detection is calculated, including:

[0048] Weight coefficients are assigned to the goodness of fit, the matching degree of the high-dimensional visual feature vector, and the anomaly detection result, respectively, wherein the anomaly detection result is given the highest weight score when the response is valid, and the weight score of other categories is lower than that of the response.

[0049] The goodness of fit is normalized to the 0-1 interval and used as the first confidence component.

[0050] The matching degree of the high-dimensional visual feature vector is used as the second confidence component;

[0051] Based on the category of the anomaly determination result, obtain the third confidence component based on the anomaly determination result;

[0052] The first confidence component, the second confidence component, and the third confidence component are weighted and summed according to their weight coefficients to obtain the overall confidence level of this detection.

[0053] Optionally, based on the estimated concentration of pesticide residues and the overall confidence level, a test report is generated, including:

[0054] Pre-set the maximum residue limit for the target pesticide;

[0055] Set a high-level confidence threshold, a low-level confidence threshold, and a two-level confidence threshold. The high-level confidence threshold value should be greater than the low-level confidence threshold value.

[0056] If the overall confidence level is lower than the low-level confidence level threshold, the detection is deemed invalid.

[0057] If the overall confidence level is lower than the high confidence level threshold but higher than or equal to the low confidence level threshold, then the confidence interval of the estimated pesticide residue concentration will be output in the test report, and an insufficient confidence level warning will be marked in the test report.

[0058] If the overall confidence level is higher than the high confidence level threshold, the estimated pesticide residue concentration is compared with the maximum residue limit, and the test report is generated based on the comparison result.

[0059] By implementing this invention, it is possible to acquire images of the reaction area and the concentration gradient of pesticide residues in grain using a portable device, and to identify a standardized sub-image set from the reaction area image. The standardized sub-image set includes images of the sample detection area, environmental reference area, and grain pesticide concentration reference area. This achieves standardized acquisition and partitioning of detection images, providing a unified and accurate image basis for subsequent calibration and analysis, and avoiding interference from cluttered original images on the detection results.

[0060] By implementing this invention, it is possible to calculate the optical correction parameters of a portable device based on the environmental reference area image, and apply the optical correction parameters to correct the sample detection area image and the grain pesticide concentration reference area image respectively, thereby obtaining corrected image data; eliminating the influence of light differences during portable device shooting, unifying image color standards, and improving the consistency and accuracy of image data under different environments.

[0061] By implementing this invention, it is possible to extract the basic feature values ​​of the corrected image data of the grain pesticide concentration reference area, and combine them with the grain pesticide residue concentration gradient to fit and generate a dynamic calibration curve for this detection, and calculate the goodness of fit; generate a dynamic calibration curve adapted to this detection scenario to replace the general static model, and at the same time evaluate the calibration reliability through the goodness of fit, providing an accurate quantitative basis for concentration estimation.

[0062] By implementing this invention, it is possible to extract high-dimensional visual feature vectors from the corrected image data of the sample detection area image and calculate the matching degree of the high-dimensional visual feature vectors; capture sample reaction features in multiple dimensions, improve the accuracy of feature recognition by comparing with a standard library, and provide rich basis for subsequent concentration estimation and anomaly judgment.

[0063] By implementing this invention, the high-dimensional visual feature vector and the dynamic calibration curve can be input into a pre-trained quality analysis model to obtain the estimated concentration of pesticide residues in the sample to be tested and the anomaly judgment result of this test; by combining the multidimensional information of the feature vector and the concentration correlation of the calibration curve, accurate concentration estimation can be achieved, while quickly identifying abnormal situations in the detection process and reducing invalid detection results.

[0064] By implementing this invention, it is possible to calculate the overall confidence level of the current detection based on the goodness of fit of the dynamic calibration curve, the matching degree of the high-dimensional visual feature vector, and the anomaly determination result.

[0065] By implementing this invention, it is possible to generate a test report based on the estimated concentration of the pesticide residue and the overall confidence level.

[0066] In summary, by implementing this invention, smartphones can be transformed into intelligent optical analyzers, enabling rapid and accurate detection of pesticide residues in grains under complex conditions, thereby improving the accuracy and confidence of the detection results. Attached Figure Description

[0067] Figure 1 This is a schematic diagram of a rapid detection system for pesticide residues in grain provided by the present invention;

[0068] Figure 2 This invention provides a schematic flowchart for a rapid detection system for pesticide residues in grains.

[0069] In the attached diagram, the components represented by each number are as follows:

[0070] Image acquisition module 11, image correction module 12, fitting evaluation module 13, feature extraction module 14, residual estimation module 15, confidence evaluation module 16, and report generation module 17. Detailed Implementation

[0071] Example 1, as Figure 1 As shown, this embodiment of the invention provides a rapid detection system for pesticide residues in grains, comprising:

[0072] Image acquisition module 11 is used to acquire the reaction area image and pesticide residue concentration gradient of the food pesticide residue detection reagent based on a portable device, and to identify a standardized sub-image set from the reaction area image. The standardized sub-image set includes a sample detection area image, an environmental reference area image and a food pesticide concentration reference area image.

[0073] The image correction module 12 is used to calculate the optical correction parameters of the portable device based on the environmental reference area image, and apply the optical correction parameters to correct the sample detection area image and the grain pesticide concentration reference area image respectively, so as to obtain the corrected image data.

[0074] The fitting evaluation module 13 is used to extract the basic feature values ​​of the corrected image data of the pesticide concentration reference area of ​​the grain, and combine the pesticide residue concentration gradient of the grain to fit and generate the dynamic calibration curve of this detection, and calculate the goodness of fit.

[0075] The feature extraction module 14 is used to extract high-dimensional visual feature vectors from the corrected image data of the sample detection area image and calculate the high-dimensional visual feature vector matching degree.

[0076] The residue estimation module 15 is used to input the high-dimensional visual feature vector and the dynamic calibration curve into a pre-trained quality analysis model to obtain the estimated pesticide residue concentration of the sample to be tested and the anomaly judgment result of this test.

[0077] The confidence assessment module 16 is used to calculate the overall confidence of this detection based on the goodness of fit of the dynamic calibration curve, the matching degree of the high-dimensional visual feature vector, and the anomaly determination result.

[0078] The report generation module 17 is used to generate a test report based on the estimated concentration of pesticide residues and the overall confidence level.

[0079] In the image acquisition module 11, the reaction area image and pesticide residue concentration gradient of the food pesticide residue detection reagent are acquired based on the portable device, and a standardized sub-image set is identified from the reaction area image, including:

[0080] Activate the image acquisition module of the portable device to capture the original image of the grain pesticide residue detection reagent;

[0081] The reaction area image and the pesticide residue concentration gradient of the grain were extracted from the original image;

[0082] Based on the image segmentation algorithm, the sample detection area image, the environmental reference area image, and the grain pesticide concentration reference area image are segmented from the reaction area image;

[0083] After performing image alignment processing on the sample detection area image, the environmental reference area image, and the grain pesticide concentration reference area image, the standardized sub-image set is obtained.

[0084] In this embodiment, the image acquisition module 11 is used to acquire standardized image data and concentration gradient information that can be used for subsequent analysis, providing a unified and standardized input basis for the entire detection system, which is a fundamental prerequisite for ensuring the accuracy and stability of the entire detection system.

[0085] To achieve the above objectives, it is first necessary to activate the image acquisition module of the portable device to capture the original image of the food pesticide residue detection reagent.

[0086] The portable devices mentioned are mainly portable electronic devices such as mobile phones and tablets. For example, the camera of a mobile phone or other portable device can be activated to photograph the food pesticide residue detection reagent. During the photographing, it is necessary to ensure that the environmental reference area, concentration reference area, and sample detection area of ​​the reagent are completely captured in the image, so as to obtain an original image containing all reaction information.

[0087] The grain pesticide residue detection reagent includes an environmental reference area, a concentration reference area, and a sample detection area. This reagent is compatible with portable devices such as mobile phones for image capture, providing the detection system with standardized images and grain pesticide residue concentration gradient inputs to ensure detection accuracy.

[0088] Next, the reaction area image and the pesticide residue concentration gradient of the grain are extracted from the original image;

[0089] This involves identifying and extracting the reaction area image of the pesticide residue detection reagent from the original image, while simultaneously reading the pre-set pesticide residue concentration gradient on the reagent. The pesticide residue concentration gradient is obtained by reading standard color patches representing a series of known pesticide concentration gradients within the reaction area's concentration reference region.

[0090] For example, the concentration gradient can be set as a series of known concentration levels of 0.01 mg / kg, 0.05 mg / kg, and 0.1 mg / kg.

[0091] Then, based on the image segmentation algorithm, the sample detection area image, the environmental reference area image, and the grain pesticide concentration reference area image are segmented from the reaction area image;

[0092] This involves using image segmentation algorithms to process the reaction area image and reading the actual captured pixel values ​​of pre-defined standard grayscale and standard color blocks within the area. For example, it reads the pixel values ​​of standard grayscale blocks with reflectances of 10%, 50%, and 90% in the environmental reference area, and the pixel values ​​of standard color blocks corresponding to different pesticide concentrations in the concentration reference area. Based on the characteristic differences of these pixel values, the sample detection area image, the environmental reference area image, and the grain pesticide concentration reference area image are accurately segmented.

[0093] After performing image alignment processing on the sample detection area image, the environmental reference area image, and the grain pesticide concentration reference area image, the standardized sub-image set is obtained.

[0094] This involves performing spatial alignment processing on the three types of segmented sub-images to correct image misalignment caused by tilted shooting angles and positional shifts. For example, the center of the reaction spot in the sample detection area and the center of the color patch in the concentration reference area are aligned to the same coordinate system. After processing, the three types of images are integrated to form a standardized sub-image set.

[0095] In the image acquisition module 11, the sample detection area image, the environmental reference area image, and the grain pesticide concentration reference area image are segmented from the reaction area image, including:

[0096] Read the actual captured pixel values ​​of multiple preset standard grayscale color blocks in the reaction area image;

[0097] Read the actual captured pixel values ​​of multiple preset standard color blocks in the reaction area image.

[0098] This involves reading the actual pixel values ​​of multiple pre-defined standard grayscale patches in the reaction area image, such as the pixel values ​​corresponding to grayscale patches with reflectances of 10%, 50%, and 90% in the environmental reference area. Simultaneously, it reads the actual pixel values ​​of multiple standard color patches, such as the pixel values ​​of color patches corresponding to pesticide concentrations of 0.01 mg / kg and 0.05 mg / kg in the concentration reference area. Based on the characteristic differences in the pixel values ​​of the two types of color patches, the three types of regions are segmented.

[0099] like Figure 2 As shown, in the image correction module 12 of this application embodiment, based on the environmental reference area image, optical correction parameters of the portable device are calculated, and the optical correction parameters are applied to correct the sample detection area image and the grain pesticide concentration reference area image respectively, to obtain corrected image data, including:

[0100] Obtain the theoretical reference pixel value of the standard grayscale color block under a standard D65 light source;

[0101] Establish a non-linear color mapping relationship from the actual captured pixel value to the theoretical reference pixel value;

[0102] A color lookup table is generated based on the nonlinear color mapping relationship;

[0103] Configure the optical correction parameters of the portable device based on the color lookup table;

[0104] The optical correction parameters are applied to correct the image of the sample detection area and the image of the grain pesticide concentration reference area, respectively, to obtain the corrected image data.

[0105] In this embodiment, the image correction module 12 is used to eliminate color deviations caused by ambient light and differences in device hardware when shooting with portable devices, so that the color data of the sample detection area image and the grain pesticide concentration reference area image are unified to the standard benchmark, ensuring the accuracy of subsequent feature extraction and dynamic calibration curve fitting.

[0106] To achieve the above objectives, it is first necessary to obtain the theoretical reference pixel value of the standard grayscale color block under a standard D65 light source.

[0107] This means defining the theoretical reference pixel value for each standard grayscale color patch in the environmental reference area under a standard D65 light source. The standard D65 light source is a standard light source simulating midday sunlight, providing a unified color judgment benchmark. For example, a dark gray patch with 10% reflectivity has a theoretical reference pixel value of 30; a medium gray patch with 50% reflectivity has a theoretical reference pixel value of 128; and a light gray patch with 90% reflectivity has a theoretical reference pixel value of 230. These values ​​are fixed reference values ​​predetermined based on standard optical characteristics.

[0108] Next, a non-linear color mapping relationship is established from the actual captured pixel value to the theoretical reference pixel value;

[0109] This involves retrieving the actual pixel values ​​previously captured from the reaction area image and pairing them with the corresponding theoretical reference pixel values ​​for analysis. Due to the influence of ambient light and equipment hardware, the actual captured pixel values ​​often deviate from the theoretical values. For example, a medium gray patch with 50% reflectance might have an actual captured pixel value of 100 in dim lighting and 150 in bright light. An algorithm is used to establish a non-linear color mapping relationship from these actual captured pixel values ​​to the theoretical reference pixel value of 128, accurately describing the correspondence between the two.

[0110] Then, a color lookup table is generated based on the nonlinear color mapping relationship;

[0111] Based on the established non-linear color mapping relationship, a complete color lookup table is generated. This color lookup table is presented in matrix form, containing the mapping relationship between all possible actual captured pixel values ​​and their corresponding standard theoretical pixel values. For example, the table will clearly indicate that the actual captured pixel value 100 corresponds to the standard theoretical pixel value 128, the actual captured pixel value 150 corresponds to the standard theoretical pixel value 128, the actual captured pixel value 40 corresponds to the standard theoretical pixel value 30, and so on, forming a set of pixel value conversion reference tables that can be directly queried and called, i.e., a color lookup table.

[0112] Furthermore, based on the color lookup table, the optical correction parameters of the portable device are configured;

[0113] This involves configuring the optical correction parameters of portable devices based on color lookup tables. These parameters encompass key information such as pixel value conversion formulas and color channel adjustment coefficients. Essentially, they translate the mapping rules in the color lookup tables into image correction instructions that the portable device can execute. For example, when setting the device to capture an image, all pixel values ​​must be adjusted according to the corresponding relationships in the color lookup table, calculating the conversion weights for different pixel ranges.

[0114] Finally, the optical correction parameters are applied to correct the image of the sample detection area and the image of the grain pesticide concentration reference area, respectively, to obtain the corrected image data.

[0115] The configured optical correction parameters are then applied to the sample detection area image and the grain pesticide concentration reference area image. Each pixel in both images undergoes color correction, replacing the original pixel value according to the mapping relationship in the color lookup table. For example, if a pixel in the sample detection area image has an actual captured value of 110, and its corresponding theoretical pixel value in the color lookup table is 128, then that pixel value is corrected to 128. Similarly, if the actual captured pixel value of the color patch corresponding to a concentration of 0.05 mg / kg in the grain pesticide concentration reference area deviates from the standard, it is also corrected according to the same rules. Finally, corrected image data that eliminates deviations and conforms to the standard benchmark is obtained.

[0116] In the fitting evaluation module 13, based on the corrected image data of the grain pesticide concentration reference area, its basic feature values ​​are extracted, and combined with the grain pesticide residue concentration gradient, a dynamic calibration curve for this detection is generated, and the goodness of fit is calculated, including:

[0117] In the corrected image data of the pesticide concentration reference area for grain, reaction region sub-blocks corresponding to different known concentration levels are identified;

[0118] Calculate the average pixel intensity value of each known concentration level reaction region sub-block in a specific color channel determined after optical correction, and use the average pixel intensity value as the basic feature value corresponding to that concentration level;

[0119] A fitting function is constructed using the gradient of pesticide residue concentrations in the grain as the independent variable and the corresponding basic feature value as the dependent variable.

[0120] Generate the dynamic calibration curve used to describe the response relationship between pesticide residue concentration gradient and basic characteristic value in grain;

[0121] The determination coefficient of the dynamic calibration curve is calculated as the goodness of fit for evaluating the reliability of the calibration.

[0122] In this embodiment, the purpose of the above steps is to establish a quantitative correspondence between the concentration of pesticide residues in grains and the basic feature values ​​of the image, generate an accurate dynamic calibration curve, and evaluate the calibration reliability through goodness of fit, so as to provide a scientific basis for subsequent estimation of pesticide residue concentrations in samples, avoid the limitations of static threshold comparison, and improve detection accuracy and result reliability.

[0123] To achieve the above objective, firstly, it is necessary to identify the reaction region sub-blocks corresponding to different known concentration levels in the corrected image data of the grain pesticide concentration reference area;

[0124] That is, in the calibrated image data of the pesticide concentration reference area for grains, the reaction area sub-blocks corresponding to different known concentration levels are accurately identified based on preset position markers or color features.

[0125] For example, if the concentration reference area is pre-set with four known concentration levels of 0.01 mg / kg, 0.05 mg / kg, 0.1 mg / kg, and 0.5 mg / kg, then the independent reaction region sub-blocks corresponding to these four levels can be located from the calibrated image.

[0126] Then, the average pixel intensity value of each known concentration level reaction region sub-block is calculated in a specific color channel determined after the optical correction, and the average pixel intensity value is used as the basic feature value corresponding to the concentration level.

[0127] This involves identifying a specific color channel that, after optical correction, is most sensitive to changes in pesticide concentration, such as the a channel in the Lab color space or the S channel in the HSV color space. The average pixel intensity value of each known concentration level reaction region sub-block is calculated under that specific color channel, and this value is used as the base feature value for the corresponding concentration level.

[0128] For example, the average pixel intensity value of the reaction region sub-block at a concentration level of 0.01 mg / kg is 80, 110 for 0.05 mg / kg, 150 for 0.1 mg / kg, and 220 for 0.5 mg / kg.

[0129] Next, a fitting function is constructed using the gradient of pesticide residue concentration in the grain as the independent variable and the corresponding basic feature value as the dependent variable.

[0130] That is, the gradient of pesticide residue concentration in grain is used as the independent variable x, and the corresponding basic characteristic value is used as the dependent variable y. The appropriate fitting function type is selected by combining the data distribution characteristics.

[0131] For example, if the data shows a linear correlation trend, a linear fitting function y=ax+b can be constructed; if the relationship is non-linear, a polynomial fitting function y=ax²+bx+c can be selected.

[0132] For example, based on the above-mentioned grain pesticide residue concentration gradient and basic characteristic value data, a linear fitting function y=350x+76.5 can be constructed.

[0133] Furthermore, the dynamic calibration curve is generated to describe the response relationship between the pesticide residue concentration gradient and the basic characteristic value in the grain.

[0134] Based on the constructed fitting function, a dynamic calibration curve describing the relationship between the gradient of pesticide residue concentration in grain and the response of basic characteristic values ​​is plotted. This dynamic calibration curve can intuitively present the correspondence between changes in pesticide residue concentration in grain and changes in basic characteristic values.

[0135] For example, the dynamic calibration curve corresponding to the above linear fitting function shows that as the pesticide residue concentration in the grain increases from 0.01 mg / kg to 0.5 mg / kg, the average pixel intensity value steadily increases from 80 to 220.

[0136] Finally, the determination coefficient of the dynamic calibration curve is calculated as the goodness of fit for evaluating the reliability of the calibration.

[0137] The fitting evaluation module 13 calculates the determination coefficient of the dynamic calibration curve, including:

[0138] Calculate the predicted feature value corresponding to each concentration gradient based on the dynamic calibration curve;

[0139] Calculate the total sum of squares of the deviations between the actual measured fundamental characteristic values ​​and their average values, and the sum of squares of the residuals between the predicted characteristic values ​​and the actual measured fundamental characteristic values;

[0140] The determination coefficient is calculated as follows: determination coefficient = 1 - (the sum of squares of the residuals / the sum of squares of the total deviations).

[0141] The goodness of fit is assessed by calculating the coefficient of determination of the dynamic calibration curve. First, the predicted characteristic value corresponding to each pesticide residue concentration gradient in grain is calculated based on the dynamic calibration curve. For example, the predicted characteristic value corresponding to a concentration of 0.01 mg / kg is 350 × 0.01 + 76.5 = 80. Then, the total sum of squares of deviations between the actual measured basic characteristic value and its average value, as well as the sum of squares of residuals between the predicted characteristic value and the actual measured basic characteristic value, are calculated. Finally, the coefficient of determination is calculated using the formula: coefficient of determination = 1 - (sum of squares of residuals / total sum of squares).

[0142] The predicted feature value is the basic feature value estimated by substituting the fitted function of the dynamic calibration curve into the concentration gradient of pesticide residues in the grain. For example, if the fitted function is y=350x+76.5, when the concentration gradient x is 0.01mg / kg, the predicted feature value is y=350×0.01+76.5=80.

[0143] If the total sum of squares of deviations is 5000 and the sum of squares of residuals is 100, then the coefficient of determination = 1 - (100 / 5000) = 0.98. The closer the coefficient of determination is to 1, the higher the fit between the calibration curve and the actual data, and the stronger the calibration reliability.

[0144] In the feature extraction module 14, high-dimensional visual feature vectors are extracted from the corrected image data of the sample detection area image, and the high-dimensional visual feature vector matching degree is calculated, including:

[0145] A high-dimensional visual feature vector is extracted from the corrected image data of the sample detection area image. The high-dimensional visual feature vector includes color statistical features, texture complexity features, and spatial morphology features.

[0146] The color statistical features include the mean, standard deviation, skewness, and kurtosis of pixel values ​​calculated on multiple channels of the color space; the texture complexity features are texture histogram features calculated through local binary mode; and the spatial morphology features are the area, perimeter, and circularity of the reaction region.

[0147] Obtain pre-constructed standard positive sample feature libraries and standard negative sample feature libraries;

[0148] Calculate the similarity between the high-dimensional visual feature vector and the closest standard positive feature vector in the standard positive sample feature library and the standard negative sample feature library, as well as the similarity between the high-dimensional visual feature vector and the closest standard negative feature vector. The higher similarity value between the two is taken as the matching degree of the high-dimensional visual feature vector.

[0149] In this embodiment, the purpose of the above steps in the feature extraction module 14 is to comprehensively capture the multidimensional visual information of the sample detection area image, obtain the high-dimensional visual feature vector matching degree by comparing it with the standard sample feature library, provide accurate feature basis for subsequent pesticide residue concentration estimation and anomaly judgment, avoid judgment bias caused by a single feature, and improve the accuracy and reliability of detection.

[0150] To achieve the above objectives, it is first necessary to extract high-dimensional visual feature vectors from the corrected image data of the sample detection area image. The high-dimensional visual feature vectors include color statistical features, texture complexity features, and spatial morphology features.

[0151] The color statistical features include the mean, standard deviation, skewness, and kurtosis of pixel values ​​calculated on multiple channels of the color space; the texture complexity features are texture histogram features calculated through local binary mode; and the spatial morphology features are the area, perimeter, and circularity of the reaction region.

[0152] For example, color statistical features, texture complexity features, and spatial morphological features are extracted from the corrected image data of the sample detection area image to form a high-dimensional visual feature vector.

[0153] For example, color statistical characteristics include calculating the mean, standard deviation, skewness, and kurtosis of pixel values ​​across multiple color channels such as HSV and Lab. For instance, the mean pixel value of channel a in the Lab color space is 120, the standard deviation is 15, the skewness is 0.3, and the kurtosis is 2.8.

[0154] The texture complexity feature is: the texture histogram feature is calculated through local binary patterns, such as counting the frequency of different texture patterns in the image, to obtain a texture histogram containing 256 dimensions;

[0155] The spatial morphological characteristics are as follows: the calculated reaction area is 500 pixels², the perimeter is 100 pixels, and the circularity is 0.8.

[0156] Next, the pre-constructed standard positive sample feature library and standard negative sample feature library are obtained;

[0157] The standard positive sample feature library is a set of high-dimensional visual feature vectors that stores a large number of known samples containing pesticide residues, covering feature data of different pesticide types, concentrations, and environments.

[0158] The standard negative sample feature library stores the corresponding high-dimensional visual feature vectors of samples known to have no pesticide residues or not exceeding the standard. Both are pre-trained and constructed to compare with the high-dimensional visual feature vectors of the samples to be tested to determine the matching degree. The construction method is the existing technology, which will not be described in detail here.

[0159] Then, the similarity between the high-dimensional visual feature vector and the closest standard positive feature vector in the standard positive sample feature library and the standard negative sample feature library is calculated, as well as the similarity with the closest standard negative feature vector. The higher similarity value between the two is taken as the matching degree of the high-dimensional visual feature vector.

[0160] For example, algorithms such as cosine similarity can be used to calculate the similarity between the high-dimensional visual feature vector of the sample to be detected and the closest vector in the feature library of standard positive samples, such as 0.85; at the same time, the similarity with the closest vector in the feature library of standard negative samples can be calculated, such as 0.3. The higher of the two, 0.85, is taken as the matching degree of the high-dimensional visual feature vector of the sample to be detected.

[0161] In the residue estimation module 15, the high-dimensional visual feature vector and the dynamic calibration curve are input together into a pre-trained quality analysis model to obtain the estimated pesticide residue concentration of the sample to be tested and the anomaly judgment result of this test, including:

[0162] Obtain a training sample set, which includes multiple sample data collected in different portable devices and environments with different pesticide types and concentrations. Each sample data also includes the corresponding high-dimensional visual feature vector, the dynamic calibration curve, and labels for real pesticide concentration values ​​and abnormal reactions.

[0163] The quality analysis model is built based on a multi-task neural network model, which includes a pesticide residue estimation branch and an anomaly detection branch.

[0164] The multi-task neural network model is trained based on the training sample set until convergence.

[0165] The high-dimensional visual feature vector of the sample to be tested is concatenated with the dynamic calibration curve and then input into the pre-trained quality analysis model to simultaneously obtain the estimated concentration value of pesticide residues and the anomaly judgment result.

[0166] In this embodiment, the residual estimation module 15 is used to simultaneously realize accurate estimation of pesticide residue concentration and judgment of anomalies in the detection process, avoiding the limitations of single data or single task model, and improving detection efficiency and result accuracy.

[0167] To achieve the above objectives, it is first necessary to obtain a training sample set, which includes multiple sample data collected in different portable devices and environments with different pesticide types and concentrations. Each sample data also includes the corresponding high-dimensional visual feature vector, the dynamic calibration curve, and labels for real pesticide concentration values ​​and abnormal reactions.

[0168] This involves collecting sample data covering multiple scenarios, including different pesticide types such as organophosphates, pyrethroids, and carbamates; different concentration gradients such as 0.005 mg / kg, 0.01 mg / kg, 0.05 mg / kg, 0.1 mg / kg, and 0.5 mg / kg; different portable devices such as mobile phones and tablets; and different environmental conditions such as indoor lighting, outdoor cloudy days, and direct sunlight. Each sample data includes a corresponding high-dimensional visual feature vector, dynamic calibration curve parameters such as fitting function coefficients and coefficients of determination, as well as labels for actual pesticide concentration values ​​and abnormal reaction labels.

[0169] Next, the quality analysis model is built based on a multi-task neural network model, which includes a pesticide residue estimation branch and an anomaly detection branch.

[0170] For example, the basic network architecture of the quality analysis model can use ResNet50 as the backbone feature extraction network to receive input data composed of spliced ​​high-dimensional visual feature vectors and dynamic calibration curve parameters. For example, the input dimension is set to 256 dimensions, of which the high-dimensional visual feature vector accounts for 200 dimensions and the dynamic calibration curve parameters account for 56 dimensions.

[0171] Two parallel branches are built after the main feature extraction network: a pesticide residue estimation branch and an anomaly detection branch. The pesticide residue estimation branch adopts a fully connected layer structure with three hidden layers, containing 128, 64, and 32 neurons respectively. The ReLU activation function is used, and the output layer has one neuron, using a linear activation function to output continuous concentration values. The anomaly detection branch also has three fully connected hidden layers with 64, 32, and 16 neurons. The ReLU activation function is used, and the output layer uses a Softmax activation function to output four probability values ​​corresponding to four anomaly labels.

[0172] The loss function adopted is the joint loss function. The pesticide residue estimation branch uses the mean squared error loss function, and the anomaly detection branch uses the cross-entropy loss function. The weight ratio of the two is set to 1:0.8.

[0173] In the training parameter settings of the multi-task neural network model, the batch size is set to 32, the initial learning rate is 0.001, the Adam optimizer is used, the weight decay coefficient is 0.0001, and the momentum parameter is 0.9.

[0174] The training process involves dividing the training sample data into a training set and a validation set in a 7:3 ratio. After each round of training, the model performance is evaluated using the validation set. When the change in the joint loss value on the validation set is less than 0.0001 over 10 consecutive rounds, and the pesticide residue estimation error (MAE) is less than 0.002 mg / kg, and the anomaly detection accuracy is higher than 98%, the model is considered to have converged, training is stopped, and the quality analysis model is obtained.

[0175] Finally, the high-dimensional visual feature vector of the sample to be tested is concatenated with the dynamic calibration curve and input into the pre-trained quality analysis model to simultaneously obtain the estimated concentration of pesticide residues and the anomaly determination results.

[0176] The high-dimensional visual feature vector of the sample to be tested is concatenated with the parameters of the dynamic calibration curve to form 256-dimensional input data, which is then input into the pre-trained quality analysis model. The quality analysis model extracts deep fusion features through the backbone feature extraction network, and then calculates them separately through two branches, outputting the results simultaneously. For example, the output pesticide residue estimated concentration is 0.032 mg / kg, and the anomaly judgment result is that the reaction is effective.

[0177] In the confidence assessment module 16, based on the goodness of fit of the dynamic calibration curve, the matching degree of the high-dimensional visual feature vector, and the anomaly determination result, the overall confidence level of this detection is calculated, including:

[0178] Weight coefficients are assigned to the goodness of fit, the matching degree of the high-dimensional visual feature vector, and the anomaly detection result, respectively, wherein the anomaly detection result is given the highest weight score when the response is valid, and the weight score of other categories is lower than that of the response.

[0179] The goodness of fit is normalized to the 0-1 interval and used as the first confidence component.

[0180] The matching degree of the high-dimensional visual feature vector is used as the second confidence component;

[0181] Based on the category of the anomaly determination result, obtain the third confidence component based on the anomaly determination result;

[0182] The first confidence component, the second confidence component, and the third confidence component are weighted and summed according to their weight coefficients to obtain the overall confidence level of this detection.

[0183] In this embodiment, the purpose of the confidence assessment module 16 is to comprehensively integrate key reliability indicators throughout the entire testing process and quantify the overall confidence level of the test through scientific weighted calculation. This avoids the one-sidedness of evaluating a single indicator while highlighting the core impact of the testing process's effectiveness, providing a clear quantitative basis for the credibility of the test results.

[0184] To achieve the above objectives, it is first necessary to assign weight coefficients to the goodness of fit, the matching degree of the high-dimensional visual feature vector, and the anomaly detection result, respectively. The anomaly detection result is assigned the highest weight score when the response is valid, and the weight score of other categories is lower than that of the response.

[0185] For example, when the anomaly detection result is a valid response, the highest weight of 0.5 is assigned; the goodness-of-fit weight is 0.3, which is used to reflect the reliability of the calibration curve; and the high-dimensional visual feature vector matching weight is 0.2, which reflects the fit between the sample features and the standard library.

[0186] If the anomaly determination result is a reagent deterioration, camera obstruction, insufficient reaction, or other categories, its weight is reduced to 0.1, and the remaining weights are redistributed to goodness of fit 0.4 and high-dimensional visual feature vector matching degree 0.5, highlighting the supporting role of feature matching and calibration curves in the results.

[0187] Next, the goodness of fit is normalized to the 0-1 interval and used as the first confidence component;

[0188] For example, if the normalized goodness-of-fit result is 0.95, it indicates that the calibration curve closely matches the actual data, and the first confidence component is 0.95. If the goodness-of-fit is 0.7, it indicates that the calibration reliability is average, and the first confidence component is 0.7.

[0189] Then, the matching degree of the high-dimensional visual feature vector is used as the second confidence component;

[0190] The matching degree of high-dimensional visual feature vectors is calculated by algorithms such as cosine similarity, and its value range is naturally between 0 and 1, which is directly used as the second confidence component.

[0191] Furthermore, based on the category of the anomaly determination result, a third confidence component based on the anomaly determination result is obtained;

[0192] Fixed scores are pre-set for each category of anomaly assessment results, and quantitative standards for different levels of effectiveness are clearly defined. For example, anomaly assessment results may include effective reaction, obstructed photography, reagent deterioration, and incomplete reaction.

[0193] For example, for a valid response: the third confidence component is set to 1.0, indicating that there are no abnormalities in the detection process and the data is reliable.

[0194] Regarding camera occlusion: the third confidence component is set to 0.3, as shooting issues may affect image data, but there is some room for correction.

[0195] Regarding reagent deterioration: the third confidence component is set to 0.2. Reagent failure will lead to distorted reaction results and low reliability.

[0196] For incomplete reactions: the third confidence component is set to 0.1. Incomplete reactions will directly affect feature extraction and concentration estimation, resulting in extremely low confidence.

[0197] Finally, the first confidence component, the second confidence component, and the third confidence component are weighted and summed according to their weight coefficients to obtain the overall confidence level of this detection.

[0198] For example, if the first confidence component is 0.95, the second confidence component is 0.92, and the third confidence component is 1.0, with confidence component weights of 0.3, 0.2, and 0.5 respectively, then the overall confidence level = 0.95 × 0.3 + 0.92 × 0.2 + 1.0 × 0.5 = 0.285 + 0.184 + 0.5 = 0.969.

[0199] In the report generation module 17, a test report is generated based on the estimated concentration of pesticide residues and the overall confidence level, including:

[0200] Pre-set the maximum residue limit for the target pesticide;

[0201] Set a high-level confidence threshold, a low-level confidence threshold, and a two-level confidence threshold. The high-level confidence threshold value should be greater than the low-level confidence threshold value.

[0202] If the overall confidence level is lower than the low-level confidence level threshold, the detection is deemed invalid.

[0203] If the overall confidence level is lower than the high confidence level threshold but higher than or equal to the low confidence level threshold, then the confidence interval of the estimated pesticide residue concentration will be output in the test report, and an insufficient confidence level warning will be marked in the test report.

[0204] If the overall confidence level is higher than the high confidence level threshold, the estimated pesticide residue concentration is compared with the maximum residue limit, and the test report is generated based on the comparison result.

[0205] In this embodiment, the purpose of the report generation module 17 is to generate a graded test report based on the estimated concentration of pesticide residues and the overall confidence level, combined with a preset threshold. By differentiating confidence levels, the reference value of the test results is clarified, ensuring the accuracy of concentration determination at high confidence levels while providing risk warnings for low confidence results. This avoids invalid or unreliable data misleading users and ensures the scientific validity and practicality of the test report.

[0206] To achieve the above objectives, firstly, it is necessary to pre-set the maximum residue limit value for the target pesticide;

[0207] For example, based on the relevant standards for the target pesticide, the maximum residue limit (MRL) in the corresponding grain is set. Assuming the target pesticide is chlorpyrifos, the MRL in wheat is set at 0.1 mg / kg; if it is imidacloprid, the MRL in rice is set at 0.05 mg / kg.

[0208] Then, set a high-level confidence threshold, a low-level confidence threshold, and a second-level confidence threshold, with the high-level confidence threshold value being greater than the low-level confidence threshold value;

[0209] For example, the high confidence threshold is set to 0.85 and the low confidence threshold is set to 0.6. That is, an overall confidence level ≥ 0.85 is a high confidence level, 0.6 ≤ overall confidence level < 0.85 is a medium confidence level, and an overall confidence level < 0.6 is a low confidence level.

[0210] If the overall confidence level is lower than the lower confidence level threshold, the test is deemed invalid. For example, if the overall confidence level is 0.55, which is lower than the lower confidence level threshold of 0.6, the test report will clearly indicate that the test is invalid and recommend that the test be repeated.

[0211] If the overall confidence level is lower than the high-level confidence threshold but higher than or equal to the low-level confidence threshold, the confidence interval for the estimated pesticide residue concentration will be output in the test report, and a warning of insufficient confidence will be added to the test report. For example, if the overall confidence level is 0.75 and the estimated pesticide residue concentration is 0.03 mg / kg, the confidence interval calculated based on 3 standard deviations is 0.02-0.04 mg / kg. The report will indicate that this concentration is for reference only and should be used with caution if the confidence level is insufficient.

[0212] If the overall confidence level is higher than the high-confidence threshold, the estimated pesticide residue concentration is compared with the maximum residue limit (MRL), and a test report is generated based on the comparison result. For example, if the overall confidence level is 0.92, the estimated pesticide residue concentration is 0.08 mg / kg, and the MRL is 0.1 mg / kg, the estimated pesticide residue concentration is lower than the MRL, and the report is deemed acceptable. If the estimated pesticide residue concentration is 0.12 mg / kg, which is higher than the MRL, the report is deemed unacceptable.

Claims

1. A rapid detection system for pesticide residues in grains, characterized in that, include: The image acquisition module is used to acquire the reaction area image and pesticide residue concentration gradient of the food pesticide residue detection reagent based on a portable device, and to identify a standardized sub-image set from the reaction area image. The standardized sub-image set includes a sample detection area image, an environmental reference area image, and a food pesticide concentration reference area image. The image correction module is used to calculate the optical correction parameters of the portable device based on the environmental reference area image, and apply the optical correction parameters to correct the sample detection area image and the grain pesticide concentration reference area image respectively, so as to obtain the corrected image data. The fitting evaluation module is used to extract the basic feature values ​​of the corrected image data of the pesticide concentration reference area of ​​the grain, and combine it with the pesticide residue concentration gradient of the grain to fit and generate the dynamic calibration curve of this detection, and calculate the goodness of fit. The feature extraction module is used to extract high-dimensional visual feature vectors from the corrected image data of the sample detection area image and calculate the high-dimensional visual feature vector matching degree. The residue estimation module is used to input the high-dimensional visual feature vector and the dynamic calibration curve into a pre-trained quality analysis model to obtain the estimated pesticide residue concentration of the sample to be tested and the anomaly judgment result of this test. The confidence assessment module is used to calculate the overall confidence level of this detection based on the goodness of fit of the dynamic calibration curve, the matching degree of the high-dimensional visual feature vector, and the anomaly determination result. The report generation module is used to generate a test report based on the estimated concentration of pesticide residues and the overall confidence level.

2. The rapid detection system for pesticide residues in grain according to claim 1, characterized in that, The reaction area image and pesticide residue concentration gradient of a food pesticide residue detection reagent are acquired using a portable device, and a standardized sub-image set is identified from the reaction area image, including: Activate the image acquisition module of the portable device to capture the original image of the grain pesticide residue detection reagent; The reaction area image and the pesticide residue concentration gradient of the grain were extracted from the original image; Based on the image segmentation algorithm, the sample detection area image, the environmental reference area image, and the grain pesticide concentration reference area image are segmented from the reaction area image; After performing image alignment processing on the sample detection area image, the environmental reference area image, and the grain pesticide concentration reference area image, the standardized sub-image set is obtained.

3. The rapid detection system for pesticide residues in grain according to claim 2, characterized in that, The process of segmenting the sample detection area image, the environmental reference area image, and the grain pesticide concentration reference area image from the reaction area image includes: Read the actual captured pixel values ​​of multiple preset standard grayscale color blocks in the reaction area image; Read the actual captured pixel values ​​of multiple preset standard color blocks in the reaction area image.

4. The rapid detection system for pesticide residues in grain according to claim 3, characterized in that, Based on the environmental reference area image, optical correction parameters for the portable device are calculated, and these parameters are applied to correct the sample detection area image and the grain pesticide concentration reference area image, respectively, to obtain corrected image data, including: Obtain the theoretical reference pixel value of the standard grayscale color block under a standard D65 light source; Establish a non-linear color mapping relationship from the actual captured pixel value to the theoretical reference pixel value; A color lookup table is generated based on the nonlinear color mapping relationship; Configure the optical correction parameters of the portable device based on the color lookup table; The optical correction parameters are applied to correct the image of the sample detection area and the image of the grain pesticide concentration reference area, respectively, to obtain the corrected image data.

5. The rapid detection system for pesticide residues in grain according to claim 1, characterized in that, Based on the corrected image data of the grain pesticide concentration reference area, its basic feature values ​​are extracted, and combined with the grain pesticide residue concentration gradient, a dynamic calibration curve for this detection is generated, and the goodness of fit is calculated, including: In the corrected image data of the pesticide concentration reference area for grain, reaction region sub-blocks corresponding to different known concentration levels are identified; Calculate the average pixel intensity value of each known concentration level reaction region sub-block in a specific color channel determined after optical correction, and use the average pixel intensity value as the basic feature value corresponding to that concentration level; A fitting function is constructed using the gradient of pesticide residue concentrations in the grain as the independent variable and the corresponding basic feature value as the dependent variable. Generate the dynamic calibration curve used to describe the response relationship between pesticide residue concentration gradient and basic characteristic value in grain; The determination coefficient of the dynamic calibration curve is calculated as the goodness of fit for evaluating the reliability of the calibration.

6. The rapid detection system for pesticide residues in grain according to claim 5, characterized in that, Calculating the coefficient of determination of the dynamic calibration curve includes: Calculate the predicted feature value corresponding to each concentration gradient based on the dynamic calibration curve; Calculate the total sum of squares of the deviations between the actual measured fundamental characteristic values ​​and their average values, and the sum of squares of the residuals between the predicted characteristic values ​​and the actual measured fundamental characteristic values; The determination coefficient is calculated as follows: determination coefficient = 1 - (the sum of squares of the residuals / the sum of squares of the total deviations).

7. The rapid detection system for pesticide residues in grain according to claim 1, characterized in that, From the corrected image data of the sample detection area image, high-dimensional visual feature vectors are extracted, and the matching degree of the high-dimensional visual feature vectors is calculated, including: A high-dimensional visual feature vector is extracted from the corrected image data of the sample detection area image. The high-dimensional visual feature vector includes color statistical features, texture complexity features, and spatial morphology features. The color statistical features include the mean, standard deviation, skewness, and kurtosis of pixel values ​​calculated on multiple channels of the color space; the texture complexity features are texture histogram features calculated through local binary mode; and the spatial morphology features are the area, perimeter, and circularity of the reaction region. Obtain pre-constructed standard positive sample feature libraries and standard negative sample feature libraries; Calculate the similarity between the high-dimensional visual feature vector and the closest standard positive feature vector in the standard positive sample feature library and the standard negative sample feature library, as well as the similarity between the high-dimensional visual feature vector and the closest standard negative feature vector. The higher similarity value between the two is taken as the matching degree of the high-dimensional visual feature vector.

8. The rapid detection system for pesticide residues in grain according to claim 1, characterized in that, The high-dimensional visual feature vector and the dynamic calibration curve are input together into a pre-trained quality analysis model to obtain the estimated pesticide residue concentration of the sample to be tested and the anomaly judgment results of this test, including: Obtain a training sample set, which includes multiple sample data collected in different portable devices and environments with different pesticide types and concentrations. Each sample data also includes the corresponding high-dimensional visual feature vector, the dynamic calibration curve, and labels for real pesticide concentration values ​​and abnormal reactions. The quality analysis model is built based on a multi-task neural network model, which includes a pesticide residue estimation branch and an anomaly detection branch. The multi-task neural network model is trained based on the training sample set until convergence. The high-dimensional visual feature vector of the sample to be tested is concatenated with the dynamic calibration curve and then input into the pre-trained quality analysis model to simultaneously obtain the estimated concentration value of pesticide residues and the anomaly judgment result.

9. A rapid detection system for pesticide residues in grains according to claim 1, characterized in that, Based on the goodness of fit of the dynamic calibration curve, the matching degree of the high-dimensional visual feature vector, and the anomaly detection result, the overall confidence level of this detection is calculated, including: Weight coefficients are assigned to the goodness of fit, the matching degree of the high-dimensional visual feature vector, and the anomaly detection result, respectively, wherein the anomaly detection result is given the highest weight score when the response is valid, and the weight score of other categories is lower than that of the response. The goodness of fit is normalized to the 0-1 interval and used as the first confidence component. The matching degree of the high-dimensional visual feature vector is used as the second confidence component; Based on the category of the anomaly determination result, obtain the third confidence component based on the anomaly determination result; The first confidence component, the second confidence component, and the third confidence component are weighted and summed according to their weight coefficients to obtain the overall confidence level of this detection.

10. A rapid detection system for pesticide residues in grains according to claim 1, characterized in that, Based on the estimated concentration of pesticide residues and the overall confidence level, a test report is generated, including: Pre-set the maximum residue limit for the target pesticide; Set a high-level confidence threshold, a low-level confidence threshold, and a two-level confidence threshold. The high-level confidence threshold value should be greater than the low-level confidence threshold value. If the overall confidence level is lower than the low-level confidence level threshold, the detection is deemed invalid. If the overall confidence level is lower than the high confidence level threshold but higher than or equal to the low confidence level threshold, then the confidence interval of the estimated pesticide residue concentration will be output in the test report, and an insufficient confidence level warning will be marked in the test report. If the overall confidence level is higher than the high confidence level threshold, the estimated pesticide residue concentration is compared with the maximum residue limit, and the test report is generated based on the comparison result.