Water gauge water level detection method based on visual processing
Through the water level detection method based on visual processing, combined with object detection and mathematical derivation, the water level value of the water level is automatically identified and calculated, which solves the shortcomings of traditional water level measurement methods in extreme weather conditions, and achieves a more accurate and safe water level monitor.
Patent Information
- Application Number
- CN202411391734.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-02-11
AI Technical Summary
Traditional water level measurement methods rely on manual direct reading of the water level scale, which has the problem that recognition accuracy is limited by the observer's visual judgment and has potential safety risks, especially in extreme weather conditions, which cannot be effectively observed.
A water level detection method based on visual processing, including object detection, image binarization, Canny edge detection, Hough transformation, RANSAC algorithm fitting and preset formula calculation, automatically identify and calculate the water level value of the water level .
It achieves more accurate, safe and 24/7 water level monitoring, breaks away from the limitations of traditional manual reading, and is robust to complex environmental factors such as lighting deviation and water surface reflection.
Smart Images

Figure CN119418034A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of water level detection, and in particular to a water gauge water level detection method based on visual processing. Background Art
[0002] Water level data plays a vital role in many fields such as water conservancy project management, water transportation operation, flood prevention and control, drought warning, and prediction of various hydrological phenomena. Traditional water level measurement methods rely on manual direct reading of water level gauges. This method has the problem that the recognition accuracy is limited by the observer's visual judgment and has potential safety hazards, especially in extreme weather conditions. Effective observation cannot be implemented. The application of machine vision algorithms can largely overcome the above difficulties and achieve more accurate, safe and all-weather water level monitoring.
[0003] In the automatic recognition system of water gauge readings, water level detection based on visual algorithms is a key link in the calculation process. Earlier technologies relied on relatively rough and limited accuracy image grayscale value analysis methods, or used large-scale image segmentation models with slow computing speeds to extract multiple key feature points on the water level to determine the location of the water level. These methods, as part of the water gauge recognition process, all showed certain limitations. Especially in the face of complex environmental factors such as inconsistent lighting conditions and water surface reflections, traditional methods are difficult to accurately lock the true location of the water level. Summary of the invention
[0004] The technical problem to be solved by the present invention is that traditional water level measurement methods rely on direct manual reading of the water level gauge. This method has the problem that the recognition accuracy is limited by the observer's visual judgment and has potential safety hazards, especially in extreme weather conditions, where effective observation cannot be implemented. In order to solve the above problems, a water level detection method of a water level gauge based on visual processing is provided.
[0005] The object of the present invention is achieved in the following manner:
[0006] A water level detection method for a water gauge based on visual processing, the method comprising the following steps:
[0007] S1: Get an image containing water ruler scale;
[0008] S2: Object detection obtains the coordinates of the water ruler in the image;
[0009] S3: Image binarization, using Gaussian filtering and morphological operations to remove noise;
[0010] S4: Canny edge detection and grayscale centroid method to obtain coordinates;
[0011] S5: Hough transform to get the boundary between land and water;
[0012] S6: Use RANSAC algorithm to fit the upper and lower asymptotes of the water gauge L1, L2 and water level line L3;
[0013] S7: Calculate the intersection point P of the asymptote L2 and the water level line L3;
[0014] S8: Substitute the preset formula to calculate the water level value of the water gauge.
[0015] In S2, the target detection process includes:
[0016] S21: obtaining water gauge images under different conditions, marking the area where the water gauge is located in the image, and dividing the marked data set into a training set and a validation set according to a certain ratio;
[0017] S22: According to the existing target detection framework, the training set is trained according to the set weights to obtain a water gauge area recognition training model based on target detection;
[0018] S23: Use the above-trained model to predict the water ruler image to be detected, and obtain the coordinates of the image frame containing the water ruler [X1, Y1, L1, W1], where X1, Y1 are the coordinates of the upper left corner of the image frame, and L1, W1 are the coordinates of the lower right corner of the image frame.
[0019] According to the coordinates of the water ruler image frame obtained by target detection, the image processing operations include:
[0020] According to the image frame coordinates, the image is cropped to obtain the region of interest, the cropped area is binarized, and Gaussian filtering and morphological operations are used to remove noise.
[0021] The image is binarized, and the image processing operations on the image obtained by Gaussian filtering and morphological operations include:
[0022] The coordinates of the center point of the upper surface of the water ruler are obtained according to the grayscale centroid method, and the lowest point among the non-zero points of the grayscale value, that is, the maximum point, is obtained according to the Canny edge detection to obtain the coordinates of the center point of the lower surface.
[0023] In S5, the operation of Hough transform includes:
[0024] S51: Firstly, edge detection is performed on the image to obtain edge information of the image;
[0025] S52: parameter space initialization, that is, creating an empty Hough space, where each edge point corresponds to a straight line in the parameter space;
[0026] S53: For each edge point, traverse the Hough space to find possible straight lines or curves. Accumulate each point related to the curve in the Hough space;
[0027] S54: setting a threshold, judging the accumulated value according to the threshold, and determining a valid straight line in the Hough space;
[0028] S55: According to the above threshold, find the maximum value of the accumulated values to obtain the land-water boundary.
[0029] In S6, the operation of performing straight line fitting includes:
[0030] The point coordinates obtained through steps S4 to S5 are used to fit the center points of the upper and lower surface of the water gauge using the RANSAC algorithm to obtain the asymptotic lines of the upper and lower surfaces of the water gauge, which are recorded as L1 and L2 respectively. The water-land boundary line obtained through Hough transform in step S5 is used to extract the feature points of the straight line, and the water level line L3 is fitted using RANSAC.
[0031] In S7 to S8, the operation of calculating the water level of the water gauge includes:
[0032] The upper asymptote L1, lower asymptote L2, and water level line L3 fitted by RANSAC are used, and the lower asymptote L2 and water level line L3 are combined to find the intersection point P; the water level value d of the water gauge is derived according to the three-dimensional visual relationship of the asymptotes, and then the water level of the water gauge is calculated.
[0033]
[0034] Among them, d is the scale value of the water ruler, D0 is the level point of the highest water ruler, Δ is the distance between adjacent water rulers, ranging from 10 to 20 cm, D0 and Δ need to be obtained in advance through prior knowledge, the land and water boundary is between water ruler i and water ruler i+1, l is the distance between the intersection point P and water ruler i, and T is the distance between adjacent water ruler images, which is determined by the water ruler asymptotes and the extracted water ruler position.
[0035] Beneficial effects of the invention: The invention proposes a water gauge water level detection method based on visual processing, which combines the target detection result and integrates it into a mathematical derivation formula to calculate the water gauge water level. It not only gets rid of the traditional manual reading of the water gauge scale, but also has good robustness for lighting deviation, water surface reflection and other conditions. Combined with the machine vision algorithm, it overcomes the problem that effective observation cannot be implemented under extreme weather conditions to a large extent, and realizes more accurate, safe and all-weather water level monitoring. The method has strong reliability, is easy to implement, has high real-time performance, does not require manual observation, and can automatically identify the water gauge water level line. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a flow chart of water level detection of water gauge based on image processing algorithm in the present invention;
[0037] Figure 2 This is a flow chart of extracting the center of gravity of the upper surface of the water gauge in the present invention;
[0038] Figure 3 It is a flow chart of waterway boundary line obtained by Hough transformation in the present invention;
[0039] Figure 4 It is a calculation model diagram of the water level and waterline priori formula in the present invention. DETAILED DESCRIPTION
[0040] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0041] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same technical meanings as those commonly understood by those skilled in the art to which the present application belongs.
[0042] like Figure 1 The present invention is a water level detection method of a water gauge based on visual processing, and the steps are as follows:
[0043] In order to achieve the above object, the present invention proposes a water gauge water level detection method using image processing, comprising the following steps:
[0044] S1: Get an image containing water ruler scale;
[0045] S2: Object detection obtains the coordinates of the water ruler in the image;
[0046] S3: Image binarization, using Gaussian filtering and morphological operations to remove noise;
[0047] S4: Canny edge detection and grayscale centroid method to obtain coordinates;
[0048] S5: Hough transform to obtain the waterway boundary line;
[0049] S6: Use RANSAC algorithm to fit the upper and lower asymptotes L1, L2 of the water gauge and the water level line L3;
[0050] S7: Calculate the intersection point P of the asymptote L2 and the water level line L3;
[0051] S8: Substitute the preset formula to calculate the water level value of the water gauge;
[0052] Specifically, in step S2, the water gauge image obtained in S1 is put into the target detection model for training to obtain the coordinates of the water gauge in the image. The detailed steps are as follows:
[0053] S21: obtaining water gauge images under different conditions, marking the area where the water gauge is located in the image, and dividing the marked data set into a training set and a validation set according to a certain ratio;
[0054] S22: According to the existing target detection framework, the training set is trained according to the set weights to obtain a water gauge area recognition training model based on target detection;
[0055] S23: Use the trained model to predict the water gauge image to be detected, and obtain the coordinates of the image frame containing the water gauge [X1, Y1, L1, W1], where X1, Y1 are the coordinates of the upper left corner of the image frame, and L1, W1 are the coordinates of the lower right corner of the image frame;
[0056] Specifically, in step S3, the image is binarized and noise is removed by Gaussian filtering and morphological operations. The detailed steps are as follows:
[0057] According to the image frame coordinates, the image is cropped to obtain the region of interest, the cropped region is binarized, and Gaussian filtering and morphological operations are used to remove noise;
[0058] Specifically, in step S4, the coordinates are obtained using Canny edge detection and grayscale centroid method. The detailed steps are as follows:
[0059] The coordinates of the center point of the upper surface of the water ruler are obtained according to the grayscale centroid method, and the coordinates of the center point of the lower surface are obtained according to the Canny edge detection to obtain the lowest point among the non-zero grayscale values and the maximum point of the row.
[0060] Specifically, in step S5, the land-water boundary is obtained by using Hough transform, and the detailed steps are as follows:
[0061] S51: Firstly, edge detection is performed on the image to obtain edge information of the image;
[0062] S52: parameter space initialization, that is, creating an empty Hough space, where each edge point corresponds to a straight line in the parameter space;
[0063] S53: For each edge point, traverse the Hough space to find possible straight lines or curves. Accumulate each point related to the curve in the Hough space;
[0064] S54: setting a threshold, judging the accumulated value according to the threshold, and determining a valid straight line in the Hough space;
[0065] S55: according to the above threshold, find the maximum value of the accumulated value, so as to obtain the boundary line between land and water;
[0066] Specifically, in step S6, the RANSAC algorithm is used to fit the upper and lower asymptotes L1, L2 of the water gauge and the water level line L3; the detailed steps are as follows:
[0067] The point coordinates obtained from steps S4 to S5 are used to fit the center points of the upper and lower surface of the water gauge using the RANSAC algorithm to obtain the asymptotic lines of the upper and lower surfaces of the water gauge, which are recorded as L1 and L2 respectively; the water-land boundary line obtained by Hough transform in step S5 is used to extract the feature points of the straight line, and the water level line L3 is fitted using RANSAC;
[0068] Specifically, in step S7, the intersection point P of the asymptote L2 and the water level line L3 is calculated, and the detailed steps are as follows:
[0069] Use the upper asymptote L1, lower asymptote L2, and water level L3 fitted by RANSAC, and jointly calculate the lower asymptote L2 and water level L3 to find the intersection point P;
[0070] Specifically, in step S8, the preset formula is substituted to calculate the water level value of the water gauge. The detailed steps are as follows:
[0071] According to the intersection point P calculated in advance, substitute the following formula to calculate the water level value of the water gauge, and the water level value is recorded as d;
[0072]
[0073] Wherein, d is the scale value of the water ruler, D0 is the level point of the highest water ruler, Δ is the distance between adjacent water rulers, ranging from 10 to 20 cm, D0 and Δ need to be obtained in advance through prior knowledge, the water-land boundary is between water ruler i and water ruler i+1, l is the distance between the intersection point P and water ruler i, and T is the distance between adjacent water ruler images, which can be determined by the water ruler asymptote and the extracted water ruler position;
[0074] like Figure 2 In step S3, the image is binarized, and the noise is removed by Gaussian filtering and morphological operations. Then, the grayscale centroid method is used in step S4 to obtain the center coordinates of the water ruler upper surface.
[0075] like Figure 3 In step S5, a flow chart of the land-water boundary is obtained through Hough transform.
[0076] like Figure 4 , in step S8, the model diagram of the water gauge water level line prior formula is obtained.
[0077] The present invention combines the target detection result and incorporates it into a mathematical derivation formula to calculate the water level of the water gauge, which not only gets rid of the traditional manual reading of the water gauge scale, but also has good robustness to lighting deviation, water surface reflection and the like. Combined with the machine vision algorithm, it overcomes the problem that effective observation cannot be implemented under extreme weather conditions to a large extent, and realizes more accurate, safe and all-weather water level monitoring. The method has strong reliability, is easy to implement, has high real-time performance, does not require manual observation, and can automatically identify the water level line of the water gauge.
[0078] The above is only a preferred embodiment of the present invention. It should be pointed out that for those skilled in the art, several changes and improvements can be made without departing from the overall concept of the present invention, which should also be regarded as the scope of protection of the present invention.
Claims
1. A water level detection method based on visual processing, characterized in that: The method comprises the following steps: S1: Get an image containing water ruler scale; S2: Object detection obtains the coordinates of the water ruler in the image; S3: Image binarization, using Gaussian filtering and morphological operations to remove noise; S4: Canny edge detection and grayscale centroid method to obtain coordinates; S5: Hough transform to get the boundary between land and water; S6: Use RANSAC algorithm to fit the upper and lower asymptotes of the water gauge L1, L2 and water level line L3; S7: Calculate the intersection point P of the asymptote L2 and the water level line L3; S8: Substitute the preset formula to calculate the water level value of the water gauge.
2. The water level detection method based on visual processing according to claim 1 is characterized in that: In S2, the target detection process includes: S21: obtaining water gauge images under different conditions, marking the area where the water gauge is located in the image, and dividing the marked data set into a training set and a validation set according to a certain ratio; S22: According to the existing target detection framework, the training set is trained according to the set weights to obtain a water gauge area recognition training model based on target detection; S23: Use the above-trained model to predict the water ruler image to be detected, and obtain the coordinates of the image frame containing the water ruler [X1, Y1, L1, W1], where X1, Y1 are the coordinates of the upper left corner of the image frame, and L1, W1 are the coordinates of the lower right corner of the image frame.
3. The water level detection method based on visual processing according to claim 2 is characterized in that: According to the coordinates of the water ruler image frame obtained by target detection, the image processing operations include: According to the image frame coordinates, the image is cropped to obtain the region of interest, the cropped area is binarized, and Gaussian filtering and morphological operations are used to remove noise.
4. The water level detection method based on visual processing according to claim 3 is characterized in that: The image is binarized, and the image processing operations on the image obtained by Gaussian filtering and morphological operations include: The coordinates of the center point of the upper surface of the water ruler are obtained according to the grayscale centroid method, and the lowest point among the non-zero points of the grayscale value, that is, the maximum point, is obtained according to the Canny edge detection to obtain the coordinates of the center point of the lower surface.
5. The water level detection method based on visual processing according to claim 1 is characterized in that: In S5, the operation of Hough transform includes: S51: Firstly, edge detection is performed on the image to obtain edge information of the image; S52: parameter space initialization, that is, creating an empty Hough space, where each edge point corresponds to a straight line in the parameter space; S53: For each edge point, traverse the Hough space to find possible straight lines or curves. Accumulate each point related to the curve in the Hough space; S54: setting a threshold, judging the accumulated value according to the threshold, and determining a valid straight line in the Hough space; S55: According to the above threshold, find the maximum value of the accumulated values to obtain the land-water boundary.
6. The water level detection method based on visual processing according to claim 1 is characterized in that: In S6, the operation of performing straight line fitting includes: The point coordinates obtained through steps S4 to S5 are used to fit the center points of the upper and lower surface of the water gauge using the RANSAC algorithm to obtain the asymptotic lines of the upper and lower surfaces of the water gauge, which are recorded as L1 and L2 respectively. The water-land boundary line obtained through Hough transform in step S5 is used to extract the feature points of the straight line, and the water level line L3 is fitted using RANSAC.
7. The water level detection method based on visual processing according to claim 1 is characterized in that: In S7 to S8, the operation of calculating the water level of the water gauge includes: The upper asymptote L1, lower asymptote L2, and water level line L3 fitted by RANSAC are used, and the lower asymptote L2 and water level line L3 are combined to find the intersection point P; the water level value d of the water gauge is derived according to the three-dimensional visual relationship of the asymptotes, and then the water level of the water gauge is calculated. Among them, d is the scale value of the water ruler, D0 is the level point of the highest water ruler, Δ is the distance between adjacent water rulers, ranging from 10 to 20 cm, D0 and Δ need to be obtained in advance through prior knowledge, the land and water boundary is between water ruler i and water ruler i+1, l is the distance between the intersection point P and water ruler i, and T is the distance between adjacent water ruler images, which is determined by the water ruler asymptotes and the extracted water ruler position.