# The Monitoring and Early Warning System of Water Biological Environment Based on Machine Vision

Authors: Lihong Zhou
Journal: Mathematical Problems in Engineering
 (2022)

---

## Abstract

Water contaminated by microorganisms can lead to the outbreak and prevalence of various diseases, which seriously threaten the health of people. In the monitoring of the water biological environment, the traditional methods have low detection sensitivity and low efficiency, so it is urgent to design a water biological monitoring system with low cost and high monitoring efficiency. Machine vision has the advantages of fast speed, appropriate precision, and strong anti-interference ability, which has been greatly developed in recent years. In this paper, the monitoring and early warning system of the water biological environment is built, in which the SVM algorithm is applied to image processing and feature extraction, and each module of the system is designed. Finally, the computational complexity of the system algorithm and the detection accuracy of the system are tested, and the results show that the system has the advantages of low cost, low computational complexity, and high monitoring efficiency, which can provide a reference for water resources protection.


---

## Body

## 1. Introduction

Water is not only an important material for human survival but also a valuable natural resource. The per capita water resources occupancy rate of our country is only a quarter of the average level, and the water resources present the characteristics of more south and less north in space, which seriously restrict the development of the economy [1, 2]. There are mainly four categories of microorganisms in water, namely, bacteria, viruses, algae, and parasites, and studies have shown that 35% of intestinal diseases are caused by water pollution. The actual risk of microorganisms is much higher than that of toxic and harmful substances, and the microbial pollution of water sources can lead to the outbreak and prevalence of various diseases, which seriously threatens the health of people [3, 4]. The traditional molecular biology techniques include immunology and probe hybridization, whose detection sensitivity is very poor, and the conventional method can only detect one microorganism at a time. In recent years, more and more attention has been paid to the monitoring of water biological environment, but there is still a big gap compared with the level of developed countries. Therefore, it is of great significance to design a water biological monitoring system with low cost, high monitoring efficiency, and wide application for water resources protection.Domestic and foreign scholars have carried out a series of research on the monitoring of water biological environment. Combining multi-wavelength ultraviolet absorption spectrometry with PLS, an algorithm for predicting COD value in water samples was proposed in reference [5], in which the influence of turbidity on the absorbance is considered and the linear equation is used to compensate the influence of turbidity. The COD of wastewater was detected in the reference, and the calibration model was established to predict the COD value [6]. The COD model was proposed in the reference, which greatly improved the detection accuracy of sewage [7]. By using the multiple scattering correction methods, the influence of turbidity on water quality detection was eliminated in the reference, which not only improved the signal-to-noise ratio of water quality detection by spectroscopy but also provided a new way for the establishment of water quality detection and analysis model [8]. In summary, more and more attention has been paid to the monitoring of the water biological environment, and more research results have been achieved. However, the degree of automation of water biological monitoring is not high enough, so it is urgent to find a water biological monitoring method with a high degree of automation and high monitoring efficiency, which is of great significance to the protection of water resources. The machine vision system has the advantages of noncontact, fast speed, appropriate accuracy, and strong anti-interference ability; it is a new attempt to introduce machine vision into water biological environment monitoring and early warning.Firstly, the requirements and basic principles of a water biological monitoring system are analyzed in this paper, and the overall design of a water biological monitoring system is carried out. Then, the monitoring and early warning system of the water biological environment is designed, in which the SVM algorithm is used in image processing and feature extraction, and the function of the system is realized from the three aspects. Finally, the computational complexity of the system algorithm and the detection accuracy of the system are tested.


## 2. Overall Design of Water Biological Environment Monitoring System

### 2.1. Demand Analysis

In order to ensure the scientific and stability of the system, it is necessary to design a water biological environment monitoring system that meets the management requirements. In the design of the system, the requirements of the system should be analyzed firstly, a complete system should have six requirements that are stability, real-time, accuracy, wide applicability, scalability, and energy saving [9], as shown in Figure 1.Figure 1
System requirement analysis.Firstly, the system should have the characteristics of stability. The water monitoring system is generally deployed in the harsh environment in the wild, if the user has abnormal phenomena such as information miscommunication and node failure in the use process, the user experience will be greatly reduced. In the design of the system, the environments that may be encountered should be fully considered, and the system design should be carried out in strict accordance with industrial standards. The system should have the characteristics of real-time; the sensors should be able to collect water data in time according to the set cycle, and then the collected data is uploaded to the monitoring center through the network. At the same time, when the monitoring center sends control commands to the monitoring system, the monitoring system needs to respond immediately. Accuracy is crucial for a water quality monitoring system, which is the basis for all data analysis. In the design of the system, not only the accuracy of the sensor itself but also the accuracy of the analog-to-digital conversion should be considered [10].At the same time, the system should have wide applicability, and the water quality monitoring system should have the ability to replace sensors easily so that the system can meet the needs of different users. The system should have scalability, it is necessary to upgrade and adjust the hardware and software of the water quality monitoring system with the continuous improvement of monitoring requirements. In order to avoid frequent replacement of system hardware, it is required to consider the amount of the system while considering the system cost, so as to add new functions and applications in the future. In some inconvenient wiring areas, wireless data transmission and battery power supply are needed, so the energy saving of the system should be considered. In order to prolong the lifetime of monitoring nodes, it is necessary to consider the power consumption of monitoring nodes in the design process.


### 2.2. Basic Principles

The main work of a water biological environment monitoring system based on machine vision is to establish an intelligent environment monitoring system, which mainly uses computer vision and image processing technology. Without human intervention, the monitoring of the water biological environment can be realized by analyzing the video captured by the camera [11]. The control system needs to meet five requirements, which are multiparameter monitoring, automatic acquisition, data transmission, storage display, and alarm prompt, as shown in Figure 2.Figure 2
Basic principles.In order to reduce the system cost, each monitoring node needs to carry multiple types of sensors, so the monitoring node should have the ability to simultaneously process multiple signals. In the system, the sensor can automatically collect water parameters according to the system settings, the monitoring node is responsible for converting the collected multi-channel analog electrical signals into digital electrical signals, which are then stored in the data register. Each monitoring node needs to send the data stored in the register to the monitoring gateway for summary, then the collected data are finally uniformly sent to the monitoring center, and the touch screen and monitoring center on the monitoring gateway can visually display the data. When the monitoring data are not within the range set by the system, the monitoring center will issue the corresponding alarm information, prompting users to make processing.


### 2.3. Overall Design

The water biological environment monitoring system is an intelligent environment monitoring system, in which the monitoring of the water biological environment can be realized through the analysis of the video [12]. The system is mainly composed of six parts, which include a CCD image sensor, a computer equipped with an image acquisition card, a video server, a data server, special image processing software, and environment evaluation software, as shown in Figure 3.Figure 3
System components.The system comprehensively monitors multiple water sources through multiple cameras; the video image saved to the video server is transmitted to the client in real time. The data server is an important part of image processing, which undertakes the core functions of digital image processing, image recognition, alarm processing, and database service of all video channels [13], and the main process is shown in Figure 4.Figure 4
Main flow of the system.Firstly, the monitoring points need to be arranged in each water source, and the video code is transmitted to the video server through the optical fiber, which is obtained from the CCD camera. Then, the video signal digitized by the video server is compressed into digital images and the video signal code is saved to the video server. The server decodes multiple streams, and the results and abnormal images are saved to the database server, which is provided to the client at the same time. The obtained data that can be used for various statistics or report management is displayed on the client, so the remote computer terminal can issue control commands, timing commands, or alarm commands.


## 2.1. Demand Analysis

In order to ensure the scientific and stability of the system, it is necessary to design a water biological environment monitoring system that meets the management requirements. In the design of the system, the requirements of the system should be analyzed firstly, a complete system should have six requirements that are stability, real-time, accuracy, wide applicability, scalability, and energy saving [9], as shown in Figure 1.Figure 1
System requirement analysis.Firstly, the system should have the characteristics of stability. The water monitoring system is generally deployed in the harsh environment in the wild, if the user has abnormal phenomena such as information miscommunication and node failure in the use process, the user experience will be greatly reduced. In the design of the system, the environments that may be encountered should be fully considered, and the system design should be carried out in strict accordance with industrial standards. The system should have the characteristics of real-time; the sensors should be able to collect water data in time according to the set cycle, and then the collected data is uploaded to the monitoring center through the network. At the same time, when the monitoring center sends control commands to the monitoring system, the monitoring system needs to respond immediately. Accuracy is crucial for a water quality monitoring system, which is the basis for all data analysis. In the design of the system, not only the accuracy of the sensor itself but also the accuracy of the analog-to-digital conversion should be considered [10].At the same time, the system should have wide applicability, and the water quality monitoring system should have the ability to replace sensors easily so that the system can meet the needs of different users. The system should have scalability, it is necessary to upgrade and adjust the hardware and software of the water quality monitoring system with the continuous improvement of monitoring requirements. In order to avoid frequent replacement of system hardware, it is required to consider the amount of the system while considering the system cost, so as to add new functions and applications in the future. In some inconvenient wiring areas, wireless data transmission and battery power supply are needed, so the energy saving of the system should be considered. In order to prolong the lifetime of monitoring nodes, it is necessary to consider the power consumption of monitoring nodes in the design process.


## 2.2. Basic Principles

The main work of a water biological environment monitoring system based on machine vision is to establish an intelligent environment monitoring system, which mainly uses computer vision and image processing technology. Without human intervention, the monitoring of the water biological environment can be realized by analyzing the video captured by the camera [11]. The control system needs to meet five requirements, which are multiparameter monitoring, automatic acquisition, data transmission, storage display, and alarm prompt, as shown in Figure 2.Figure 2
Basic principles.In order to reduce the system cost, each monitoring node needs to carry multiple types of sensors, so the monitoring node should have the ability to simultaneously process multiple signals. In the system, the sensor can automatically collect water parameters according to the system settings, the monitoring node is responsible for converting the collected multi-channel analog electrical signals into digital electrical signals, which are then stored in the data register. Each monitoring node needs to send the data stored in the register to the monitoring gateway for summary, then the collected data are finally uniformly sent to the monitoring center, and the touch screen and monitoring center on the monitoring gateway can visually display the data. When the monitoring data are not within the range set by the system, the monitoring center will issue the corresponding alarm information, prompting users to make processing.


## 2.3. Overall Design

The water biological environment monitoring system is an intelligent environment monitoring system, in which the monitoring of the water biological environment can be realized through the analysis of the video [12]. The system is mainly composed of six parts, which include a CCD image sensor, a computer equipped with an image acquisition card, a video server, a data server, special image processing software, and environment evaluation software, as shown in Figure 3.Figure 3
System components.The system comprehensively monitors multiple water sources through multiple cameras; the video image saved to the video server is transmitted to the client in real time. The data server is an important part of image processing, which undertakes the core functions of digital image processing, image recognition, alarm processing, and database service of all video channels [13], and the main process is shown in Figure 4.Figure 4
Main flow of the system.Firstly, the monitoring points need to be arranged in each water source, and the video code is transmitted to the video server through the optical fiber, which is obtained from the CCD camera. Then, the video signal digitized by the video server is compressed into digital images and the video signal code is saved to the video server. The server decodes multiple streams, and the results and abnormal images are saved to the database server, which is provided to the client at the same time. The obtained data that can be used for various statistics or report management is displayed on the client, so the remote computer terminal can issue control commands, timing commands, or alarm commands.


## 3. Design of Water Biological Environment Monitoring System

### 3.1. Algorithm of Water Biological Environment Monitoring

The SVM is a learning algorithm developed based on statistical theory, which has been widely used in text classification, image classification, and bioinformatics. The basic image classification and recognition system are mainly composed of three parts, one is image information collection, one is processing, and the other is feature extraction and classification. The SVM is established based on the VC dimension theory and structural risk minimization principle, the best compromise between the complexity of the model and the learning ability is sought to obtain the best generalization ability according to the limited sample information. VC dimension reflects the learning ability of the function set, which is an important indicator of the learning performance of the function set; the larger the VC dimension is, the more complex the learning machine is. The SVM learning algorithm is applied to image processing and feature extraction, which can realize the monitoring of the water biological environment.The concept of generalization error bound is introduced into statistical learning, in which the real risk should be composed of two parts, one is an empirical risk that represents the error of the classifier, and the other is a confidence risk that represents the credibility of the classification results of the classifier. The calculation method is shown in teh following formula:(1)Rw≤Rcmpw+ϕn/h,where Rw represents the real risk, Rcmpw represents the empirical risk, and ϕn/h represents the confidence risk.The linear indivisibility of sample data is realized mainly through two aspects, one is the relaxation variable, and the other is the kernel function technology. A threshold is added to the classification function, and the category attribution of the sample can be determined by comparing the value of the classification function with the threshold. The linear function is shown in Formula (2); if the threshold is 0, the category of the sample can be determined according to Formula (3).(2)gx≤wx+b.(3)fx=sgngx,where x represents the sample vector. The above linear function is not only limited to two-dimensional space but also applicable in n-dimensional space, and w will be the n-dimensional vector in the corresponding formula.When classifying an image, the training sample required by the computer consists of a feature vector of the image and an identifier representing the class of the sample, as shown in Formula (4). According to the above representation, the interval from a sample point to a hyperplane is defined as the interval of a function, as shown in Formula (5).(4)Di=xi,yi,(5)δi=yiwxi+b,where xi represents the image feature vector with high dimension, yi represents the classification identifier, and δi represents the interval of the function, which is always greater than 0.The distance from vectorxi to hyperplane can be obtained by normalizing w and b, as shown in the following formula:(6)δi=1wgxi,where xi represents the vector in the n-dimensional space and δi represents the distance from the vector xi to the hyperplane, which measures the Euclidean distance from the sample point to the classification function in the input space.The maximum misclassification number of training set S based on the classification surface is shown in the following formula:(7)G=2Rδ2,where G represents the maximum number of misclassifications, R represents the maximum length of the sample vector, and δ represents the interval between the training set and the classification hyperplane.A geometric interval is used to measure the pros and cons of the classification model, the greater the geometric interval, the smaller the misclassification number. The goal of classifier training is to maximize the geometric interval, and the relationship between geometric interval and function interval is shown in the following formula:(8)δf=wδg,where δf represents the function interval, δf represents the geometric interval. When the fixed-function interval is 1, the maximization of the geometric interval is equivalent to finding the minimum w.Then, the weight coefficient vector of the optimal classification surface can be obtained, and the final expression of SVM is shown in the following formula:(9)fx=sgnw⋅x+b,where d represents the number of support vectors and b represents the classification threshold, which can be obtained by constraint conditions.In this paper, different algorithms are used to compare the effects of different processing modules, and the SVP algorithm is selected for feature extraction of raw water images finally. The classifier is used to monitor the biological environment of the water body, and the overall algorithm framework of the system is shown in Figure5.Figure 5
Algorithm framework of the system.


### 3.2. System Realization

#### 3.2.1. System Bottom Hardware Configuration

According to the design requirements of the water quality monitoring system, the communication between the monitoring gateway and the monitoring node, and the communication between the monitoring gateway and the HMI interface are realized by a serial port in this paper. In addition, the FreeRTOS system and LwIP system are used in the system, so they also need to be set up.The ethernet transmission supports two modes, one is MII mode and the other is RMII mode. The MII mode contains a management interface and a data interface, which includes two independent channels for sending and receiving data. The management interface includes a clock signal interface and a data signal interface, and the upper layer can monitor and manage PHY through the management interface. In this article, the MII mode is selected for data transmission finally.Due to the complex function of the FreeRTOS system is not applied, so the default settings of the software are used to meet the requirements. When the LwIP is configured, routers are not used to assign IP addresses in this paper, so the DHCP functionality in LwIP is not required. The Debug function in LwIP is opened to facilitate debugging problems in system design.After all the peripheral configuration is completed, the project file can be generated. Then, it is necessary to conduct a simple test on the open serial port and Ethernet, so as to see whether the peripherals can work properly, which can avoid the waste of a lot of debugging time due to the underlying error. Finally, the task function is written based on the generated project file, which can realize the corresponding function.


#### 3.2.2. Data Acquisition Program Design

In this paper, the communication between the monitoring gateway and the node is completed through the serial port, the monitoring gateway sends commands to each monitoring node, and the data are saved in the register for later data upload after the data stored on each monitoring node are read. After the data is received, it is necessary to detect whether the configuration information on the monitoring node is changed, and if it is changed, the configuration information should be sent to the monitoring node. In order to prevent the data loss caused by the power outage of the system, the data power outage protection function is added in this paper. When the data acquisition is completed, the system can determine whether the power outage protection is needed.In the data acquisition program, the serial port interrupts service function is the core part, and the system should have a certain fault tolerance ability for the data with a large receiving interval in the serial interrupt service function, which can avoid data errors caused by the large interval. After receiving the data, the system needs to open the interrupt receiving of the serial port again, otherwise, the system cannot receive the data normally.


#### 3.2.3. Data Upload Program Design

The data upload system used in this paper supports two ways, one is Ethernet and the other is GPRS. The purpose of the data acquisition program is to upload the data received by the data acquisition program to the monitoring center so that users can view and save the data. When using GPRS to upload data, DTU wireless transmission is used to transmit data.It should be noted that the data stored in Modbus adopts a small-end mode, the high bytes of data are stored in the high address of memory, and the low bytes are stored in the low address of memory. The data sent through Ethernet are in the large-end mode, and the way of storing data in large-end mode and small-end mode is the opposite. When parsing the data sent by the monitoring center, it is necessary to transform the data size first. After the data from the monitoring center are parsed, the data need to be written to the monitoring node by using the function code, and the configuration information of the node needs to be changed.


## 3.1. Algorithm of Water Biological Environment Monitoring

The SVM is a learning algorithm developed based on statistical theory, which has been widely used in text classification, image classification, and bioinformatics. The basic image classification and recognition system are mainly composed of three parts, one is image information collection, one is processing, and the other is feature extraction and classification. The SVM is established based on the VC dimension theory and structural risk minimization principle, the best compromise between the complexity of the model and the learning ability is sought to obtain the best generalization ability according to the limited sample information. VC dimension reflects the learning ability of the function set, which is an important indicator of the learning performance of the function set; the larger the VC dimension is, the more complex the learning machine is. The SVM learning algorithm is applied to image processing and feature extraction, which can realize the monitoring of the water biological environment.The concept of generalization error bound is introduced into statistical learning, in which the real risk should be composed of two parts, one is an empirical risk that represents the error of the classifier, and the other is a confidence risk that represents the credibility of the classification results of the classifier. The calculation method is shown in teh following formula:(1)Rw≤Rcmpw+ϕn/h,where Rw represents the real risk, Rcmpw represents the empirical risk, and ϕn/h represents the confidence risk.The linear indivisibility of sample data is realized mainly through two aspects, one is the relaxation variable, and the other is the kernel function technology. A threshold is added to the classification function, and the category attribution of the sample can be determined by comparing the value of the classification function with the threshold. The linear function is shown in Formula (2); if the threshold is 0, the category of the sample can be determined according to Formula (3).(2)gx≤wx+b.(3)fx=sgngx,where x represents the sample vector. The above linear function is not only limited to two-dimensional space but also applicable in n-dimensional space, and w will be the n-dimensional vector in the corresponding formula.When classifying an image, the training sample required by the computer consists of a feature vector of the image and an identifier representing the class of the sample, as shown in Formula (4). According to the above representation, the interval from a sample point to a hyperplane is defined as the interval of a function, as shown in Formula (5).(4)Di=xi,yi,(5)δi=yiwxi+b,where xi represents the image feature vector with high dimension, yi represents the classification identifier, and δi represents the interval of the function, which is always greater than 0.The distance from vectorxi to hyperplane can be obtained by normalizing w and b, as shown in the following formula:(6)δi=1wgxi,where xi represents the vector in the n-dimensional space and δi represents the distance from the vector xi to the hyperplane, which measures the Euclidean distance from the sample point to the classification function in the input space.The maximum misclassification number of training set S based on the classification surface is shown in the following formula:(7)G=2Rδ2,where G represents the maximum number of misclassifications, R represents the maximum length of the sample vector, and δ represents the interval between the training set and the classification hyperplane.A geometric interval is used to measure the pros and cons of the classification model, the greater the geometric interval, the smaller the misclassification number. The goal of classifier training is to maximize the geometric interval, and the relationship between geometric interval and function interval is shown in the following formula:(8)δf=wδg,where δf represents the function interval, δf represents the geometric interval. When the fixed-function interval is 1, the maximization of the geometric interval is equivalent to finding the minimum w.Then, the weight coefficient vector of the optimal classification surface can be obtained, and the final expression of SVM is shown in the following formula:(9)fx=sgnw⋅x+b,where d represents the number of support vectors and b represents the classification threshold, which can be obtained by constraint conditions.In this paper, different algorithms are used to compare the effects of different processing modules, and the SVP algorithm is selected for feature extraction of raw water images finally. The classifier is used to monitor the biological environment of the water body, and the overall algorithm framework of the system is shown in Figure5.Figure 5
Algorithm framework of the system.


## 3.2. System Realization

### 3.2.1. System Bottom Hardware Configuration

According to the design requirements of the water quality monitoring system, the communication between the monitoring gateway and the monitoring node, and the communication between the monitoring gateway and the HMI interface are realized by a serial port in this paper. In addition, the FreeRTOS system and LwIP system are used in the system, so they also need to be set up.The ethernet transmission supports two modes, one is MII mode and the other is RMII mode. The MII mode contains a management interface and a data interface, which includes two independent channels for sending and receiving data. The management interface includes a clock signal interface and a data signal interface, and the upper layer can monitor and manage PHY through the management interface. In this article, the MII mode is selected for data transmission finally.Due to the complex function of the FreeRTOS system is not applied, so the default settings of the software are used to meet the requirements. When the LwIP is configured, routers are not used to assign IP addresses in this paper, so the DHCP functionality in LwIP is not required. The Debug function in LwIP is opened to facilitate debugging problems in system design.After all the peripheral configuration is completed, the project file can be generated. Then, it is necessary to conduct a simple test on the open serial port and Ethernet, so as to see whether the peripherals can work properly, which can avoid the waste of a lot of debugging time due to the underlying error. Finally, the task function is written based on the generated project file, which can realize the corresponding function.


### 3.2.2. Data Acquisition Program Design

In this paper, the communication between the monitoring gateway and the node is completed through the serial port, the monitoring gateway sends commands to each monitoring node, and the data are saved in the register for later data upload after the data stored on each monitoring node are read. After the data is received, it is necessary to detect whether the configuration information on the monitoring node is changed, and if it is changed, the configuration information should be sent to the monitoring node. In order to prevent the data loss caused by the power outage of the system, the data power outage protection function is added in this paper. When the data acquisition is completed, the system can determine whether the power outage protection is needed.In the data acquisition program, the serial port interrupts service function is the core part, and the system should have a certain fault tolerance ability for the data with a large receiving interval in the serial interrupt service function, which can avoid data errors caused by the large interval. After receiving the data, the system needs to open the interrupt receiving of the serial port again, otherwise, the system cannot receive the data normally.


### 3.2.3. Data Upload Program Design

The data upload system used in this paper supports two ways, one is Ethernet and the other is GPRS. The purpose of the data acquisition program is to upload the data received by the data acquisition program to the monitoring center so that users can view and save the data. When using GPRS to upload data, DTU wireless transmission is used to transmit data.It should be noted that the data stored in Modbus adopts a small-end mode, the high bytes of data are stored in the high address of memory, and the low bytes are stored in the low address of memory. The data sent through Ethernet are in the large-end mode, and the way of storing data in large-end mode and small-end mode is the opposite. When parsing the data sent by the monitoring center, it is necessary to transform the data size first. After the data from the monitoring center are parsed, the data need to be written to the monitoring node by using the function code, and the configuration information of the node needs to be changed.


## 3.2.1. System Bottom Hardware Configuration

According to the design requirements of the water quality monitoring system, the communication between the monitoring gateway and the monitoring node, and the communication between the monitoring gateway and the HMI interface are realized by a serial port in this paper. In addition, the FreeRTOS system and LwIP system are used in the system, so they also need to be set up.The ethernet transmission supports two modes, one is MII mode and the other is RMII mode. The MII mode contains a management interface and a data interface, which includes two independent channels for sending and receiving data. The management interface includes a clock signal interface and a data signal interface, and the upper layer can monitor and manage PHY through the management interface. In this article, the MII mode is selected for data transmission finally.Due to the complex function of the FreeRTOS system is not applied, so the default settings of the software are used to meet the requirements. When the LwIP is configured, routers are not used to assign IP addresses in this paper, so the DHCP functionality in LwIP is not required. The Debug function in LwIP is opened to facilitate debugging problems in system design.After all the peripheral configuration is completed, the project file can be generated. Then, it is necessary to conduct a simple test on the open serial port and Ethernet, so as to see whether the peripherals can work properly, which can avoid the waste of a lot of debugging time due to the underlying error. Finally, the task function is written based on the generated project file, which can realize the corresponding function.


## 3.2.2. Data Acquisition Program Design

In this paper, the communication between the monitoring gateway and the node is completed through the serial port, the monitoring gateway sends commands to each monitoring node, and the data are saved in the register for later data upload after the data stored on each monitoring node are read. After the data is received, it is necessary to detect whether the configuration information on the monitoring node is changed, and if it is changed, the configuration information should be sent to the monitoring node. In order to prevent the data loss caused by the power outage of the system, the data power outage protection function is added in this paper. When the data acquisition is completed, the system can determine whether the power outage protection is needed.In the data acquisition program, the serial port interrupts service function is the core part, and the system should have a certain fault tolerance ability for the data with a large receiving interval in the serial interrupt service function, which can avoid data errors caused by the large interval. After receiving the data, the system needs to open the interrupt receiving of the serial port again, otherwise, the system cannot receive the data normally.


## 3.2.3. Data Upload Program Design

The data upload system used in this paper supports two ways, one is Ethernet and the other is GPRS. The purpose of the data acquisition program is to upload the data received by the data acquisition program to the monitoring center so that users can view and save the data. When using GPRS to upload data, DTU wireless transmission is used to transmit data.It should be noted that the data stored in Modbus adopts a small-end mode, the high bytes of data are stored in the high address of memory, and the low bytes are stored in the low address of memory. The data sent through Ethernet are in the large-end mode, and the way of storing data in large-end mode and small-end mode is the opposite. When parsing the data sent by the monitoring center, it is necessary to transform the data size first. After the data from the monitoring center are parsed, the data need to be written to the monitoring node by using the function code, and the configuration information of the node needs to be changed.


## 4. System Performance Testing

This paper collects the data of monitoring nodes firstly, and then these data are processed at the gateway end, and the system sends the processed node data to the monitoring center finally. Before building the system, the monitoring node and the monitoring gateway should be tested separately, that is, whether the designed monitoring node can collect data normally and whether the monitoring gateway can establish a connection with the monitoring center. The connection test between the monitoring gateway and the monitoring center is tested through the network test tool, the monitoring gateway is connected to the computer through the network line, and the IP address of the monitoring gateway is input under the command prompt. The results show that the packet loss rate through the network is 0, so the monitoring gateway can normally connect with the monitoring center.The SVM algorithm is applied to image processing and feature extraction in this paper, which can realize the monitoring of the water biological environment. The superiority of the algorithm directly affects the performance of the system, so the performance of different algorithms is compared. This paper compares the computing time of the proposed algorithm with the traditional algorithm, and the operation time of the five samples was tested, as shown in Figure6.Figure 6
Computational complexity.Then, the prediction results are compared with the actual results to test the prediction results of the system. The value of dissolved oxygen in the water was monitored by the system in this paper, which was tested by the conventional method at the same time, and the results are shown in Figure7. It can be seen from Figure 7 that the predicted values of the system are in good agreement with the actual values. In the scatter plot shown in Figure 7, the distribution of points is divided from the lower-left corner to the upper-right corner, which indicates that the predicted value of the system is positively correlated with the measured value. The point distribution is close to a straight line, which shows that the predicted value is highly correlated with the measured value and the prediction effect of the system built in this paper is good.Figure 7
Scatter plot.Finally, the early warning function of the system is tested in this paper, and the early warning accuracy of the system is shown in Figure8. When the water biological environment is medium or below, the warning is issued, when the water biological environment is good or above, the system does not warn. It can be seen that the system has a high early warning sensitivity, and the early warning accuracy for different degrees of water can reach more than 95%. When the water biological environment is medium, the early warning accuracy can reach 97.86%, which indicate that the system has high warning accuracy and good engineering application prospect.Figure 8
Early warning accuracy.


## 5. Conclusion

Firstly, the requirements and basic principles of the water biological monitoring system are analyzed, and then the overall design of the system has been defined, whose components include a CCD image sensor, computer equipped with an image acquisition card, video server, data server, special image processing software, and environmental analysis software. Then, the early warning system of water biological environment monitoring was designed, in which the SVM algorithm was used for image processing and feature extraction, and the functions of the system are realized from three aspects. Finally, the computational complexity of the system algorithm and the detection accuracy of the system are tested, and the results show that the detection accuracy of the system can reach more than 95%. The system built in this paper has the advantages of low cost, low computational complexity, and high monitoring efficiency, which can provide an important reference for water resources protection.



---

*Source: 8280706-2022-06-24.xml*