Barrel liquid level detection method and system for surface water monitoring station field image
Patent Information
- Application Number
- CN202511753053.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-09-29
- Estimated Expiration
- 2045-11-26
AI Technical Summary
[0004]本发明所要解决的技术问题在于:如何解决现有技术中只能预警一个液位高度,不能进行实时检测的问题,提供了用于地表水监测站现场图像的桶体液位检测方法
[0061]1、精准实时:基于先进的图像处理技术,能够非接触式地实时测量液位高度,避免了人工误判,数据客观准确。
Smart Images

Figure CN121577121B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer image processing technology, and more specifically to a method and system for detecting liquid level in barrels for use in on-site images of surface water monitoring stations. Background Technology
[0002] In the daily operation and maintenance of surface water monitoring stations, monitoring the liquid levels in waste liquid tanks and pure water tanks is a crucial step in ensuring continuous monitoring and preventing environmental pollution. If the waste liquid tank level is too high and overflows, it will cause serious pollution to the surrounding soil and water bodies, violating the core requirements of environmental monitoring. Conversely, if the pure water tank level is too low, the monitoring equipment will malfunction due to lack of water, affecting the continuity and accuracy of surface water monitoring data.
[0003] Existing technologies mainly rely on contact-based liquid level detection, which can only provide early warnings for a single liquid level and cannot perform real-time monitoring. Therefore, this paper proposes a method and system for detecting liquid levels in a container based on on-site images from surface water monitoring stations. Summary of the Invention
[0004] The technical problem to be solved by this invention is: how to solve the problem that the existing technology can only provide early warning of a liquid level and cannot perform real-time detection, and provides a method for detecting the liquid level in a tank using on-site images of surface water monitoring stations.
[0005] The present invention solves the above-mentioned technical problems through the following technical solution, and the present invention includes the following steps:
[0006] S1: Image Preprocessing
[0007] Illumination compensation, downsampling, and image sharpening were performed on the collected on-site images of the surface water monitoring station to obtain the processed on-site images of the surface water monitoring station.
[0008] S2: Object Detection
[0009] The trained target detection model was used to detect the processed surface water monitoring station images to obtain the detection results of barrel categories and the key point detection results of the corresponding barrels.
[0010] S3: Liquid Level Detection
[0011] Calculate the liquid level inside the tank based on the detection results of key points on the tank.
[0012] S4: Active Warning
[0013] The liquid level in each tank is monitored in real time. When the liquid level exceeds the preset threshold, an alarm is issued and the maintenance personnel are notified via the network for timely handling.
[0014] Furthermore, in step S1, the specific process of illumination compensation is as follows:
[0015] S11: Perform color space conversion, the specific formula is as follows:
[0016] ;
[0017] in, These are the original images, i.e., on-site images from the surface water monitoring station. This represents a color space conversion function. This indicates a channel separation operation. These represent the original luminance component, the green-red luminance component, and the blue-yellow luminance component, respectively.
[0018] S12: Global illumination is estimated using Gaussian kernel convolution to achieve illumination component estimation. The specific formula is as follows:
[0019] ;
[0020] ;
[0021] in, For kernel coordinates, Represents the Gaussian kernel. Used to control the Gaussian kernel size. This represents the convolution operation. This represents the blurred illumination component matrix;
[0022] S13: The specific formula for performing illumination-reflection decomposition in the logarithmic domain is as follows:
[0023] ;
[0024] in, Represents the logarithmic field reflection component matrix;
[0025] Transform to a linear space and normalize:
[0026] ;
[0027] in, This indicates linear normalization. Indicates the reflected component;
[0028] S14: Perform contrast-limited histogram equalization, the specific formula is as follows:
[0029] ;
[0030] in, This indicates histogram equalization processing. This represents the equalized reflection component. This represents the histogram clipping threshold. , Indicates the size of the grid blocks. ;
[0031] S15: Adjust the dynamic range of output brightness via gamma correction.
[0032] ;
[0033] in, To correct the reflected component, ;
[0034] S16: Reconstruct the image to obtain the illumination-compensated on-site image of the surface water monitoring station. The specific formula is as follows:
[0035]
[0036] in, The image is the reconstructed image, i.e., the on-site image of the surface water monitoring station after illumination compensation. Indicates a channel merging operation; This is a color space conversion function.
[0037] Furthermore, in step S1, downsampling involves using illumination-compensated on-site images of the surface water monitoring station. Perform bilinear interpolation to scale to a fixed size.
[0038] Furthermore, in step S1, during the image downsampling process, the Laplacian operator is used to weighted fuse with the original image to enhance edge and texture features in the image, as shown in the following formula:
[0039]
[0040]
[0041]
[0042] in, Represents the discrete Laplacian convolution kernel. This represents the convolution operation. This indicates the output edge-enhanced image. This represents the mean of the Laplace calculation results. This represents the standard deviation of the Laplace calculation result. Image height, Image width, express The value is restricted to the interval [a, b], where α represents the sharpening intensity coefficient. These are the pixel values of the image after initial illumination compensation processing, where x and y represent the spatial coordinates of the pixel. This represents the pixel value of the sharpened output image obtained after Laplacian edge enhancement.
[0043] Furthermore, in step S2, the target detection model comprises three parts: Backbone, Neck, and Head. The Backbone extracts multi-scale features from the image, which are then fused by the Neck. Finally, the Head generates the target category, bounding box, and key points based on the fused features. The Backbone includes sequentially connected multi-layer convolutional units and a cross-stage residual structure. The Neck is implemented based on a multi-feature pyramid. The Head receives the multi-scale fused features from the Neck and performs convolutional predictions at different resolutions to output the target detection results.
[0044] Furthermore, in step S2, the tank types include waste liquid tanks and pure water tanks, and the corresponding key points include scale key points and liquid level key points. The scale key points are used to establish a measurement benchmark, and the liquid level key points are used to indicate the actual water level height. The scale key points and liquid level key points are distributed on both sides of the scale on the tank.
[0045] Furthermore, in step S3, the specific calculation process is as follows:
[0046] S31: The least squares method is used to fit the equation of the scale line based on the key points of the scale, as follows:
[0047]
[0048] Where n is the index of the key point on the scale. This represents the coordinates of the nth scale mark. Let A be the slope and intercept of the scale line equation, A be the design matrix, and y be the target vector for linear fitting.
[0049] S32: Mapping scale line equations using key points of liquid level, as detailed below:
[0050]
[0051] in, The coordinates of the key points of the liquid level, The coordinates of the key liquid level points projected onto the fitted scale line;
[0052] S33: Calculate the liquid level height based on the coordinates of the mapped point and the equation of the scale line.
[0053]
[0054] in, This refers to the liquid level height. Represents the coordinate position of the first tick mark. This represents the coordinate position of the last tick mark, where i represents the tick index, ranging from 1 to n-1. Represents the relative interval between adjacent scale divisions; when the liquid level coordinates The liquid level is 0 when it is below the first scale coordinate, and when the liquid level coordinate is... The liquid level is 1 when it is above the last scale coordinate. When the liquid level is between two graduations, the liquid level height is calculated by multiplying the relative position relationship by the relative interval between the graduations.
[0055] This invention also provides a tank liquid level detection system for surface water monitoring station field images, which uses the above-described method to detect the liquid level height of each tank in the surface water monitoring station field images, including:
[0056] The image preprocessing module is used to perform illumination compensation, downsampling, and image sharpening operations on the collected on-site images of the surface water monitoring station to obtain the processed on-site images of the surface water monitoring station.
[0057] The target detection module is used to detect the processed on-site images of the surface water monitoring station using a trained target detection model, and to obtain the detection results of the barrel category and the key point detection results of the corresponding barrel in the image.
[0058] The liquid level detection module is used to calculate the liquid level height inside the tank based on the detection results of key points on the tank.
[0059] The active early warning module is used to monitor the liquid level in each tank in real time. When the liquid level exceeds the preset threshold, an alarm is issued and the operation and maintenance personnel are notified via the network for timely handling.
[0060] The present invention has the following advantages over the prior art:
[0061] 1. Precise and Real-time: Based on advanced image processing technology, it can measure liquid level height in real time without contact, avoiding human error and ensuring objective and accurate data.
[0062] 2. Proactive early warning: By linking preset thresholds with automatic alarms, the system transforms passive detection into proactive early warning, providing maintenance personnel with sufficient response time and eliminating the risk of waste liquid spillage at the source.
[0063] 3. Remote and efficient: With the help of the network, remote monitoring and notification are achieved, and maintenance personnel can grasp the overall situation without being on-site, which greatly improves management efficiency and reduces maintenance costs. Attached Figure Description
[0064] Figure 1 This is a flowchart illustrating the method for detecting the liquid level in a tank using on-site images of a surface water monitoring station, as described in an embodiment of the present invention.
[0065] Figure 2 This is a schematic diagram of the target detection model in an embodiment of the present invention. Detailed Implementation
[0066] The embodiments of the present invention are described in detail below. These embodiments are implemented based on the technical solution of the present invention, and provide detailed implementation methods and specific operation processes. However, the scope of protection of the present invention is not limited to the following embodiments.
[0067] like Figure 1 As shown, this embodiment provides a technical solution: a method for detecting the liquid level in a tank using on-site images of a surface water monitoring station, comprising the following steps:
[0068] 1. Image preprocessing
[0069] 1.1 Illumination Compensation
[0070] Surface water monitoring stations are easily affected by day and night lighting conditions, leading to loss of detail in dark areas and overexposure in bright areas, severely impacting detection accuracy. To address this issue, a lighting compensation method based on Retinex theory is employed, decomposing the image into reflection and illumination components to achieve adaptive compensation for uneven lighting and reduce the influence of actual environmental light sources.
[0071] (1) Perform color space conversion
[0072]
[0073] in, For the original image, This represents a color space conversion function. This indicates a channel separation operation. These represent the original luminance component, the green-red luminance component, and the blue-yellow luminance component, respectively.
[0074] (2) Illumination component estimation
[0075] Global illumination is estimated using Gaussian kernel convolution.
[0076]
[0077]
[0078] in, For kernel coordinates, Represents the Gaussian kernel. Used to control the Gaussian kernel size. This represents the convolution operation. This represents the blurred illumination component matrix;
[0079] (3) Extraction of reflection components
[0080] Light-reflection decomposition in the logarithmic domain:
[0081]
[0082] in, Represents the logarithmic field reflection component matrix;
[0083] Transform to a linear space and normalize:
[0084]
[0085] in, This indicates linear normalization. Indicates the reflected component;
[0086] (4) Contrast-limited histogram equalization
[0087]
[0088] in, This indicates histogram equalization processing. This represents the equalized reflection component. This represents the histogram clipping threshold. , Indicates the size of the grid blocks. ;
[0089] (5) Gamma correction
[0090] Adjust the dynamic range of output brightness
[0091]
[0092] in, To correct the reflected component, ;
[0093] (6) Image reconstruction
[0094]
[0095] in, The image is the reconstructed image, i.e., the on-site image of the surface water monitoring station after illumination compensation. This indicates a channel merging operation, which takes three single-channel matrices and combines them into a three-channel LAB color space image; This is a color space conversion function that converts the input LAB color space image back to a BGR color space image.
[0096] 1.2 Downsampling
[0097] Image after illumination compensation Perform bilinear interpolation to scale to a fixed size (e.g., 640×640) to improve the speed of subsequent model inference and reduce hardware resource consumption.
[0098] 1.3 Image Sharpening
[0099] During image downsampling, some high-frequency details (especially fine edges) may be lost or weakened. Using the Laplacian operator to weighted fuse with the original image can enhance the edge and texture features in the image and improve the accuracy of key point detection.
[0100]
[0101]
[0102]
[0103] in, Represents the discrete Laplacian convolution kernel. This represents the convolution operation. This indicates the output edge-enhanced image. This represents the mean of the Laplace calculation results. This represents the standard deviation of the Laplace calculation result. Image height, Image width, express The value is restricted to the interval [a, b], where α represents the sharpening intensity coefficient. These are the pixel values of the image after initial illumination compensation processing, where x and y represent the spatial coordinates of the pixel. This represents the pixel value of the sharpened output image obtained after Laplacian edge enhancement.
[0104] 2. Target Detection
[0105] Based on object detection, key points such as the barrel's border, category, and liquid level scale are identified.
[0106] like Figure 2 As shown, the object detection model structure consists of three parts: Backbone, Neck, and Head.
[0107] Backbone: As the feature extraction part of the model, it consists of multiple layers of convolutional units connected sequentially with cross-stage residual structures.
[0108] The preprocessed surface water monitoring station images are sequentially processed through multiple convolutional normalized activation units (CBS) and cross-stage partial residual blocks (CSP ResNet Block) to achieve multi-level feature extraction and semantic expression enhancement. The final output is integrated with multi-scale contextual information by the spatial pyramid pooling module (SPPF) to form a high-level feature map with strong semantic expression and multi-scale perception capabilities, providing input for subsequent feature fusion layers.
[0109] The CBS module comprises convolutional layers, batch normalization layers, and a SiLU activation function for basic feature extraction. The CSP ResNet Block module introduces some cross-stage residual connections within the feature flow to improve gradient propagation efficiency and reduce computational redundancy. The SPPF module expands the receptive field through multi-scale pooling parallel operations, enhancing the global representation capability of features. This backbone network can extract key visual features that best represent barrels, scales, liquid surfaces, and colors from complex monitoring site images, providing basic feature support for subsequent target classification and localization.
[0110] Neck: Based on the Multiple Feature Pyramid (FPN-PAN), it effectively aggregates multi-scale features from the Backbone and significantly improves the spatial detail resolution and semantic representation strength of the fused features through a cross-level bidirectional feature interaction mechanism (top-down semantic propagation and bottom-up detail feedback).
[0111] During the fusion process, features from different layers are fully transferred through feature concatenation and residual connections, further enhancing feature consistency and spatial representation integrity. After processing by this module, the output multi-scale fused feature map can still maintain clear boundaries and significant semantic features of the target structure in complex backgrounds, providing high-quality input for subsequent detection head predictions.
[0112] Head: Receives multi-scale fusion features from Neck, performs convolutional predictions at different resolutions, and outputs target detection results, namely 3 types of detection heads, corresponding to target category, bounding box and key points respectively.
[0113] In this testing process:
[0114] Bucket category determination: Based on the specific color characteristics of the scale, waste liquid buckets and pure water buckets are distinguished.
[0115] Key point detection: Scale key points are used to establish measurement benchmarks; liquid level key points are used to indicate the actual water level height. To improve the accuracy of liquid level recognition and prevent the liquid level point and scale from coinciding and affecting the recognition results, the scale points (scale key points) and liquid level points (liquid level key points) are distributed on both sides of the scale when labeling data.
[0116] 3. Image post-processing
[0117] The liquid level is calculated based on the extracted key points. To reduce outliers at individual scale points, multi-point linear fitting is used, and the key liquid level points are mapped onto the scale lines. The liquid level is then calculated based on their relative positions.
[0118] The specific steps are as follows:
[0119] (1) Fitting the scale line equation
[0120] The least squares method was used to fit the equation of the scale line based on the coordinates of the key points of the scale, as follows:
[0121]
[0122] Where n is the index of the key point on the scale. This represents the coordinates of the nth scale mark. Let A be the slope and intercept of the scale line equation, A be the design matrix, which represents the data of the predictor variables (independent variables) and defines the structure of the linear model, and y be the target vector for linear fitting.
[0123] (2) Mapping scale line equations using key liquid level points:
[0124]
[0125] in, The coordinates of the key points of the liquid level, The coordinates of the key liquid level points projected onto the fitted scale line;
[0126] (3) Calculate the liquid level
[0127] Calculate the liquid level height based on the coordinates of the mapping point and the equation of the scale line.
[0128]
[0129] in, This refers to the liquid level height. Represents the coordinate position of the first tick mark. This represents the coordinate position of the last tick mark, where i represents the tick index, ranging from 1 to n-1. Represents the relative interval between adjacent scale divisions. When the liquid level coordinates... The liquid level is 0 when it is below the first scale coordinate, and when the liquid level coordinate is... The liquid level is 1 when it is above the last scale coordinate. When the liquid level is between two graduations, the liquid level height is calculated by multiplying the relative position relationship by the relative interval between the graduations.
[0130] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A method for detecting the liquid level in a tank for use in on-site images of surface water monitoring stations, characterized in that, Includes the following steps: S1: Image Preprocessing Illumination compensation, downsampling, and image sharpening were performed on the collected on-site images of the surface water monitoring station to obtain the processed on-site images of the surface water monitoring station. S2: Object Detection The trained target detection model was used to detect the processed surface water monitoring station images to obtain the detection results of barrel categories and the key point detection results of the corresponding barrels. S3: Liquid Level Detection Calculate the liquid level inside the tank based on the detection results of key points on the tank. S4: Proactive Early Warning The liquid level in each tank is monitored in real time. When the liquid level exceeds the preset threshold, an alarm is issued and the operation and maintenance personnel are notified via the network for timely handling. In step S1, the specific process of illumination compensation is as follows: S11: Perform color space conversion, the specific formula is as follows: ; in, These are the original images, i.e., on-site images from the surface water monitoring station. This represents a color space conversion function. This indicates a channel separation operation. These represent the original luminance component, the green-red luminance component, and the blue-yellow luminance component, respectively. S12: Global illumination is estimated using Gaussian kernel convolution to achieve illumination component estimation. The specific formula is as follows: ; ; in, For kernel coordinates, Represents the Gaussian kernel. Used to control the Gaussian kernel size. This represents the convolution operation. This represents the blurred illumination component matrix; S13: The specific formula for performing illumination-reflection decomposition in the logarithmic domain is as follows: ; in, Represents the logarithmic field reflection component matrix; Transform to a linear space and normalize: ; in, This indicates linear normalization. Indicates the reflected component; S14: Perform contrast-limited histogram equalization, the specific formula is as follows: ; in, This indicates histogram equalization processing. This represents the equalized reflection component. This represents the histogram clipping threshold. , Indicates the size of the grid blocks. ; S15: Adjust the dynamic range of output brightness via gamma correction. ; in, To correct the reflected component, ; S16: Reconstruct the image to obtain the illumination-compensated on-site image of the surface water monitoring station. The specific formula is as follows: ; in, The image is the reconstructed image, i.e., the on-site image of the surface water monitoring station after illumination compensation. Indicates a channel merging operation; This is a color space conversion function.
2. The method for detecting the liquid level in a tank for on-site images of a surface water monitoring station according to claim 1, characterized in that, In step S1, downsampling involves using illumination-compensated on-site images of the surface water monitoring station. Perform bilinear interpolation to scale to a fixed size.
3. The method for detecting the liquid level in a tank for on-site images of a surface water monitoring station according to claim 2, characterized in that, In step S1, during the image downsampling process, the Laplacian operator is used to weighted fuse with the original image to enhance edge and texture features in the image. The specific formula is as follows: ; ; ; in, Represents the discrete Laplacian convolution kernel. This represents the convolution operation. This indicates the output edge-enhanced image. This represents the mean of the Laplace calculation results. This represents the standard deviation of the Laplace calculation result. Image height, Image width, express The value is restricted to the interval [a, b], where α represents the sharpening intensity coefficient. These are the pixel values of the image after initial illumination compensation processing, where x and y represent the spatial coordinates of the pixel. This represents the pixel value of the sharpened output image obtained after Laplacian edge enhancement.
4. The method for detecting the liquid level in a tank for on-site images of a surface water monitoring station according to claim 1, characterized in that, In step S2, the target detection model comprises three parts: Backbone, Neck, and Head. The Backbone extracts multi-scale features from the image, which are then fused by the Neck. Finally, the Head generates the target category, bounding box, and key points based on the fused features. The Backbone includes sequentially connected multi-layer convolutional units and a cross-stage residual structure. The Neck is implemented based on a multi-feature pyramid. The Head receives the multi-scale fused features from the Neck and performs convolutional predictions at different resolutions to output the target detection results.
5. The method for detecting the liquid level in a tank for on-site images of a surface water monitoring station according to claim 4, characterized in that, In step S2, the tank types include waste liquid tanks and pure water tanks, and the corresponding key points include scale key points and liquid level key points. The scale key points are used to establish a measurement benchmark, and the liquid level key points are used to indicate the actual water level height. The scale key points and liquid level key points are distributed on both sides of the scale on the tank.
6. The method for detecting the liquid level in a tank for on-site images of a surface water monitoring station according to claim 1, characterized in that, In step S3, the specific calculation process is as follows: S31: The least squares method is used to fit the equation of the scale line based on the key points of the scale, as follows: ; Where n is the index of the key point on the scale. This represents the coordinates of the nth scale mark. Let A be the slope and intercept of the scale line equation, A be the design matrix, and y be the target vector for linear fitting. S32: Mapping scale line equations using key points of liquid level, as detailed below: ; in, The coordinates of the key points of the liquid level, The coordinates of the key liquid level points projected onto the fitted scale line; S33: Calculate the liquid level height based on the coordinates of the mapped point and the equation of the scale line. ; in, This refers to the liquid level height. Represents the coordinate position of the first tick mark. This represents the coordinate position of the last tick mark, where i represents the tick index, ranging from 1 to n-1. Represents the relative interval between adjacent scale divisions; when the liquid level coordinates The liquid level is 0 when it is below the first scale coordinate, and when the liquid level coordinate is... The liquid level is 1 when it is above the last scale coordinate. When the liquid level is between two graduations, the liquid level height is calculated by multiplying the relative position relationship by the relative interval between the graduations.
7. A tank-type liquid level detection system for on-site images of surface water monitoring stations, characterized in that, The method described in any one of claims 1 to 6 is used to detect the liquid level height of each tank in the field image of a surface water monitoring station, including: The image preprocessing module is used to perform illumination compensation, downsampling, and image sharpening operations on the collected on-site images of the surface water monitoring station to obtain the processed on-site images of the surface water monitoring station. The target detection module is used to detect the processed on-site images of the surface water monitoring station using a trained target detection model, and to obtain the detection results of the barrel category and the key point detection results of the corresponding barrel in the image. The liquid level detection module is used to calculate the liquid level height inside the tank based on the detection results of key points on the tank. The active early warning module is used to monitor the liquid level in each tank in real time. When the liquid level exceeds the preset threshold, an alarm is issued and the operation and maintenance personnel are notified via the network for timely handling.
Citation Information
Patent Citations
Ship water gauge identification method, system and equipment based on deep learning
CN119625754A