Vegetation index calculation method, device, equipment and program product

By receiving user-configured computation tasks, and based on the dependency relationship between vegetation index and spectral channels, the vegetation index is cached and calculated row by row, and the cached data is released after the calculation of a single row is completed. This solves the problem of high peak memory usage in the existing technology and achieves efficient utilization of computing resources.

CN122312554APending Publication Date: 2026-06-30TP-LINK

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TP-LINK
Filing Date
2026-03-30
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing vegetation index calculation systems have high peak memory usage during calculations, resulting in a waste of computing resources.

Method used

By receiving the computation task configured by the user, the necessary set of spectral channels is determined based on the dependency relationship between vegetation index and spectral channels. The vegetation index is cached and calculated row by row, and the cached data is released after the calculation of a single row is completed.

Benefits of technology

This significantly reduces the amount of spectral data cached, lowers memory usage, and improves the efficiency of computing resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122312554A_ABST
    Figure CN122312554A_ABST
Patent Text Reader

Abstract

This application relates to the field of agricultural Internet of Things (IoT), and particularly to a method, apparatus, device, and program product for calculating vegetation indices. The method includes: receiving a user-configured vegetation index calculation task, wherein the calculation task includes at least one vegetation index to be calculated; based on a preset dependency relationship between vegetation indices and spectral channels, and combined with the vegetation indices included in the calculation task, parsing to obtain the necessary set of spectral channels required for the calculation task; acquiring the necessary spectral data corresponding to the necessary set of spectral channels, and caching the image data of the current processing row and adjacent rows in the necessary spectral data; calculating the vegetation index in the calculation task row by row based on the cached image data; and when the calculation of a single row of vegetation indices is completed, outputting the single row of vegetation indices and releasing the cached data related to the calculation of the single row of vegetation indices. This method can significantly reduce the memory usage of vegetation index calculation and improve memory utilization efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of agricultural Internet of Things, and in particular to a vegetation index calculation method, device, equipment and program product. Background Technology

[0002] Vegetation spectral data refers to the intensity information of electromagnetic waves (including visible and near-infrared light) reflected from vegetation (such as crops and forests) at different wavelengths. Pixels in vegetation spectral data acquired by multispectral cameras typically include reflectance values ​​for different spectral channels. Vegetation index calculation systems can calculate vegetation indices corresponding to the reflectance values ​​of different spectral channels, facilitating quantitative assessment of the physiological state of vegetation, such as chlorophyll content, biomass, health status, and water stress.

[0003] Current vegetation index calculation systems typically start multiple threads or loops simultaneously to perform parallel calculations on all preset indices. Since each index calculation requires independent storage of intermediate results and retention of all channel data until all index calculations are completed, this results in high peak memory usage and can easily lead to a waste of computing resources. Summary of the Invention

[0004] In view of this, embodiments of this application provide a vegetation index calculation method, apparatus, device and program product to solve the problem that the high peak memory usage and easy waste of computing resources are caused when calculating vegetation index in the prior art.

[0005] A first aspect of this application provides a method for calculating a vegetation index, the method comprising: Receive a vegetation index calculation task configured by the user, wherein the calculation task includes at least one vegetation index to be calculated. Based on the preset dependency relationship between vegetation indices and spectral channels, and combined with the vegetation indices included in the computation task, the necessary set of spectral channels required to perform the computation task is obtained by analysis. Obtain the necessary spectral data corresponding to the necessary spectral channel set, and cache the image data of the current processing row and the adjacent rows of the current processing row in the necessary spectral data. Calculate the vegetation index in the calculation task row by row based on the cached image data. When the single-row vegetation index is calculated, the single-row vegetation index is output and the cached data related to the calculation of the single-row vegetation index is released.

[0006] In conjunction with the first aspect, in a first possible implementation of the first aspect, image data of the current processing row and adjacent rows of the necessary spectral data are cached, and the vegetation index in the computation task is calculated row by row based on the cached image data, including: Cache the sliding cache window in the necessary spectral data, where the sliding cache window includes data of the current processing row, the previous row, and the next row in the original spectral data for calculation; Calculate the values of the necessary spectral channels at each pixel position of the current processing row through the data in the sliding cache window; Calculate the vegetation index of the current processing row in the calculation task according to the values of the necessary spectral channels at each pixel position of the current processing row.

[0007] Combined with the first possible implementation manner of the first aspect, in the second possible implementation manner of the first aspect, maintain a sliding cache window including three rows of data, including: When the current processing row is the 0th row, maintain the current processing row and the previous row in the sliding cache window as the 0th row, and the next row as the 1st row; When scrolling and updating to the current processing row being the ith row, maintain the (i - 1)th row in the sliding cache window as the previous row, the ith row as the current processing row, and the (i + 1)th row as the next row, where 0 < i < n - 1 and n is the total number of rows; When the current processing row is the (n - 1)th row, maintain the (n - 2)th row as the previous row, the (n - 1)th row as the current processing row, and the next row.

[0008] Combined with the first aspect, in the third possible implementation manner of the first aspect, output the single-row vegetation index, including at least one of the following methods: Write the single-row vegetation index into the first image file; and / or, Perform color mapping processing on the single-row vegetation index to obtain a single-row color image, and encode and write the single-row color image into the second image file.

[0009] Combined with the first aspect, in the fourth possible implementation manner of the first aspect, release the cache data related to calculating the single-row vegetation index, including at least one of the following methods: After the position of the sliding cache window is updated, release the data cached in the sliding cache window before the update that is not needed; Release the intermediate data cached for calculating the single-row vegetation index; Release the calculated single-row vegetation index.[[ID=​​​​​When the device starts up, it reads the page configuration file to obtain the vegetation index calculation task configured by the user.

[0011] In combination with the five possible implementations of the first aspect, in the sixth possible implementation of the first aspect, the vegetation indexes included in the calculation task include the first vegetation index and the second vegetation index. Based on the preset dependency relationship between vegetation indices and spectral channels, and combined with the vegetation indices included in the computational task, the necessary set of spectral channels required to perform the computational task is obtained through analysis, including: Based on the preset dependency relationship between vegetation index and spectral channels, the first spectral channel set corresponding to the first vegetation index and the second spectral channel set corresponding to the second vegetation index are obtained by parsing. The necessary spectral channel set is determined based on the union of the first spectral channel set and the second spectral channel set.

[0012] A second aspect of this application provides a vegetation index calculation device, the device comprising: A calculation task receiving unit is used to receive a vegetation index calculation task configured by the user, wherein the calculation task includes at least one vegetation index to be calculated. The necessary spectral channel set resolution unit is used to resolve the necessary spectral channel set required for performing the calculation task based on the preset dependency relationship between vegetation indices and spectral channels, combined with the vegetation indices included in the calculation task. The vegetation index calculation unit is used to acquire the necessary spectral data corresponding to the necessary spectral channel set, cache the image data of the current processing row and the adjacent rows of the current processing row in the necessary spectral data, and calculate the vegetation index in the calculation task row by row according to the cached image data. The cache release unit is used to output the single-row vegetation index and release the cached data related to the calculation of the single-row vegetation index when the calculation of the single-row vegetation index is completed.

[0013] A third aspect of this application provides a vegetation index calculation device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the vegetation index calculation device performs the method as described in any of the first aspects.

[0014] A fourth aspect of this application provides a computer program product that, when run on a computer, causes the computer to execute the methods described in the first aspect or its various implementations.

[0015] A fifth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method as described in any of the first aspects.

[0016] A sixth aspect of this application provides a chip for implementing the methods in the various implementations of the first aspect described above. Specifically, the chip includes a processor for calling and running a computer program from a memory, causing a device equipped with the chip to perform the methods as described in the first aspect or its various implementations.

[0017] The beneficial effects of this application embodiment compared with the prior art are as follows: The vegetation index calculation method in this application embodiment receives the calculation task configured by the user, determines the necessary set of spectral channels based on the vegetation index of the calculation task, and obtains the necessary spectral data based on the necessary set of spectral channels, thereby reducing the amount of spectral data cached. Then, the vegetation index of the current processing row can be calculated by caching the image data of the current processing row and the adjacent rows of the current processing row. Compared with caching the entire image data, the amount of image data cached can be greatly reduced. Furthermore, when the vegetation index of a single row is calculated, the cached data related to the calculation of the vegetation index of a single row is released, thereby further reducing memory occupation and improving the efficiency of computing resource utilization. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a schematic diagram of an implementation scenario of a vegetation index calculation method provided in this application embodiment; Figure 2 This is a schematic diagram illustrating the implementation process of a vegetation index calculation method provided in an embodiment of this application; Figure 3 This is a schematic diagram illustrating the implementation process of a method for obtaining computing tasks provided in an embodiment of this application; Figure 4 This is a schematic diagram illustrating the dependence of a vegetation index on spectral channels provided in an embodiment of this application; Figure 5 This is a schematic diagram of a vegetation index calculation process provided in an embodiment of this application; Figure 6 This is a schematic diagram of a vegetation index calculation device provided in an embodiment of this application; Figure 7 This is a schematic diagram of a vegetation index calculation device provided in an embodiment of this application. Detailed Implementation

[0020] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0021] To illustrate the technical solution described in this application, specific embodiments are provided below.

[0022] Vegetation spectral data records the intensity information of electromagnetic waves (including visible and near-infrared light) reflected from vegetation (such as crops and forests) in different bands. This type of data, acquired through multispectral cameras, typically contains reflectance values ​​for multiple spectral channels per pixel. Vegetation index calculation systems can use these reflectance values ​​to derive quantitative vegetation indices that reflect physiological states such as chlorophyll content, biomass, health status, and water stress, thereby enabling a quantitative assessment of vegetation condition.

[0023] Existing vegetation index calculation systems typically employ multi-threading or loop-based methods to simultaneously calculate all preset indices. Since each index calculation requires independent storage of intermediate results, and data from all channels must be retained until all indices are calculated, this results in high peak memory usage and a waste of computational resources.

[0024] To address the aforementioned problems, this application proposes a method for calculating vegetation indices. Figure 1 This diagram illustrates an implementation scenario for the method, which includes a multispectral camera and a vegetation index calculation device. The multispectral camera acquires image data across multiple spectral channels, while the vegetation index calculation device receives a user-configured vegetation index calculation task and determines the vegetation indices to be calculated. Based on pre-defined dependencies between vegetation indices and spectral channels, the necessary spectral data for the calculated vegetation indices is determined. Only the current processing row and its adjacent rows need to be cached. This allows for row-by-row calculation of vegetation indices that meet user configuration requirements, significantly reducing cache usage. Furthermore, upon completion of a single row's vegetation index calculation, the single-row vegetation index is output, and the cached data related to that calculation is released, further improving cache utilization efficiency.

[0025] This method does not require calculating all channels and all exponents. Instead, it dynamically constructs a minimal computational path based on the user-configured computational task, requiring only the loading of a minimal dataset and immediate release after computation. It does not rely on dedicated hardware accelerators, significantly reducing the hardware processor requirements. Its computational demands are lower than typical ARM Cortex-M / A series processors, and it can be easily ported to various embedded processors with equivalent or superior performance. It is suitable for any embedded vision system with RAW image acquisition capabilities.

[0026] Figure 2 The implementation flow diagram of a vegetation index calculation method provided in the embodiments of this application is described in detail below: In S201, a vegetation index calculation task configured by the user is received, wherein the calculation task includes at least one vegetation index to be calculated.

[0027] The computational task in this application embodiment involves calculating one or more vegetation indices. Vegetation indices are key indicators used in remote sensing to quantify vegetation characteristics, primarily calculated from reflectance data in different bands of multispectral imagery from satellites or UAVs. Common vegetation indices include NDVI (Normalized Difference Vegetation Index), NDRE (Normalized Difference Red Edge Index), OSAVI (Optimized Soil-Adjusted Vegetation Index), GNDVI (Green Normalized Difference Vegetation Index), and LCI (Leaf Chlorophyll Index).

[0028] When receiving a user-configured vegetation index calculation task, it can Figure 3 As shown, it includes: In S301, user configuration information is received through the configuration page, and a page configuration file is generated.

[0029] The configuration page is an interactive interface provided by the system, usually in the form of a web page. On this configuration page, users can select the vegetation indices to be used in the current or subsequent calculation tasks through checkboxes, drop-down menus, and other methods.

[0030] After receiving the configuration information selected and submitted by the user, the system saves the configuration information to the page configuration file. This file can be a simple text file, such as a .ini or .conf file, or it can also be a JSON or XML file.

[0031] In S302, when the device starts up, the page configuration file is read to obtain the calculation task of the vegetation index configured by the user.

[0032] Each time the vegetation index calculation device (such as the Nongyan intelligent monitoring terminal) starts up or the main program initializes, it will actively read the page configuration file generated or updated in step S301. By parsing the page configuration file, the vegetation index configured by the user can be obtained.

[0033] The system receives vegetation index calculation tasks configured by the user through a page configuration file. This eliminates the need for users to modify firmware code, recompile, or flash the device. The system's calculation behavior can be dynamically changed simply by modifying the configuration file, effectively supporting remote OTA configuration updates and rapid on-site adjustments.

[0034] In addition, the entire configuration process occurs at the application software level without touching the underlying firmware, enabling a flexible application mode of one-time deployment and unlimited expansion, which can effectively reduce the cost of system maintenance and function updates.

[0035] In S202, based on the preset dependency relationship between vegetation indices and spectral channels, and combined with the vegetation indices included in the calculation task, the necessary set of spectral channels required to perform the calculation task is obtained by parsing.

[0036] The predefined dependency between vegetation indices and spectral channels, i.e., the number of spectral channels required to calculate different vegetation indices. For example... Figure 4 In the dependency table shown, the vegetation index NDVI depends on the NIR (near-infrared) and Red spectral channels, the vegetation index GNDVI depends on the NIR (near-infrared) and Green spectral channels, the vegetation index NDRE depends on the NIR (near-infrared) and RedEdge spectral channels, the vegetation index OSAVI depends on the NIR (near-infrared) and Red spectral channels, and the vegetation index LCI depends on the NIR (near-infrared), Red, and RedEdge spectral channels.

[0037] Based on the vegetation indices included in the computation task, it is only necessary to determine the spectral channels corresponding to each vegetation index in the computation task. The necessary set of spectral channels can be determined through the spectral channels corresponding to each vegetation index, so that it is not necessary to load the data of all spectral channels into the cache, which can reduce the cache usage.

[0038] For example, when the vegetation index of the calculation task includes a first vegetation index and a second vegetation index, the necessary spectral channel set can be determined by parsing the first spectral channel set corresponding to the first vegetation index and the second spectral channel set corresponding to the second vegetation index based on the preset dependency relationship between vegetation index and spectral channel; the necessary spectral channel set is then determined by the union of the first spectral channel set and the second spectral channel set.

[0039] It is understandable that the vegetation indices in the calculation task are not limited to the first vegetation index and the second vegetation index, but can also include multiple vegetation indices. The spectral channel sets corresponding to multiple vegetation indices can be calculated respectively, and the necessary spectral channel set can be determined based on the union of multiple spectral channel sets.

[0040] For example, if the vegetation indices included in the user-configured computation task are NDVI and NDRE, then the necessary spectral channel set is determined to be NIR, Red, and RedEdge, without the need for Green spectral channel data. Therefore, all spectral data except for NIR, Red, and RedEdge can be deleted from the original spectral data, and only the NIR, Red, and RedEdge spectral channels need to be loaded, thus effectively reducing the amount of spectral data loaded.

[0041] If the traditional approach requires caching complete image data for all four spectral channels (NIR, Red, Green, and RedEdge) simultaneously, then if the necessary set of spectral channels only includes NIR, Red, and RedEdge, then the Green spectral channel data does not need to be loaded, thus reducing memory usage.

[0042] In S203, the necessary spectral data corresponding to the necessary spectral channel set is obtained, and the image data of the current processing row and the adjacent rows of the current processing row in the necessary spectral data are cached. The vegetation index in the calculation task is calculated row by row based on the cached image data.

[0043] To further optimize memory usage when loading spectral data for the necessary spectral channel set, this embodiment adopts a row-by-row calculation method. This simplifies the spectral data loaded each time to the current processing row and its adjacent rows. Specifically, when calculating the vegetation index at the pixel location of the current processing row, only the image data of the current processing row and its adjacent rows needs to be loaded (this image data includes only the spectral data for the necessary spectral channel set). When calculating the vegetation index row-by-row based on the image data of the current processing row and its adjacent rows from the cached necessary spectral data, it can be done as follows: Figure 5 As shown, it includes: In S501, cache the sliding cache window in the necessary spectral data, where the sliding cache window includes the data of the current processing row, the previous row, and the next row in the original spectral data for calculation.

[0044] The sliding cache window in the embodiments of this application is used to determine the currently cached spectral data, including the current processing row, the previous row of the current processing row, and the next row of the current processing row. As the current processing row moves backward, the position of the sliding cache window changes accordingly, so that the sliding cache window always includes the current processing row, as well as the previous row and the next row of the current processing row.

[0045] Based on the different positions of the sliding cache window, the spectral data included in the sliding cache window will also change.

[0046] For example, when the current processing row is the 0th row, maintain that the current processing row and the previous row in the sliding cache window are both the 0th row, and the next row is the 1st row. When scrolling and updating to the current processing row being the ith row, maintain that the (i - 1)th row in the sliding cache window is the previous row, the ith row is the current processing row, and the (i + 1)th row is the next row, where 0 < i < n - 1, and n is the total number of rows. When the current processing row is the (n - 1)th row, maintain that the (n - 2)th row is the previous row, the (n - 1)th row is the current processing row, and the next row.

[0047] That is to say, when the current processing row is the 0th row (the first row), the current processing row and the previous row are the same, and when the current processing row is the (n - 1)th row (the last row of the image), the current processing row and the next row are the same row. Through this setting, when the current processing row is any row in the spectral image, the adjacent rows of the current processing row, that is, the previous row and the next row, can be determined.

[0048] In S502, calculate the values of the necessary spectral channels at each pixel position of the current processing row through the data in the sliding cache window.

[0049] The calculation formulas of vegetation indices (such as NDVI, GNDVI, etc.) (such as (NIR - Red) / (NIR + Red)) require the reflectance values of specific spectral bands (such as NIR, Red channels) at each pixel position as input. However, the original RAW data output by multi-spectral sensors (such as Bayer array filter cameras) usually contains information of only one band (such as Red or NIR, etc.) at each pixel point. In order to obtain the complete values of all required bands at each pixel point, it can be estimated through the information of surrounding pixels, such as by interpolation. When interpolating based on the spectral data of the current processing row, the previous row, and the next row cached in the sliding cache window, methods such as row-by-row bilinear interpolation, nearest neighbor interpolation, bicubic interpolation, or spline interpolation can be used to determine the complete values of all required bands at each pixel point.

[0050] For each target pixel (x, y) that needs to be calculated, interpolation can be performed using three rows of data. The interpolation formula can be expressed as: interpolated=(1-dx)(1-dy)*q11+dx(1-dy)*q21+(1-dx)dy*q12+dx*dy*q22; Where dy = 0.5 (midpoint of the interline), dx = (x - x0) / 2, dx and dy represent the normalized offset of the target point relative to its upper left reference point; interpolated represents the calculated pixel value of the target pixel; q11, q21, q12, and q22 represent the values ​​of the four known pixels in the 2x2 neighborhood around the target point; Q11 represents the known point at the upper left corner of the target pixel P, with coordinates (x1, y1), and dx = x - x1. dy represents the distance of the target pixel P on the Y-axis relative to Q11, and dy = y - y1.

[0051] In other words, the interpolation calculation to determine the vegetation index only uses the current row and the rows above and below it, without accessing other rows.

[0052] In S503, the vegetation index of the current processing row in the computation task is calculated based on the values ​​of the necessary spectral channels at each pixel position of the current processing row.

[0053] After interpolation is completed and the necessary spectral channel values ​​for each pixel position in the current processing row are estimated, the vegetation index of the current processing row in the calculation task can be determined based on the estimation results, i.e., calculated according to the definition of the vegetation index.

[0054] For example, according to the calculation formula of the vegetation index NDVI: (NIR-Red) / (NIR+Red), the NIR value and Red value of the pixel to be calculated can be substituted into the formula to obtain the vegetation index NDVI.

[0055] In possible implementations, if the number of bits per pixel in a single row of RAW data obtained from the sliding buffer window via the hardware interface is not an integer number of bytes, the number of bits per pixel can be expanded to an integer number of bytes. For example, if the RAW data is 10 bits, it can be expanded to 16 bits (2 bytes), which is beneficial for subsequent calculations. The calculated vegetation index can also be mapped to 16 bits.

[0056] It is understandable that adjacent rows can be either a single adjacent row or several adjacent rows.

[0057] In S204, when the single-row vegetation index is calculated, the single-row vegetation index is output and the cached data related to the calculation of the single-row vegetation index is released.

[0058] For each enabled vegetation index (i.e., the vegetation index included in the user-configured calculation task), calculate the vegetation index corresponding to each pixel in the current processing row in sequence, store it in the vegetation index cache row, and output the calculated vegetation index. The single-row vegetation index can be written to the first image file, and / or the single-row vegetation index can be color mapped to obtain a single-row color image, and then the single-row color image can be written to the second image file.

[0059] For example, the TIFFWriteScanline() function can be called to write the vegetation index cache line output_line[vi] (16-bit) line by line to a TIFF file. Alternatively, the jpeg_write_scanlines() encoding function can be called to convert the vegetation index cache line output_line[vi] into a heatmap (0~65535 mapped to 10 color levels, <32767.5 is black), and then encode it line by line into a JPEG image.

[0060] After calculating the vegetation index for one or more rows of spectral data, the cached data related to calculating the vegetation index for a single row can be released to improve memory utilization efficiency. Releasing the cache can include at least one of the following: 1. After the position of the sliding cache window is updated, release the cached, unused data in the sliding cache window before the update.

[0061] When the sliding cache window moves one row, a new row of spectral data needs to be added, and the oldest row of spectral data needs to be deleted at the same time. While the sliding cache window is moving, the previous row of spectral data can be deleted, and the cache occupied by the previous row of spectral data can be released.

[0062] Alternatively, the cache can be released after moving several lines.

[0063] 2. Release the intermediate data cached for calculating the single-row vegetation index.

[0064] During the calculation of vegetation indices, intermediate data needs to be cached, such as the necessary spectral data for each pixel location obtained through interpolation. Once the vegetation index calculation for the current processing row is complete, the cache occupied by the intermediate data can be released.

[0065] 3. Release the calculated single-row vegetation index.

[0066] After the vegetation index for each pixel in the current processing row is calculated, the vegetation index can be written to a file, and the cache occupied by the vegetation index cache row can be released.

[0067] Alternatively, intermediate data and / or single-row vegetation indices can be cached for several rows before being released.

[0068] By managing the timely and effective release of cache during the computation process, the memory utilization efficiency of the device can be further improved.

[0069] Assuming the image size is 2560*1440, and each pixel's single spectral data occupies 2 bytes of storage space, the traditional solution needs to cache the complete image data of all four spectral channels (NIR, Red, Green, and RedEdge) simultaneously. The cache required for caching the spectral data of the four spectral channels is 2560×1440×2×4=29.49MB. Allocating independent 16-bit output buffers for the five vegetation indices requires 7.37MB×5=36.85MB. Adding the heatmap buffer (11.06 MB), the peak memory usage reaches as high as 77.39MB, far exceeding the available memory of mainstream embedded devices.

[0070] In this embodiment, the peak memory usage can be stably controlled within 0.35MB by using a three-line sliding cache mechanism (caching only 3 lines × width × 2 bytes) and a line-by-line calculation and instant release strategy.

[0071] In other words, compared with traditional technologies, the memory usage in this application embodiment can be reduced from 77.39MB to 0.35MB, a reduction of 99.5%, and the memory complexity can be reduced from O(W×H) to O(W). This enables real-time parallel calculation of five vegetation indices (NDVI, GNDVI, NDRE, OSAVI, LCI) on embedded devices with ≤512MB of RAM, breaking through the computational bottleneck of existing technologies on resource-constrained platforms.

[0072] Moreover, in traditional vegetation index calculation devices, the calculation logic is embedded in the firmware. Adding or modifying indices (such as adding EVI or MSAVI) requires recompiling and flashing the firmware, resulting in high deployment costs and long cycles. In contrast, the embodiments of this application allow users to dynamically specify the indices to be calculated through configuration on a user page (such as NDVI or NDRE). The system automatically resolves dependencies, loads only the necessary channels, and requires zero code modification, zero restarts, and zero upgrades. This results in a configuration change response time of less than 100ms, without service interruption. It also supports remote OTA configuration updates, greatly reducing maintenance costs and improving system scalability and flexibility. This makes it suitable for agricultural IoT deployments in multiple scenarios, with multiple users and diverse needs.

[0073] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0074] Figure 6 A schematic diagram of a vegetation index calculation device provided in an embodiment of this application, the device comprising: The calculation task receiving unit 601 is used to receive a vegetation index calculation task configured by the user, wherein the calculation task includes at least one vegetation index to be calculated.

[0075] The necessary spectral channel set parsing unit 602 is used to parse the necessary spectral channel set required for performing the calculation task based on the preset dependency relationship between vegetation indices and spectral channels, combined with the vegetation indices included in the calculation task.

[0076] The vegetation index calculation unit 603 is used to acquire the necessary spectral data corresponding to the necessary spectral channel set, cache the image data of the current processing row and the adjacent rows of the current processing row in the necessary spectral data, and calculate the vegetation index in the calculation task row by row according to the cached image data.

[0077] The cache release unit 604 is used to output the single-row vegetation index and release the cached data related to the calculation of the single-row vegetation index when the calculation of the single-row vegetation index is completed.

[0078] Figure 6 The vegetation index calculation device shown is, with Figure 2 The vegetation index calculation method shown corresponds to this.

[0079] Figure 7 This is a schematic diagram of a vegetation index calculation device provided in an embodiment of this application. Figure 7 As shown, the vegetation index calculation device 7 of this embodiment includes: a processor 70, a memory 71, and a computer program 72 stored in the memory 71 and executable on the processor 70, such as a vegetation index calculation program. When the processor 70 executes the computer program 72, it implements the steps in the above-described embodiments of vegetation index calculation methods. Alternatively, when the processor 70 executes the computer program 72, it implements the functions of each module / unit in the above-described device embodiments.

[0080] For example, the computer program 72 may be divided into one or more modules / units, which are stored in the memory 71 and executed by the processor 70 to complete this application. The one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program 72 in the vegetation index calculation device 7.

[0081] The vegetation index calculation device may include, but is not limited to, a processor 70 and a memory 71. Those skilled in the art will understand that... Figure 7This is merely an example of a vegetation index calculation device 7 and does not constitute a limitation on the vegetation index calculation device 7. It may include more or fewer components than shown, or combine certain components, or different components. For example, the vegetation index calculation device may also include input / output devices, network access devices, buses, etc.

[0082] The processor 70 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0083] The memory 71 can be an internal storage unit of the vegetation index calculation device 7, such as a hard disk or memory of the vegetation index calculation device 7. The memory 71 can also be an external storage device of the vegetation index calculation device 7, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the vegetation index calculation device 7. Furthermore, the memory 71 can include both internal storage units and external storage devices of the vegetation index calculation device 7. The memory 71 is used to store the computer program and other programs and data required by the vegetation index calculation device. The memory 71 can also be used to temporarily store data that has been output or will be output.

[0084] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0085] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0086] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0087] In the embodiments provided in this application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling or direct coupling or communication connection may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0088] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0089] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0090] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by hardware related to computer program instructions. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.

[0091] In addition, this application also provides a computer program product that, when run on a computer, causes the computer to execute the methods in the above-described implementations.

[0092] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A method of calculating a vegetation index, characterized by, The method includes: Receiving a calculation task of a vegetation index configured by a user, where the calculation task includes at least one vegetation index to be calculated; Based on a preset dependency relationship between the vegetation index and spectral channels, and combining the vegetation indices included in the calculation task, parsing to obtain a set of necessary spectral channels required for performing the calculation task; Obtaining necessary spectral data corresponding to the set of necessary spectral channels, caching image data of the current processing row and the adjacent rows of the current processing row in the necessary spectral data, and calculating the vegetation indices in the calculation task row by row according to the cached image data; When the calculation of the vegetation index for a single row is completed, outputting the vegetation index for the single row and releasing the cached data related to the calculation of the vegetation index for the single row.

2. The method of claim 1, wherein, Caching image data of the current processing row and the adjacent rows of the current processing row in the necessary spectral data, and calculating the vegetation indices in the calculation task row by row according to the cached image data, includes: Caching a sliding cache window in the necessary spectral data, where the sliding cache window includes data of the current processing row, the previous row, and the next row in the original spectral data for calculation; Calculating the values of the necessary spectral channels at each pixel position of the current processing row through the data in the sliding cache window; Calculating the vegetation index of the current processing row in the calculation task according to the values of the necessary spectral channels at each pixel position of the current processing row.

3. The method of claim 2, wherein, Maintaining a sliding cache window including three rows of data, including: When the current processing row is the 0th row, maintaining the current processing row and the previous row in the sliding cache window as the 0th row, and the next row as the 1st row; When rolling and updating to the current processing row being the ith row, maintaining the (i - 1)th row of the sliding cache window as the previous row, the ith row as the current processing row, and the (i + 1)th row as the next row, where 0 < i < n - 1 and n is the total number of rows; When the current processing row is the (n - 1)th row, maintaining the (n - 2)th row as the previous row, the (n - 1)th row as the current processing row, and the next row.

4. The method according to claim 1, characterized in that, Outputting the vegetation index for the single row includes at least one of the following methods: Writing the vegetation index for the single row into a first image file; and / or, Performing color mapping processing on the vegetation index for the single row to obtain a single-row color image, and encoding and writing the single-row color image into a second image file.

5. The method according to claim 1, characterized in that, Releasing the cached data related to the calculation of the vegetation index for the single row includes at least one of the following methods: After the position of the sliding cache window is updated, releasing the data cached in the sliding cache window before the update that is not needed; Releasing the intermediate data cached for calculating the vegetation index for the single row; Releasing the calculated vegetation index for the single row.

6. The method according to claim 1, characterized in that, Receiving a calculation task of a vegetation index configured by a user, includes: Receiving user configuration information through a configuration page and generating a page configuration file; When the device is started, reading the page configuration file to obtain the calculation task of the vegetation index configured by the user.

7. The method according to any one of claims 1-6, characterized in that, The vegetation indices included in the calculation task include a first vegetation index and a second vegetation index; Based on the preset dependency relationship between vegetation indices and spectral channels, and combined with the vegetation indices included in the computational task, the necessary set of spectral channels required to perform the computational task is obtained through analysis, including: Based on the preset dependency relationship between vegetation index and spectral channels, the first spectral channel set corresponding to the first vegetation index and the second spectral channel set corresponding to the second vegetation index are obtained by parsing. The necessary spectral channel set is determined based on the union of the first spectral channel set and the second spectral channel set.

8. A vegetation index calculation device, characterized in that, The device includes: A calculation task receiving unit is used to receive a vegetation index calculation task configured by the user, wherein the calculation task includes at least one vegetation index to be calculated. The necessary spectral channel set resolution unit is used to resolve the necessary spectral channel set required for performing the calculation task based on the preset dependency relationship between vegetation indices and spectral channels, combined with the vegetation indices included in the calculation task. The vegetation index calculation unit is used to acquire the necessary spectral data corresponding to the necessary spectral channel set, cache the image data of the current processing row and the adjacent rows of the current processing row in the necessary spectral data, and calculate the vegetation index in the calculation task row by row according to the cached image data. The cache release unit is used to output the single-row vegetation index and release the cached data related to the calculation of the single-row vegetation index when the calculation of the single-row vegetation index is completed.

9. A vegetation index calculation device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it causes the vegetation index calculation device to implement the method as described in any one of claims 1-7.

10. A computer program product comprising computer program instructions, characterized in that, When the computer program is run, the method as described in any one of claims 1-7 is performed.