A water level measurement method based on binocular stereo vision

Through the iteratively optimized semi-global SGM stereo matching and RANSAC plane fitting method, the accuracy and robustness problems of water level measurement in complex water surface environments are solved, and high-precision water level measurement is achieved, which is suitable for fields such as smart water conservancy and emergency rescue.

CN119810041BActive Publication Date: 2025-09-23HOHAI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411849382.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-09-23
Estimated Expiration
2044-12-16

AI Technical Summary

Technical Problem

Existing water level measurement technology has low accuracy and poor robustness in complex water surface environments, especially under the influence of weak texture and optical noise, it is difficult to obtain accurate disparity maps, resulting in low horizontal plane fitting accuracy, and the existing deep learning model has insufficient generalization ability in water surface environments.

Method used

An iteratively optimized semi-global SGM stereo matching method is adopted, combined with disparity consistency constraint and sub-pixel optimization. The disparity map of the water surface image is obtained by a binocular camera, and the RANSAC method is used to fit the water surface plane. Combined with the binocular camera parameter selection, the measurement accuracy and anti-interference ability are improved.

Benefits of technology

High-precision water level measurement is achieved in complex environments such as different lighting, water flow and floating objects, which reduces the algorithm complexity and improves the accuracy and robustness of the measurement, meeting the water level monitoring needs of routine and emergency scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119810041B_ABST
    Figure CN119810041B_ABST
Patent Text Reader

Abstract

The present invention discloses a water level measurement method based on binocular stereo vision, comprising the following steps: selecting a binocular camera based on the actual measurement scenario; horizontally mounting the binocular camera on a riverbank, adjusting the pitch angle so that the left and right views cover the water surface area under the full range of water levels, and synchronously acquiring water surface images of the left and right views using the binocular camera; employing an iteratively optimized semi-global stereo matching method to acquire corresponding disparity maps pixel by pixel; based on the calibration results of the binocular camera, utilizing the relationship between disparity and depth to acquire the three-dimensional point cloud coordinate values ​​of the water surface image; performing plane fitting on the point cloud using the RANSAC algorithm to generate a horizontal plane equation; calculating the distance from the optical center of the left camera to the horizontal plane, and converting it based on the camera's elevation to obtain the water level. The present invention enables shore-based instrument deployment, enabling remote water level measurement in an inclined manner. The measurement does not rely on any reference objects contacting the water body, such as a water gauge, and can be implemented immediately in harsh environments such as high flood seasons. The method is particularly suitable for emergency water level monitoring.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of water level measurement using an image method, and in particular to a water level measurement method based on binocular stereo vision. Background Art

[0002] Water level measurement is fundamental to hydrological monitoring of rivers, lakes, and reservoirs. Timely and accurate water level measurement is crucial for refined water resource management and flood disaster warning and forecasting. Existing water level measurement technologies used in hydrological monitoring are primarily categorized into two main types: contact and non-contact. Contact water level gauges primarily include: 1) Float-type water level gauges, which offer excellent stability and reliability and are generally suitable for water level fluctuations within a 40-meter range. However, they require a well logging system, resulting in high construction and maintenance costs and unsuitable for heavily silted channels and sections with gentle slopes. 2) Pressure-type water level gauges, which offer a simpler structure and lower cost, are generally suitable for water level fluctuations within a 20-meter range. However, they are unsuitable for water bodies with high sediment concentrations or for measuring locations such as estuaries, where seawater influences current density and siltation are prevalent. 3) Liquid-medium ultrasonic water level gauges, which are suitable for measuring locations where well logging systems are not feasible, typically require installation at a minimum water level of 0.5 meters. They are unsuitable for silted channels and suffer from temperature and temporal drift. Non-contact water level meters mainly include: 1) Gas-mediated ultrasonic water level meters, which have a simple principle and low cost. They are suitable for installation at a position more than 0.5m above the highest water level. However, it is necessary to ensure that there are no obstructing reflectors within the beam angle range in the direction of the transducer emission. They are not suitable for measuring sections with gentle slopes, and the problems of temperature drift and time drift are more serious. 2) Laser water level meters, which have high ranging accuracy, up to the millimeter level, but require water level logging. 3) Radar water level meters, which have high measurement accuracy, up to the centimeter level, and no obvious temperature drift and time drift problems, but need to be arranged vertically above the measured water body. They are not suitable for measuring sections with gentle slopes, and there must be no obstruction within the radar signal beam angle range. Measurements may be interrupted in rainy and snowy days. 4) Visual water level meter: This mainly identifies the water level reading of a reference object such as a water gauge in the water body and converts it into water level. In principle, it has no temperature drift and time drift problems, can detect at an angle, and the results are intuitive, which is conducive to visual verification. However, water level detection and identification are more sensitive to complex lighting conditions (reflections, glare), weather (fog, heavy rain), and water flow (waves, floating objects) on the water surface. In particular, the surface of the water gauge is easily entangled by floating objects, resulting in measurement failure or even damage to the water gauge, requiring manual wading maintenance. Therefore, it is usually suitable for scenarios with stable installation conditions such as vertical slopes or bridge piers.

[0003] Stereoscopic vision technology stems from the human need for depth perception and the understanding of binocular stereoscopic vision mechanisms. As a key branch of machine vision, it has undergone decades of development since its inception and is now widely used in fields such as industry, medicine, robotics, and virtual reality. Humans perceive the depth and distance of objects in three-dimensional space through the parallax difference between their left and right eyes. Stereoscopic vision technology attempts to mimic this principle of binocular vision to obtain depth information in three-dimensional scenes. This technology uses images of an object captured from different angles. After determining the feature correspondence between the images using stereoscopic vision algorithms such as epipolar constraints and stereo matching, it uses triangulation principles to calculate the spatial geometric information of the object. To address this issue, the present invention provides a water level measurement method based on binocular stereoscopic vision. This method utilizes the parallax principle to recover the three-dimensional coordinates of the water surface from the left and right images. It then measures the distance from the camera to the fitted horizontal plane and converts it into the water level value. Relying solely on the natural features of the water surface, without the need for manually deployed reference structures such as water gauges, it achieves completely non-contact shore-based inclined water level measurement. This simple, low-cost measurement method can effectively meet the needs of water level monitoring in both routine and emergency scenarios, and has great application potential in smart water conservancy, emergency rescue, and other fields.

[0004] In stereo vision applications, the baseline length of a binocular camera directly affects measurement range and accuracy. Therefore, an appropriate baseline length must be determined based on the camera's focal length and the actual detection distance. The core technology behind binocular stereo vision-based water level measurement lies in obtaining an accurate disparity map from the left and right images and utilizing the disparity principle to generate 3D point cloud data. Currently, methods for obtaining disparity maps can be categorized into two main types: traditional stereo matching and deep learning stereo matching. Among them, traditional stereo matching algorithms include PMS (patch match stereo), BM (block matching), Census, etc. Since water surface images are easily affected by optical noise such as mirror reflection, shadow, glare, and ripples, feature extraction and matching of weak texture and repeated texture areas are difficult. Occlusion by slopes, vegetation, and floating objects on the water surface also leads to holes in the generated disparity map or outliers that cannot represent the real water surface. Therefore, it is necessary to fit the point cloud plane after obtaining three-dimensional point cloud data using the disparity map. This is of great significance for obtaining water level values. Classic plane fitting methods include least square method (least square) and eigenvalue method. However, these methods cannot eliminate the influence of outliers on plane fitting, resulting in low horizontal plane fitting accuracy and poor robustness. Although deep learning methods can extract complex global features and contextual information, and have obvious advantages in dealing with mirror reflections, weak textures, or even textureless areas in water environments, there is currently no high-precision disparity map dataset in a real water environment in the field of stereo vision research. As a result, deep learning stereo matching models trained directly using existing land environments and artificially synthesized datasets still have problems such as insufficient generalization ability. Summary of the Invention

[0005] Purpose of the invention: The present invention provides a water level measurement method based on binocular stereo vision, which can optimize the parallax information of repeated texture and weak texture areas of water surface images, and improve the accuracy of water level value acquisition under complex lighting conditions.

[0006] Technical solution: The water level measurement method based on binocular stereo vision described in the present invention includes the following steps:

[0007] Step 1: Select the binocular camera according to the actual measurement scene;

[0008] Step 2: Set up the binocular camera horizontally on the river bank, adjust the pitch angle so that the left and right views can cover the water surface area under the full range of water levels, and use the binocular camera to synchronously obtain the water surface images of the left and right views;

[0009] Step 3: Using the iteratively optimized semi-global SGM stereo matching method, the SAD and Census initial cost values ​​of the water surface image are first calculated pixel by pixel, making full use of the neighborhood information of the pixel points to reduce the brightness anomaly of individual pixels caused by water surface reflection. Then, the initial cost values ​​are aggregated and optimized using the iterative scan line optimization algorithm. Based on the smoothness and continuity of the water surface, the cost values ​​of the weak texture areas are extrapolated from the rich texture areas to obtain the optimized cost values ​​of the left and right water surface images, which improves the matching accuracy of the weak texture areas. The disparity value corresponding to the minimum optimized cost value is selected for each pixel to obtain the initial disparity map. Finally, based on the disparity consistency constraint, the initial disparity value is optimized using consistency detection and sub-pixel optimization methods to output the final disparity map.

[0010] Step 4: Based on the known calibration results of the binocular camera, the three-dimensional point cloud coordinate value corresponding to each pixel of the water surface image is obtained by using the conversion relationship between parallax and depth;

[0011] Step 5: Based on the RANSAC method, the three-dimensional point cloud is processed using plane fitting to generate the horizontal plane equation;

[0012] Step 6: Calculate the distance from the optical center of the left camera to the horizontal plane to obtain the elevation of the water surface relative to the binocular camera.

[0013] Furthermore, in step 1, the binocular stereo vision system is selected according to the actual measurement scene. When the depth measurement distance Z is the minimum measurement distance, in order to ensure that the common field of view of the binocular camera occupies at least r of the left or right field of view, the influence of the binocular camera focal length f and the field of view angle α on the baseline length B is analyzed according to formula (1). From the principle of binocular vision, formula (2) can be obtained. For Z, the independent variable is d, and the partial derivative of d is obtained to obtain formula (3):

[0014]

[0015]

[0016]

[0017] Where d is the parallax, which is multiplied by the parallax accuracy s according to formula (3) d , it is concluded that when the parallax accuracy is one pixel, the focal length f, baseline length B and measurement distance Z have an impact on the depth measurement accuracy s z In actual measurement scenarios, the value range of baseline B is obtained based on the sounding accuracy being less than η.

[0018]

[0019] Furthermore, in step 2, the binocular camera is used to synchronously obtain the water surface images of the left and right views. First, the binocular camera needs to be connected, the measurement time needs to be set, and then the left and right image sequences need to be synchronously captured to obtain the water surface images of the left and right views after epipolar correction.

[0020] Furthermore, water surface images include those with different lighting, water flow, and floating objects to verify the generalization and scene adaptability of the method.

[0021] Furthermore, in step 3, the improved semi-global SGM stereo matching method includes the following steps:

[0022] Step 31: Calculate the initial SAD cost value C of the water surface image pixel by pixel according to formula (5): SAD (p,d):

[0023]

[0024] Where d is the disparity, and I is the grayscale value of the pixel to be measured;

[0025] According to formula (6), the Census transformation value C of the pixel point is obtained s (p):

[0026]

[0027] Where I is the grayscale value at pixel p; Indicates bitwise connection; N p represents the neighborhood of pixel p; the function ξ(I(p),I(q)) is defined by formula (7):

[0028]

[0029] The Hamming distance between two bit strings is used to represent the Census cost of pixel p:

[0030] C Census (p,d)=Hamming(C ls (p),C rs (pd)), d∈[d min ,d max ] (8)

[0031] Calculate the initial cost value of pixel p according to formula (9):

[0032] C(p,d)=ρ(C Census (p,d),λ Census )+ρ(C SAD (p,d),λ SAD ),d∈[d min ,d max ] (9)

[0033] in, is the normalized cost value of pixel p, c is the SAD and Census cost value, and λ is the control parameter;

[0034] Step 32: After obtaining the initial cost value, perform cost optimization processing, adopt the semi-global (SGM) algorithm, combine the optimization method of the global energy function, use the dynamic programming strategy to aggregate the 8-path costs, and perform multiple iterations;

[0035] Step 33: Using the Winner Takes All (WTA) algorithm, the disparity value corresponding to the minimum cost value is selected for each pixel as the initial disparity, and two disparity maps are obtained, the size of which is consistent with the input original image.

[0036] Step 34: Obtain the disparity value D for the pixel point p in the left disparity map p , then the disparity of the corresponding same-name point in the right disparity map is D pd , perform left-right consistency detection on the initial disparity map according to formula (12):

[0037]

[0038] When the disparity value between the same-name point pairs differs by more than 1 pixel, the pixel is marked as an invalid pixel and removed. Then, the sub-pixel optimization technology is used to further improve the disparity accuracy. The disparity optimization result is obtained by the quadratic curve interpolation method according to formula (13), and the final disparity map is output.

[0039]

[0040] Among them, D p is the disparity value of pixel p, C agg (p,d+1) and Cagg (p, d-1) are the aggregation costs of point p when the disparity is d+1 and d-1 respectively.

[0041] Furthermore, in step 32, the 8-path cost aggregation is performed using a dynamic programming strategy, and multiple iterations are performed, specifically including the following steps:

[0042] Step 321: Calculate the aggregation cost C for each of the eight directions. r (p,d);

[0043] Step 322: Get the aggregation cost C of pixel p agg (p,d);

[0044] Step 323: If the upper limit of the number of iterations is reached, go to step 33; otherwise, continue iterating.

[0045]

[0046] Where C1(p,d) is the cost of pixel p when the parallax is d, the second term is the smoothing term, C r (pr,d) refers to the aggregation cost of a pixel along the aggregation direction, C r (pr,d±1) refers to the aggregation cost value when the disparity value along the aggregation direction differs by less than 1 pixel. It refers to the minimum value of all cost values ​​when the disparity value differs by more than 1 pixel. The third item is to ensure that the new path cost value does not exceed a certain value, that is, C r (p,d)≤C max +P2, finally, the aggregation cost of pixel p when the disparity is d is:

[0047]

[0048] Furthermore, in step 4, the three-dimensional coordinate values ​​of the water surface image are calculated according to formula (14):

[0049]

[0050] Where B is the baseline length of the binocular camera, f is the focal length of the binocular camera, and (x, y) is the coordinate of point p in the image coordinate system.

[0051] Furthermore, in step 5, the RANSAC method is used to construct the water surface plane equation, which includes the following steps:

[0052] Step 51: Randomly select three non-collinear points from the water surface three-dimensional point cloud coordinate data set S to determine a preliminary plane model Ax+By+Cz+D=0, where A, B, C, and D are coefficients of the model.

[0053] Step 52: Calculate each other data point s according to formula (15) j ∈S is the distance h from this plane, and a threshold τ is set. If h≤τ, then s j Recorded as interior points, the number of interior points is recorded as M i :

[0054]

[0055] Among them, I is the indicator function, when the condition s j The value is 1 when ≤τ holds, otherwise it is 0, and n is the total number of data in the dataset S;

[0056] Step 53: According to formula (16), if the number of internal points of the current model is M i 'Exceeded the previous maximum number of internal points M i , then the updated optimal model parameters are A'x+B'y+C'z+D'=0;

[0057] Step 54: Repeat the above steps until the preset number of iterations N is reached;

[0058] Step 55. Finally, the model with the largest number of inliers is selected as the final result.

[0059] Furthermore, in step 6, the distance from the optical center of the left camera to the water surface is calculated according to formula (17) to obtain the elevation value:

[0060]

[0061] Beneficial effects: Compared with the existing technology, the present invention has the following significant advantages: the present invention analyzes and selects binocular camera parameters according to requirements such as measurement distance and measurement accuracy to match the actual application scenario; in addition, the present invention has strong anti-interference ability, and meets the needs of immediate measurement under multiple scenarios such as different lighting, water flow, and floating objects, and only requires one binocular camera and processing unit to complete water level measurement; the present invention also optimizes the stereo matching method, adopts a cost calculation method that is more robust to brightness difference and image noise, and optimizes the cost aggregation algorithm to ensure that the algorithm complexity is reduced while effectively reducing the "stripe effect", and iterates the above aggregation method to smooth the aggregation cost, thereby improving the accuracy of the aggregation algorithm and making the obtained water level value more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 Schematic diagram of the method of the present invention.

[0063] Figure 2 Schematic diagram of the relationship between the baseline length and field of view angle of the binocular camera of the present invention.

[0064] Figure 3This is a depth error variation curve obtained by the present invention.

[0065] FIG4( a ) is a left view of a water surface image after epipolar correction.

[0066] FIG4( b ) is a right view of the water surface image after epipolar correction.

[0067] Figure 5 Schematic diagram of the Census cost calculation method of the present invention.

[0068] Figure 6 Schematic diagram of the scan line optimization method of the present invention.

[0069] Figure 7 Schematic diagram of the winner-take-all (WTA) method of the present invention.

[0070] Figure 8 Schematic diagram of the sub-pixel optimization method of the present invention.

[0071] Figure 9 Schematic diagram of the binocular camera system of the present invention.

[0072] Figure 10 Schematic diagram of the plane fitting principle of the present invention.

[0073] Figure 11 This is a layout diagram of the measured scene of the present invention.

[0074] Figure 12 This is the horizontal plane fitting result diagram of the present invention. DETAILED DESCRIPTION

[0075] like Figure 1 As shown, a water level measurement method based on binocular stereo vision includes the following steps:

[0076] S1: Select the binocular stereo vision system according to the actual measurement scene. When the depth measurement distance Z is within the range of 2 to 20m, select According to formula (18), the effect of the binocular camera focal length f = 4 mm and the field of view angle α = 72° on the baseline length is analyzed, as shown in the following example: Figure 2 As shown, the baseline value range is B max ≤1.94m, and according to formula (19), the error analysis of the baseline length B applicable to the measurement distance of 20m is performed to obtain the depth error change curve, as shown in Figure 3 The data shown in Table 1 are as follows. To ensure the measurement accuracy is within 2 cm, take B min =0.83m, and combined with formula (18), the baseline value range is 0.83m≤B≤1.94m;

[0077]

[0078]

[0079] Table 1 Depth error changes with baseline length

[0080]

[0081] S2: If Figure 9 As shown in Figure 4, the water surface images of the left and right views are synchronously acquired using a binocular camera. First, the binocular camera needs to be connected, the measurement time needs to be set, and then the left and right image sequences need to be synchronously captured. The water surface images of the left and right views after epipolar correction are obtained as shown in Figure 4(a) and Figure 4(b).

[0082] S3: The semi-global (SGM) stereo matching method based on iterative optimization includes the following steps:

[0083] S3.1: Calculate the initial SAD cost value C of the water surface image pixel by pixel according to formula (20) SAD (p,d):

[0084]

[0085] Where d is the disparity, and I is the grayscale value of the pixel to be measured.

[0086] According to formula (21), the Census transformation value C of the pixel point is obtained s (p):

[0087]

[0088] Where I is the grayscale value at pixel p; Indicates bitwise connection; N p represents the neighborhood of pixel p; the function ξ(I(p),I(q)) is defined by formula (22):

[0089]

[0090] The Hamming distance between two bit strings is used to represent the Census cost of pixel p, such as Figure 5 As shown:

[0091] C Census (p,d)=Hamming(C ls (p),C rs (pd)), d∈[d min ,d max ] (twenty three)

[0092] Calculate the initial cost value of pixel p according to formula (24):

[0093] C(p,d)=ρ(C Census (p,d),λ Census )+ρ(C SAD (p,d),λ SAD ),d∈[d min ,d max ] (twenty four)

[0094] in, is the normalized cost value of pixel p, c is the SAD and Census cost value, and λ is the control parameter.

[0095] S3.2: After obtaining the initial cost value, the cost value is optimized. The semi-global (SGM) algorithm is used. By combining the optimization method of the global energy function, the dynamic programming strategy is used to aggregate the 8-path costs, such as Figure 6 As shown, multiple iterations are performed, and the iterative steps are as follows:

[0096] (1) Calculate the aggregation cost C for each of the eight directions r (p,d);

[0097] (2) Get the aggregation cost C of pixel p agg (p,d);

[0098] (3) If the upper limit of the number of iterations is reached, go to S3.3, otherwise continue iterating;

[0099]

[0100] Where C1(p,d) is the cost of pixel p when the parallax is d, the second term is the smoothing term, C r (pr,d) refers to the aggregation cost of a pixel along the aggregation direction, C r (pr,d±1) refers to the aggregation cost value when the disparity value along the aggregation direction differs by less than 1 pixel. It refers to the minimum value of all cost values ​​when the disparity value differs by more than 1 pixel. The third item is to ensure that the new path cost value does not exceed a certain value, that is, C r (p,d)≤C max +P2. Finally, the aggregation cost of pixel p when the disparity is d is:

[0101]

[0102] S3.3: Use the Winner Takes All (WTA) algorithm to select the disparity value corresponding to the minimum cost value for each pixel as the initial disparity, and obtain the left and right disparity maps, whose sizes are consistent with the input original image, such as Figure 7 shown.

[0103] S3.4: Obtain the disparity value D for the pixel point p in the left disparity map p , then the disparity of the corresponding same-name point in the right disparity map is D pd , perform left-right consistency detection on the initial disparity map according to formula (27):

[0104]

[0105] When the disparity value between the same-name point pairs exceeds 1 pixel, the pixel is marked as an invalid pixel and removed. Sub-pixel optimization technology is then used to further improve the disparity accuracy, such as Figure 8 As shown, according to formula (28), the disparity optimization result is obtained by the quadratic curve interpolation method, and the final disparity map is output.

[0106]

[0107] Among them, D p is the disparity value of pixel p, C agg (p,d+1) and C agg (p, d+1) are the aggregation costs of point p when the disparity is d+1 and d-1 respectively.

[0108] S4: Calculate the three-dimensional coordinate values ​​of the water surface image according to formula (29):

[0109]

[0110] Where B = 0.120m is the baseline length of the binocular camera, f is the focal length of the binocular camera, and (x, y) is the coordinate of point p in the image coordinate system.

[0111] S5: Use the RANSAC method to construct the water surface plane equation, including the following steps:

[0112] S5.1: Randomly select three non-collinear points from the water surface 3D point cloud coordinate dataset S to determine a preliminary plane model Ax+By+Cz+D=0, where A, B, C, and D are the coefficients of the model;

[0113] S5.2: Each other data point s j ∈S is the distance h from this plane, and a threshold τ is set. If h≤τ, then s j The number of interior points is denoted as M i :

[0114]

[0115] S5.3: If the number of inliers in the current model is M i 'Exceeded the previous maximum number of internal points M i , then update the optimal model parameters;

[0116] S5.4: Repeat the above steps until the preset number of iterations N=100 is reached;

[0117] S5.5: Finally, the model with the largest number of inliers is selected as the final result, and the plane equation 1.00y-0.01z+1.06=0 is obtained, which corresponds to the first measured elevation value in Table 1. The schematic diagram is shown as follows Figure 10 shown.

[0118] S6: Calculate the distance from the optical center of the left camera to the water surface according to formula (31) to obtain the elevation value H. Calculate the water level value according to the camera position relationship, as follows: Figure 11 Finally, the measurement result is compared with the true value of the water level by formula (32). The test result with a difference of less than 5% is marked as valid, that is, the test result is considered reliable. Otherwise, the test result is considered invalid, and the test result can be corrected later based on this result.

[0119]

[0120]

[0121] Among them, H real This is the distance from the camera to the water surface.

[0122] To test the effectiveness of the method for water level detection, a scene with a water level of 1-5m was selected for testing. The test used the average of three elevation values ​​measured by the laser rangefinder as the reference true value. The measurement results are shown in Table 2. The relative error is controlled within 3%. The visualization results of the fitted horizontal plane are shown in Figure 12 shown.

[0123] Table 2 Relative error of measurement results within 1-5m

[0124]

Claims

1. A water level measurement method based on binocular stereo vision, characterized in that: The steps include: Step 1: Select the binocular camera according to the actual measurement scene; Step 2: Set up the binocular camera horizontally on the river bank, adjust the pitch angle so that the left and right views can cover the water surface area under the full range of water levels, and use the binocular camera to synchronously obtain the water surface images of the left and right views; Step 3: Using the iteratively optimized semi-global SGM stereo matching method, the SAD and Census initial cost values ​​of the water surface image are first calculated pixel by pixel, making full use of the neighborhood information of the pixel points to reduce the brightness anomaly of individual pixels caused by water surface reflection. Then, the initial cost values ​​are aggregated and optimized using the iterative scan line optimization algorithm. Based on the smoothness and continuity of the water surface, the cost values ​​of the weak texture areas are extrapolated from the rich texture areas to obtain the optimized cost values ​​of the left and right water surface images, which improves the matching accuracy of the weak texture areas. The disparity value corresponding to the minimum optimized cost value is selected for each pixel to obtain the initial disparity map. Finally, based on the disparity consistency constraint, the initial disparity value is optimized using consistency detection and sub-pixel optimization methods to output the final disparity map. Step 4: Based on the known calibration results of the binocular camera, the three-dimensional point cloud coordinate value corresponding to each pixel of the water surface image is obtained by using the conversion relationship between parallax and depth; Step 5: Based on the RANSAC method, the three-dimensional point cloud is processed using plane fitting to generate the horizontal plane equation; Step 6: Calculate the distance from the optical center of the left camera to the horizontal plane to obtain the elevation of the water surface relative to the binocular camera.

2. The water level measurement method based on binocular stereo vision according to claim 1, wherein: In step 1, the binocular stereo vision system is selected according to the actual measurement scene. When the depth measurement distance Z is the minimum measurement distance, in order to ensure that the common field of view of the binocular camera occupies at least r of the left or right field of view, the influence of the binocular camera focal length f and the field of view angle α on the baseline length B is analyzed according to formula (1). Formula (2) is obtained from the principle of binocular vision. For Z, the independent variable is d, and the partial derivative of d is obtained to obtain formula (3): Where d is the parallax, which is multiplied by the parallax accuracy s according to formula (3) d , it is concluded that when the parallax accuracy is one pixel, the focal length f, baseline length B and measurement distance Z have an impact on the depth measurement accuracy s z In actual measurement scenarios, the value range of baseline B is obtained based on the sounding accuracy being less than η.

3. The water level measurement method based on binocular stereo vision according to claim 1, wherein: In step 2, a binocular camera is used to synchronously acquire the left and right water surface images. First, the binocular camera needs to be connected, the measurement time needs to be set, and then the left and right image sequences need to be synchronously captured to obtain the left and right water surface images after epipolar correction.

4. The water level measurement method based on binocular stereo vision according to claim 3, wherein: Water surface images include those with different lighting, water flow, and floating objects to verify the generalization and scene adaptability of the method.

5. The water level measurement method based on binocular stereo vision according to claim 1, wherein: In step 3, the improved semi-global SGM stereo matching method includes the following steps: Step 31: Calculate the initial SAD cost value C of the water surface image pixel by pixel according to formula (5): SAD (p,d): Where d is the disparity, and I is the grayscale value of the pixel to be measured; According to formula (6), the Census transformation value C of the pixel point is obtained s (p): Where I is the grayscale value at pixel p; Indicates bitwise connection; N p represents the neighborhood of pixel p; the function ξ(I(p),I(q)) is defined by formula (7): The Hamming distance between two bit strings is used to represent the Census cost of pixel p: C Census (p,d)=Hamming(C ls (p),C rs (p-d)),d∈[d min ,d max ] (8) Calculate the initial cost value of pixel p according to formula (9): C(p,d)=ρ(C Census (p,d),λ Census )+ρ(C SAD (p,d),λ SAD ),d∈[d min ,d max ] (9) in, is the normalized cost value of pixel p, c is the SAD and Census cost value, and λ is the control parameter; Step 32: After obtaining the initial cost value, perform cost optimization processing, using a semi-global SGM algorithm, combining the optimization method of the global energy function, and using a dynamic programming strategy to aggregate the 8-path costs, and perform multiple iterations; Step 33: Using the Winner Takes All (WTA) algorithm, the disparity value corresponding to the minimum cost value is selected for each pixel as the initial disparity, and two disparity maps are obtained, the size of which is consistent with the input original image. Step 34: Obtain the disparity value D for the pixel point p in the left disparity map p , then the disparity of the corresponding same-name point in the right disparity map is D pd , perform left-right consistency detection on the initial disparity map according to formula (12): When the disparity value between the same-name point pairs differs by more than 1 pixel, the pixel is marked as an invalid pixel and removed. Then, the sub-pixel optimization technology is used to further improve the disparity accuracy. The disparity optimization result is obtained by the quadratic curve interpolation method according to formula (13), and the final disparity map is output. Among them, D p is the disparity value of pixel p, C agg (p,d+1) and C agg (p, d-1) are the aggregation costs of point p when the disparity is d+1 and d-1 respectively.

6. The water level measurement method based on binocular stereo vision according to claim 5, characterized in that: In step 32, the 8-path cost aggregation is performed using a dynamic programming strategy and multiple iterations are performed. Specifically, the following steps are included: Step 321: Calculate the aggregation cost C for each of the eight directions. r (p,d); Step 322: Get the aggregation cost C of pixel p agg (p,d); Step 323: If the upper limit of the number of iterations is reached, go to step 33; otherwise, continue iterating. Where C1(p,d) is the cost of pixel p when the parallax is d, the second term is the smoothing term, C r (pr,d) refers to the aggregation cost of a pixel along the aggregation direction, C r (pr,d±1) refers to the aggregation cost value when the disparity value along the aggregation direction differs by less than 1 pixel. It refers to the minimum value of all cost values ​​when the disparity value differs by more than 1 pixel. The third item is to ensure that the new path cost value does not exceed a certain value, that is, C r (p,d)≤C max +P2, finally, the aggregation cost of pixel p when the disparity is d is:

7. The water level measurement method based on binocular stereo vision according to claim 1, characterized in that: In step 4, the three-dimensional coordinate values ​​of the water surface image are calculated according to formula (14): Where B is the baseline length of the binocular camera, f is the focal length of the binocular camera, and (x, y) is the coordinate of point p in the image coordinate system.

8. The water level measurement method based on binocular stereo vision according to claim 1, wherein: In step 5, the RANSAC method is used to construct the water surface plane equation, which includes the following steps: Step 51: Randomly select three non-collinear points from the water surface three-dimensional point cloud coordinate data set S to determine a preliminary plane model Ax+By+Cz+D=0, where A, B, C, and D are coefficients of the model. Step 52: Calculate each other data point s according to formula (15) j ∈S is the distance h from this plane, and a threshold τ is set. If h≤τ, then s j Recorded as interior points, the number of interior points is recorded as M i : Among them, I is the indicator function, when the condition s j The value is 1 when ≤τ holds, otherwise it is 0, and n is the total number of data in the dataset S; Step 53: According to formula (16), if the number of internal points of the current model is M i 'Exceeded the previous maximum number of internal points M i , then the updated optimal model parameters are A'x+B'y+C'z+D'=0; Step 54: Repeat the above steps until the preset number of iterations N is reached; Step 55. Finally, the model with the largest number of inliers is selected as the final result.

9. The water level measurement method based on binocular stereo vision according to claim 1, wherein: In step 6, the distance from the optical center of the left camera to the water surface is calculated according to formula (17) to obtain the elevation value:

Citation Information

Patent Citations

  • Underwater point cloud acquisition method based on binocular camera

    CN111563921A

  • Binocular camera-based ship height measurement system and method

    CN113223075A