A Complex Environmental Water-Level Detection Method Based on Improved YOLOv5m
Abstract
:1. Introduction
2. Related Work
2.1. Dataset
2.2. Water-Level Detection
2.2.1. Image Correction
- (1)
- Using object detection methods to extract regions of interest and extracting the area where the water-level gauge is located from the image to reduce external environmental interference.
- (2)
- Perform grayscale transformation on the extracted region of interest image and use the Canny operator to automatically determine the threshold to convert it into a binary image.
- (3)
- Use the Hough line transformation function to process binary images, obtain a large number of tilt angle values, and then calculate the average of these tilt angle θ values as the tilt angle of the water-level gauge in the image.
- (4)
- Finally, in Figure 3, the coordinates of the top-left corner of the bounding box are (x0, y0), with the width and height of the bounding box being w0 and h0, respectively. From these values, the coordinates of the rotation center can be determined as (x0 + w0/2, y0 + h0/2). Then, by applying OpenCV’s affine transformation function, the original image is rotated around this rotation center point by the calculated tilt angle θ. This rotation aligns the water gauge vertically with the horizontal plane, resulting in a corrected image of the water gauge. The principles of this transformation are illustrated in Formulas (1) and (2) below.
2.2.2. Water-Level Gauge Segmentation
2.2.3. Content Assisted Adjustment Strategy
2.2.4. Water-Level Calculation
- (1)
- Create a training set that includes the actual water-level gauge heights and corresponding water-level values in the images. By normalizing the data, it is limited to the range of from 0 to 1 to eliminate the potential adverse effects caused by singular sample data.
- (2)
- Establish a linear regression model.
- (3)
- Train and test the model to obtain the optimal model and obtain the weight as w and the bias as b of the model.
3. Algorithm
3.1. Water-Level Gauge Correction Algorithm
3.1.1. Automatic Determination of Threshold Canny Algorithm
- (1)
- Gaussian filtering is applied to grayscale images to reduce the impact of noise.
- (2)
- Unlike the unimproved Canny operator, the improved high and low thresholds are calculated based on the median of the grayscale image. As shown in Formulas (5) and (6).
- (3)
- Perform Gaussian filtering again on the binarized image obtained from the Canny operator to further reduce the impact of noise.
3.1.2. Hough Line Transformation Function
3.2. Improved YOLOv5m
3.2.1. Overall
3.2.2. Input
3.2.3. Backbone
3.2.4. Neck
3.2.5. Head
3.2.6. Attention Mechanism
3.3. Linear Regression
4. Experiment and Analysis
4.1. Experimental Environment
4.2. Water-Level Gauge Correction Experiment
4.3. Water-Level Gauge Segmentation Experiment
4.4. Water-Level Measurement Experiment
4.4.1. Comparative Experiment
4.4.2. Ablation Experiment
5. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Jan, F.; Min-Allah, N.; Saeed, S.; Iqbal, S.Z.; Ahmed, R. IoT-Based Solutions to Monitor Water Level, Leakage, and Motor Control for Smart Water Tanks. Water 2022, 14, 309. [Google Scholar] [CrossRef]
- Syrmos, E.; Sidiropoulos, V.; Bechtsis, D.; Stergiopoulos, F.; Aivazidou, E.; Vrakas, D.; Vezinias, P.; Vlahavas, I. An Intelligent Modular Water Monitoring IoT System for Real-Time Quantitative and Qualitative Measurements. Sustainability 2023, 15, 2127. [Google Scholar] [CrossRef]
- Khampuengson, T.; Wang, W. Novel Methods for Imputing Missing Values in Water Level Monitoring Data. Water Resour. Manag. 2023, 37, 851–878. [Google Scholar] [CrossRef]
- Jafari, N.H.; Li, X.; Chen, Q.; Le, C.-Y.; Betzer, L.P.; Liang, Y. Real-time water level monitoring using live cameras and computer vision techniques. Comput. Geosci. 2021, 147, 104642. [Google Scholar] [CrossRef]
- Herzog, A.; Stahl, K.; Blauhut, V.; Weiler, M. Measuring zero water level in stream reaches: A comparison of an image-based versus a conventional method. Hydrol. Process. 2022, 36, 1890. [Google Scholar] [CrossRef]
- Sun, W.; Wang, D.; Xu, S.; Wang, J.; Ma, H.J. Water Level Detection Algorithm Based on Computer Vision. J. Appl. Sci. 2022, 40, 434–447, (In Chinese with English abstract). [Google Scholar]
- Jiang, B. Research on Remote Water Level Monitoring System Based on Image Recognition. Master’s Thesis, XiDian University, Xi’an, China, 2012. (In Chinese with English abstract). [Google Scholar]
- Zhang, Y.; Wang, J.; Zhang, G.; Liu, M. Review of image water level detection. Electron. Meas. Technol. 2021, 44, 10, (In Chinese with English abstract). [Google Scholar]
- Zhang, Z.; Zhou, Y.; Liu, H.; Zhang, L.; Wang, H. Visual measurement of water level under complex illumination conditions. Sensors 2019, 19, 4141. [Google Scholar] [CrossRef] [PubMed]
- Luo, Y.; Dong, Z.; Liu, Y.; Wang, X.; Shi, Q.; Han, Y. Research on stage-divided water level prediction technology of rivers-connected lake based on machine learning: A case study of Hongze Lake, China. Stoch. Environ. Res. Risk Assess. 2021, 35, 2049–2065. [Google Scholar] [CrossRef]
- Dou, G.; Chen, R.; Han, C.; Liu, Z.; Liu, J. Research on Water-Level Recognition Method Based on Image Processing and Convolutional Neural Networks. Water 2022, 14, 1890. [Google Scholar] [CrossRef]
- Ibañez, S.C.; Dajac, C.V.G.; Liponhay, M.P.; Legara, E.F.T.; Esteban, J.M.H.; Monterola, C.P. Forecasting Reservoir Water Levels Using Deep Neural Networks: A Case Study of Angat Dam in the Philippines. Water 2021, 14, 34. [Google Scholar] [CrossRef]
- Pan, M.; Zhou, H.; Cao, J.; Liu, Y.; Hao, J.; Li, S.; Chen, C.-H. Water Level Prediction Model Based on GRU and CNN. IEEE Access 2020, 8, 60090–60100. [Google Scholar] [CrossRef]
- Baek, S.-S.; Pyo, J.; Chun, J.A. Prediction of Water Level and Water Quality Using a CNN-LSTM Combined Deep Learning Approach. Water 2020, 12, 3399. [Google Scholar] [CrossRef]
- Liu, Y.; Liu, Y.; Yuan, C.; Chen, X. An Improved Long-Term Water Level Prediction Method for N-BEATS. Int. J. Comput. Sci. Inf. Technol. 2024, 3, 360–366. [Google Scholar] [CrossRef]
- Liu, Y.; Wang, H.; Feng, W.; Huang, H. Short Term Real-Time Rolling Forecast of Urban River Water Levels Based on LSTM: A Case Study in Fuzhou City, China. Int. J. Environ. Res. Public Health 2021, 18, 9287. [Google Scholar] [CrossRef] [PubMed]
- Noor, F.; Haq, S.; Rakib, M.; Ahmed, T.; Jamal, Z.; Siam, Z.S.; Hasan, R.T.; Adnan, M.S.G.; Dewan, A.; Rahman, R.M. Water Level Forecasting Using Spatiotemporal Attention-Based Long Short-Term Memory Network. Water 2022, 14, 612. [Google Scholar] [CrossRef]
- Xu, J.; Fan, H.; Luo, M.; Li, P.; Jeong, T.; Xu, L. Transformer Based Water Level Prediction in Poyang Lake, China. Water 2023, 15, 576. [Google Scholar] [CrossRef]
- Hung, C.-H.; FanJiang, Y.-Y.; Wang, D.-J.; Chen, K.-C. Contactless Water Level Detection System for Pickling Barrels Using Image Recognition Technology. IEEE Access 2023, 11, 113931–113940. [Google Scholar] [CrossRef]
- Bochkovskiy, A.; Wang, C.-Y.; Liao, H.-Y.M. Yolov4: Optimal speed and accuracy of object detection. arXiv 2020, arXiv:2004.10934. [Google Scholar]
- Wang, C.-Y.; Bochkovskiy, A.; Liao, H.-Y.M. YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Vancouver, BC, Canada, 17–24 June 2023; pp. 7464–7475. [Google Scholar]
- Qiao, G.; Yang, M.; Wang, H. A water level measurement approach based on YOLOv5s. Sensors 2022, 22, 3714. [Google Scholar] [CrossRef]
- Azad, A.S.; Sokkalingam, R.; Daud, H.; Adhikary, S.K.; Khurshid, H.; Mazlan, S.N.A.; Rabbani, M.B.A. Water Level Prediction through Hybrid SARIMA and ANN Models Based on Time Series Analysis: Red Hills Reservoir Case Study. Sustainability 2022, 14, 1843. [Google Scholar] [CrossRef]
- Chen, C.; Fu, R.; Ai, X.; Huang, C.; Cong, L.; Li, X.; Jiang, J.; Pei, Q. An Integrated Method for River Water Level Recognition from Surveillance Images Using Convolution Neural Networks. Remote Sens. 2022, 14, 6023. [Google Scholar] [CrossRef]
- Xie, Z.; Jin, J.; Wang, J.; Zhang, R.; Li, S. Application of Deep Learning Techniques in Water Level Measurement: Combining Improved SegFormer-UNet Model with Virtual Water Gauge. Appl. Sci. 2023, 13, 5614. [Google Scholar] [CrossRef]
- Woo, S.; Park, J.; Lee, J.-Y.; Kweon, I.S. Cbam: Convolutional block attention module. In Proceedings of the European Conference on Computer Vision (ECCV), Munich, Germany, 8–14 September 2018; pp. 3–19. [Google Scholar]
- Liu, T.; Luo, R.; Xu, L.; Feng, D.; Cao, L.; Liu, S.; Guo, J. Spatial channel attention for deep convolutional neural networks. Mathematics 2022, 10, 1750. [Google Scholar] [CrossRef]
- Hu, J.; Shen, L.; Sun, G. Squeeze-and-excitation networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–23 June 2018; pp. 7132–7141. [Google Scholar]
Method | Error ≤ 1 cm | Error ≤ 1 cm | Error ≥ 3 cm | Average Error (cm) |
---|---|---|---|---|
Tradition | ~ | ~ | ~ | ~ |
Qiao [22] | 14% | 49% | 37% | 2.6 |
Chen [24] | 25% | 56% | 19% | 1.9 |
Self | 46% | 37% | 17% | 1.7 |
Scene | Error ≤ 1 cm | Error ≤ 1 cm | Error ≥ 3 cm | Average Error (cm) |
---|---|---|---|---|
Sunny | 58% | 42% | 0% | 0.9 |
Cloudy | 40% | 28% | 32% | 1.9 |
Rainy | 0% | 73% | 27% | 2.2 |
Night | 88% | 11% | 1% | 0.8 |
Soiling | 21% | 51% | 28% | 2.3 |
Special | 100% | 0% | 0% | 0.8 |
Method | Improved | Assisted | Error ≤ 1 cm | Error ≤ 3 cm | Error ≥ 3 cm | Average Error (cm) |
---|---|---|---|---|---|---|
Self | × | × | 12% | 43% | 45% | 2.8 |
Self | × | √ | 17% | 57% | 26% | 2.3 |
Self | √ | × | 17% | 58% | 25% | 2.2 |
Self | √ | √ | 46% | 37% | 17% | 1.7 |
Method | Scene | Improved | Assisted | Error ≤ 1 cm | Error ≤ 3 cm | Error ≥ 3 cm | Average Error (cm) |
---|---|---|---|---|---|---|---|
Self | Day | × | × | 10% | 42% | 48% | 2.8 |
Self | Night | × | × | 8% | 44% | 48% | 2.8 |
Self | Day | √ | × | 19% | 52% | 29% | 2.3 |
Self | Night | √ | × | 14% | 66% | 20% | 2.3 |
Self | Day | × | √ | 9% | 45% | 46% | 2.8 |
Self | Night | × | √ | 18% | 54% | 28% | 2.3 |
Self | Day | √ | √ | 21% | 51% | 28% | 2.3 |
Self | Night | √ | √ | 88% | 11% | 1% | 0.8 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Li, J.; Tong, C.; Yuan, H.; Huang, W. A Complex Environmental Water-Level Detection Method Based on Improved YOLOv5m. Sensors 2024, 24, 5235. https://doi.org/10.3390/s24165235
Li J, Tong C, Yuan H, Huang W. A Complex Environmental Water-Level Detection Method Based on Improved YOLOv5m. Sensors. 2024; 24(16):5235. https://doi.org/10.3390/s24165235
Chicago/Turabian StyleLi, Jiadong, Chunya Tong, Hongxing Yuan, and Wennan Huang. 2024. "A Complex Environmental Water-Level Detection Method Based on Improved YOLOv5m" Sensors 24, no. 16: 5235. https://doi.org/10.3390/s24165235