Soybean nitrogen content detection method and device based on multispectral technology and storage medium

By selecting and adjusting the initial model from the preset model library of spectral data, and adjusting it according to the center wavelength of the band, the problem of low detection accuracy of spectral data was solved, and higher nitrogen detection accuracy was achieved.

CN121506307APending Publication Date: 2026-02-10ZHEJIANG ACADEMY OF AGRICULTURE SCIENCES +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511649273.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-12
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

Existing soybean nitrogen detection models based on spectral data have low accuracy and are difficult to adapt to different spectral devices and wavelength variations.

Method used

By acquiring the spectral data of the soybean to be tested, selecting the initial model from the preset model library, and adjusting the initial model according to the center wavelength of each band and the standard center wavelength used when training the initial model, the target model is obtained. The spectral data is then input to achieve the detection of soybean nitrogen content.

Benefits of technology

The detection accuracy of the soybean nitrogen detection model based on spectral data has been improved, and it can adapt to different spectral equipment and band changes, achieving higher detection precision.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121506307A_ABST
    Figure CN121506307A_ABST
Patent Text Reader

Abstract

The invention discloses a soybean nitrogen content detection method and device based on a multispectral technology and a storage medium. Relates to the technical field of plants, and comprises the following steps: obtaining spectral data of to-be-detected soybeans, the spectral data comprising the wave band number and the central wavelength of each wave band; according to the wave band number, an initial model is selected from a preset model library, and the initial model is one of a first preset model, a second preset model and a third preset model; adjusting the initial model according to the central wavelength of each wave band and a standard central wavelength used when the initial model is trained to obtain a target model; and inputting the spectral data into the target model to obtain a soybean nitrogen content detection value. According to the invention, the problem of low detection accuracy of a soybean nitrogen detection model based on spectral data in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of plant technology, and more specifically, to a method, apparatus, and storage medium for detecting nitrogen content in soybeans based on multispectral technology. Background Technology

[0002] Nitrogen is a core component of chlorophyll, protein, and various enzyme systems in soybeans. Its supply level directly regulates the photosynthetic rate of leaves, dry matter accumulation, and grain protein content, thus being regarded as a key nutrient element determining yield and quality. Traditional nitrogen diagnosis relies on field sampling and laboratory chemical analysis (Kjeldahl nitrogen determination, elemental analyzers, etc.). Although it has high precision, it has inherent drawbacks such as highly destructive sampling, cumbersome procedures, long analysis cycles, high labor and reagent costs, and low spatial coverage, making it difficult to meet the needs of modern precision agriculture for "large-scale, real-time, and non-destructive" information acquisition.

[0003] In recent years, low-altitude unmanned aerial vehicle (UAV) multispectral remote sensing has become an effective means of rapid monitoring of crop nitrogen content due to its maneuverability, centimeter-to-decimeter spatial resolution, and hourly data acquisition capabilities. Studies commonly utilize UAV platforms to acquire canopy reflectance in blue, green, red, red-edge, and near-infrared bands, establishing quantitative inversion models between reflectance spectra and measured nitrogen content. However, existing detection models rely entirely on the sensor used at the time of application for the number of bands, center wavelength, and bandwidth, making them difficult to adapt to subsequent equipment changes or scenarios with missing bands. When the spectrum changes, the accuracy of nitrogen detection becomes lower.

[0004] There is currently no effective solution to the technical problem of low detection accuracy in soybean nitrogen detection models based on spectral data. Summary of the Invention

[0005] The main objective of this application is to provide a method, apparatus, and storage medium for detecting soybean nitrogen content based on multispectral technology, in order to solve the problem of low detection accuracy of soybean nitrogen detection models based on spectral data in related technologies.

[0006] To achieve the above objectives, according to one aspect of this application, a method for detecting soybean nitrogen content based on multispectral technology is provided. The method includes: acquiring spectral data of the soybean to be tested, wherein the spectral data includes the number of bands and the center wavelength of each band; selecting an initial model from a preset model library according to the number of bands, wherein the initial model is one of a first preset model, a second preset model, and a third preset model, wherein the first preset model is a model trained based on a first training sample set, where each training sample in the first training sample set has 6 bands; the second preset model is a model trained based on a second training sample set, where each training sample in the second training sample set has 5 bands; and the third preset model is a model trained based on a third training sample set, where each training sample in the third training sample set has 4 bands; adjusting the initial model according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain a target model; and inputting the spectral data into the target model to obtain the soybean nitrogen content detection value.

[0007] Optionally, the first preset model is obtained through the following steps: obtaining a first training sample set, wherein the first training sample set includes multiple first training samples, each first training sample including spectral data and corresponding true nitrogen values ​​for six bands: blue, green, red, red-edge 1, red-edge 2, and near-infrared; dividing the first training sample set into a first training subset and a first test subset; training the forest regression algorithm model and the artificial neural network based on the first training subset to obtain a first candidate forest regression algorithm model and a first candidate artificial neural network; calculating the first training error of the first candidate forest regression algorithm model based on the first test subset; calculating the second training error of the first candidate artificial neural network based on the first test subset; comparing the magnitudes of the first training error and the second training error, and determining the model with the smaller training error among the first candidate forest regression algorithm model and the first candidate artificial neural network as the first preset model.

[0008] Optionally, the second preset model is obtained through the following steps: obtaining a second training sample set, wherein the second training sample set includes multiple second training samples, each of which includes spectral data and corresponding true nitrogen values ​​for five bands: blue, green, red, red-edge 2, and near-infrared; dividing the second training sample set into a second training subset and a second test subset; training the forest regression algorithm model and the artificial neural network based on the second training subset to obtain a second candidate forest regression algorithm model and a second candidate artificial neural network; calculating the third training error of the second candidate forest regression algorithm model based on the second test subset; calculating the fourth training error of the second candidate artificial neural network based on the second test subset; comparing the magnitudes of the third and fourth training errors, and determining the model with the smaller training error between the second candidate forest regression algorithm model and the second candidate artificial neural network as the second preset model.

[0009] Optionally, the third preset model is obtained through the following steps: obtaining a third training sample set, wherein the third training sample set includes multiple third training samples, each of which includes spectral data and corresponding true nitrogen values ​​for four bands: green, red, red-edge 2, and near-infrared; dividing the third training sample set into a third training subset and a third test subset; training the partial least squares regression model and the support vector regression model based on the third training subset to obtain candidate partial least squares regression models and candidate support vector regression models; calculating the fifth training error of the candidate partial least squares regression model based on the third test subset; calculating the sixth training error of the candidate support vector regression model based on the third test subset; comparing the magnitudes of the fifth training error and the sixth training error, and determining the model with the smaller training error among the candidate partial least squares regression model and the candidate support vector regression model as the third preset model.

[0010] Optionally, adjusting the initial model based on the center wavelength of each band and the standard center wavelength used when training the initial model to obtain the target model includes: calculating the offset of the center wavelength of each band in the spectral data relative to the standard center wavelength used when training the initial model; if the offset is less than a preset size, correcting the regression coefficients of the initial model to obtain the target model; if the offset is not less than a preset size, obtaining a new training sample set, retraining the initial model, and obtaining the target model.

[0011] Optionally, inputting spectral data into the target model to obtain the soybean nitrogen content detection value includes: radiometric calibration of the spectral data to convert the spectral data into reflectance; calculating the vegetation index based on the reflectance; and inputting the reflectance and vegetation index into the target model to obtain the soybean nitrogen content detection value.

[0012] According to another aspect of this application, a soybean nitrogen content detection device based on multispectral technology is provided, comprising: an acquisition unit for acquiring spectral data of soybeans to be detected, wherein the spectral data includes the number of bands and the center wavelength of each band; a selection unit for selecting an initial model from a preset model library according to the number of bands, wherein the initial model is one of a first preset model, a second preset model, and a third preset model, wherein the first preset model is a model trained based on a first training sample set, wherein the number of bands in the spectral data of each training sample in the first training sample set is 6, the second preset model is a model trained based on a second training sample set, wherein the number of bands in the spectral data of each training sample in the second training sample set is 5, and the third preset model is a model trained based on a third training sample set, wherein the number of bands in the spectral data of each training sample in the third training sample set is 4; an adjustment unit for adjusting the initial model according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain a target model; and an input unit for inputting the spectral data into the target model to obtain the soybean nitrogen content detection value.

[0013] Optionally, the first preset model in the selection unit is obtained through the following steps: a first acquisition module, used to acquire a first training sample set, wherein the first training sample set includes multiple first training samples, each first training sample including spectral data and corresponding true nitrogen values ​​for six bands: blue, green, red, red-edge 1, red-edge 2, and near-infrared; a first partitioning module, used to partition the first training sample set into a first training subset and a first test subset; a first training module, used to train the forest regression algorithm model and the artificial neural network based on the first training subset to obtain a first candidate forest regression algorithm model and a first candidate artificial neural network; a first calculation module, used to calculate the first training error of the first candidate forest regression algorithm model based on the first test subset; a second calculation module, used to calculate the second training error of the first candidate artificial neural network based on the first test subset; and a first determination module, used to compare the magnitudes of the first training error and the second training error, and determine the model with the smaller training error among the first candidate forest regression algorithm model and the first candidate artificial neural network as the first preset model.

[0014] Optionally, the second preset model in the selection unit is obtained through the following steps: a second acquisition module, used to acquire a second training sample set, wherein the second training sample set includes multiple second training samples, each second training sample including spectral data and corresponding true nitrogen values ​​for five bands: blue, green, red, red-edge 2, and near-infrared; a second partitioning module, used to partition the second training sample set into a second training subset and a second test subset; a second training module, used to train the forest regression algorithm model and the artificial neural network based on the second training subset, to obtain a second candidate forest regression algorithm model and a second candidate artificial neural network; a third calculation module, used to calculate the third training error of the second candidate forest regression algorithm model based on the second test subset; a fourth calculation module, used to calculate the fourth training error of the second candidate artificial neural network based on the second test subset; and a second determination module, used to compare the magnitudes of the third training error and the fourth training error, and determine the model with the smaller training error among the second candidate forest regression algorithm model and the second candidate artificial neural network as the second preset model.

[0015] Optionally, the third preset model in the selection unit is obtained through the following steps: a third acquisition module, used to acquire a third training sample set, wherein the third training sample set includes multiple third training samples, each of which includes spectral data and corresponding true nitrogen values ​​for four bands: green, red, red-edge 2, and near-infrared; a third partitioning module, used to partition the third training sample set into a third training subset and a third test subset; a third training module, used to train the partial least squares regression model and the support vector regression model based on the third training subset, to obtain candidate partial least squares regression models and candidate support vector regression models; a fifth calculation module, used to calculate the fifth training error of the candidate partial least squares regression model based on the third test subset; a sixth calculation module, used to calculate the sixth training error of the candidate support vector regression model based on the third test subset; and a third determination module, used to compare the magnitudes of the fifth training error and the sixth training error, and determine the model with the smaller training error among the candidate partial least squares regression model and the candidate support vector regression model as the third preset model.

[0016] Optionally, the adjustment unit includes: a seventh calculation module, used to calculate the offset of the center wavelength of each band in the spectral data relative to the standard center wavelength used when training the initial model; a correction module, used to correct the regression coefficients of the initial model if the offset is less than a preset size, to obtain the target model; and a fourth training module, used to obtain a new training sample set and retrain the initial model if the offset is not less than a preset size, to obtain the target model.

[0017] Optionally, the input unit includes: a conversion module for radiometric calibration of the spectral data, converting the spectral data into reflectance; an eighth calculation module for calculating the vegetation index based on reflectance; and an input module for inputting the reflectance and vegetation index into the target model to obtain the soybean nitrogen content detection value. According to another aspect of this application, a computer-readable storage medium is also provided, wherein the computer-readable storage medium includes a stored executable program, wherein, when the executable program runs, it controls the device where the computer-readable storage medium is located to execute the above-described soybean nitrogen content detection method based on multispectral technology.

[0018] According to another aspect of this application, a computer-readable storage medium is also provided, wherein the computer-readable storage medium includes a stored executable program, wherein, when the executable program is running, it controls the device where the computer-readable storage medium is located to perform the above-described method for detecting soybean nitrogen content based on multispectral technology.

[0019] According to another aspect of this application, an electronic device is also provided, comprising: a memory storing an executable program; and a processor for running the program, wherein the program executes the above-described method for detecting soybean nitrogen content based on multispectral technology during runtime.

[0020] According to another aspect of this application, a computer program product is also provided, including computer instructions, characterized in that the computer instructions, when executed by a processor, implement the steps of the above-described method for detecting soybean nitrogen content based on multispectral technology.

[0021] In this embodiment, spectral data of the soybean to be tested is acquired, including the number of bands and the center wavelength of each band. An initial model is selected from a preset model library based on the number of bands. The initial model is one of three preset models: a first preset model, a second preset model, and a third preset model. The first preset model is trained on a first training sample set, where each training sample in the first training sample set has 6 bands. The second preset model is trained on a second training sample set, where each training sample in the second training sample set has 5 bands. The third preset model is trained on a third training sample set, where each training sample in the third training sample set has 4 bands. The initial model is adjusted according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain the target model. The spectral data is then input into the target model to obtain the soybean nitrogen content detection value. This solves the technical problem of low detection accuracy in soybean nitrogen detection models based on spectral data. In this application, an initial model from a preset model library is selected based on the number of bands in the spectral data of the soybean to be tested. The initial model is adjusted according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain the target model. The spectral data is then input into the target model to obtain the soybean nitrogen content detection value, thereby achieving the technical effect of improving the detection accuracy of the nitrogen detection model based on spectral data. Attached Figure Description

[0022] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings: Figure 1 A hardware block diagram of a computer terminal for implementing a soybean nitrogen content detection method based on multispectral technology is shown. Figure 2 This is a flowchart of an optional soybean nitrogen content detection method based on multispectral technology according to an embodiment of this application; Figure 3 This is a schematic diagram of an optional soybean nitrogen content detection device based on multispectral technology, provided according to an embodiment of this application; Figure 4 A schematic diagram of an optional electronic device according to an embodiment of this application. Detailed Implementation

[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0025] Example 1 According to an embodiment of this application, a method embodiment for detecting soybean nitrogen content based on multispectral technology is also provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0026] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal (or mobile device) for implementing a soybean nitrogen content detection method based on multispectral technology is shown. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0027] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0028] The memory 104 can be used to store software programs and modules for application software, such as the program instructions / data storage device corresponding to the soybean nitrogen content detection method based on multispectral technology in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the aforementioned soybean nitrogen content detection method based on multispectral technology. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0029] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0030] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or mobile device).

[0031] Under the aforementioned operating environment, this application provides the following: Figure 2 The method for detecting soybean nitrogen content based on multispectral technology is shown. Figure 2 This is a flowchart of a soybean nitrogen content detection method based on multispectral technology according to Embodiment 1 of this application.

[0032] Step S201: Obtain the spectral data of the soybean to be tested, wherein the spectral data includes the number of bands and the center wavelength of each band.

[0033] Optionally, the spectral data of the soybean to be tested can be the surface reflectance spectrum. The number of bands refers to the actual number of channels available for a single imaging operation. In most cases, it is six bands: blue, green, red, red edge 1, red edge 2, and near-infrared. Due to equipment limitations or other reasons, it can also be spectral data with five bands: blue, green, red, red edge 2, and near-infrared, or even spectral data with four bands: green, red, red edge 2, and near-infrared. The center wavelength of each band can be used as the reference for subsequent band matching and spectral resampling.

[0034] Step S202: Select an initial model from the preset model library according to the number of bands. The initial model is one of the first preset model, the second preset model, and the third preset model. The first preset model is a model trained based on the first training sample set, where each training sample in the first training sample set has 6 bands of spectral data. The second preset model is a model trained based on the second training sample set, where each training sample in the second training sample set has 5 bands of spectral data. The third preset model is a model trained based on the third training sample set, where each training sample in the third training sample set has 4 bands of spectral data.

[0035] Optionally, the aforementioned preset model library includes a first preset model, a second preset model, and a third preset model. The first preset model is trained based on a first training sample set, where each training sample in the first training sample set has 6 bands in its spectral data (blue, green, red, red-edge 1, red-edge 2, and near-infrared). The second preset model is trained based on a second training sample set, where each training sample in the second training sample set has 6 bands in its spectral data (blue, green, red, red-edge 2, and near-infrared). The third preset model is trained based on a third training sample set, where each training sample in the third training sample set has 4 bands in its spectral data (green, red, red-edge 2, and near-infrared). An initial model can be selected from the preset model library based on the spectral data of the soybean to be tested. If the spectral data of the soybean to be tested includes 6 bands, the first preset model is selected; if the spectral data of the soybean to be tested includes 5 bands, the second preset model is selected; and if the spectral data of the soybean to be tested includes 4 bands, the third preset model is selected.

[0036] Step S203: Adjust the initial model according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain the target model.

[0037] Optionally, in multispectral imaging, even if different sensors (or different batches of the same sensor) have the same number of bands, the center wavelength of the acquired spectral data will still have a certain shift. If there is a deviation between the center wavelength of the spectral data of the soybean to be tested and the standard center wavelength used when training the initial model, directly inputting the spectral data into the initial model without calculating the deviation will cause the initial model to fail or fail to output accurate nitrogen values. To adjust the initial model based on the center wavelength of each band in the spectral data of the soybean to be tested and the standard center wavelength used when training the initial model, it is necessary to first calculate the offset Δλ between the center wavelength of each band in the spectral data of the soybean to be tested and the standard center wavelength used when training the initial model, and set a preset size. If the offset is less than the preset size, the regression coefficients of the initial model can be corrected. If the offset is not less than the preset size, a new training sample set can be obtained, the initial model can be retrained, and the target model can be obtained.

[0038] Step S204: Input the spectral data into the target model to obtain the soybean nitrogen content detection value.

[0039] Optionally, the spectral data is input into the target model. The target model is an initial model selected based on the number of bands. The initial model is then adjusted based on the center wavelength of each band and the standard center wavelength of the initial model used for training. The resulting target model outputs more accurate nitrogen content detection values.

[0040] The soybean nitrogen content detection method based on multispectral technology provided in this application acquires the spectral data of the soybean to be tested, wherein the spectral data includes the number of bands and the center wavelength of each band; an initial model is selected from a preset model library according to the number of bands, wherein the initial model is one of a first preset model, a second preset model, and a third preset model. The first preset model is a model trained based on a first training sample set, wherein each training sample in the first training sample set has 6 spectral bands; the second preset model is a model trained based on a second training sample set, wherein each training sample in the second training sample set has 5 spectral bands; and the third preset model is a model trained based on a third training sample set, wherein each training sample in the third training sample set has 4 spectral bands; the initial model is adjusted according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain a target model; the spectral data is input into the target model to obtain the soybean nitrogen content detection value, thus solving the technical problem of low detection accuracy of soybean nitrogen detection models based on spectral data. In this application, an initial model from a preset model library is selected based on the number of bands in the spectral data of the soybean to be tested. The initial model is adjusted according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain the target model. The spectral data is then input into the target model to obtain the soybean nitrogen content detection value, thereby achieving the technical effect of improving the detection accuracy of the nitrogen detection model based on spectral data.

[0041] Optionally, in the soybean nitrogen content detection method based on multispectral technology provided in this application embodiment, the first preset model is obtained through the following steps: The first step is to obtain the first training sample set, which includes multiple first training samples. Each first training sample includes spectral data and corresponding true nitrogen values ​​for six bands: blue, green, red, red edge 1, red edge 2, and near-infrared.

[0042] Optionally, the first training sample set is a training sample set used to train the first preset model. Each first training sample in the training sample set contains spectral data in six bands: blue (≈450 nm), green (≈560 nm), red (≈650 nm), red edge 1 (≈705 nm), red edge 2 (≈740 nm), and near-infrared (≈840 nm). The spectral data in these six bands contain red-edge double peaks, thus providing the richest nitrogen-sensitive region. The corresponding true nitrogen values ​​can be determined using the Kjeldahl method in the laboratory. The first training sample consists of a one-to-one correspondence between spectral data and true nitrogen values.

[0043] The second step is to divide the first training sample set into a first training subset and a first test subset.

[0044] Optionally, the first training sample set can be divided into a first training subset and a first test subset according to a preset ratio such as 8:2 or 7:3. The first training subset is used to train the first candidate model, and the first test subset is used to test the detection performance of the model trained by the first training subset.

[0045] The third step is to train the forest regression algorithm model and the artificial neural network based on the first training subset to obtain the first candidate forest regression algorithm model and the first candidate artificial neural network.

[0046] Optionally, the forest regression algorithm model and the artificial neural network can be trained separately based on the first training subset. The forest regression algorithm model, relying on Bootstrap sampling and feature subspace randomization mechanisms, can achieve anti-overfitting estimation in highly collinear red-edge band environments, and quantifies the contribution of each channel using OOB error and variable importance. The artificial neural network can capture the slope abrupt change at 705 nm and 740 nm and its complex interaction with higher-order vegetation indices through multi-layer nonlinear mapping, making it suitable for high-dimensional input expansion. The forest regression algorithm model and the artificial neural network are compared under the same training-test partition, and the one with the smaller error is sealed as the first preset model.

[0047] The fourth step is to calculate the first training error of the first candidate forest regression algorithm model based on the first test subset.

[0048] Optionally, the spectral data of each training sample in the first test subset can be input into the first candidate forest regression algorithm model to obtain nitrogen detection values, which can then be compared with the true nitrogen values ​​to obtain the first training error.

[0049] The fifth step is to calculate the second training error of the first candidate artificial neural network based on the first test subset.

[0050] Optionally, the spectral data of the first test subset can be input into the first candidate artificial neural network to obtain the predicted nitrogen value, which can then be compared with the true nitrogen value to obtain the second training error.

[0051] The sixth step is to compare the magnitudes of the first training error and the second training error, and determine the model with the smaller training error among the first candidate forest regression algorithm model and the first candidate artificial neural network model as the first preset model.

[0052] Optionally, the candidate with the smaller error in the first candidate forest regression algorithm model and the first candidate artificial neural network model is selected as the first preset model because it has higher accuracy in detecting soybean nitrogen content.

[0053] Optionally, in the soybean nitrogen content detection method based on multispectral technology provided in this application embodiment, the second preset model is obtained through the following steps: The first step is to obtain the second training sample set, which includes multiple second training samples. Each second training sample includes spectral data and corresponding true nitrogen values ​​for five bands: blue, green, red, red-edge 2, and near-infrared.

[0054] Optionally, the spectral data in the second training sample set lacks Red Edge 1 (≈705 nm), which includes five bands: blue, green, red, Red Edge 2, and near-infrared. With Red Edge 1 missing from the spectral data, i.e., 705 nm, only a single peak at 740 nm remains in the red edge region. The input vector is reduced from 6 dimensions to 5 dimensions, decreasing the usable information by approximately 17%. The peak value of the first derivative of reflectance near 705 nm disappears, and the nitrogen-spectral response curve degenerates from a "double-peaked S-shape" to a "weak single-shoulder S-shape," requiring the algorithm to capture subtle and non-linear slope changes.

[0055] The second step is to divide the second training sample set into a second training subset and a second test subset.

[0056] Optionally, the second training sample set can be divided into a second training subset and a second test subset according to a preset ratio such as 8:2 or 7:3. The second training subset is used to train the second candidate model, and the second test subset is used to test the detection performance of the model trained by the second training subset.

[0057] The third step involves training the forest regression algorithm model and the artificial neural network based on the second training subset, resulting in the second candidate forest regression algorithm model and the second candidate artificial neural network.

[0058] Optionally, in the 5-band spectrum (excluding red edge 1), the reflectance values ​​of the four channels—green (≈560 nm), red (≈650 nm), red edge 2 (≈740 nm), and near-infrared (≈840 nm)—are highly linearly correlated, leading to multicollinearity in the input feature space. This means that the information carried by different dimensions highly overlaps, causing a sharp increase in the variance of the coefficient estimates in traditional linear regression. The forest regression algorithm model breaks the multicollinearity at the feature sampling level by randomly selecting only 2–3 band subsets for splitting each tree, and then uses Bagging to aggregate them. This effectively suppresses variance expansion in the highly correlated four-dimensional subspace, maintaining model stability and generalization ability. The artificial neural network captures subtle curvature changes in the near-infrared (740 nm) region with nonlinear activation. Compared with other traditional or deep learning algorithms, it achieves the optimal balance between accuracy, interpretability, and implementation cost. Therefore, the forest regression algorithm model and the artificial neural network are trained, and a second preset model is determined by comparing the error magnitude.

[0059] The fourth step is to calculate the third training error of the second candidate forest regression algorithm model based on the second test subset.

[0060] Optionally, the spectral data of each training sample in the second test subset can be input into the second candidate forest regression algorithm model to obtain soybean nitrogen detection values, which can then be compared with the true nitrogen values ​​to obtain the third training error.

[0061] Fifth step: Calculate the fourth training error of the second candidate artificial neural network based on the second test subset.

[0062] Optionally, the spectral data of the second test subset can be input into the second candidate artificial neural network to obtain the soybean nitrogen detection value, which can then be compared with the true nitrogen value to obtain the fourth training error.

[0063] The sixth step is to compare the magnitudes of the third and fourth training errors, and determine the second candidate forest regression algorithm model and the model with the smaller training error among the second candidate artificial neural network models as the second preset model.

[0064] Optionally, the second candidate forest regression algorithm model and the second candidate artificial neural network model with smaller errors represent higher accuracy in detecting nitrogen and are selected as the second preset model.

[0065] Optionally, in the soybean nitrogen content detection method based on multispectral technology provided in this application embodiment, the third preset model is obtained through the following steps: The first step is to obtain the third training sample set, which includes multiple third training samples. Each third training sample includes spectral data and corresponding true nitrogen values ​​for four bands: green, red, red-edge 2, and near-infrared.

[0066] Optionally, some basic 4-channel sensors can acquire spectral data containing four bands, and the spectral data of each third training sample in the acquired third training sample set contains four bands. After the red edge 1 (705nm) and the blue region are missing from the spectral data, the peak of the first derivative of the nitrogen spectrum disappears, and the slope change degenerates from a "double-peaked S-shape" to a "weak single-shoulder S-shape". The algorithm needs to be able to capture the weak and possibly nonlinear curvature changes.

[0067] The second step is to divide the third training sample set into a third training subset and a third test subset.

[0068] Optionally, the third training sample set can be divided into a third training subset and a third test subset according to a preset ratio such as 8:2 or 7:3. The third training subset is used to train the third candidate model, and the third test subset is used to test the detection performance of the model trained by the third training subset.

[0069] The third step involves training the partial least squares regression model and the support vector regression model based on the third training subset to obtain candidate partial least squares regression models and candidate support vector regression models.

[0070] Optionally, spectral data containing four bands (excluding the blue region and red edge 1) reduces the input dimension to four, significantly compressing the available information and increasing inter-band collinearity while significantly weakening the nitrogen-sensitive slope. Partial Least Squares Regression (PLR) and Support Vector Regression (SVR) models are selected for training. PLAR projects the 4-dimensional X to ≤3 orthogonal latent variables, maximizing the covariance of X and Y, effectively suppressing VIF shocks and avoiding coefficient sign flipping. SVR implicitly maps the 4-dimensional input to a high-dimensional Hilbert space, approximating the weak curvature variation in the Green-Red-740-NIR region and compensating for information loss after the 705 nm gap. Therefore, PLAR and SVR models are trained, and a third preset model is determined by comparing the error magnitudes.

[0071] The fourth step is to calculate the fifth training error of the candidate partial least squares regression model based on the third test subset.

[0072] Optionally, the spectral data of the third test subset can be input into the candidate partial least squares regression model to obtain the soybean nitrogen detection value, which can then be compared with the true nitrogen value to obtain the fifth training error.

[0073] The fifth step is to calculate the sixth training error of the candidate support vector regression model based on the third test subset.

[0074] Optionally, the spectral data of the third test subset can be input into the candidate support vector regression model to obtain the soybean nitrogen detection value, which can then be compared with the true nitrogen value to obtain the sixth training error.

[0075] The sixth step is to compare the magnitudes of the fifth and sixth training errors and determine the model with the smaller training error among the candidate partial least squares regression model and the candidate support vector regression model as the third preset model.

[0076] Optionally, the candidate partial least squares regression model and the candidate support vector regression model with the smaller error represent higher accuracy in detecting nitrogen and are selected as the third preset model. Optionally, in the soybean nitrogen content detection method based on multispectral technology provided in this application embodiment, the initial model is adjusted according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain the target model, including: The first step is to calculate the offset of the center wavelength of each band in the spectral data relative to the standard center wavelength used when training the initial model.

[0077] Optionally, the center wavelength for the spectral data can be read from the header file or the laboratory calibration certificate. The standard center wavelength used when training the initial model can be obtained from the model header file. The offset refers to the absolute value of the difference between the center wavelength of each band in the spectral data and the standard center wavelength used when training the initial model.

[0078] The second step is to correct the regression coefficients of the initial model if the offset is less than the preset size, so as to obtain the target model.

[0079] Optionally, the preset size determines whether the initial model needs to be retrained. When the calculated offset is less than this preset size, the regression coefficients of the initial model can be corrected, meaning retraining is not required. The preset size can be determined based on nitrogen error tolerance. For example, 1 nm offset corresponds to 0.02% nitrogen error, and if the upper limit corresponding to a nitrogen error tolerance of ≤0.05% is approximately 2.5 nm, then the preset size can be 2.5 nm.

[0080] The third step is to obtain a new training sample set and retrain the initial model if the offset is not less than the preset size, and then obtain the target model.

[0081] Optionally, if the calculated offset is greater than or equal to this preset size, the training samples need to be re-determined, the initial model needs to be retrained, and the target model needs to be obtained.

[0082] Optionally, in the soybean nitrogen content detection method based on multispectral technology provided in this application embodiment, inputting spectral data into the target model to obtain soybean nitrogen content detection values ​​includes: The first step is to radiometrically calibrate the spectral data, converting it into reflectance.

[0083] Optionally, the raw spectral data is a dimensionless number output by the sensor, affected by gain, exposure, and solar elevation angle. Radiometric calibration converts the raw spectral data into physical radiance L (W·m⁻²·sr⁻¹). Then, atmospheric correction is applied to eliminate Rayleigh scattering, aerosol absorption, and water vapor absorption, yielding the surface reflectance ρ (0–1, dimensionless).

[0084] The second step is to calculate the vegetation index based on reflectance.

[0085] Optionally, vegetation indices refer to the amplification of vegetation biophysical signals and the suppression of soil / atmospheric background by using linear or nonlinear combinations of band reflectance. Vegetation indices can include NDVI, GNDVI, and NDRE, etc. The formula for calculating NDVI is: (NIR - Red) / (NIR + Red), the formula for calculating GNDVI is: (NIR - Green) / (NIR + Green), and the formula for calculating NDRE is: (NIR - RedEdge2) / (NIR + RedEdge2).

[0086] The third step involves inputting reflectance and vegetation index into the target model to obtain the soybean nitrogen content detection value.

[0087] Optionally, the reflectance calculated based on the original spectral data and the vegetation index calculated based on the reflectance are input into the target model, and the target model can output the soybean nitrogen content detection value.

[0088] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0089] Example 2 This application also provides a soybean nitrogen content detection device based on multispectral technology. It should be noted that this soybean nitrogen content detection device based on multispectral technology can be used to execute the soybean nitrogen content detection method based on multispectral technology provided in this application. The following describes the soybean nitrogen content detection device based on multispectral technology provided in this application.

[0090] According to an embodiment of this application, an apparatus for implementing the above-described method for detecting soybean nitrogen content based on multispectral technology is also provided, such as... Figure 3 As shown, the device includes: an acquisition unit 301, a selection unit 302, an adjustment unit 303, and an input unit 304.

[0091] Specifically, the acquisition unit 301 is used to acquire the spectral data of the soybean to be detected, wherein the spectral data includes the number of bands and the center wavelength of each band; Selection unit 302 is used to select an initial model from a preset model library based on the number of bands. The initial model is one of a first preset model, a second preset model, and a third preset model. The first preset model is a model trained based on a first training sample set, where each training sample in the first training sample set has 6 bands of spectral data. The second preset model is a model trained based on a second training sample set, where each training sample in the second training sample set has 5 bands of spectral data. The third preset model is a model trained based on a third training sample set, where each training sample in the third training sample set has 4 bands of spectral data. The adjustment unit 303 is used to adjust the initial model according to the center wavelength of each band and the standard center wavelength used when training the initial model, so as to obtain the target model. Input unit 304 is used to input spectral data into the target model to obtain the soybean nitrogen content detection value.

[0092] The soybean nitrogen content detection device based on multispectral technology provided in this application embodiment acquires spectral data of the soybean to be detected through an acquisition unit 301. The spectral data includes the number of bands and the center wavelength of each band. A selection unit 302 selects an initial model from a preset model library based on the number of bands. The initial model is one of a first preset model, a second preset model, and a third preset model. The first preset model is a model trained based on a first training sample set, where each training sample in the first training sample set has 6 spectral bands. The second preset model is a model trained based on a second training sample set, where each training sample in the second training sample set has 5 spectral bands. The third preset model is a model trained based on a third training sample set, where each training sample in the third training sample set has 4 spectral bands. An adjustment unit 303 adjusts the initial model according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain a target model. An input unit 304 inputs the spectral data into the target model to obtain the soybean nitrogen content detection value. This solves the technical problem of low detection accuracy of soybean nitrogen detection models based on spectral data and achieves the technical effect of improving the detection accuracy of nitrogen detection models based on spectral data.

[0093] Optionally, in the soybean nitrogen content detection device based on multispectral technology provided in this application embodiment, the first preset model in the selection unit 302 is obtained through the following steps: a first acquisition module, used to acquire a first training sample set, wherein the first training sample set includes multiple first training samples, each first training sample including spectral data of six bands: blue, green, red, red-edge 1, red-edge 2, and near-infrared, and the corresponding true nitrogen values; a first partitioning module, used to partition the first training sample set into a first training subset and a first test subset; a first training module, used to train the forest regression algorithm model and the artificial neural network based on the first training subset to obtain a first candidate forest regression algorithm model and a first candidate artificial neural network; a first calculation module, used to calculate the first training error of the first candidate forest regression algorithm model based on the first test subset; a second calculation module, used to calculate the second training error of the first candidate artificial neural network based on the first test subset; and a first determination module, used to compare the magnitudes of the first training error and the second training error, and determine the model with the smaller training error among the first candidate forest regression algorithm model and the first candidate artificial neural network as the first preset model.

[0094] Optionally, in the soybean nitrogen content detection device based on multispectral technology provided in this application embodiment, the second preset model in the selection unit 302 is obtained through the following steps: a second acquisition module, used to acquire a second training sample set, wherein the second training sample set includes multiple second training samples, each second training sample including spectral data of five bands: blue, green, red, red-edge 2, and near-infrared, and the corresponding true nitrogen values; a second partitioning module, used to partition the second training sample set into a second training subset and a second test subset; a second training module, used to train the forest regression algorithm model and the artificial neural network based on the second training subset to obtain a second candidate forest regression algorithm model and a second candidate artificial neural network; a third calculation module, used to calculate the third training error of the second candidate forest regression algorithm model based on the second test subset; a fourth calculation module, used to calculate the fourth training error of the second candidate artificial neural network based on the second test subset; and a second determination module, used to compare the magnitudes of the third training error and the fourth training error, and determine the model with the smaller training error among the second candidate forest regression algorithm model and the second candidate artificial neural network as the second preset model.

[0095] Optionally, in the soybean nitrogen content detection device based on multispectral technology provided in this application embodiment, the third preset model in the selection unit 302 is obtained through the following steps: a third acquisition module, used to acquire a third training sample set, wherein the third training sample set includes multiple third training samples, each third training sample including spectral data of four bands: green, red, red-edge 2, and near-infrared, and the corresponding true nitrogen values; a third partitioning module, used to divide the third training sample set into a third training subset and a third test subset; a third training module, used to train the partial least squares regression model and the support vector regression model based on the third training subset to obtain candidate partial least squares regression models and candidate support vector regression models; a fifth calculation module, used to calculate the fifth training error of the candidate partial least squares regression model based on the third test subset; a sixth calculation module, used to calculate the sixth training error of the candidate support vector regression model based on the third test subset; and a third determination module, used to compare the magnitudes of the fifth training error and the sixth training error, and determine the model with the smaller training error among the candidate partial least squares regression model and the candidate support vector regression model as the third preset model.

[0096] Optionally, in the soybean nitrogen content detection device based on multispectral technology provided in this application embodiment, the adjustment unit 303 includes: a seventh calculation module, used to calculate the offset of the center wavelength of each band in the spectral data relative to the standard center wavelength used when training the initial model; a correction module, used to correct the regression coefficients of the initial model if the offset is less than a preset size, to obtain the target model; and a fourth training module, used to obtain a new training sample set and retrain the initial model if the offset is not less than a preset size, to obtain the target model.

[0097] Optionally, in the soybean nitrogen content detection device based on multispectral technology provided in this application embodiment, the input unit 304 includes: a conversion module for radiometric calibration of spectral data and conversion of spectral data into reflectance; an eighth calculation module for calculating vegetation index based on reflectance; and an input module for inputting reflectance and vegetation index into the target model to obtain soybean nitrogen content detection value.

[0098] It should be noted that the acquisition unit 301, selection unit 302, adjustment unit 303, and input unit 304 mentioned above correspond to steps S201 to S204 in Embodiment 1. The four units and the corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above modules or units can be hardware or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above modules can also be part of the device and run in the computer terminal 10 provided in Embodiment 1.

[0099] Example 3 Embodiments of this application may provide a computer terminal, which may be any computer terminal device in a group of computer terminals. Optionally, in this embodiment, the aforementioned computer terminal may also be replaced with a mobile terminal or an electronic device, etc.

[0100] Optionally, in this embodiment, the computer terminal may be located in at least one of a plurality of network devices in a computer network.

[0101] In this embodiment, the aforementioned computer terminal can execute program code for the following steps in the soybean nitrogen content detection method based on multispectral technology: acquiring spectral data of the soybean to be detected, wherein the spectral data includes the number of bands and the center wavelength of each band; selecting an initial model from a preset model library according to the number of bands, wherein the initial model is one of a first preset model, a second preset model, and a third preset model, the first preset model being a model trained based on a first training sample set, wherein each training sample in the first training sample set has 6 spectral bands, the second preset model being a model trained based on a second training sample set, wherein each training sample in the second training sample set has 5 spectral bands, and the third preset model being a model trained based on a third training sample set, wherein each training sample in the third training sample set has 4 spectral bands; adjusting the initial model according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain a target model; and inputting the spectral data into the target model to obtain the soybean nitrogen content detection value.

[0102] Optionally, the aforementioned computer terminal can execute program code for the following steps in the soybean nitrogen content detection method based on multispectral technology: The first preset model is obtained through the following steps: acquiring a first training sample set, wherein the first training sample set includes multiple first training samples, each first training sample including spectral data and corresponding true nitrogen values ​​for six bands: blue, green, red, red-edge 1, red-edge 2, and near-infrared; dividing the first training sample set into a first training subset and a first test subset; training the forest regression algorithm model and the artificial neural network based on the first training subset to obtain a first candidate forest regression algorithm model and a first candidate artificial neural network; calculating the first training error of the first candidate forest regression algorithm model based on the first test subset; calculating the second training error of the first candidate artificial neural network based on the first test subset; comparing the magnitudes of the first training error and the second training error, and determining the model with the smaller training error among the first candidate forest regression algorithm model and the first candidate artificial neural network as the first preset model.

[0103] Optionally, the aforementioned computer terminal can execute the program code for the following steps in the soybean nitrogen content detection method based on multispectral technology: The second preset model is obtained through the following steps: acquiring a second training sample set, wherein the second training sample set includes multiple second training samples, each second training sample including spectral data and corresponding true nitrogen values ​​for five bands: blue, green, red, red-edge 2, and near-infrared; dividing the second training sample set into a second training subset and a second test subset; training the forest regression algorithm model and the artificial neural network based on the second training subset to obtain a second candidate forest regression algorithm model and a second candidate artificial neural network; calculating the third training error of the second candidate forest regression algorithm model based on the second test subset; calculating the fourth training error of the second candidate artificial neural network based on the second test subset; comparing the magnitudes of the third training error and the fourth training error, and determining the model with the smaller training error between the second candidate forest regression algorithm model and the second candidate artificial neural network as the second preset model.

[0104] Optionally, the aforementioned computer terminal can execute the program code for the following steps in the soybean nitrogen content detection method based on multispectral technology: The third preset model is obtained through the following steps: acquiring a third training sample set, wherein the third training sample set includes multiple third training samples, each of which includes spectral data and corresponding true nitrogen values ​​for four bands: green, red, red-edge 2, and near-infrared; dividing the third training sample set into a third training subset and a third test subset; training the partial least squares regression model and the support vector regression model based on the third training subset to obtain candidate partial least squares regression models and candidate support vector regression models; calculating the fifth training error of the candidate partial least squares regression model based on the third test subset; calculating the sixth training error of the candidate support vector regression model based on the third test subset; comparing the magnitudes of the fifth training error and the sixth training error, and determining the model with the smaller training error among the candidate partial least squares regression model and the candidate support vector regression model as the third preset model.

[0105] Optionally, the aforementioned computer terminal can execute program code for the following steps in the soybean nitrogen content detection method based on multispectral technology: adjusting the initial model according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain the target model includes: calculating the offset of the center wavelength of each band in the spectral data relative to the standard center wavelength used when training the initial model; if the offset is less than a preset size, then correcting the regression coefficients of the initial model to obtain the target model; if the offset is not less than a preset size, then obtaining a new training sample set, retraining the initial model, and obtaining the target model.

[0106] Optionally, the aforementioned computer terminal can execute program code for the following steps in the soybean nitrogen content detection method based on multispectral technology: inputting spectral data into the target model to obtain soybean nitrogen content detection values, including: radiometric calibration of the spectral data and conversion of the spectral data into reflectance; calculating the vegetation index based on the reflectance; and inputting the reflectance and vegetation index into the target model to obtain soybean nitrogen content detection values.

[0107] Optionally, Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application. Figure 4 As shown, the electronic device may include: one or more ( Figure 4 (Only one is shown) Processor 402, memory 404, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.

[0108] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the soybean nitrogen content detection method and device based on multispectral technology in this application embodiment. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby realizing the aforementioned soybean nitrogen content detection method based on multispectral technology. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0109] The processor can access the information and application programs stored in the memory via the transmission device to execute the steps described above in the soybean nitrogen content detection method based on multispectral technology.

[0110] This application provides a scheme for detecting soybean nitrogen content based on multispectral technology. The scheme involves acquiring spectral data of the soybean to be tested, including the number of bands and the center wavelength of each band. An initial model is selected from a preset model library based on the number of bands. The initial model is one of three preset models: a first preset model, a second preset model, and a third preset model. The first preset model is trained on a first training sample set, where each training sample has 6 spectral bands. The second preset model is trained on a second training sample set, where each training sample has 5 spectral bands. The third preset model is trained on a third training sample set, where each training sample has 4 spectral bands. The initial model is adjusted according to the center wavelength of each band and the standard center wavelength used in training the initial model to obtain a target model. The spectral data is then input into the target model to obtain the soybean nitrogen content detection value. This method solves the technical problem of low detection accuracy in soybean nitrogen detection models based on spectral data, thereby improving the accuracy of nitrogen detection models based on spectral data.

[0111] Those skilled in the art will understand that Figure 4 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones (such as tablets, PDAs, mobile internet devices (MIDs), PADs, and other terminal devices). Figure 4 This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 4 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 4 The different configurations shown.

[0112] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0113] Example 4 Embodiments of this application also provide a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the soybean nitrogen content detection method based on multispectral technology provided in Embodiment 1.

[0114] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.

[0115] Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: acquiring spectral data of the soybean to be tested, wherein the spectral data includes the number of bands and the center wavelength of each band; selecting an initial model from a preset model library according to the number of bands, wherein the initial model is one of a first preset model, a second preset model, and a third preset model, the first preset model being a model trained based on a first training sample set, wherein the number of bands in the spectral data of each training sample in the first training sample set is 6, the second preset model being a model trained based on a second training sample set, wherein the number of bands in the spectral data of each training sample in the second training sample set is 5, and the third preset model being a model trained based on a third training sample set, wherein the number of bands in the spectral data of each training sample in the third training sample set is 4; adjusting the initial model according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain a target model; inputting the spectral data into the target model to obtain the soybean nitrogen content detection value.

[0116] Optionally, the storage medium is also configured to store program code for performing the following steps: The first preset model is obtained through the following steps: acquiring a first training sample set, wherein the first training sample set includes multiple first training samples, each first training sample including spectral data and corresponding true nitrogen values ​​for six bands: blue, green, red, red-edge 1, red-edge 2, and near-infrared; dividing the first training sample set into a first training subset and a first test subset; training the forest regression algorithm model and the artificial neural network based on the first training subset to obtain a first candidate forest regression algorithm model and a first candidate artificial neural network; calculating the first training error of the first candidate forest regression algorithm model based on the first test subset; calculating the second training error of the first candidate artificial neural network based on the first test subset; comparing the magnitudes of the first training error and the second training error, and determining the model with the smaller training error among the first candidate forest regression algorithm model and the first candidate artificial neural network as the first preset model.

[0117] Optionally, the storage medium is also configured to store program code for performing the following steps: The second preset model is obtained through the following steps: acquiring a second training sample set, wherein the second training sample set includes multiple second training samples, each second training sample including spectral data and corresponding true nitrogen values ​​for five bands: blue, green, red, red-edge 2, and near-infrared; dividing the second training sample set into a second training subset and a second test subset; training the forest regression algorithm model and the artificial neural network based on the second training subset to obtain a second candidate forest regression algorithm model and a second candidate artificial neural network; calculating the third training error of the second candidate forest regression algorithm model based on the second test subset; calculating the fourth training error of the second candidate artificial neural network based on the second test subset; comparing the magnitudes of the third training error and the fourth training error, and determining the model with the smaller training error between the second candidate forest regression algorithm model and the second candidate artificial neural network as the second preset model.

[0118] Optionally, the storage medium is also configured to store program code for performing the following steps: The third preset model is obtained through the following steps: acquiring a third training sample set, wherein the third training sample set includes multiple third training samples, each of which includes spectral data and corresponding true nitrogen values ​​for four bands: green, red, red-edge 2, and near-infrared; dividing the third training sample set into a third training subset and a third test subset; training a partial least squares regression model and a support vector regression model based on the third training subset to obtain candidate partial least squares regression models and candidate support vector regression models; calculating the fifth training error of the candidate partial least squares regression model based on the third test subset; calculating the sixth training error of the candidate support vector regression model based on the third test subset; comparing the magnitudes of the fifth training error and the sixth training error, and determining the model with the smaller training error among the candidate partial least squares regression model and candidate support vector regression model as the third preset model.

[0119] Optionally, the storage medium is also configured to store program code for performing the following steps: adjusting the initial model according to the center wavelength of each band and the standard center wavelength used when training the initial model to obtain the target model includes: calculating the offset of the center wavelength of each band in the spectral data relative to the standard center wavelength used when training the initial model; if the offset is less than a preset size, correcting the regression coefficients of the initial model to obtain the target model; if the offset is not less than a preset size, obtaining a new training sample set, retraining the initial model, and obtaining the target model.

[0120] Optionally, the storage medium is also configured to store program code for performing the following steps: inputting spectral data into the target model to obtain soybean nitrogen content detection values, including: radiometrically calibrating the spectral data and converting the spectral data into reflectance; calculating the vegetation index based on the reflectance; and inputting the reflectance and vegetation index into the target model to obtain soybean nitrogen content detection values.

[0121] This application also provides a computer program product that, when executed on a data processing device, is suitable for performing the steps of a soybean nitrogen content detection method based on multispectral technology.

[0122] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0123] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0124] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of 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 coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of units or modules may be electrical or other forms.

[0125] 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.

[0126] 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.

[0127] If the integrated 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, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0128] The above are merely preferred embodiments of this application. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for detecting nitrogen content in soybeans based on multispectral technology, characterized in that, include: Acquire spectral data of the soybean to be tested, wherein the spectral data includes the number of bands and the center wavelength of each band; An initial model is selected from a preset model library based on the number of bands. The initial model is one of a first preset model, a second preset model, and a third preset model. The first preset model is a model trained on a first training sample set, where each training sample in the first training sample set contains 6 bands of spectral data. The second preset model is a model trained on a second training sample set, where each training sample in the second training sample set contains 5 bands of spectral data. The third preset model is a model trained on a third training sample set, where each training sample in the third training sample set contains 4 bands of spectral data. The initial model is adjusted based on the center wavelength of each band and the standard center wavelength used when training the initial model to obtain the target model; The spectral data is input into the target model to obtain the soybean nitrogen content detection value.

2. The method according to claim 1, characterized in that, The first preset model is obtained through the following steps: Obtain a first training sample set, wherein the first training sample set includes multiple first training samples, and each first training sample includes spectral data and corresponding true nitrogen values ​​for six bands: blue, green, red, red edge 1, red edge 2, and near-infrared. The first training sample set is divided into a first training subset and a first test subset; The forest regression algorithm model and the artificial neural network are trained based on the first training subset to obtain the first candidate forest regression algorithm model and the first candidate artificial neural network. Calculate the first training error of the first candidate forest regression algorithm model based on the first test subset; Calculate the second training error of the first candidate artificial neural network based on the first test subset; By comparing the magnitudes of the first training error and the second training error, the model with the smaller training error among the first candidate forest regression algorithm model and the first candidate artificial neural network is determined as the first preset model.

3. The method according to claim 1, characterized in that, The second preset model is obtained through the following steps: Obtain a second training sample set, wherein the second training sample set includes multiple second training samples, and each second training sample includes spectral data and corresponding true nitrogen values ​​for five bands: blue, green, red, red-edge 2, and near-infrared. The second training sample set is divided into a second training subset and a second test subset; The forest regression algorithm model and the artificial neural network are trained based on the second training subset to obtain the second candidate forest regression algorithm model and the second candidate artificial neural network. The third training error of the second candidate forest regression algorithm model is calculated based on the second test subset; The fourth training error of the second candidate artificial neural network is calculated based on the second test subset; By comparing the magnitudes of the third training error and the fourth training error, the model with the smaller training error among the second candidate forest regression algorithm model and the second candidate artificial neural network is determined as the second preset model.

4. The method according to claim 1, characterized in that, The third preset model is obtained through the following steps: Obtain a third training sample set, wherein the third training sample set includes multiple third training samples, and each third training sample includes spectral data and corresponding true nitrogen values ​​for four bands: green, red, red edge 2, and near-infrared. The third training sample set is divided into a third training subset and a third test subset; Based on the third training subset, the partial least squares regression model and the support vector regression model are trained to obtain candidate partial least squares regression models and candidate support vector regression models. The fifth training error of the candidate partial least squares regression model is calculated based on the third test subset; The sixth training error of the candidate support vector regression model is calculated based on the third test subset; By comparing the magnitudes of the fifth training error and the sixth training error, the model with the smaller training error among the candidate partial least squares regression model and the candidate support vector regression model is determined as the third preset model.

5. The method according to claim 1, characterized in that, The initial model is adjusted based on the center wavelength of each band and the standard center wavelength used when training the initial model to obtain the target model, which includes: Calculate the offset of the center wavelength of each band in the spectral data relative to the standard center wavelength used when training the initial model; If the offset is less than a preset size, the regression coefficients of the initial model are corrected to obtain the target model; If the offset is not less than a preset size, a new training sample set is obtained, the initial model is retrained, and the target model is obtained.

6. The method according to claim 1, characterized in that, Inputting the spectral data into the target model yields soybean nitrogen content detection values, including: The spectral data is radiometrically calibrated and converted into reflectance. The vegetation index is calculated based on the reflectance. The reflectance and vegetation index are input into the target model to obtain the soybean nitrogen content detection value.

7. A soybean nitrogen content detection device based on multispectral technology, characterized in that, include: An acquisition unit is used to acquire spectral data of the soybean to be tested, wherein the spectral data includes the number of bands and the center wavelength of each band; The selection unit is used to select an initial model from a preset model library according to the number of bands. The initial model is one of a first preset model, a second preset model, and a third preset model. The first preset model is a model trained based on a first training sample set, where each training sample in the first training sample set has 6 bands of spectral data. The second preset model is a model trained based on a second training sample set, where each training sample in the second training sample set has 5 bands of spectral data. The third preset model is a model trained based on a third training sample set, where each training sample in the third training sample set has 4 bands of spectral data. An adjustment unit is used to adjust the initial model according to the center wavelength of each band and the standard center wavelength used when training the initial model, so as to obtain the target model; The input unit is used to input the spectral data into the target model to obtain the soybean nitrogen content detection value.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program, wherein, when the executable program is executed, it controls the device on which the computer-readable storage medium is located to perform the soybean nitrogen content detection method based on multispectral technology as described in any one of claims 1 to 6.

9. An electronic device, characterized in that, include: Memory, which stores executable programs; A processor for running the program, wherein the program executes the soybean nitrogen content detection method based on multispectral technology according to any one of claims 1 to 6.

10. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the steps of the soybean nitrogen content detection method based on multispectral technology as described in any one of claims 1 to 6.