Hyperspectral water quality detection device and method

By designing a compact hyperspectral water quality detection device and combining convolutional neural networks and multi-head self-attention mechanisms, the problems of large size, high cost, and insufficient real-time performance of existing equipment have been solved, realizing rapid, multi-parameter water quality detection and prediction, which is suitable for portable and field applications.

CN121409871APending Publication Date: 2026-01-27GUILIN UNIV OF ELECTRONIC TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511975599.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-25
Publication Date
2026-01-27

AI Technical Summary

Technical Problem

Existing hyperspectral water quality detection equipment is bulky, costly, and lacks real-time performance, making it difficult to achieve rapid, multi-parameter water quality monitoring and prediction.

Method used

Design a compact hyperspectral water quality detection device, comprising a water tank, a transparent sample box, a hyperspectral camera, a full-spectrum light source, a driving module, and a processing module. Combine convolutional neural networks and multi-head self-attention mechanisms for spectral data processing to achieve rapid, real-time multi-parameter water quality detection.

Benefits of technology

It achieves high-precision water quality detection with small size, low cost, and fast response, supports multi-parameter parallel monitoring and prediction, and is suitable for portable and field applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121409871A_ABST
    Figure CN121409871A_ABST
Patent Text Reader

Abstract

The invention provides a hyperspectral water quality detection device and a hyperspectral water quality detection method, and aims to realize water quality detection with small volume, high detection speed, high real-time performance and high precision. The device comprises a water tank, a black sealing box embedded into a transparent sample box, a hyperspectral camera, a full-spectrum light source and a processing module. A water sample is irradiated by a light source through a transparent sample box, a hyperspectral camera collects spectral data of the water sample, an embedded processing module preprocesses the data, and feature extraction and multi-parameter prediction are performed by using a water quality analysis algorithm based on a one-dimensional convolutional neural network and a multi-head attention structure. By constructing a water quality spectrum database to train the model, real-time parallel analysis and accurate prediction of spectrum data in a specific area can be realized, and predicted water quality parameters include but are not limited to indexes such as COD, turbidity, total nitrogen, total phosphorus, ammonia nitrogen and chlorophyll. The device can realize high-precision and multi-parameter water quality real-time detection, and is small in size, fast in response and wide in application range.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of water quality testing technology, and relates to a hyperspectral water quality testing device and method, particularly to a device and operating method capable of acquiring water sample spectra in real time and performing multi-parameter analysis. Background Technology

[0002] With increasing environmental pollution and heightened awareness of water resource protection, the demand for water quality testing technologies is growing. Traditional water quality testing methods typically rely on chemical reagents and laboratory analysis. While these methods can provide relatively accurate results, they are complex, time-consuming, and costly, failing to meet the need for real-time water quality monitoring. Hyperspectral imaging technology, as a novel detection technology combining optics and image processing, is non-contact, non-destructive, rapid, and highly accurate. It can acquire full-spectral information of water samples, enabling multi-parameter detection and analysis of water quality.

[0003] However, most current hyperspectral water quality testing equipment is bulky, complex in structure, and expensive, limiting its widespread adoption in portable scenarios and field applications. Furthermore, existing equipment relies primarily on manual methods or complex algorithms for water quality parameter analysis, lacking real-time performance and failing to respond quickly to dynamic water quality changes. These issues have spurred the development of a small, low-cost, fast-detection hyperspectral water quality testing device with real-time performance and high accuracy, becoming a key direction for solving water quality testing challenges. Current technologies lack efficient real-time analysis methods for water quality analysis, making it difficult to rapidly monitor dynamic water quality changes across multiple parameters. Therefore, a method is needed that is not only compact and optically stable but also enables a complete water quality testing workflow. Summary of the Invention

[0004] This invention discloses a hyperspectral water quality detection device and method, which can achieve rapid, real-time and high-precision detection of water quality parameters with small size and compact structure, and supports parallel monitoring and prediction of multiple parameters of water bodies.

[0005] This invention provides a hyperspectral water quality detection device, comprising a water tank, a transparent sample box, a hyperspectral camera, a full-spectrum light source, a drive module, and a processing module. The water tank is made of black opaque material and has a sealed structure, with a small hole on its front wall for the hyperspectral camera to capture images. The transparent sample box is fitted tightly against the inner side of the front wall of the water tank to hold the water sample. The hyperspectral camera is fixedly installed outside the water tank and captures hyperspectral images of the water sample horizontally through the small hole. A full-spectrum light source is installed on the outer side of the rear wall of the transparent sample box to provide stable illumination of the water sample covering the hyperspectral band. The drive module provides stable power to the full-spectrum light source. The processing module is electrically connected to the hyperspectral camera and is used to receive spectral data, perform spectral preprocessing, and output water quality parameter prediction results based on a trained water quality analysis model.

[0006] This invention provides a hyperspectral water quality detection method, comprising the following steps:

[0007] The water sample was subjected to full-spectrum irradiation and multiple consecutive hyperspectral images were acquired as it flowed through a transparent sample container.

[0008] The acquired spectral image data is preprocessed to obtain stable spectral data;

[0009] The spectral data is input into a water quality analysis model, and a convolutional network is used to extract features from the spectral data to obtain the spectral features of local bands.

[0010] The features output by the convolutional network are processed through a multi-head self-attention mechanism to model the correlation between features in different bands;

[0011] It outputs the water quality parameters or concentration changes of the water body to be tested, thus realizing water quality detection.

[0012] The spectral acquisition is achieved by placing a full-spectrum light source on the back side of the transparent sample box, allowing the light to pass sequentially through the rear wall of the sample box, the sample liquid, and the front wall before entering the hyperspectral camera to obtain a hyperspectral image containing water information.

[0013] The spectral preprocessing reduces noise and eliminates ambient light and system background interference by averaging and background subtraction of multiple consecutive hyperspectral images.

[0014] The convolutional network extracts local spectral features of adjacent bands by performing multi-layer convolution operations on the input one-dimensional spectral curve, thereby enhancing the ability to represent changes in spectral details.

[0015] The multi-head self-attention network models the global correlation between features in different spectral bands by performing multi-head self-attention calculations on the features output by the convolutional network, thereby improving the comprehensive analysis capability of complex spectral patterns.

[0016] The hyperspectral water quality detection device and method provided by this invention achieve optical isolation through a sealed water tank, acquire full-band spectral information through a hyperspectral camera, and combine a complete spectral acquisition, preprocessing and multi-parameter prediction process to achieve high-precision, multi-parameter real-time water quality detection. It has the advantages of small size, low cost, fast response, multiple detection indicators and wide applicability. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. The present invention can be further understood in conjunction with the content of the accompanying drawings. The components shown in the drawings are not necessarily drawn to scale, but the focus is on illustrating the principles of the embodiments.

[0018] Figure 1 This is a schematic diagram of a hyperspectral water quality detection device provided in one embodiment of the present invention.

[0019] Figure 2 This is a schematic diagram of a hyperspectral water quality detection method provided in one embodiment of the present invention.

[0020] Figure 3 This is a diagram of a multi-head self-attention network structure provided in one embodiment of the present invention. Detailed Implementation

[0021] The following describes in detail specific embodiments of the hyperspectral water quality detection device and method of the present invention. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.

[0022] Please see Figure 1 , Figure 2 and Figure 3 This invention provides a water quality detection method based on continuous hyperspectral images, comprising the following steps:

[0023] Please see Figure 1The attached diagram shows a schematic diagram of a hyperspectral water quality detection device. The device includes a sealed water tank 1, a hyperspectral camera 2 fixedly mounted in front of the water tank, a transparent sample box 3 embedded in the sealed water tank 1, a full-spectrum light source 4 fixed to the outer side of the rear wall of the transparent sample box 3, and a drive module 5 located on the top of the water tank. The water tank 1 has an inlet 6 and an outlet 7 for the inflow and outflow of water samples. The top and sides of the water tank are black to reduce external light interference. A small hole 8 is opened in the center of the front wall of the water tank for aligning the hyperspectral camera 2 with the front wall of the transparent sample box 3 to acquire spectral images of the water sample. The light source is a full-spectrum light source covering the wavelength range of the hyperspectral camera, fixedly mounted on the outer side of the rear wall of the transparent sample box 3, horizontally illuminating the rear wall of the transparent sample box so that the light passes through the sample liquid and enters the hyperspectral camera. The drive module 5 provides stable power support to the light source 4 to ensure its efficient operation. The hyperspectral camera 2 is connected to the processing module via a USB interface. Combined with neural network analysis data, it can process hyperspectral images in real time and predict multiple water quality parameters of water samples (including but not limited to: COD, TOC, BOD, turbidity, TDS, copper, nickel, chromium, iron, total nitrogen TN, total phosphorus TP, ammonia nitrogen, and chlorophyll). The attached drawings clearly show the layout and functional coordination of the components in the device, further clarifying the technical solution and implementation of the present invention.

[0024] Please see Figure 2 This invention provides a hyperspectral water quality detection method, comprising the following steps:

[0025] S100, Water Sample Preparation.

[0026] Specifically, the water to be tested is injected through the inlet of the water tank, flows through the transparent sample container area, and is discharged from the outlet. The water tank is designed as a sealed structure, with black material used on the sides and top to reduce external light interference and improve the accuracy of spectral acquisition.

[0027] S101, Light source driver.

[0028] Specifically, the full-spectrum light source is fixed to the outer side of the rear wall of the transparent sample box, covering the wavelength range of the hyperspectral camera and forming a stable transmitted light field; the drive module is installed on the top of the water tank to provide continuous and stable power to the light source, ensuring the continuous and stable operation of the light source.

[0029] S102, taken with a hyperspectral camera.

[0030] Specifically, the hyperspectral camera is fixedly installed in front of the water tank and takes horizontal pictures through a small hole in the front wall of the water tank. It is closely aligned with the front wall of the transparent sample box and covers the effective area of ​​the water sample inside the transparent sample box to obtain spectral image data of the water sample.

[0031] S103, Data Acquisition and Preprocessing.

[0032] Specifically, the hyperspectral camera connected via USB transmits the acquired spectral data to the processing module. The processing module performs preprocessing operations on the spectral sequence, including averaging multiple consecutive frames and background subtraction. This process can be represented as follows:

[0033]

[0034] Among them, S t (λ) represents the spectral data acquired in the t-th frame, S bg (λ) represents the background spectrum, and N represents the number of frames involved in the averaging.

[0035] Based on this, the spectral data is normalized to suppress dimensional differences across different bands. The normalization expression is as follows:

[0036]

[0037] in, and These represent the mean and standard deviation of the spectral sequence, respectively.

[0038] The spectral sequence after the above preprocessing is used as input data for the neural network model to achieve stable representation of spectral information and provide a reliable basis for subsequent feature extraction and prediction of water quality parameters.

[0039] S104, Model Analysis and Processing.

[0040] Specifically, the preprocessed spectral sequence is input into a trained water quality analysis model, which employs a network architecture combining a convolutional neural network (CNN) and a multi-head attention structure. The CNN module extracts local features from the spectral sequence, capturing changes in correlation between bands. Subsequently, the high-dimensional features extracted by the CNN are input into the multi-head attention module, which consists of n parallel attention heads. Each head independently learns the sensitive features of a water quality parameter and outputs the corresponding prediction results. This enables parallel prediction of multiple parameters, including COD, TOC, BOD, turbidity, TDS, copper, nickel, chromium, iron, total nitrogen (TN), total phosphorus (TP), ammonia nitrogen, and chlorophyll, thereby improving prediction accuracy and real-time performance.

[0041] S105, Output the results.

[0042] Specifically, the processing module uses a highly efficient neural network algorithm to intelligently analyze the collected spectral data and generate water quality parameter prediction results. Real-time analysis results are presented via a host computer or display device for monitoring water quality or providing control references.

[0043] The model analysis and processing, the network structure is as follows: Figure 3 As shown. The preprocessed hyperspectral spectral sequence The data is input into a water quality analysis model, and firstly, a convolutional neural network (CNN) is used to perform multi-layer convolution operations on the spectral data. The k-th layer convolutional feature can be represented as:

[0044]

[0045] in, These are the input features for the previous layer. and These are the weights and bias parameters of the k-th convolutional kernel, respectively. It is a non-linear activation function that extracts local spectral features at different scales through multi-layer convolution.

[0046] Subsequently, the features output by the convolutional network are mapped to a unified vector sequence F and input into the multi-head attention module. For the h-th attention head, the attention calculation process is as follows:

[0047]

[0048]

[0049] in, , respectively, are mapping matrices for queries, keys, and values, where d is the feature dimension.

[0050] Each attention head is independent of the others; attention features are not concatenated or shared. The output of each attention head is independent. The predicted values ​​of the target water quality parameters are obtained through the corresponding regression mapping function:

[0051]

[0052] This enables parallel prediction of n water quality indicators, avoids characteristic interference between different parameters, and improves prediction accuracy and stability.

[0053] Finally, experimental verification, as the final stage of the process of one embodiment of the present invention, verifies the feasibility and effectiveness of the method proposed in the present invention through actual experiments.

[0054] In the experimental verification phase, this invention selected several existing water quality detection and spectral analysis methods as comparative methods, and conducted quantitative and qualitative experiments respectively. In the quantitative experiment, the prediction performance of different methods for water quality parameters was compared. The evaluation indicators included root mean square error (RMSE) and coefficient of determination R², where a smaller error value and R² closer to 1 indicate higher prediction accuracy. The experimental results are shown in the table below. The method of this invention outperforms the comparative methods in the prediction accuracy indicators of each water quality parameter, demonstrating higher prediction accuracy and stability.

[0055]

[0056] The above-disclosed embodiments are merely preferred embodiments of the hyperspectral water quality detection device and method of the present invention, used to illustrate the technical solution of the present invention, and not to limit it. Those skilled in the art can make various equivalent substitutions or improvements to the device structure, spectral acquisition method, data processing flow, and network structure and parameter settings of the water quality analysis model according to actual application needs without departing from the technical concept of the present invention; all equivalent changes or modifications made in accordance with the claims of the present invention should be covered within the protection scope of the present invention.

Claims

1. A hyperspectral water quality detection device, applied to multi-parameter water quality analysis, characterized in that: A water tank, which is a cubic or near-cubic structure, has holes on its front wall for mounting a hyperspectral camera. The water tank is made of opaque material to form a closed optical isolation space. A transparent sample box is installed close to the inside of the front wall of the water tank, with its inlet and outlet holes facing the water tank's inlet and outlet. A hyperspectral camera, installed outside the water tank, images the water inside the transparent sample box through the holes; A full-spectrum light source is located on the outer side of the rear wall of the transparent sample box to irradiate the water sample. The drive module, located outside the water tank, is used to power the full-spectrum light source; The processing module communicates with the hyperspectral camera to analyze the acquired hyperspectral data and output water quality parameters.

2. The hyperspectral water quality detection device as described in claim 1, wherein the full-spectrum light source is characterized in that, It is positioned on the side of the transparent sample box facing away from the hyperspectral camera, so that light passes sequentially through the back wall of the transparent sample box, the sample liquid, and the front wall before entering the hyperspectral camera.

3. A water quality detection method based on hyperspectral imaging, characterized in that, Includes the following steps: (1) Water sample introduction: The water to be tested is introduced through the water tank inlet and flows through the transparent sample box area for hyperspectral acquisition. (2) Illumination by light source: The driving module powers the full-spectrum lamp source, which then illuminates the rear wall of the transparent sample box horizontally, forming a stable transmitted light field. (3) Hyperspectral image acquisition: The hyperspectral camera acquires hyperspectral images of the water inside the transparent sample box through holes in the front wall of the water tank and transmits them to the processing module. (4) Spectral preprocessing: The acquired hyperspectral data were subjected to light source correction, background subtraction, noise suppression, and ROI spectral extraction to obtain a standardized one-dimensional spectral sequence. (5) Feature extraction and parameter prediction: The preprocessed spectral data is input into a convolutional neural network and a multi-head self-attention combined structure for feature analysis. The convolutional network is used to extract multi-scale local spectral features, and a query matrix Q, a key matrix K, and a value matrix V are constructed in the multi-head self-attention structure to capture the sensitive band features of different water quality parameters. Each attention head outputs a feature representation for predicting different water quality parameters, enabling parallel modeling and prediction of multiple water quality indicators.

4. The water quality detection method as described in claim 3, wherein the spectral preprocessing is characterized in that, This includes averaging multiple consecutive frames of spectral images to improve the signal-to-noise ratio, and performing background subtraction processing on the averaged spectral data to reduce the impact of ambient light and system background on the detection results.

5. The water quality detection method as described in claim 3, wherein the feature extraction is characterized in that, Convolutional neural networks consist of at least three one-dimensional convolutional layers for extracting local spectral variation patterns.

6. The water quality detection method as described in claim 3, wherein the multi-head self-attention system is characterized in that, n attention heads are used to predict n parameters, including turbidity, chemical oxygen demand (COD), total organic carbon (TOC), ammonia nitrogen, and heavy metal ions.