A visual-based water level real-time detection system and method
Patent Information
- Application Number
- CN202610922538.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-25
- Publication Date
- 2026-10-30
AI Technical Summary
首先,在复杂环境适应性方面,现有方法往往对环境因素如强光、弱光、水面波动等较为敏感,例如在夜晚或雾天等低光照条件、水面耀光和倒影都会导致检测精度下降
[0016]本发明的优点和积极效果是:
Smart Images

Figure CN123016411A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing and water level monitoring technology, and in particular to a vision-based real-time water level detection system and method. Background Technology
[0002] Water level monitoring, as an important monitoring tool in fields such as water conservancy and environmental protection, plays a crucial role in flood control and disaster reduction, water resource management, and ecological environmental protection. Traditional water level monitoring methods mainly rely on mechanical sensors or manual observation, such as float-type water level gauges and pressure-type water level gauges. However, these methods have revealed many limitations in practical applications, such as susceptibility to environmental interference, limited measurement accuracy, and high maintenance costs.
[0003] In recent years, scholars both domestically and internationally have made significant progress in the research of vision-based water level detection methods. Early research mainly focused on the application of traditional image processing methods, such as template-matching-based water level detection algorithms. This method identifies the water level position by comparing it with a water level gauge template, but its high dependence on lighting conditions and image quality limits its detection accuracy. Subsequently, edge-detection-based water level detection methods gradually emerged, with the Canny operator being widely used in water level line extraction tasks due to its excellent edge detection performance. However, the robustness of this method in complex environments still needs improvement. Recently, with the development of deep learning technology, water level detection methods incorporating convolutional neural networks (CNNs) have gradually become a research hotspot. For example, some researchers have attempted to combine improved YOLOv5 with RankSE modules for intelligent water level detection and semantic segmentation-based water level monitoring methods. Although these methods perform well in specific scenarios, their high computational complexity makes it difficult to meet real-time requirements.
[0004] Although existing research has achieved some success in vision-based water level detection methods, several problems still need to be addressed. First, in terms of adaptability to complex environments, existing methods are often sensitive to environmental factors such as strong light, weak light, and water surface fluctuations. For example, low light conditions such as nighttime or foggy days, as well as water surface glare and reflections, can lead to a decrease in detection accuracy. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of the prior art and propose a vision-based real-time water level detection system and method to detect river water level height, reduce personnel operation costs, and avoid data errors caused by improper personnel operation.
[0006] The technical problem solved by this invention is achieved through the following technical solution: A vision-based real-time water level detection system includes a video stream access module, a parameter configuration module, an image preprocessing module, a water level feature extraction module, a data post-processing module, and a data storage server, wherein the video stream access module, parameter configuration module, image preprocessing module, water level feature extraction module, data post-processing module, and data storage server are connected sequentially. The video stream access module is used to acquire real-time video streams of the monitored area, including the piling water gauge, through image acquisition equipment; The parameter configuration module is used to manually set the water level baseline and offset parameters; The image preprocessing module is used to perform noise removal and contrast enhancement on the acquired video frame images; The water level feature extraction module is used to extract the water level lines from the preprocessed image. The data post-processing module is used to calculate the water level height based on the detected digital information, key points of the water surface line, and calibration parameters by generating a virtual water gauge, solving for intersections, and dynamically correcting them. The data storage server is used to receive and store water level information and issue alarms when the water level is abnormal.
[0007] Furthermore, the image preprocessing module includes: a Gaussian filter, a median filter, and a histogram equalization unit connected in sequence. Among them, the Gaussian filter traverses all pixels of the image through Gaussian kernel convolution, and performs a weighted average of neighboring pixels to smooth out abrupt changes in image grayscale and weaken fine and messy noise; it preserves the overall image outline, including the water level gauge and the general edge of the water surface. The median filter follows the Gaussian filter output image and uses an algorithm that sorts neighboring pixels by gray level and replaces the center pixel with the median value to remove abrupt, single-point abnormal pixels. It also specifically removes salt-and-pepper noise, including isolated black and white noise, raindrops, flying insects, and sensor dead pixels. The histogram equalization unit performs grayscale dynamic range stretching and illumination equalization enhancement on the two-stage filtered image, highlighting the details of the water gauge edge and waterline, which facilitates accurate segmentation of the water body and gauge area by subsequent algorithms.
[0008] Furthermore, the data post-processing module includes: a RANSAC line segment fitting unit, a virtual water level generation unit, a Kalman filter, an intersection point solving unit, and a dynamic correction unit. The RANSAC line segment fitting unit uses a random sampling consensus algorithm to remove interference points from aquatic plants and floating objects at the edge feature points, fits the vertical scale line of the water gauge to the horizontal water edge line, and outputs the straight line parameters to provide reliable geometric features for water level calculation. The virtual water level gauge generation unit combines camera calibration parameters and fitted scale lines to establish a mapping relationship between image pixels and actual water levels, generating a virtual water level gauge to achieve accurate conversion between pixel position and physical elevation, ensuring that readings can still be taken even when obstructed. The intersection point solution unit combines the equations of the water gauge baseline and the water edge line, calculates the pixel intersection points of the two, and converts the intersection point coordinates into the initial water level raw values through the virtual water gauge mapping relationship, providing observation data for subsequent filtering processing; Based on the continuous change of water level, the Kalman filter integrates predicted and observed values, filters out water level jumps and spikes caused by waves and obstructions, and outputs smooth and stable basic water level data, thus improving the reliability of the data. The dynamic correction unit performs benchmark calibration, wind and wave compensation, and anomaly correction for system errors such as camera displacement and support deformation, eliminating long-term drift errors and outputting the final accurate real-time water level to adapt to complex working conditions.
[0009] Moreover, the water level feature extraction module includes a water gauge positioning unit, a digit detection unit, a digit recognition unit, and a water level detection unit, wherein the water gauge positioning unit is used to accurately cut the water gauge region using the YOLOv8 model and E-character detection and clustering algorithm. The digital detection unit is used to detect the position of the main scale digits on the water gauge using the YOLOv5 model; The digit recognition unit is used to identify digit categories using the FastReID fine-grained classification model; The water level detection unit is used to locate key points of the water surface intersection line using the CenterNet key point detection model.
[0010] A detection method for a vision-based real-time water level detection system includes the following steps: Step S1: Acquire real-time video stream of the monitoring area including the piling water gauge using image acquisition equipment; Step S2: Preprocess the acquired video frame images. The preprocessing includes noise removal and contrast enhancement operations performed sequentially. Step S3: Accurately locate the water gauge region in the preprocessed image. Accurate location includes: initially defining the water gauge region using the YOLOv8 object detection model, then detecting the "E" character on the water gauge, and performing spatial clustering analysis on all detected "E" characters using the DBSCAN clustering algorithm, and cutting out the water gauge region based on the clustering results. Step S4: Perform digit detection and recognition in the cut-out water gauge area, including: using the YOLOv5 object detection framework to detect the position of the main scale digits, and using the FastReID fine-grained classification model with ResNet-50 as the backbone network and combined with triplet loss to identify the detected digit positions and obtain digit category information; Step S5: Using the CenterNet key point detection model based on the Hourglass Network structure and heatmap encoding method, accurately locate one or more key points on the intersection line of the water surface and the water gauge. Step S6: Manually calibrate the zero point height, tilt angle, and step position parameters of the water gauge; Step S7: Perform data post-processing and water level calculation; Step S8: Upload the calculated real-time water level to the backend server for display and storage, and issue an alarm message when the water level exceeds the preset threshold.
[0011] The feature is that the noise removal operation in step S2 is specifically as follows: first, Gaussian filtering is applied to remove random noise, and then medium-value filtering is applied to remove salt and pepper noise while maintaining the integrity of the water level line edge. The contrast enhancement operation is specifically as follows: the gray value of the image pixels is redistributed using the histogram equalization method to expand the dynamic range of the image.
[0012] The feature is that the detection of the "E" character on the water gauge in step S3 is performed using a lightweight Anchor-free model.
[0013] The feature is that the YOLOv5 object detection framework in step S4 is trained in conjunction with Mosaic data augmentation and the CIoULoss loss function.
[0014] The feature is that the parameters manually calibrated in step S6 also include the offset between the water level scale in the camera image and the actual water level parameters in the scene.
[0015] The characteristic is that step S7 includes the following steps: Step S7.1: Use the RANSAC algorithm to fit line segments at key points of the water surface intersection line and introduce an adaptive weighting mechanism; Step S7.2: Based on the digital information identified in step S4 and the parameters calibrated in step S6, a virtual water gauge is generated using linear interpolation and coordinate transformation; Step S7.3: Enhance the stability of the virtual water level gauge by combining Kalman filtering; Step S7.4: Extract feature points of the water surface line and the virtual water gauge edge in the image, fit a straight line model using the RANSAC algorithm and remove outliers to solve for the geometric intersection point; convert the pixel coordinates of the intersection point to the physical elevation through calibration mapping, and then use Kalman filtering to fuse time series observations to suppress wave disturbances; finally, combine historical trends and environmental parameters to complete dynamic correction and output a high-precision water level height.
[0016] The advantages and positive effects of this invention are: 1. High robustness and environmental adaptability: This invention significantly reduces the sensitivity to complex environments such as light, haze, and water surface fluctuations by combining preprocessing with Gaussian filtering, median filtering and histogram equalization, as well as a water level positioning strategy based on "E" character clustering.
[0017] 2. High detection accuracy: This invention integrates the advantages of multiple deep learning models such as YOLOv8, YOLOv5, FastReID, and CenterNet, and optimizes water level positioning, digital detection and recognition, and water level line positioning respectively. Combined with post-processing techniques such as RANSAC fitting and Kalman filtering, it achieves high-precision end-to-end water level measurement.
[0018] 3. Real-time performance: By embedding the core processing module into the front-end camera device, this invention reduces data transmission latency and, combined with a lightweight model design, meets the requirements for real-time water level monitoring.
[0019] 4. High degree of automation: This invention realizes full automation of the process from video acquisition, image processing, water level calculation to data uploading and alarm, reducing the burden of manual operation and human error. Attached Figure Description
[0020] Figure 1 Example diagram of the pile-type water gauge used in this invention (left: nighttime image, right: daytime image); Figure 2 This is an overall flowchart of the vision-based real-time water level detection method described in this invention. Detailed Implementation
[0021] The present invention will be further described in detail below with reference to the accompanying drawings.
[0022] A vision-based real-time water level detection system includes a video stream access module, a parameter configuration module, an image preprocessing module, a water level feature extraction module, a data post-processing module, and a data storage server, wherein the video stream access module, parameter configuration module, image preprocessing module, water level feature extraction module, data post-processing module, and data storage server are connected sequentially. The video stream access module is used to acquire real-time video streams of the monitored area, including the piling water gauge, through image acquisition equipment; The parameter configuration module is used to manually set the water level baseline and offset parameters; The image preprocessing module is used to perform noise removal and contrast enhancement on the acquired video frame images; The water level feature extraction module is used to extract the water level lines from the preprocessed image. The data post-processing module is used to calculate the water level height based on the detected digital information, key points of the water surface line, and calibration parameters by generating a virtual water gauge, solving for intersections, and dynamically correcting them. The data storage server is used to receive and store water level information and issue alarms when the water level is abnormal.
[0023] A detection method for a vision-based real-time water level detection system includes the following steps: Step 1: Video Stream Acquisition and Configuration This invention employs a high-resolution industrial network camera (IPC) with a resolution of 1920×1080 pixels and a frame rate of 30fps to ensure that the water level gauge is centered in the image. The camera integrates a parameter configuration module, an image preprocessing module, a water level feature extraction module, and a data post-processing module. The camera sends one image frame to the processing system every 0.5 seconds. Operators can manually set parameters such as the water level baseline and offset via the parameter configuration module to ensure that the water level gauge readings in the camera image correspond to the actual scene.
[0024] Step 2: Image Preprocessing The image preprocessing module refers to performing operations such as noise removal and contrast enhancement on the acquired RGB image data to highlight the key information of the water level line.
[0025] Noise Removal: Noise in the image is primarily reduced by combining median filtering and Gaussian filtering. First, Gaussian filtering removes random noise, providing a smooth image foundation. Second, the non-linear filtering characteristics of median filtering effectively detect and eliminate salt-and-pepper noise while preserving the integrity of image edge information. Furthermore, median filtering exhibits strong robustness to impulse noise, effectively retaining the clarity of key information such as water levels while removing noise, significantly improving the image's signal-to-noise ratio and providing high-quality input data for subsequent processing.
[0026] Water level enhancement: Histogram equalization is used to redistribute the gray values of image pixels, making the image histogram more uniformly distributed, thereby expanding the dynamic range of the image and enhancing contrast. In water level detection tasks, due to the influence of complex environmental conditions (such as insufficient lighting, haze, etc.), the acquired images often have low contrast, making it difficult to clearly identify key information such as water level lines.
[0027] Histogram equalization maps image gray values using a cumulative distribution function, expanding the concentrated gray values in the original image to the entire gray range, thereby highlighting the detailed features of key information such as water levels.
[0028] Step 3: Water level gauge positioning First, the YOLOv8 object detection model is used to detect the water level indicator across the entire image, outputting its bounding box. Then, within this bounding box, another detection model is used to identify the "E" characters on the water level indicator. Finally, the DBSCAN clustering algorithm is used to spatially cluster the center points of all detected "E" characters. Because the "E" characters are regularly distributed along the direction of the water level indicator, the clustering results effectively eliminate false detections and accurately delineate the complete area of the water level indicator, ensuring stable localization even when parts of the water level indicator are occluded or in poor lighting conditions.
[0029] Step 4: Digital Detection and Recognition After precisely segmenting the water gauge area, the YOLOv5 model (with Mosaic data augmentation and CIoU Loss) is used to detect the positions of the main scale digits on the water gauge. Then, each detected digit image patch is fed into the FastReID fine-grained classification model. This model uses ResNet-50 as the backbone network and is trained using triplet loss. It can accurately classify blurred, tilted, or partially occluded digits, outputting specific digit values (such as "0", "1", "2", etc.) and their corresponding scale positions.
[0030] Step 5: Water level detection A CenterNet keypoint detection model is employed. This model uses an Hourglass Network as the encoder-decoder, outputting a heatmap to encode the keypoint locations of the intersection line between the water surface and the water gauge. By finding the peak points in the heatmap, the coordinates of the keypoints on the water surface line with sub-pixel accuracy can be obtained.
[0031] Step 6: Parameter Calibration During system initialization, manually calibrate the following key parameters: Zero point height of the water level gauge: The actual physical height corresponding to the "0" mark on the water level gauge.
[0032] Water gauge tilt angle: Due to installation or viewing angle, the water gauge may not be vertical in the image, and its tilt angle needs to be calibrated.
[0033] Step position: If the water gauge is composed of multiple segments, mark the image coordinates of the connection points of each segment.
[0034] Step 7: Virtual water gauge generation and water level calculation Line segment fitting: For the key points of the water surface line detected in step 5, the RANSAC algorithm is used for robust fitting to obtain the accurate equation of the water surface line. Adaptive weights are introduced into the algorithm to reduce the influence of outliers.
[0035] Virtual water level gauge generation: Based on the digital information identified in step 4 and the actual physical height parameters calibrated in step 6, a linear interpolation algorithm is used to generate continuous virtual water level gauge scales corresponding to the actual physical height on the water level gauge image coordinates. Simultaneously, Kalman filtering is applied to smooth the virtual water level gauge parameters generated in consecutive frames, improving stability.
[0036] Intersection point determination: Calculate the coordinates of the intersection point between the straight line on the water surface and the virtual water gauge (one or a group of line segments). Based on the position of the intersection point on the virtual water gauge, the actual physical height of the current water surface is directly obtained through coordinate transformation.
[0037] Dynamic correction: Combine historical water level data from the past few frames to dynamically and smoothly correct the current calculated value and output the final water level height.
[0038] Step 8: Data Upload and Alarms The final water level data is uploaded to the backend server in real time. The server displays the water level change curve and current value at the monitoring point. When the water level exceeds the preset warning or guaranteed level, the system automatically issues an alarm message via sound and light, SMS, or application programming interface.
[0039] It should be emphasized that the embodiments described in this invention are illustrative rather than limiting. Therefore, this invention includes, but is not limited to, the embodiments described in the specific implementation. Any other implementations derived by those skilled in the art based on the technical solutions of this invention are also within the scope of protection of this invention.
Claims
1. A vision-based real-time water level detection system, characterized in that: It includes a video stream access module, a parameter configuration module, an image preprocessing module, a water level feature extraction module, a data post-processing module, and a data storage server, wherein the video stream access module, parameter configuration module, image preprocessing module, water level feature extraction module, data post-processing module, and data storage server are connected in sequence; The video stream access module is used to acquire real-time video streams of the monitored area, including the piling water gauge, through image acquisition equipment; The parameter configuration module is used to manually set the water level baseline and offset parameters; The image preprocessing module is used to perform noise removal and contrast enhancement on the acquired video frame images; The water level feature extraction module is used to extract the water level lines from the preprocessed image. The data post-processing module is used to calculate the water level height based on the detected digital information, key points of the water surface line, and calibration parameters by generating a virtual water gauge, solving for intersections, and dynamically correcting them. The data storage server is used to receive and store water level information and issue alarms when the water level is abnormal.
2. The vision-based real-time water level detection system according to claim 1, characterized in that: The image preprocessing module includes: a Gaussian filter, a median filter, and a histogram equalization unit connected in sequence. Among them, the Gaussian filter traverses all pixels of the image through Gaussian kernel convolution, and performs a weighted average of neighboring pixels to smooth out abrupt changes in image grayscale and weaken fine and messy noise; it preserves the overall image outline, including the water level gauge and the general edge of the water surface. The median filter follows the Gaussian filter output image and uses an algorithm that sorts neighboring pixels by gray level and replaces the center pixel with the median value to remove abrupt, single-point abnormal pixels. It also specifically removes salt-and-pepper noise, including isolated black and white noise, raindrops, flying insects, and sensor dead pixels. The histogram equalization unit performs grayscale dynamic range stretching and illumination equalization enhancement on the two-stage filtered image, highlighting the details of the water gauge edge and waterline, which facilitates accurate segmentation of the water body and gauge area by subsequent algorithms.
3. The vision-based real-time water level detection system according to claim 1, characterized in that: The data post-processing module includes: a RANSAC line segment fitting unit, a virtual water level gauge generation unit, a Kalman filter, an intersection point solving unit, and a dynamic correction unit. The RANSAC line segment fitting unit uses a random sampling consensus algorithm to remove interference points from aquatic plants and floating objects at the edge feature points, fits the vertical scale line of the water gauge to the horizontal water edge line, and outputs the straight line parameters to provide reliable geometric features for water level calculation. The virtual water level gauge generation unit combines camera calibration parameters and fitted scale lines to establish a mapping relationship between image pixels and actual water levels, generating a virtual water level gauge to achieve accurate conversion between pixel position and physical elevation, ensuring that readings can still be taken even when obstructed. The intersection point solution unit combines the equations of the water gauge baseline and the water edge line, calculates the pixel intersection points of the two, and converts the intersection point coordinates into the initial water level raw values through the virtual water gauge mapping relationship, providing observation data for subsequent filtering processing; Based on the continuous change of water level, the Kalman filter integrates predicted and observed values, filters out water level jumps and spikes caused by waves and obstructions, and outputs smooth and stable basic water level data, thus improving the reliability of the data. The dynamic correction unit performs benchmark calibration, wind and wave compensation, and anomaly correction for system errors such as camera displacement and support deformation, eliminating long-term drift errors and outputting the final accurate real-time water level to adapt to complex working conditions.
4. The vision-based real-time water level detection system according to claim 1, characterized in that: The water level feature extraction module includes a water level gauge positioning unit, a digit detection unit, a digit recognition unit, and a water level detection unit. The water level gauge positioning unit is used to accurately cut the water level gauge region using the YOLOv8 model and E-character detection and clustering algorithm. The digital detection unit is used to detect the position of the main scale digits on the water gauge using the YOLOv5 model; The digit recognition unit is used to identify digit categories using the FastReID fine-grained classification model; The water level detection unit is used to locate key points of the water surface intersection line using the CenterNet key point detection model.
5. A detection method for a vision-based real-time water level detection system as described in any one of claims 1 to 4, characterized in that: Includes the following steps: Step S1: Acquire real-time video stream of the monitoring area including the piling water gauge using image acquisition equipment; Step S2: Preprocess the acquired video frame images. The preprocessing includes noise removal and contrast enhancement operations performed sequentially. Step S3: Accurately locate the water gauge region in the preprocessed image. Accurate location includes: using the YOLOv8 object detection model to initially define the water gauge region, then detecting the "E" character on the water gauge, and using the DBSCAN clustering algorithm to perform spatial clustering analysis on all detected "E" characters, and cutting out the water gauge region based on the clustering results. Step S4: Perform digit detection and recognition in the cut-out water gauge area, including: using the YOLOv5 object detection framework to detect the position of the main scale digits, and using the FastReID fine-grained classification model with ResNet-50 as the backbone network and combined with triplet loss to identify the detected digit positions and obtain digit category information; Step S5: Using the CenterNet key point detection model based on the Hourglass Network structure and heatmap encoding method, accurately locate one or more key points on the intersection line of the water surface and the water gauge. Step S6: Manually calibrate the zero point height, tilt angle, and step position parameters of the water gauge; Step S7: Perform data post-processing and water level calculation; Step S8: Upload the calculated real-time water level to the backend server for display and storage, and issue an alarm message when the water level exceeds the preset threshold.
6. The detection method of a vision-based real-time water level detection system according to claim 5, characterized in that: The noise removal operation in step S2 is as follows: first, Gaussian filtering is applied to remove random noise, and then medium-value filtering is applied to remove salt and pepper noise while maintaining the integrity of the water level line edge. The contrast enhancement operation is as follows: the gray value of the image pixels is redistributed using the histogram equalization method to expand the dynamic range of the image.
7. The detection method of a vision-based real-time water level detection system according to claim 5, characterized in that: The detection of the "E" character on the water gauge in step S3 is performed using a lightweight Anchor-free model.
8. The detection method of a vision-based real-time water level detection system according to claim 5, characterized in that: In step S4, the YOLOv5 object detection framework is trained in conjunction with Mosaic data augmentation and the CIoU Loss loss function.
9. The detection method of a vision-based real-time water level detection system according to claim 5, characterized in that: The parameters manually calibrated in step S6 also include the offset between the water level gauge scale in the camera image and the actual water level gauge parameters in the scene.
10. The detection method of a vision-based real-time water level detection system according to claim 5, characterized in that: Step S7 includes the following steps: Step S7.1: Use the RANSAC algorithm to fit line segments at key points of the water surface intersection line and introduce an adaptive weighting mechanism; Step S7.2: Based on the digital information identified in step S4 and the parameters calibrated in step S6, a virtual water gauge is generated using linear interpolation and coordinate transformation; Step S7.3: Enhance the stability of the virtual water level gauge by combining Kalman filtering; Step S7.4: Extract feature points of the water surface line and the virtual water gauge edge in the image, fit a straight line model using the RANSAC algorithm and remove outliers to solve for the geometric intersection point; convert the pixel coordinates of the intersection point to the physical elevation through calibration mapping, and then use Kalman filtering to fuse time series observations to suppress wave disturbances; finally, combine historical trends and environmental parameters to complete dynamic correction and output a high-precision water level height.
