Food component rapid detection method based on Internet of Things chemical sensing
By combining IoT chemical sensors with Theil–Sen and CUSUM analysis, robust quantitative modeling and change identification of food components have been achieved, solving the problems of unstable detection results and insufficient real-time performance in existing technologies, and improving the reliability and real-time performance of food component detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-03-31
AI Technical Summary
Existing food component detection technologies are difficult to achieve real-time, continuous on-site monitoring, and have limited ability to identify environmental noise, sensor drift, and abnormal data, resulting in unstable detection results and low efficiency in communication resource utilization.
By employing an IoT-based chemical sensing approach, robust quantitative modeling is performed using the Theil–Sen method, combined with CUSUM cumulative and change analysis, enabling continuous monitoring and change identification of food components and generating change event data.
It enables rapid and stable detection of food components, reduces the impact of noise interference and sensor drift, improves the reliability and real-time performance of detection results, reduces invalid data transmission, and is suitable for long-term operation in an IoT environment.
Smart Images

Figure CN121768532A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of food testing and analysis technology, and in particular to a rapid detection method for food components based on Internet of Things (IoT) chemical sensing. Background Technology
[0002] With the development of food safety supervision and intelligent testing technologies, the rapid detection of food components, especially trace elements and micro-components, has become an important technical requirement for food quality control, production process monitoring, and risk early warning. Currently, food component detection generally relies on laboratory analytical methods, such as spectroscopic analysis, electrochemical analysis, or chromatographic detection, and the detection and analysis are usually completed by sending samples for centralized testing after sampling.
[0003] Existing food component detection technologies still have significant limitations in practical applications. On the one hand, traditional detection methods are mostly offline or periodic, with complex processes and long response times, making it difficult to meet the real-time sensing needs for component changes in food production or distribution, and unsuitable for continuous online monitoring scenarios. On the other hand, while on-site detection based on chemical sensors has rapid response capabilities, it is easily affected by environmental noise, sensor drift, and abnormal data during actual operation. Existing methods based on simple linear fitting or fixed threshold judgment have limited ability to identify anomalies and slow changes, easily leading to fluctuations in detection results or delayed change judgment.
[0004] In addition, existing food component detection systems typically adopt a fixed sampling-centralized reporting data processing mode, which lacks a dynamic discrimination mechanism for component changes. This makes it difficult to trigger the output of detection results and data sharing in a timely manner when significant changes occur in components, resulting in low efficiency in communication resource utilization and high system power consumption.
[0005] Therefore, how to provide a rapid detection method for food components based on Internet of Things chemical sensing is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0006] One objective of this invention is to propose a rapid detection method for food components based on IoT chemical sensing, for the rapid detection and continuous monitoring of food components, especially trace components in food. This invention performs windowing processing on the continuous signals collected by the chemical sensor, uses the Theil-Sen method to complete robust quantitative modeling of food components, and combines CUSUM cumulative and change analysis to identify and output event-based results of changes in food components, thereby generating detection results of changes in food components. This method has the advantages of continuous detection process, strong adaptability to abnormal data, timely change identification, and suitability for long-term field operation.
[0007] The rapid food component detection method based on Internet of Things chemical sensing according to embodiments of the present invention includes the following steps: The system collects continuous chemical sensing signals output from chemical sensor nodes at the food testing site, generates a raw signal sequence with timestamps according to a preset sampling period, and acquires and stores calibration parameters corresponding to the chemical sensor nodes and the food components to be tested. The original signal sequence is preprocessed, including denoising, baseline correction, outlier suppression and drift correction, to obtain a preprocessed signal sequence. Based on a preset sliding window length and window update step size, the preprocessed signal sequence is windowed to generate a set of windowed signal sequences updated over time. For each windowed signal sequence, calibration parameters are called, and Theil–Sen regression is used to quantitatively model the windowed signal sequence, outputting the estimated concentration of food components corresponding to the window, and constructing a continuously updated online concentration sequence according to the window time sequence; The online concentration sequence is used as input to perform CUSUM cumulative and change analysis, and the cumulative statistics are calculated point by point to generate a change statistics sequence and a change judgment indicator sequence corresponding to the online concentration sequence. Based on the change determination identifier sequence, the change trigger index is determined. Data corresponding to the change trigger index is extracted from the online concentration sequence and the change statistics sequence to form change event data containing concentration information, statistics information, timestamp, window identifier and node identifier. The system summarizes and structures the data on changes in food composition, and outputs the detection results.
[0008] Optionally, the generation of the timestamped original signal sequence includes: At the food testing site, chemical sensor nodes continuously generate chemical sensing signals related to the food components while in contact with the food sample to be tested. A preset sampling period is set in the chemical sensor node, and periodic sampling operations are performed on the chemical sensing signal according to the preset sampling period; At the sampling time corresponding to each sampling period, the sampled chemical sensing signal is conditioned and digitally processed to obtain the digital chemical sensing signal corresponding to the corresponding sampling time. Each digital chemical sensing signal is assigned a corresponding sampling timestamp, and the digital chemical sensing signal and the sampling timestamp are combined to form multiple sampling data units. The multiple sampling data units are arranged in the order of sampling time to form a time-stamped original signal sequence. Acquire calibration parameters corresponding to the chemical sensor node and the food component to be tested. The calibration parameters include zero-point parameters and sensitivity parameters. Then, associate and store the calibration parameters with the corresponding chemical sensor node identifier and food component identifier.
[0009] Optionally, the generation of the time-updated windowed signal sequence set includes: Sampling data units are read from the original time-stamped signal sequence in chronological order. Preprocessing is performed on the digitized chemical sensing signals within these data units to obtain a preprocessed signal sequence that corresponds to the sampling timestamp. A preset sliding window length and window update step size are set. The preset sliding window length limits the number of consecutive preprocessed signals within a single window, and the window update step size limits the time interval between adjacent windows. Based on the preset sliding window length, consecutive preprocessed signals are extracted from the preprocessed signal sequence in chronological order to form a windowed signal sequence, and the corresponding window time range is recorded. The starting position of the extracted preprocessed signal sequence is updated according to the window update step size. This windowing operation is repeated to generate multiple windowed signal sequences arranged in chronological order. All windowed signal sequences and their corresponding window time ranges are then aggregated to form a time-updated set of windowed signal sequences.
[0010] Optionally, the quantitative modeling of the windowed signal sequence using Theil–Sen regression includes: For each windowed signal sequence, the sampling data units within the corresponding window are read in the order of sampling time, and the sampling time information and digital chemical sensing signal corresponding to each sampling data unit are extracted to construct a set of sample points within the window. Within the set of sample points in the window, two sample points with different sampling times are selected in sequence. The two sample points are used as a set of slope calculation units, and the corresponding candidate slope values are calculated based on the corresponding set of slope calculation units. Based on the combination relationship of sample points in the sample point set within the window, the slope candidate value calculation operation is repeatedly performed on all sample point pairs that meet different sampling time conditions to generate a slope candidate set containing multiple slope candidate values. Sorting is performed on the candidate slope set, and the candidate slope value corresponding to the median position is selected from the sorting results to determine the slope estimate corresponding to the window. Based on the slope estimate, the corresponding intercept candidate value is calculated for each sample point in the sample point set within the window, and the intercept candidate values are aggregated to form an intercept candidate set. Sorting is performed on the intercept candidate set, and the intercept candidate value corresponding to the median position is selected from the sorting result to determine the intercept estimate value corresponding to the window. By combining the slope estimate and the intercept estimate, a Theil–Sen regression model corresponding to the window is constructed. Based on the regression model, quantitative modeling is performed on the windowed signal sequence within the window, and the modeling result corresponding to the window is output.
[0011] Optionally, the construction of the continuously updated online concentration sequence includes: Based on the modeling results corresponding to the corresponding window, read the window identifier and window time information corresponding to the modeling results, construct a window modeling record set, and arrange the window modeling record set according to the time order of the window time information; Obtain calibration parameters, extract zero-point parameters and sensitivity parameters that match the label of the food component to be tested from the calibration parameters, and generate a calibration parameter record corresponding to the label of the food component to be tested; For each window modeling record in the window modeling record set, the corresponding calibration parameter record is called, the concentration conversion operation is performed on the modeling results in the window modeling record, the food component concentration value corresponding to the window identifier is output, and the food component concentration value is combined with the window identifier and window time information to form a window concentration record. The window concentration records are written into the online concentration sequence buffer in chronological order according to the window time information. The ordered arrangement of the window concentration records in the online concentration sequence buffer constitutes the online concentration sequence. The set of windowed signal sequences updated over time is used to generate new windows. Based on the modeling results corresponding to the windows, a new window modeling record containing the new modeling results is generated. The calibration parameter record is then called to perform a concentration conversion operation to generate a new window concentration record. The newly added window concentration record is appended to the online concentration sequence buffer according to the sequence index, completing the continuous update of the online concentration sequence, and synchronously updating the association between the corresponding window identifier and window time information in the online concentration sequence.
[0012] Optionally, the generation of the change statistics sequence and the change determination identifier sequence includes: Based on the window concentration records arranged in order of window time information in the online concentration sequence, the concentration values of food components are extracted to form a concentration input sequence, and a sequence index is assigned to the concentration input sequence; At the current sequence index, a continuous concentration value is extracted from the concentration input sequence to form a robust variable sliding window, which is divided into a first half sub-window and a second half sub-window in chronological order. Representative values are calculated for the first half sub-window and the second half sub-window respectively, and the variable input is generated by the difference between the representative values of the first half sub-window and the second half sub-window. The variable input is then used to generate a variable sequence in chronological order. Based on the change sequence, the cumulative state used to generate change statistics is recursively updated according to CUSUM cumulative and change analysis. After each recursively update, the change statistics corresponding to the current sequence index are determined from the cumulative state, and the change statistics are written into the change statistics sequence in the order of the sequence index. The change statistics are compared with the pre-detection threshold. When the pre-detection threshold is reached, the corresponding sequence index is recorded as the starting index of the confirmation interval, and the change statistics are continuously generated within the confirmation interval. At the end of the confirmation interval, the maximum value of the change statistics within the confirmation interval is determined and compared with the confirmation threshold. When the change statistics reach the confirmation threshold, the corresponding change judgment identifier is generated. When the confirmation threshold is reached, the change judgment identifier corresponding to the start index of the confirmation interval is written into the change judgment identifier sequence and the change trigger index is recorded. When the confirmation threshold is not reached, the non-change judgment identifier corresponding to the start index of the confirmation interval is written into the change judgment identifier sequence. After generating the change determination identifier, the cumulative state and the confirmation interval state are reset, and the change quantity sequence, change statistics sequence and change determination identifier sequence are generated for the sequence index.
[0013] Optionally, the formation of the change event data includes: Based on the change determination identifier sequence, the change determination identifier corresponding to each sequence index is obtained in the order of sequence index, and an index-by-index scan is performed on the change determination identifier; During the scanning process, when the change determination flag corresponding to a certain sequence index is a change determination flag, the corresponding sequence index is determined as the change trigger index; Based on the change-triggered index, same-index localization is performed in the online concentration sequence, change statistics sequence, and change quantity sequence to obtain the target record set consistent with the change-triggered index; Extract the window concentration record corresponding to the target record set from the online concentration sequence, and extract the food component concentration value, window identifier and window time information from the window concentration record to form the trigger window concentration data; Extract the change statistics corresponding to the target record set from the change statistics sequence, and extract the change statistics value corresponding to the change trigger index from the change statistics to form the trigger statistics data. Extract the change input corresponding to the target record set from the change sequence, and extract the change value corresponding to the change trigger index from the change input to form the trigger change data; The trigger window concentration data, trigger statistics data, and trigger change data are associated and encapsulated with the change trigger index to generate change event data. The change event data includes the change trigger index, window identifier, window time information, food component concentration value, change statistics value, and change value.
[0014] Optionally, the output of the food component change detection results includes: summarizing and processing the change event data, sorting and deduplicating the change event data according to the change trigger index, extracting the corresponding food component concentration value, window time information and change statistics information from each change event data, constructing a food component change record set, performing structured encapsulation according to time order, generating food component change detection result data containing food component identifier, change occurrence time, corresponding concentration value and change statistics, and outputting the food component change detection result data to a local storage unit or communication interface.
[0015] The beneficial effects of this invention are: (1) This invention combines continuous acquisition of chemical sensing data, windowing processing and robust quantitative modeling, and uses the Theil–Sen method to continuously estimate the concentration of food components. This effectively reduces the impact of noise interference, sensor drift and abnormal data on the detection results, so that the quantitative analysis of trace components in food can maintain stability and consistency in complex field environments, and improves the reliability of rapid detection of food components.
[0016] (2) By introducing an improved CUSUM accumulation and change analysis mechanism on the continuously updated food component concentration sequence, this invention enables timely identification and judgment of minute changes in food components, transforming the traditional periodic or offline analysis into an active detection process based on statistical changes, significantly shortening the identification response time of component changes and enhancing the real-time nature of food component change monitoring.
[0017] (3) By constructing change event data and using change trigger as the core to output detection results, this invention realizes the event-based organization and output of detection data, avoids the continuous transmission of invalid or redundant data, is suitable for long-term operation in the Internet of Things environment, helps to reduce system communication load and power consumption, and provides an efficient data foundation for the on-site application, storage and sharing of food component detection results. Attached Figure Description
[0018] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a flowchart of the rapid food component detection method based on Internet of Things chemical sensing proposed in this invention; Figure 2 This is a schematic diagram of the quantitative modeling process for food components based on the Theil–Sen method in this invention; Figure 3 This is a schematic diagram illustrating the generation of change statistics and change determination identifiers based on improved CUSUM cumulative and change analysis in this invention. Detailed Implementation
[0019] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0020] refer to Figures 1-3 A rapid food component detection method based on IoT chemical sensing includes the following steps: The system collects continuous chemical sensing signals output from chemical sensor nodes at the food testing site, generates a raw signal sequence with timestamps according to a preset sampling period, and acquires and stores calibration parameters corresponding to the chemical sensor nodes and the food components to be tested. The original signal sequence is preprocessed, including denoising, baseline correction, outlier suppression and drift correction, to obtain a preprocessed signal sequence. Based on a preset sliding window length and window update step size, the preprocessed signal sequence is windowed to generate a set of windowed signal sequences updated over time. For each windowed signal sequence, calibration parameters are called, and Theil–Sen regression is used to quantitatively model the windowed signal sequence, outputting the estimated concentration of food components corresponding to the window, and constructing a continuously updated online concentration sequence according to the window time sequence; The online concentration sequence is used as input to perform CUSUM cumulative and change analysis, and the cumulative statistics are calculated point by point to generate a change statistics sequence and a change judgment indicator sequence corresponding to the online concentration sequence. Based on the change determination identifier sequence, the change trigger index is determined. Data corresponding to the change trigger index is extracted from the online concentration sequence and the change statistics sequence to form change event data containing concentration information, statistics information, timestamp, window identifier and node identifier. The system summarizes and structures the data on changes in food composition, and outputs the detection results.
[0021] In this embodiment, the generation of the original signal sequence with timestamps includes: At the food testing site, chemical sensor nodes continuously generate chemical sensing signals related to the food components while in contact with the food sample to be tested. A preset sampling period is set in the chemical sensor node, and periodic sampling operations are performed on the chemical sensing signal according to the preset sampling period; At the sampling time corresponding to each sampling period, the sampled chemical sensing signal is conditioned and digitally processed to obtain the digital chemical sensing signal corresponding to the corresponding sampling time. Signal conditioning and digitization refers to sequentially adjusting the amplitude and suppressing the noise of the sampled chemical sensing signal to make the signal meet the digitization conditions, and then converting the continuously changing chemical sensing signal into a corresponding discrete numerical signal according to the preset resolution and sampling accuracy. Each digital chemical sensing signal is assigned a corresponding sampling timestamp, and the digital chemical sensing signal and the sampling timestamp are combined to form multiple sampling data units. The multiple sampling data units are arranged in the order of sampling time to form a time-stamped original signal sequence. Acquire calibration parameters corresponding to the chemical sensor node and the food component to be tested. The calibration parameters include zero-point parameters and sensitivity parameters. Then, associate and store the calibration parameters with the corresponding chemical sensor node identifier and food component identifier.
[0022] In this embodiment, the generation of the time-updated windowed signal sequence set includes: Sampling data units are read from the original time-stamped signal sequence in chronological order. Preprocessing is performed on the digitized chemical sensing signals within these data units to obtain a preprocessed signal sequence that corresponds to the sampling timestamp. A preset sliding window length and window update step size are set. The preset sliding window length limits the number of consecutive preprocessed signals within a single window, and the window update step size limits the time interval between adjacent windows. Based on the preset sliding window length, consecutive preprocessed signals are extracted from the preprocessed signal sequence in chronological order to form a windowed signal sequence, and the corresponding window time range is recorded. The starting position of the extracted preprocessed signal sequence is updated according to the window update step size. This windowing operation is repeated to generate multiple windowed signal sequences arranged in chronological order. All windowed signal sequences and their corresponding window time ranges are then aggregated to form a time-updated set of windowed signal sequences.
[0023] In this embodiment, the quantitative modeling of the windowed signal sequence using Theil–Sen regression includes: For each windowed signal sequence, the sampling data units within the corresponding window are read in the order of sampling time, and the sampling time information and digital chemical sensing signal corresponding to each sampling data unit are extracted to construct a set of sample points within the window. Within the set of sample points in the window, two sample points with different sampling times are selected in sequence. The two sample points are used as a set of slope calculation units, and the corresponding candidate slope values are calculated based on the corresponding set of slope calculation units. Based on the combination relationship of sample points in the sample point set within the window, the slope candidate value calculation operation is repeatedly performed on all sample point pairs that meet different sampling time conditions to generate a slope candidate set containing multiple slope candidate values. According to the combination relationship of sample points in the sample point set within the window, each sample point is taken as the starting point and paired with all sample points with different sampling times in turn, generating all sample point pairs without repetition or omission. Each pair of sample points participates in the calculation of the slope candidate value only once. Repeatedly performing the slope candidate value calculation operation means performing the slope calculation process once for each pair of sample points in the sample point set within the window, according to the pre-determined order of the sample point pairs. After each pair of sample points is completed, the obtained slope candidate value is recorded and stored in the slope candidate set. Then, the process switches to the next pair of unprocessed sample points until all sample point pairs within the window have completed the corresponding slope candidate value calculation. Sorting is performed on the candidate slope set, and the candidate slope value corresponding to the median position is selected from the sorting results to determine the slope estimate corresponding to the window. Performing a sorting operation refers to arranging the generated candidate value set as a whole according to its numerical size, rearranging the candidate values in the set in ascending or descending order to form an ordered sequence with a definite order, and clarifying the position index relationship of each candidate value in the ordered sequence; Based on the slope estimate, the corresponding intercept candidate value is calculated for each sample point in the sample point set within the window, and the intercept candidate values are aggregated to form an intercept candidate set. Sorting is performed on the intercept candidate set, and the intercept candidate value corresponding to the median position is selected from the sorting result to determine the intercept estimate value corresponding to the window. The slope estimate and the intercept estimate are combined to construct the Theil–Sen regression model corresponding to the window. Based on the regression model, quantitative modeling is performed on the windowed signal sequence within the window, and the modeling result corresponding to the window is output. Performing quantitative modeling refers to, after obtaining the slope estimate and intercept estimate corresponding to the window, applying the slope estimate and intercept estimate together to each sampling time point according to the sampling time order of the sample point set within the window, generating a corresponding model output value for each sampling time point in the windowed signal sequence, and arranging each model output value in the sampling time order to form a modeling result sequence that corresponds one-to-one with the windowed signal sequence.
[0024] In this embodiment, the construction of the continuously updated online concentration sequence includes: Based on the modeling results corresponding to the corresponding window, read the window identifier and window time information corresponding to the modeling results, construct a window modeling record set, and arrange the window modeling record set according to the time order of the window time information; Obtain calibration parameters, extract zero-point parameters and sensitivity parameters that match the label of the food component to be tested from the calibration parameters, and generate a calibration parameter record corresponding to the label of the food component to be tested; For each window modeling record in the window modeling record set, the corresponding calibration parameter record is called, the concentration conversion operation is performed on the modeling results in the window modeling record, the food component concentration value corresponding to the window identifier is output, and the food component concentration value is combined with the window identifier and window time information to form a window concentration record. Performing a concentration conversion operation means, based on the acquired calibration parameters, taking the modeling result corresponding to the window as the input quantity, and performing a numerical conversion on the modeling result according to the signal-concentration correspondence defined in the calibration parameters, to obtain the food component concentration value that corresponds one-to-one with the modeling result of the window, and maintaining the association between the concentration value and the corresponding window identifier and window time information; The window concentration records are written into the online concentration sequence buffer in chronological order according to the window time information. The ordered arrangement of the window concentration records in the online concentration sequence buffer constitutes the online concentration sequence. The set of windowed signal sequences updated over time is used to generate new windows. Based on the modeling results corresponding to the windows, a new window modeling record containing the new modeling results is generated. The calibration parameter record is then called to perform a concentration conversion operation to generate a new window concentration record. The newly added window concentration record is appended to the online concentration sequence buffer according to the sequence index, completing the continuous update of the online concentration sequence, and synchronously updating the association between the corresponding window identifier and window time information in the online concentration sequence.
[0025] In this embodiment, the generation of the change statistics sequence and the change determination identifier sequence includes: Based on the window concentration records arranged in order of window time information in the online concentration sequence, the concentration values of food components are extracted to form a concentration input sequence, and a sequence index is assigned to the concentration input sequence; At the current sequence index, a continuous concentration value is extracted from the concentration input sequence to form a robust variable sliding window, which is divided into a first half sub-window and a second half sub-window in chronological order. Representative values are calculated for the first half sub-window and the second half sub-window respectively, and the variable input is generated by the difference between the representative values of the first half sub-window and the second half sub-window. The variable input is then used to generate a variable sequence in chronological order. Based on the change sequence, the cumulative state used to generate change statistics is recursively updated according to CUSUM cumulative and change analysis. After each recursively update, the change statistics corresponding to the current sequence index are determined from the cumulative state, and the change statistics are written into the change statistics sequence in the order of the sequence index. Performing a recursive update means that at each sequence index, based on the change input corresponding to the current sequence index and the cumulative state corresponding to the previous sequence index, the cumulative state is updated according to the accumulation and update rules, and the updated cumulative state is used as the input for the recursive update of the next sequence index. The change statistics are compared with the pre-detection threshold. When the pre-detection threshold is reached, the corresponding sequence index is recorded as the starting index of the confirmation interval, and the change statistics are continuously generated within the confirmation interval. The pre-screening threshold refers to the first judgment limit set in advance during the change analysis process. It is used to initially screen the change statistics. When the change statistics reach the threshold, it triggers the subsequent confirmation interval analysis process. At the end of the confirmation interval, the maximum value of the change statistics within the confirmation interval is determined and compared with the confirmation threshold. When the change statistics reach the confirmation threshold, the corresponding change judgment identifier is generated. When the confirmation threshold is reached, the change judgment identifier corresponding to the start index of the confirmation interval is written into the change judgment identifier sequence and the change trigger index is recorded. When the confirmation threshold is not reached, the non-change judgment identifier corresponding to the start index of the confirmation interval is written into the change judgment identifier sequence. The confirmation threshold is the judgment boundary used for the final change determination within the confirmation interval. It is used to compare the change statistics generated within the confirmation interval, and when the change statistics reach the threshold, a corresponding change determination identifier is generated. After generating the change determination identifier, the cumulative state and the confirmation interval state are reset, and the change amount sequence, change statistics sequence and change determination identifier sequence are generated for the sequence index. Performing a reset process means that after completing a change determination, the cumulative state used to generate change statistics is cleared to zero, and the status flag of the current confirmed interval is cleared, so that the change analysis of the subsequent sequence index can start again from the initial state.
[0026] In this embodiment, the formation of the change event data includes: Based on the change determination identifier sequence, the change determination identifier corresponding to each sequence index is obtained in the order of sequence index, and an index-by-index scan is performed on the change determination identifier; Performing an index-by-index scan means reading the corresponding change determination identifiers one by one in ascending order of the sequence index of the change determination identifier sequence, judging each reading result, and recording the sequence index as the change trigger index when the change determination identifier is encountered. Then, the scan continues in the order of the sequence index until the scan ends or the preset stop condition is reached. During the scanning process, when the change determination flag corresponding to a certain sequence index is a change determination flag, the corresponding sequence index is determined as the change trigger index; Based on the change-triggered index, same-index localization is performed in the online concentration sequence, change statistics sequence, and change quantity sequence to obtain the target record set consistent with the change-triggered index; Performing same-index location means that after determining the change trigger index, using the change trigger index as a unified index value, searching for record positions with the same index value in the online concentration sequence, change statistics sequence, and change quantity sequence respectively, and reading the data records at the corresponding index positions, thereby obtaining a target record set that is consistent in time and window. Extract the window concentration record corresponding to the target record set from the online concentration sequence, and extract the food component concentration value, window identifier and window time information from the window concentration record to form the trigger window concentration data; Extract the change statistics corresponding to the target record set from the change statistics sequence, and extract the change statistics value corresponding to the change trigger index from the change statistics to form the trigger statistics data. Extract the change input corresponding to the target record set from the change sequence, and extract the change value corresponding to the change trigger index from the change input to form the trigger change data; The trigger window concentration data, trigger statistics data, and trigger change data are associated and encapsulated with the change trigger index to generate change event data. The change event data includes the change trigger index, window identifier, window time information, food component concentration value, change statistics value, and change value.
[0027] In this embodiment, the output of the food component change detection result includes: summarizing and processing the change event data, sorting and deduplicating the change event data according to the change trigger index, extracting the corresponding food component concentration value, window time information and change statistics information from each change event data, constructing a food component change record set, encapsulating it in a structured manner according to time order, generating food component change detection result data containing food component identifier, change occurrence time, corresponding concentration value and change statistics, and outputting the food component change detection result data to a local storage unit or communication interface.
[0028] Example 1: To verify the feasibility of this invention in practice, it was applied to the quality monitoring of trace components in the continuous production process of a liquid food product. This liquid food is a type of food for which the content of trace elements needs to be stably controlled during production. In this type of production scenario, abnormal changes in trace component content can be caused by various factors such as differences in raw materials, adjustments to process parameters, changes in equipment operating status, or fluctuations in external environmental conditions. Failure to identify these changes in a timely manner can pose potential risks to product quality consistency and food safety. Therefore, there is an urgent need for a detection method that can continuously monitor food components and promptly identify changes without interfering with the production process.
[0029] Under current technological conditions, food production enterprises typically obtain trace component content data by manually taking samples periodically and sending them to laboratories for analysis. While this method has certain advantages in terms of accuracy per test, the overall testing cycle is relatively long due to the multiple stages involved, including sampling, transportation, analysis, and result feedback. The test results often lag behind the actual production process, making it difficult to reflect short-term or gradual component changes that occur during production. Furthermore, this method is based on discrete samples and cannot form a continuous trajectory of component changes, lacking effective characterization of dynamic changes during production.
[0030] To address the aforementioned issues, in this embodiment, a chemical sensor node is installed at a bypass location in the liquid food production pipeline, enabling the chemical sensor to maintain continuous contact with the flowing food medium. The chemical sensor node continuously outputs chemical sensing signals related to the target trace components and samples these signals according to a preset sampling period, generating time-stamped digital signal data. The sampled data is processed in a local edge computing unit, thereby avoiding reliance on network bandwidth and remote servers.
[0031] During system operation, the chemical sensing signals first form a time-stamped raw signal sequence. The system then performs preprocessing on this raw signal sequence to remove significant transient interference and abnormal fluctuations, retaining only the effective signals that reflect the changing trends of food components. Based on this, the system segments the preprocessed signal according to a preset sliding window length and window update step size, forming a set of windowed signal sequences that are continuously updated over time. Each window corresponds to a continuous time interval in the production process, and the windows advance sequentially in chronological order, thus constructing a continuous analytical foundation.
[0032] For each windowed signal sequence, the system calls the calibration parameters corresponding to the chemical sensor node and the target component, and uses the Theil–Sen method to quantitatively model the signal within the window. This method calculates the median values of the slope and intercept based on the combination relationship between sampling points within the window, constructing a robust quantitative model and reducing the impact of noise interference, occasional outliers, and sensor drift on the quantitative results. Each window outputs a corresponding food component concentration estimate, and the concentration estimates from all windows, arranged in chronological order, form a continuously updated online concentration sequence.
[0033] After obtaining the online concentration sequence, the system further performs change detection based on CUSUM cumulative sum and change analysis. Unlike traditional methods that rely on single-point concentration deviations for cumulative judgment, this embodiment first constructs a robust change variable sliding window for the concentration sequence and divides this window into two sub-windows in chronological order, calculating representative values for each. The difference between the representative values of the two sub-windows is used as the change variable input. This change variable input reflects the changing trend of the concentration structure, effectively reducing the impact of single-point fluctuations on change judgment.
[0034] After the change quantity is input into the CUSUM cumulative analysis module, the cumulative status used to generate change statistics is continuously updated according to a recursive rule, thereby generating a sequence of change statistics over time. The system sets a pre-detection threshold and a confirmation threshold. When the change statistics reach the pre-detection threshold, the system enters the confirmation interval, where it continuously analyzes the changes in the change statistics. Only when the change statistics within the confirmation interval reach the confirmation threshold does the system generate a change judgment flag, thus avoiding misjudgments caused by short-term disturbances.
[0035] Once a change determination identifier is generated, the system determines the change trigger index by performing an index-by-index scan of the change determination identifier sequence. Based on this change trigger index, the system performs same-index location in the online concentration sequence, change statistics sequence, and change amount sequence, extracting the window concentration record, change statistics, and change amount information corresponding to the change trigger index. This data is then correlated and encapsulated to form change event data. The system summarizes and structures the change event data, outputting the food component change detection results for production process monitoring and quality management.
[0036] To verify the detection effect of the method of the present invention under continuous operation conditions, the online detection results were compared and analyzed with the traditional laboratory detection results. The relevant statistical results are shown in the table below.
[0037] Table 1. Comparison of trace component concentrations between online detection methods and laboratory detection methods.
[0038] As shown in Table 1, the detection results of trace components in food obtained by the method of the present invention in different operating intervals are highly consistent with the laboratory detection results. The average deviation of each interval is controlled within the range of 0.01 to 0.02 mg / kg, and there is no systematic overestimation or underestimation trend, indicating that the online detection results based on chemical sensing have good stability and consistency. At the same time, the fluctuation range of the detection results in each operating interval is small, indicating that the windowing processing and robust quantitative modeling method adopted can effectively suppress the influence of noise and occasional anomalies on the results. Overall, it proves that the method of the present invention can achieve reliable quantitative detection of trace components in food under continuous operating conditions.
[0039] When changes in production conditions cause fluctuations in trace component content, the method of this invention can identify component changes and generate corresponding change event data within a short period of time after the change occurs. In contrast, traditional laboratory testing methods, due to limitations in the testing process, typically require a longer time to obtain test results. Actual operational results show that the method of this invention is significantly superior to traditional testing methods in terms of change identification response speed, helping production managers to promptly identify problems and take appropriate measures.
[0040] As can be seen from the above embodiments, the rapid detection method for food components based on Internet of Things chemical sensing proposed in this invention can realize continuous online monitoring and change identification of trace components during food production. It overcomes the problems of detection lag, insufficient continuity, and difficulty in timely detection of abnormal changes in the prior art, and has good engineering application value and promotion prospects.
[0041] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A rapid detection method for food components based on Internet of Things (IoT) chemical sensing, characterized in that, include: The system collects continuous chemical sensing signals output from chemical sensor nodes at the food testing site, generates a raw signal sequence with timestamps according to a preset sampling period, and acquires and stores calibration parameters corresponding to the chemical sensor nodes and the food components to be tested. The original signal sequence is preprocessed to obtain a preprocessed signal sequence. Based on the preset sliding window length and window update step size, the preprocessed signal sequence is windowed to generate a set of windowed signal sequences updated over time. For each windowed signal sequence, calibration parameters are called, and Theil–Sen regression is used to quantitatively model the windowed signal sequence, outputting the estimated concentration of food components corresponding to the window, and constructing a continuously updated online concentration sequence according to the window time sequence; The online concentration sequence is used as input to perform CUSUM cumulative and change analysis, and the cumulative statistics are calculated point by point to generate a change statistics sequence and a change judgment indicator sequence corresponding to the online concentration sequence. Based on the change determination identifier sequence, the change trigger index is determined, and the data corresponding to the change trigger index is extracted from the online concentration sequence and the change statistics sequence to form change event data; The system summarizes and structures the data on changes in food composition, and outputs the detection results.
2. The rapid food component detection method based on IoT chemical sensing according to claim 1, characterized in that, The generation of the timestamped original signal sequence includes: At the food testing site, chemical sensor nodes continuously generate chemical sensing signals related to the food components while in contact with the food sample to be tested. A preset sampling period is set in the chemical sensor node, and periodic sampling operations are performed on the chemical sensing signal according to the preset sampling period; At the sampling time corresponding to each sampling period, the sampled chemical sensing signal is conditioned and digitally processed to obtain the digital chemical sensing signal corresponding to the corresponding sampling time. Each digital chemical sensing signal is assigned a corresponding sampling timestamp, and the digital chemical sensing signal and the sampling timestamp are combined to form multiple sampling data units. The multiple sampling data units are arranged in the order of sampling time to form a time-stamped original signal sequence. Acquire calibration parameters corresponding to the chemical sensor node and the food component to be tested. The calibration parameters include zero-point parameters and sensitivity parameters. Then, associate and store the calibration parameters with the corresponding chemical sensor node identifier and food component identifier.
3. The rapid food component detection method based on IoT chemical sensing according to claim 1, characterized in that, The generation of the time-updated windowed signal sequence set includes: The sampling data units are read from the original signal sequence with timestamps in chronological order. Preprocessing is performed on the digitized chemical sensing signals in the sampling data units to obtain a preprocessed signal sequence that corresponds to the sampling timestamps. A preset sliding window length and window update step size are set. Based on the preset sliding window length, continuous preprocessed signals are extracted from the preprocessed signal sequence in chronological order to form a windowed signal sequence, and the corresponding window time range is recorded. The starting position of the extraction of the preprocessed signal sequence is updated according to the window update step size. The windowing operation is repeated to generate multiple windowed signal sequences arranged in chronological order. The windowed signal sequences and their corresponding window time ranges are collected to form a set of windowed signal sequences updated in time.
4. The rapid food component detection method based on IoT chemical sensing according to claim 1, characterized in that, The quantitative modeling of windowed signal sequences using Theil–Sen regression includes: For each windowed signal sequence, the sampling data units within the corresponding window are read in the order of sampling time, and the sampling time information and digital chemical sensing signal corresponding to each sampling data unit are extracted to construct a set of sample points within the window. Within the set of sample points in the window, two sample points with different sampling times are selected in sequence. The two sample points are used as a set of slope calculation units, and the corresponding candidate slope values are calculated based on the corresponding set of slope calculation units. Based on the combination relationship of sample points in the sample point set within the window, the slope candidate value calculation operation is repeatedly performed on all sample point pairs that meet different sampling time conditions to generate a slope candidate set containing multiple slope candidate values. Sorting is performed on the candidate slope set, and the candidate slope value corresponding to the median position is selected from the sorting results to determine the slope estimate corresponding to the window. Based on the slope estimate, the corresponding intercept candidate value is calculated for each sample point in the sample point set within the window, and the intercept candidate values are aggregated to form an intercept candidate set. Sorting is performed on the intercept candidate set, and the intercept candidate value corresponding to the median position is selected from the sorting result to determine the intercept estimate value corresponding to the window. By combining the slope estimate and the intercept estimate, a Theil–Sen regression model corresponding to the window is constructed. Based on the regression model, quantitative modeling is performed on the windowed signal sequence within the window, and the modeling result corresponding to the window is output.
5. The rapid food component detection method based on Internet of Things chemical sensing according to claim 4, characterized in that, The construction of the continuously updated online concentration sequence includes: Based on the modeling results corresponding to the corresponding window, read the window identifier and window time information corresponding to the modeling results, construct a window modeling record set, and arrange the window modeling record set according to the time order of the window time information; Obtain calibration parameters, extract zero-point parameters and sensitivity parameters that match the label of the food component to be tested from the calibration parameters, and generate a calibration parameter record corresponding to the label of the food component to be tested; For each window modeling record in the window modeling record set, the corresponding calibration parameter record is called, the concentration conversion operation is performed on the modeling results in the window modeling record, the food component concentration value corresponding to the window identifier is output, and the food component concentration value is combined with the window identifier and window time information to form a window concentration record. The window concentration records are written into the online concentration sequence buffer in chronological order according to the window time information. The ordered arrangement of the window concentration records in the online concentration sequence buffer constitutes the online concentration sequence. The set of windowed signal sequences updated over time is used to generate new windows. Based on the modeling results corresponding to the windows, a new window modeling record containing the new modeling results is generated. The calibration parameter record is then called to perform a concentration conversion operation to generate a new window concentration record. The newly added window concentration record is appended to the online concentration sequence buffer according to the sequence index, completing the continuous update of the online concentration sequence, and synchronously updating the association between the corresponding window identifier and window time information in the online concentration sequence.
6. The rapid food component detection method based on Internet of Things chemical sensing according to claim 1, characterized in that, The generation of the change statistics sequence and the change determination identifier sequence includes: Based on the window concentration records arranged in order of window time information in the online concentration sequence, the concentration values of food components are extracted to form a concentration input sequence, and a sequence index is assigned to the concentration input sequence; At the current sequence index, a continuous concentration value is extracted from the concentration input sequence to form a robust variable sliding window, which is divided into a first half sub-window and a second half sub-window in chronological order. Representative values are calculated for the first half sub-window and the second half sub-window respectively, and the variable input is generated by the difference between the representative values of the first half sub-window and the second half sub-window. The variable input is then used to generate a variable sequence in chronological order. Based on the change sequence, the cumulative state used to generate change statistics is recursively updated according to CUSUM cumulative and change analysis. After each recursively update, the change statistics corresponding to the current sequence index are determined from the cumulative state, and the change statistics are written into the change statistics sequence in the order of the sequence index. The change statistics are compared with the pre-detection threshold. When the pre-detection threshold is reached, the corresponding sequence index is recorded as the starting index of the confirmation interval, and the change statistics are continuously generated within the confirmation interval. At the end of the confirmation interval, the maximum value of the change statistics within the confirmation interval is determined and compared with the confirmation threshold. When the change statistics reach the confirmation threshold, a corresponding change judgment flag is generated. After generating the change determination identifier, the cumulative state and the confirmation interval state are reset, and the change quantity sequence, change statistics sequence and change determination identifier sequence are generated for the sequence index.
7. The rapid food component detection method based on IoT chemical sensing according to claim 1, characterized in that, The formation of the change event data includes: Based on the change determination identifier sequence, the change determination identifier corresponding to each sequence index is obtained in the order of sequence index, and an index-by-index scan is performed on the change determination identifier; During the scanning process, when the change determination flag corresponding to a certain sequence index is a change determination flag, the corresponding sequence index is determined as the change trigger index; Based on the change-triggered index, same-index localization is performed in the online concentration sequence, change statistics sequence, and change quantity sequence to obtain the target record set consistent with the change-triggered index; Extract the window concentration record corresponding to the target record set from the online concentration sequence, and extract the food component concentration value, window identifier and window time information from the window concentration record to form the trigger window concentration data; Extract the change statistics corresponding to the target record set from the change statistics sequence, and extract the change statistics value corresponding to the change trigger index from the change statistics to form the trigger statistics data. Extract the change input corresponding to the target record set from the change sequence, and extract the change value corresponding to the change trigger index from the change input to form the trigger change data; The trigger window concentration data, trigger statistics data, and trigger change data are associated and encapsulated with the change trigger index to generate change event data.
8. The rapid food component detection method based on Internet of Things chemical sensing according to claim 1, characterized in that, The output of the food component change detection results includes: summarizing and processing the change event data, sorting and deduplicating the change event data according to the change trigger index, extracting the corresponding food component concentration value, window time information and change statistics information from each change event data, constructing a set of food component change records, encapsulating them in a structured manner according to time order, and generating food component change detection result data containing food component identifier, change occurrence time, corresponding concentration value and change statistics.