Agricultural condition data real-time processing system based on edge computing

CN122176458APending Publication Date: 2026-06-09SHAANXI AGRICULTURE & FORESTRY VOCATIONAL & TECHNICAL UNIVERSITY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHAANXI AGRICULTURE & FORESTRY VOCATIONAL & TECHNICAL UNIVERSITY
Filing Date
2026-05-12
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing agricultural IoT systems cannot effectively process multi-source, high-dimensional agricultural data at the edge gateway, leading to exhaustion of computing resources and blocking of processing threads, making it impossible to achieve real-time anomaly detection.

Method used

The edge gateway monitors the CPU and memory usage in real time, calls a multimodal hierarchical dimensionality reduction operator to extract image texture features and temporal change rate features, and uses a lightweight cross-attention network to perform feature fusion to generate local agricultural condition representation vectors. Early warning instructions are generated based on cosine similarity.

Benefits of technology

The system enables joint computation and real-time early warning of multi-source data on edge devices with limited computing power, avoiding the exhaustion of computing resources and blocking of processing threads. It adapts to the changes in data distribution during the crop growth stage and improves the real-time performance and accuracy of anomaly detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122176458A_ABST
    Figure CN122176458A_ABST
Patent Text Reader

Abstract

This invention relates to the intersection of edge computing and agricultural data processing, and discloses a real-time agricultural data processing system based on edge computing. The edge gateway collects multi-source agricultural sensor data in real time and monitors the utilization rate of the local central processing unit and memory. When the utilization rate exceeds a preset threshold, the modal labels and spatiotemporal attributes of the agricultural data are extracted. A multimodal hierarchical dimensionality reduction operator is invoked to extract local texture features of grid blocks for image-type data and rate of change features for time-series meteorological and soil data. The dimensionality-reduced features are input into a lightweight cross-attention network to output a local agricultural data representation vector. This invention constrains the computational load of multimodal fusion within the available computing power of the edge gateway, overcoming the problems of computational resource exhaustion and thread blocking in scenarios with limited computing power, and realizing local real-time anomaly detection of agricultural data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the intersection of edge computing and agricultural data processing, and discloses a real-time agricultural data processing system based on edge computing. Background Technology

[0002] Existing agricultural IoT systems typically employ an architecture combining direct forwarding from edge gateways with centralized cloud processing when handling multi-source agricultural data. Edge gateways collect real-time image sensor data and meteorological / soil time-series sensor data from farmland, without performing in-depth data analysis; instead, they directly aggregate the raw data packets and transmit them to a cloud server. Upon receiving the multi-source data, the cloud server utilizes a deep learning model deployed on high-performance servers to cross-fuse image and time-series features and identify anomalies. Once an abnormal agricultural condition is determined, warning commands are then cascaded down to the actuators in the farmland. Some edge gateways with local processing capabilities can only perform simple threshold comparisons on single-dimensional time-series sensor data and cannot perform joint analysis of images and multi-dimensional time-series data.

[0003] The core problem with the aforementioned existing technologies lies in the fact that when edge gateways are required to perform fusion processing of multi-source high-dimensional agricultural data locally to avoid cloud transmission delays, their hardware resources are limited, making them unable to support the high concurrency computation resulting from the joint input of high-dimensional image data and multi-dimensional time-series data. Existing edge gateways employ static data processing flows and lack the ability to adaptively adjust the data representation dimensions based on local computing power. When faced with multimodal high-dimensional data such as images and time-series data, fixed fusion algorithms lead to exhaustion of computing resources and blocking of processing threads, preventing edge devices from processing high-dimensional agricultural data and identifying anomalies in real time under computing power constraints. Summary of the Invention

[0004] The purpose of this invention is to provide a solution that can effectively address the problems described in the background section.

[0005] To achieve the above objectives, the technical solution adopted by the present invention is as follows: The real-time agricultural data processing system based on edge computing includes an edge gateway. The edge gateway collects multi-source agricultural sensor data in real time and monitors the usage rate of the local central processing unit and memory. When the usage rate exceeds a preset threshold, the modal labels and spatiotemporal attributes of the current agricultural data are extracted. The edge gateway calls a pre-defined multimodal hierarchical dimensionality reduction operator to extract texture features from image-based agricultural data using principal component analysis and extract rate of change features from time-series meteorological and soil data using differential analysis. The edge gateway inputs the dimensionality-reduced features of different modalities into a lightweight cross-attention network, uses the meteorological and soil time-series features as query vectors and the image texture features as key vectors, and outputs a fused local agricultural representation vector. The edge gateway calculates the cosine similarity between the local agricultural condition representation vector and the pre-stored agricultural condition anomaly feature library. When the cosine similarity exceeds a set threshold, an agricultural condition early warning command is generated at the edge and sent to the field actuator.

[0006] Preferably, the edge gateway reads the central processing unit queue depth and the number of free memory page frames according to a fixed sampling period, and uses the ratio of the queue depth to the number of free page frames as the occupancy rate; The edge gateway parses the header fields of the data packets from multi-source agricultural sensor data, marks data packets carrying video stream identifiers as image type, marks data packets carrying numerical sensor identifiers as time series type, and extracts the timestamp and sensor node number embedded in the data packets as the spatiotemporal attributes.

[0007] Preferably, for agricultural data labeled as images, the edge gateway divides the image into non-overlapping grid blocks, performs principal component analysis independently within each grid block to extract local texture features, and stitches together the local texture features of all grid blocks into the image texture features based on the spatial coordinates of the grid blocks to preserve the spatial distribution information in the image texture features.

[0008] Preferably, for meteorological and soil data tagged as time series, the edge gateway sets a sliding window, calculates the median value of the meteorological and soil data within the sliding window, subtracts the median value from the meteorological and soil data at the current time to obtain the absolute difference, and performs first-order difference calculation on the absolute difference for multiple consecutive times. The obtained first-order difference result is used as the rate of change feature to filter out stationary background noise in the meteorological and soil data.

[0009] Preferably, the lightweight cross-attention network adopts a low-rank matrix factorization structure. The edge gateway maps the query vector and the key-value vector to the low-rank hidden space respectively and then performs a dot product operation to generate an attention weight matrix. The edge gateway applies a diagonal strip mask to the attention weight matrix, retaining only the attention weights that are adjacent to a preset step size in the temporal dimension and shielding the attention weights that are far away to reduce the computational complexity of the lightweight cross-attention network.

[0010] Preferably, the agricultural anomaly feature database is divided into multiple independently stored anomaly sub-feature databases according to the crop growth stage. The edge gateway determines the current growth stage based on the timestamp in the spatiotemporal attribute and retrieves the corresponding anomaly sub-feature database. The edge gateway calculates the mean variance of all feature vectors in the abnormal sub-feature library, and adds the product of the mean variance and the preset offset coefficient to the basic similarity threshold to generate the set threshold.

[0011] Preferably, when the edge gateway performs principal component analysis to extract local texture features of grid blocks, it calculates the local variance of pixel grayscale values ​​within a single grid block. The edge gateway uses the comparison result of the local variance and the global variance threshold as the grid block weight coefficient. When stitching the local texture features of the grid blocks, the edge gateway multiplies the local texture features of each grid block with the corresponding grid block weight coefficient before stitching, so as to increase the proportion of grid blocks containing rich texture details in the subsequent fusion process.

[0012] Preferably, the edge gateway calculates the autocorrelation coefficient based on the historical sequence of meteorological and soil data. The edge gateway moves the sliding window backward along the time axis and calculates the difference in autocorrelation coefficient between adjacent windows in real time. When the difference in autocorrelation coefficient is lower than the preset correlation mutation threshold, the edge gateway locks the boundary position of the current sliding window and dynamically adjusts the length of the sliding window according to the locked boundary position so that the length of the sliding window matches the change period of the meteorological and soil data.

[0013] Preferably, before mapping the query vector and the key-value vector to the low-rank hidden space, the edge gateway inputs the image texture features into the modality alignment transformation layer. The modality alignment transformation layer maps the dimension of the image texture features to an aligned key-value vector that is consistent with the dimension of the meteorological and soil temporal features through a fully connected layer and a normalization layer. The edge gateway uses the aligned key-value vector to replace the key-value vector and inputs it into a lightweight cross-attention network to eliminate the dimensional semantic differences between the image modality and the temporal modality.

[0014] Preferably, when the cosine similarity exceeds the set threshold and an agricultural condition early warning command is generated, the edge gateway inputs the agricultural condition local representation vector into the abnormal sub-feature library corresponding to the current fertility period, calculates the Euclidean distance between the agricultural condition local representation vector and the existing cluster centers in the abnormal sub-feature library, updates the position coordinates of the existing cluster centers in the abnormal sub-feature library based on the Euclidean distance, and simultaneously recalculates the variance mean to iteratively update the set threshold.

[0015] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention monitors local occupancy by real-time calculation of the ratio of CPU queue depth to the number of free memory page frames via an edge gateway. When the occupancy exceeds the limit, a multimodal hierarchical dimensionality reduction operator is invoked to extract image texture features and temporal rate of change features. A lightweight cross-attention network constructed using low-rank matrix factorization and diagonal strip masks is then used for feature fusion. This processing logic transforms high-dimensional multi-source data into low-dimensional local agricultural condition representation vectors, constraining the computational load of multimodal fusion within the available computing power of the edge gateway. This allows edge devices to locally complete the joint computation of multi-source data and output early warning commands even when computing power is limited, overcoming the problems of computational resource exhaustion and processing thread blocking caused by fixed fusion algorithms.

[0016] 2. This invention divides the image into non-overlapping grid blocks and performs principal component analysis independently. It then uses the grid block weight coefficients calculated from local variance to perform weighted stitching, preserving the spatial distribution information in the image texture features and increasing the proportion of detailed features. For time-series data, it dynamically adjusts the sliding window length based on the difference in autocorrelation coefficients, matching the window to the changing cycle of meteorological and soil data and filtering out stable background noise. A modal alignment transformation layer maps the image texture feature dimensions to match the time-series features, eliminating dimensional semantic differences between different modalities. Based on the crop growth period, it retrieves the abnormal sub-feature library, calculates the variance mean to generate a set threshold, and updates the cluster center position based on Euclidean distance after triggering an alert to iteratively update the set threshold, making the anomaly judgment benchmark adaptable to the data distribution changes at different crop growth stages. Attached Figure Description

[0017] Figure 1 This is an overall flowchart of the real-time agricultural data processing system based on edge computing of the present invention; Figure 2 This is a flowchart of the occupancy rate calculation and modal label extraction process of the present invention; Figure 3 This is a flowchart of the image grid block dimensionality reduction and weight calculation process of the present invention; Figure 4 This is a flowchart of the time-series data dynamic window dimensionality reduction process of the present invention; Figure 5 This is a flowchart of the low-rank cross-attention and modal alignment process of the present invention; Figure 6 This is a flowchart of the dynamic threshold warning and feature library update process of the present invention. Detailed Implementation

[0018] Please refer to Figure 1This embodiment provides a real-time agricultural data processing system based on edge computing, configured as a network edge node in a farmland field. The core hardware architecture of this system includes an edge gateway, which communicates with multiple agricultural sensors and field actuators. The multiple agricultural sensors include a multispectral camera mounted on a high-altitude observation pole in the farmland, and temperature, humidity, air pressure, and wind speed sensors distributed in the soil profile. Field actuators include irrigation solenoid valves, shading net motors, and fertilizer pumps. The edge gateway internally houses a local central processing unit (CPU) and memory. The CPU uses a microprocessor based on a Reduced Instruction Set Computing (RISC) machine architecture, and the memory uses Double Data Rate Synchronous Dynamic Random Access Memory (DDRAM). During operation, the edge gateway collects real-time data from the multiple agricultural sensors, including image data from the multispectral camera and time-series meteorological and soil data from temperature and humidity sensors.

[0019] In one embodiment, reference Figure 2 The edge gateway reads the running status parameters of the local CPU and the hardware register status of the memory at a fixed sampling period to monitor the utilization rate of the local CPU and memory. Specifically, the edge gateway mounts a performance monitoring module at the operating system kernel layer. This module obtains the current queue depth by reading the local CPU's run queue file. The queue depth represents the number of tasks that are runnable and waiting for CPU scheduling. Simultaneously, the performance monitoring module reads the buddy system node data structure in the memory management unit to obtain the current number of free memory page frames. The number of free memory page frames represents the total number of physical memory page frames not currently allocated by any process. The edge gateway uses the ratio of the queue depth to the number of free page frames as the utilization rate, calculated using the following formula:

[0020] in, Indicates at time occupancy rate Indicates at time Read queue depth, Indicates at time The number of free memory page frames read. The physical meaning of this ratio is to characterize the scheduling pressure that a single free memory page frame within the edge gateway needs to handle. The edge gateway has a preset occupancy threshold, which is stored in the configuration partition of the edge gateway's non-volatile memory. When the calculated occupancy rate... When the preset threshold is exceeded, it indicates that the remaining computing resources of the edge gateway can no longer support the direct processing of the original high-dimensional data. The resource scheduler of the edge gateway triggers the interruption of the data degradation processing and enters the multimodal hierarchical dimensionality reduction processing process.

[0021] In one embodiment, after receiving multi-source agricultural sensor data, the edge gateway first parses the header fields of the data packets to extract the modality label and spatiotemporal attributes of the current agricultural data. The multi-source agricultural sensor data is encapsulated into network data packets conforming to the User Datagram Protocol (UDP). The edge gateway's network protocol stack disassembles the Internet Protocol (IP) header and the UDP header of the data packets, reading the destination port number field and the first two bytes of the application layer identifier field in the UDP header. If the destination port number matches a video stream transmission port, and the application layer identifier field contains the start code characteristics of H.264 or H.265, the edge gateway marks the data packet carrying the video stream identifier as an image class. If the destination port number matches an IoT object naming service port, and the application layer identifier field indicates a numeric structure, the edge gateway marks the data packet carrying the numeric sensor identifier as a time-series class. Simultaneously with modality marking, the edge gateway extracts the timestamp and sensor node number embedded in the data packet as the spatiotemporal attributes. The timestamp is extracted from the timestamp option field in the IP header of the data packet, and the sensor node number is extracted from the node unique identifier variable within the application layer payload structure.

[0022] In one embodiment, reference Figure 3 After triggering a data degradation processing interruption, the edge gateway invokes a pre-defined multimodal hierarchical dimensionality reduction operator to perform differentiated feature extraction logic for data with different modality labels. For agricultural data labeled as images, the edge gateway uses principal component analysis to extract texture features. The edge gateway decodes the received image frames from the video stream into a raw pixel matrix, with the channel order being red, green, and blue. The edge gateway divides the image into non-overlapping grid blocks. Specifically, the original pixel matrix is ​​cut at equal intervals in the horizontal and vertical directions according to a preset grid edge length pixel value. For pixel regions where the image edge is insufficient to form a complete grid edge length, the edge gateway aligns them to an integer multiple of the grid edge length by padding with zeros on the right or bottom. The principal component analysis is performed independently within each grid block to extract local texture features. The specific calculation process is as follows: Let a single grid block contain the set of pixels as... ,in This represents the total number of pixels within a grid block. This is a 3D color vector. The edge gateway calculates the mean vector of all pixels within this grid patch. Subsequently, the covariance matrix of the grid block pixels is calculated. Edge gateway covariance matrix Perform eigenvalue decomposition to obtain eigenvalues. and its corresponding eigenvectors The edge gateway arranges the feature vectors in descending order of feature values, and selects the top... The eigenvectors corresponding to the eigenvalues ​​constitute the projection matrix. The local texture features of the mesh block are represented as follows: The average pooling result within the grid block. The edge gateway stitches together the local texture features of all grid blocks into the image texture features based on the spatial coordinates of the grid blocks. Specifically, the edge gateway maintains a two-dimensional index array with the same number of rows and columns as the original image grid division, and writes the local texture feature vectors of each grid block into a contiguous memory buffer according to the scan line order from left to right and from top to bottom. This stitching process preserves the spatial distribution information in the image texture features.

[0023] In one embodiment, during the extraction of local texture features from a grid patch, the edge gateway calculates the local variance of the pixel grayscale values ​​within a single grid patch. The edge gateway first converts the red, green, and blue three-channel color vectors within the grid patch into single-channel grayscale values. The formula for calculating local variance is:

[0024] in, The local variance is the arithmetic mean of the grayscale values ​​of all pixels within a grid block. The edge gateway compares the local variance with a global variance threshold, which is generated offline based on a historical database of farmland images without anomalies, taking a specific quantile of the local variance of all grid blocks in that database. The edge gateway uses the comparison result of the local variance and the global variance threshold as the grid block weight coefficient. Specifically, if... Then the weighting coefficient ;like Then the weighting coefficient ,in and When stitching together the local texture features of the mesh blocks, the edge gateway multiplies each local texture feature of the mesh block by its corresponding weight coefficient before stitching. That is, the stitched result is the first... The characteristics of each grid block are This weighted stitching process increases the proportion of mesh blocks containing rich texture details in the subsequent blending process.

[0025] In one embodiment, reference Figure 4 For meteorological and soil data labeled as time series, the edge gateway uses differential extraction to extract the rate of change feature. The meteorological and soil data constitute a multidimensional time series vector. ,in The number of meteorological and soil sensors is defined. The edge gateway sets a sliding window, the initial length of which is a preset base window size. The edge gateway calculates the median value of the meteorological and soil data within the sliding window, for the first... Dimensional sensor data, median value Indicates within the window interval The median value is the value in the middle position after all observations are sorted. The edge gateway subtracts the current meteorological and soil data from this median value to obtain the absolute difference. The edge gateway performs first-order difference calculation on the absolute differences over multiple consecutive time points, and the formula for calculating the rate of change characteristic is as follows:

[0026] The edge gateway combines the first-order difference results of each dimension into the rate of change feature vector. The calculation logic removes the stationary background trend in meteorological and soil data by subtracting the median, and then filters out the stationary background noise in the meteorological and soil data through first-order difference calculation, retaining only the information of the abrupt slope of the data.

[0027] In one embodiment, the edge gateway calculates the autocorrelation coefficient based on historical sequences of meteorological and soil data to dynamically adjust the length of the sliding window. The edge gateway extracts data up to the current time with a length of... The historical sequence is used to calculate the lag order as follows: Autocorrelation coefficient:

[0028] in, Let be the mean of the historical sequence. The edge gateway moves a sliding window backward along the time axis and calculates the difference in autocorrelation coefficients between adjacent windows in real time. Let the autocorrelation coefficient calculated for the current window be . The autocorrelation coefficient calculated in the next window after moving backward by a fixed step size is: The difference in autocorrelation coefficients is then... The edge gateway is internally configured with a preset correlation mutation threshold. When the difference in the autocorrelation coefficients Below the preset correlation mutation threshold When this occurs, it indicates that the periodicity of the data within this interval has not changed. When When this occurs, it indicates that the steady-state period of the data has been broken. The edge gateway locks the boundary position of the current sliding window and dynamically adjusts the length of the sliding window based on the locked boundary position, so that the sliding window length matches the variation period of the meteorological and soil data. The edge gateway limits the adjusted window length between the minimum and maximum window lengths to prevent memory overflow.

[0029] In one embodiment, reference Figure 5 After feature extraction by the multimodal hierarchical dimensionality reduction operator, the edge gateway inputs the dimensionality-reduced features of different modalities into a lightweight cross-attention network. Before inputting into the network, the edge gateway inputs the image texture features into a modality alignment transform layer. Since the image texture features undergo dimensionality reduction through principal component analysis of grid blocks, their feature dimension is... The dimension of the rate of change of meteorological and soil temporal characteristics is The two differ in dimensional semantics. The modality alignment transformation layer is configured with a fully connected layer and a normalization layer; the weight matrix of the fully connected layer has a dimension of [missing information]. The bias vector dimension is Image texture feature matrix The linear transformation after the fully connected layer maps to the intermediate vector. ,in This represents the total number of image grid patches. The normalization layer affects the intermediate vectors. Perform layer normalization calculations along the feature dimension:

[0030] in, and The intermediate vectors are respectively in Mean and standard deviation in dimensions and These are learnable scaling and translation parameters. The normalized output alignment key vector. The dimensions are mapped to match the dimensions of the meteorological and soil temporal features. The edge gateway replaces the original key-value vector with the aligned key-value vector, eliminating the dimensional semantic differences between the image modality and the temporal modality.

[0031] In one embodiment, the lightweight cross-attention network employs a low-rank matrix factorization structure to reduce computational complexity. The meteorological and soil time-series features are used as the query vector. The aligned key value vector is used as the key vector. AND value vector ,in The sequence length represents the temporal features. The edge gateway maps the query vector and the key vector to a low-rank hidden space, respectively. The specific mapping process is implemented using two reduced-rank projection matrices for the query vector. The reduced-rank mapping is ,in , ,rank For key vectors The reduced-rank mapping is ,in , The edge gateway will derank... and Perform a dot product operation to generate the attention weight matrix:

[0032] The edge gateway applies a diagonal strip mask to the attention weight matrix. Let the diagonal strip mask matrix be... The construction rule for this matrix is ​​as follows: for each element in the matrix... If satisfied ,in To preset the step size, then If not satisfied, then The edge gateway adds the mask matrix to the original attention weight matrix: This operation only retains attention weights that are adjacent within a preset step in the temporal dimension, masking attention weights that are far away. Subsequently, the edge gateway... Normalized attention weights are calculated by applying the Softmax function to each row. The formula for calculating the fused local agricultural condition representation vector is as follows:

[0033] This structure reduces computational complexity from low-rank decomposition to stripe masking through the dual constraints of low-rank decomposition and stripe masking. Reduce to This ensures that the computational load of multimodal fusion is constrained within the available computing power of the edge gateway.

[0034] In one embodiment, reference Figure 6 The edge gateway calculates the cosine similarity between the local agricultural condition representation vector and a pre-stored agricultural anomaly feature library. The agricultural anomaly feature library is deployed in the edge gateway's local flash memory array, and internally contains multiple independently stored anomaly sub-feature libraries divided according to the crop's growth stage. The edge gateway determines the current growth stage based on the timestamp extracted from the spatiotemporal attributes. Specifically, the edge gateway internally stores a growth stage mapping lookup table built based on an accumulated temperature model. The edge gateway calculates the cumulative effective accumulated temperature corresponding to the current date, locates the current growth stage label by looking up the table, and retrieves the corresponding anomaly sub-feature library. Assume the anomaly sub-feature library corresponding to the current growth stage contains... Historical anomaly feature vectors The edge gateway calculates the local agricultural condition representation vector. Cosine similarity with each feature vector in the anomaly sub-feature library:

[0035] in, To prevent extremely small constants with a denominator of zero, the edge gateway is traversed to calculate the maximum cosine similarity. .

[0036] In one embodiment, the threshold in the anomaly sub-feature library is dynamically generated. The edge gateway calculates the mean variance of all feature vectors in the anomaly sub-feature library. First, it calculates the cluster center vector of the feature library:

[0037] Then calculate the mean of the variance:

[0038] in, The dimension of the feature vector is given. The edge gateway multiplies the mean variance by a preset offset coefficient and adds it to the base similarity threshold to generate the set threshold. :

[0039] in, Based on the basic similarity threshold, This is a preset offset coefficient. When the maximum cosine similarity... Exceeding the set threshold At this time, the edge gateway generates an agricultural condition early warning command at the edge. The early warning command is encapsulated according to the communication protocol of the field actuator, including the target actuator's device address code, control action code, and checksum. The edge gateway sends the early warning command to the field actuator through a general input / output interface, and the field actuator parses it and executes the corresponding physical action.

[0040] In one embodiment, when the cosine similarity exceeds the set threshold and an agricultural condition early warning command is generated, the edge gateway triggers an online update mechanism for the abnormal feature database. Input the abnormal sub-feature library corresponding to the current reproductive period, and calculate the Euclidean distance between the local agricultural condition representation vector and the existing cluster centers in the abnormal sub-feature library:

[0041] The edge gateway updates the position coordinates of existing cluster centers in the anomaly sub-feature library based on the Euclidean distance. If If the cluster radius is less than the preset threshold, it indicates that the warning sample belongs to a known abnormal pattern, and the edge gateway updates the cluster center using an incremental averaging method.

[0042] like If the value is greater than or equal to the preset cluster radius threshold, it indicates the emergence of a new abnormal pattern. The edge gateway adds a new cluster center in the abnormal sub-feature library, and the initial location coordinates of this new cluster center are... After updating or adding the location coordinates of cluster centers, the edge gateway synchronously recalculates the mean variance of all cluster centers in the current sub-feature library, and then applies the formula... The set threshold is iteratively updated to adapt the anomaly detection benchmark to the changes in data distribution at different growth stages of crops.

[0043] In one embodiment, the edge gateway calculates occupancy. At that time, regarding queue depth An exponential moving average filter is applied to eliminate occupancy spikes caused by instantaneous task scheduling in the operating system. The formula for updating the queue depth is:

[0044] in, This is the smoothing coefficient, and its value range is... The edge gateway uses the filtered queue depth. Substitute the values ​​into the occupancy rate calculation formula. The multimodal hierarchical dimensionality reduction operator is only triggered when the edge gateway detects that the occupancy rate exceeds the preset threshold for multiple consecutive fixed sampling periods, thus preventing frequent switching of feature extraction logic due to instantaneous resource fluctuations.

[0045] In one embodiment, when the edge gateway performs principal component analysis to extract local texture features of mesh blocks, it uses a power-law iteration method to solve the covariance matrix on the microprocessor of the edge device. One principal component feature vector. The edge gateway initializes a random vector with the same dimension as the number of columns in the covariance matrix. Then, normalize it. In each iteration, perform matrix-vector multiplication. For the obtained vector Normalization yields After completing a specified number of iterations, the vector... Converging into the covariance matrix The eigenvector corresponding to the largest eigenvalue. For the second to the... Given a feature vector, the edge gateway will multiply the current vector after each iteration. The vectors are projected onto the orthogonal complement of the subspace formed by all the obtained eigenvectors to eliminate the influence of the converged eigendirections. This iterative solution process does not require a complete eigenvalue decomposition of the covariance matrix, reducing the amount of floating-point operations.

[0046] In one embodiment, when calculating the autocorrelation coefficient difference of meteorological and soil data, the edge gateway employs a strategy of calculating each dimension independently and then taking the maximum value for the multidimensional time series. Assume the multidimensional time series includes temperature, humidity, air pressure, etc. The edge gateway calculates the dimension respectively. The difference in autocorrelation coefficient between adjacent windows ,Pick .when When the change occurs, the sliding window boundary is locked and its length is adjusted. The adjustment strategy is based on the specific dimension that triggered the change. If the change is caused by the temperature dimension, the sliding window length is extended to a first preset length that matches the daily temperature change cycle; if the change is caused by the humidity dimension, the sliding window length is shortened to a second preset length that matches the irrigation event cycle.

[0047] In one embodiment, the reduced-rank projection matrix in the low-rank matrix factorization structure of the lightweight cross-attention network is obtained through offline tensor decomposition before edge gateway deployment. The offline server retrieves the complete query projection matrix from the standard cross-attention network. Perform singular value decomposition on the matrix. Preserve singular value matrices Center front Find the largest singular value and construct a reduced-rank matrix. and When the edge gateway is running, it will... and The parameters are fixed in the read-only area of ​​memory, and two consecutive small-scale matrix multiplications are performed directly, avoiding large-scale matrix inversion or decomposition operations when resources are limited.

[0048] In one embodiment, the diagonal strip mask is not stored in the edge gateway's memory as a complete two-dimensional matrix, but rather as a sparse array storing the position indices of non-zero elements. The edge gateway is configured with two arrays of lengths... and For a one-dimensional array, use a nested loop to calculate only those that satisfy... The attention score is used to skip multiplication and addition operations for index pairs that do not meet the conditions. In the calculation... At that time, the arithmetic logic unit of the edge gateway loads and performs dot product on the vector blocks in the low-rank hidden space according to the index pointer. The unloaded long-distance vectors do not occupy register and cache resources, which further reduces the memory access bandwidth requirements and computational complexity of the lightweight cross-attention network.

[0049] In one embodiment, the edge gateway is configured with a jitter filtering mechanism when generating agricultural early warning commands. The edge gateway maintains a sliding buffer queue with a time length equal to the jitter period. When the calculated maximum cosine similarity... Exceeding the set threshold In this scenario, the edge gateway does not immediately issue an early warning command. Instead, it sets a flag and pushes it into a sliding buffer queue. Only when all flags in the sliding buffer queue are in the triggered state does the edge gateway confirm the agricultural anomaly status is valid, generate the final agricultural early warning command, and send it to the field actuator. If a flag is cleared to zero during the anti-jitter cycle, the edge gateway clears the sliding buffer queue and resets the state machine. This anti-jitter mechanism filters out false alarms caused by instantaneous data jumps from sensors.

[0050] In one embodiment, the normalization layer in the modality alignment transformation layer employs a statistical inference model. During the model initialization phase of the edge gateway, the normalization layer receives a batch of offline-acquired image texture feature samples and calculates their global mean across the feature dimensions. Compared with global standard deviation These two scalar values ​​are then fixed as constants. During the real-time operation of the edge gateway, the normalization layer no longer calculates the instantaneous mean and standard deviation of the input matrix, but directly uses the fixed values. and Perform operations This inference model eliminates the overhead of cyclic reduction caused by real-time calculation of the mean and standard deviation, reducing downtime in the data processing pipeline.

[0051] In one embodiment, the edge gateway uses a smooth, continuous function instead of a piecewise step function when calculating the grid block weight coefficients. The mapping relationship between local variance and weight coefficients is expressed as:

[0052] When the local variance is less than the global variance threshold, the weighting coefficients are... The variance increases linearly within the interval; when the local variance reaches or exceeds the global variance threshold, the weighting coefficients are clamped to their maximum value. When performing weighted stitching, the edge gateway utilizes the microprocessor's Single Instruction Multiple Data Extended Instruction Set to broadcast the weight coefficients to a register set with the same length as the local texture features of the mesh block. Element-wise multiplication is then performed with the feature vector. This process completes parallel multiplication and addition of multiple data within a single clock cycle, improving the execution efficiency of weighted stitching.

[0053] In one embodiment, the edge gateway introduces a forgetting factor when updating the cluster centers of the anomaly sub-feature library. The edge gateway maintains a sample count value for each cluster center in the anomaly sub-feature library. When updating the location coordinates of existing cluster centers based on Euclidean distance, the update formula is modified as follows:

[0054]

[0055] The edge gateway runs a timed decay task in the background, which decays the sample count values ​​of all cluster centers every preset decay period: ,in The forgetting factor has a value range of 1. When the sample count of a cluster center decays to zero, the edge gateway removes that cluster center and its associated feature vector from the flash array. This mechanism enables the anomaly feature library to discard outdated historical anomaly patterns, maintaining its ability to represent the latest agricultural conditions.

[0056] In one embodiment, for the first-order difference calculation of time-series meteorological and soil data, the edge gateway superimposes a sign function after the difference result to preserve the directional characteristics of the rate of change. The calculation of the rate of change feature vector is adjusted as follows:

[0057] in, This is a sign function; it outputs a positive value when the input is positive. When the input is negative, the output is... Output when input is zero By introducing a sign function, the rate of change feature not only includes the magnitude of the absolute difference change, but also encodes whether the original meteorological and soil data is in an upward or downward trend, providing richer temporal dynamic semantic information for subsequent cross-attention fusion.

[0058] In one embodiment, when parsing data packets from multi-source agricultural sensors, the edge gateway is configured with a frame integrity verification mechanism for data packets identified by the video stream. The edge gateway maintains a receive window and sequence number counter at the transport layer of the network protocol stack. When packet loss or out-of-order delivery of video stream data packets is detected, the edge gateway does not mark the incomplete image frame as an image; instead, it marks it as discarded and sends a retransmission request to the multispectral camera or skips the current frame and waits for the next keyframe. This mechanism ensures that the image data input to the principal component analysis module has a complete spatial topology, preventing deviations in covariance matrix calculations due to missing image patches.

[0059] In one embodiment, the multimodal hierarchical dimensionality reduction operator of the edge gateway is deployed in the user space of the operating system as a dynamic link library. After detecting that the occupancy rate exceeds a preset threshold, the resource scheduler sends the shared memory address and data length parameters to the independent daemon process running the multimodal hierarchical dimensionality reduction operator via an inter-process communication mechanism. Upon receiving the parameters, the daemon process directly mounts the sensor data buffer mapped from the operating system kernel space to the user space, avoiding the overhead of copying data from kernel space to user space. The daemon process sequentially calls the image feature extraction interface and the time-series feature extraction interface. After processing, it writes the fused representation vector to another pre-allocated shared memory region and notifies the main control process via a semaphore to perform subsequent cosine similarity calculations.

[0060] In one embodiment, the edge gateway employs a dual-heap data structure when calculating the median value of meteorological and soil data within a sliding window. The edge gateway maintains a max-heap to store smaller values ​​in the left half of the window and a min-heap to store larger values ​​in the right half, ensuring the difference in the number of elements between the two heaps does not exceed one. When the sliding window moves forward one time step, introducing new data and removing the oldest data, the edge gateway performs a deletion adjustment based on the heap to which the removed data belonged, inserts the new data into the corresponding heap, and then performs a balancing operation. The median value is directly taken as the top element of the max-heap or the average of the two top elements. This dual-heap structure reduces the time complexity of obtaining the median from that of sorting algorithms. Reduce to This meets the edge gateway's requirements for high-frequency real-time processing of time-series data.

[0061] In one embodiment, after receiving an agricultural condition early warning command, the field actuator of the edge gateway performs physical actions and generates a hardware response signal. The edge gateway's general-purpose input / output pins are configured for interrupt-triggered mode. When the rising edge of the response signal is detected, the edge gateway records the current timestamp and actuator status word, and encapsulates this status information into a status reporting data packet. The edge gateway inserts the status reporting data packet into the cloud uplink queue to be sent. When the local CPU and memory usage recover to below a preset threshold, the edge gateway sends the status reporting data packet, along with the original, undiminished agricultural condition sensor data, to the cloud server via the wireless communication module, realizing a collaborative working mode of real-time control at the edge and global auditing at the cloud.

[0062] In one embodiment, when the edge gateway calculates the cosine similarity between the local agricultural condition representation vector and the anomaly sub-feature library, if the anomaly sub-feature library is empty, the edge gateway directly writes the current local agricultural condition representation vector as the initial cluster center into the anomaly sub-feature library and sets the maximum cosine similarity to zero, without triggering an early warning command. This cold start logic avoids system malfunctions caused by abnormal threshold calculations due to a lack of historical anomaly samples when the system is first deployed or the reproductive period has just begun to switch.

[0063] In one embodiment, a lightweight cross-attention network performs a weighted summation of value vectors. At that time, due to the effect of the diagonal strip mask, The matrix contains a large number of zero elements. The edge gateway employs an optimization strategy of multiplying sparse and dense matrices, only traversing... The row and column indices of the non-zero elements in the value vector matrix. The vectors from the corresponding columns are extracted, multiplied by the attention weight scalars, and then accumulated into the corresponding rows of the resulting matrix. This calculation method completely skips the multiplication by zero operation, significantly reducing the invalid computation cycles in the fusion stage.

[0064] In one embodiment, when the edge gateway uses the ratio of queue depth to the number of free page frames as the occupancy rate, it performs a logarithmic transformation on the ratio. The transformation formula is as follows:

[0065] The edge gateway will be transformed The value is compared with a preset threshold. The logarithmic transformation compresses the numerical range of occupancy rate when the edge gateway is under extreme congestion, giving the resource scheduler higher monitoring sensitivity during light and medium load phases, while preventing floating-point overflow due to excessively large values ​​during heavy load phases.

[0066] In one embodiment, the weight matrix of the fully connected layer in the modality alignment transformation layer of the edge gateway is stored using int8 integer quantization. The edge gateway obtains the floating-point weight matrix of the fully connected layer during the offline phase. Calculate its absolute maximum value According to the formula Floating-point numbers are mapped to 8-bit integers. During real-time inference, the edge gateway also scales the input image texture features to int8 format, performs integer matrix multiplication using the microprocessor's internal vector dot product instruction, and finally dequantizes the result back to a floating-point number before inputting it into the normalization layer. int8 quantization reduces the memory footprint of the fully connected layer, thereby reducing memory bandwidth consumption during modality alignment.

[0067] In one embodiment, when extracting modal labels for image data, if the edge gateway detects multiple video stream identifiers in data packets at the same time, it sorts them according to the priority of the Quality of Service (QoS) field in the packet header. The edge gateway extracts the highest-priority video stream data packets for grid partitioning and principal component analysis. For low-priority video stream data packets, the edge gateway only extracts their frame header information as auxiliary spatiotemporal attributes and does not perform texture feature extraction. This strategy ensures the analysis accuracy of core field-of-view data even in extreme cases where concurrent access from multiple cameras leads to computational constraints.

[0068] In one embodiment, the edge gateway configures upper and lower boundary constraints for a set threshold in the anomaly sub-feature library. The calculation results of the set threshold... Restricted to the range Inside. when The number of anomalous samples increased dramatically due to their large aggregation, leading to the calculated... Exceed At that time, the edge gateway will set a threshold clamp at .when Because outliers are removed by the forgetting mechanism and approach zero, the calculated values ​​become... Below At that time, the edge gateway will set a threshold clamp at Boundary constraints prevent the dynamic threshold mechanism from degenerating to extreme states where it can never trigger an early warning or is extremely easy to trigger one, thus maintaining the robustness of the early warning system.

Claims

1. A real-time agricultural data processing system based on edge computing, characterized in that, This includes an edge gateway, which collects multi-source agricultural sensor data in real time and monitors the usage rate of the local central processing unit and memory. When the usage rate exceeds a preset threshold, it extracts the modal tags and spatiotemporal attributes of the current agricultural data. The edge gateway calls a pre-defined multimodal hierarchical dimensionality reduction operator to extract texture features from image-based agricultural data using principal component analysis and extract rate of change features from time-series meteorological and soil data using differential analysis. The edge gateway inputs the dimensionality-reduced features of different modalities into a lightweight cross-attention network, uses meteorological and soil time-series features as query vectors and image texture features as key vectors, and outputs a fused local agricultural representation vector. The edge gateway calculates the cosine similarity between the local agricultural condition representation vector and the pre-stored agricultural condition anomaly feature library. When the cosine similarity exceeds a set threshold, an agricultural condition early warning command is generated at the edge and sent to the field actuator.

2. The real-time agricultural data processing system based on edge computing according to claim 1, characterized in that, The edge gateway reads the central processing unit queue depth and the number of free memory page frames according to a fixed sampling period, and uses the ratio of the queue depth to the number of free page frames as the occupancy rate; The edge gateway parses the header fields of the data packets from multi-source agricultural sensor data, marks data packets carrying video stream identifiers as image type, marks data packets carrying numerical sensor identifiers as time series type, and extracts the timestamp and sensor node number embedded in the data packets as the spatiotemporal attributes.

3. The real-time agricultural data processing system based on edge computing according to claim 2, characterized in that, For agricultural data labeled as images, the edge gateway divides the image into non-overlapping grid blocks. Within each grid block, the principal component analysis is performed independently to extract local texture features. The edge gateway then stitches together the local texture features of all grid blocks into the image texture features based on the spatial coordinates of the grid blocks.

4. The real-time agricultural data processing system based on edge computing according to claim 2, characterized in that, For meteorological and soil data tagged as time series, the edge gateway sets a sliding window, calculates the median value of the meteorological and soil data within the sliding window, subtracts the median value from the meteorological and soil data at the current time to obtain the absolute difference, and performs first-order difference calculation on the absolute difference for multiple consecutive time periods, using the obtained first-order difference result as the rate of change feature.

5. The real-time agricultural data processing system based on edge computing according to claim 1, characterized in that, The lightweight cross-attention network adopts a low-rank matrix factorization structure. The edge gateway maps the query vector and the key value vector to the low-rank hidden space respectively and then performs a dot product operation to generate an attention weight matrix. The edge gateway applies a diagonal strip mask to the attention weight matrix, retaining only the attention weights of adjacent preset steps in the temporal dimension and masking the attention weights of distant distances.

6. The real-time agricultural data processing system based on edge computing according to claim 1, characterized in that, The agricultural anomaly feature database is divided into multiple independently stored anomaly sub-feature databases according to the crop growth stage. The edge gateway determines the current growth stage based on the timestamp in the spatiotemporal attribute and retrieves the corresponding anomaly sub-feature database. The edge gateway calculates the mean variance of all feature vectors in the abnormal sub-feature library, and adds the product of the mean variance and the preset offset coefficient to the basic similarity threshold to generate the set threshold.

7. The real-time agricultural data processing system based on edge computing according to claim 3, characterized in that, When performing principal component analysis to extract local texture features of grid blocks, the edge gateway calculates the local variance of pixel grayscale values ​​within a single grid block. The edge gateway uses the comparison result of the local variance with the global variance threshold as the grid block weight coefficient. When stitching the local texture features of the grid blocks, the edge gateway multiplies each local texture feature of the grid block with the corresponding grid block weight coefficient before stitching.

8. The real-time agricultural data processing system based on edge computing according to claim 4, characterized in that, The edge gateway calculates the autocorrelation coefficient based on the historical sequence of meteorological and soil data. The edge gateway moves the sliding window backward along the time axis and calculates the difference in autocorrelation coefficient between adjacent windows in real time. When the difference in autocorrelation coefficient is lower than the preset correlation mutation threshold, the edge gateway locks the boundary position of the current sliding window and dynamically adjusts the length of the sliding window according to the locked boundary position so that the length of the sliding window matches the change period of the meteorological and soil data.

9. The real-time agricultural data processing system based on edge computing according to claim 5, characterized in that, Before mapping the query vector and the key-value vector to the low-rank hidden space, the edge gateway inputs the image texture features into the modality alignment transformation layer. The modality alignment transformation layer maps the dimension of the image texture features to an aligned key-value vector that is consistent with the dimension of the meteorological and soil time-series features through a fully connected layer and a normalization layer. The edge gateway then uses the aligned key-value vector to replace the key-value vector and inputs it into the lightweight cross-attention network.

10. The real-time agricultural data processing system based on edge computing according to claim 6, characterized in that, When the cosine similarity exceeds the set threshold and an agricultural condition early warning command is generated, the edge gateway inputs the agricultural condition local representation vector into the abnormal sub-feature library corresponding to the current fertility period, calculates the Euclidean distance between the agricultural condition local representation vector and the existing cluster centers in the abnormal sub-feature library, updates the position coordinates of the existing cluster centers in the abnormal sub-feature library based on the Euclidean distance, and simultaneously recalculates the variance mean to iteratively update the set threshold.