Water flow velocity estimation method and system based on traditional optical flow calculation

CN117576168BActive Publication Date: 2026-09-22ECCOM NETWORK SYST CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311525100.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-15
Publication Date
2026-09-22
Estimated Expiration
2043-11-15

AI Technical Summary

Technical Problem

[0006]专利文献CN115690154A(申请号:202211324411.7)公开了一种低水流速检测方法及电子设备,属于水流测速的技术领域,解决了现有技术在低流速或水面特征较少的场景下存在流速检测不精准的技术问题

Benefits of technology

[0114]1、本发明提供了一整套完整的水流速度估计算法的实现流程,通过改进的lk光流追踪算法实现标准模式下水流特征点的高效追踪与劣质特征点的剔除;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117576168B_ABST
    Figure CN117576168B_ABST
Patent Text Reader

Abstract

The application provides a water flow velocity estimation method and system based on traditional optical flow calculation, comprising the following steps: S1, acquiring water flow images {Img0, Img1,..., Imgn} continuously; S2, pre-processing the acquired images to obtain pre-processed images; S3, drawing a velocity measuring line, the direction of the velocity measuring line being consistent with the water flow direction; S4, calculating the motion vector optical flow field of the images based on the pre-processed images, and screening the motion vectors according to the direction of the velocity measuring line to obtain effective motion vectors; S5, calibrating the camera to obtain the camera focal length, and keeping the parameters of the camera unchanged after calibration; S6, measuring the scale of any point on the image according to the camera calibration result; S7, estimating the actual distance of motion according to the motion vector coordinates of the optical flow tracking and the scale; S8, measuring the actual distance of water flow motion, and calculating the final water flow velocity based on the actual distance of water flow motion and the motion time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of hydrological water flow velocity detection technology, specifically to a method and system for estimating water flow velocity based on traditional optical flow calculation. Background Technology

[0002] my country has a vast territory with numerous rivers and mountains, and the effective utilization of water resources is of great significance to my country's economic development. However, abundant water resources are often accompanied by the threat of floods. While natural environment and topography are unchangeable, effective supervision and control measures, along with early warning systems, can significantly reduce the losses and dangers caused by floods during the development and utilization of water resources.

[0003] As an important type of hydrological information, water flow velocity is the foundation for research on calculating river flow estimation. The estimation and measurement of river flow velocity has always been a hot topic in the water conservancy industry.

[0004] Traditional methods for measuring water flow velocity include not only the buoy method but also current meter measurement and gradient area method. However, these methods are often only applicable to specific scenarios and require manual on-site measurement, lacking safety and convenience. Nowadays, with the development of wireless network cameras and video surveillance technology, intelligent monitoring plays a role in more and more fields, and in many cases, it can even replace manual labor, greatly reducing manpower costs while improving efficiency and safety in production and daily life. Against this backdrop, flow velocity measurement technology based on video surveillance has been widely studied both domestically and internationally.

[0005] In various image-based velocimetry methods, motion estimation based on optical flow computation can reduce measurement costs and enable long-term real-time measurements. Inspired by traditional rigid body motion tracking and detection, this invention applies the conventional sparse optical flow algorithm to calculate the velocity of water surface flow without auxiliary conditions, proposing a water flow velocity estimation algorithm based on traditional optical flow computation.

[0006] Patent document CN115690154A (application number: 202211324411.7) discloses a low water flow velocity detection method and electronic device, belonging to the technical field of water flow velocity measurement. It solves the technical problem of inaccurate flow velocity detection in existing technologies under low flow velocity or with few water surface features. The low water flow velocity detection method includes: calibrating the camera's intrinsic parameters at different zoom levels to obtain a relationship function between zoom and intrinsic parameters; performing dense optical flow tracking between each two adjacent frames in a multi-frame continuous image to obtain multiple pairs of matching feature points; generating the motion trajectory of each pixel in the multi-frame continuous image based on these matching feature points; based on the motion trajectory of each pixel in the multi-frame continuous image, sequentially performing slope filtering and clustering filtering on the matching feature points of the first and last frames to obtain filtered matching feature points; and converting the image coordinates of the filtered matching feature points into world coordinates based on the relationship function between zoom and intrinsic parameters. This patent uses dense optical flow to track the motion trajectory of pixels and filters high-quality feature trajectories through the slope and clustering methods of the motion trajectory. Regarding camera calibration, this patent calibrates the camera at different zoom levels, obtaining the relationship function between camera zoom and intrinsic parameters, and then maps the image coordinates to world coordinates. This invention uses sparse optical flow tracing, which is faster than dense optical flow tracing algorithms. In feature point selection, it not only uses reverse tracking to eliminate unstable feature points but also manually draws velocity measurement lines to guide the direction of water flow, filtering out interfering motion vectors, improving tracking accuracy and reducing the influence of external factors on water flow velocity measurement. In terms of camera calibration, this invention obtains the camera's intrinsic focal length in a single calibration and can be used in multiple scenarios, eliminating the need for scene-by-scene calibration and reducing labor costs. Summary of the Invention

[0007] To address the shortcomings of existing technologies, the purpose of this invention is to provide a method and system for estimating water flow velocity based on traditional optical flow calculation.

[0008] A method for estimating water flow velocity based on traditional optical flow calculation provided by the present invention includes:

[0009] Step S1: Acquire continuous water flow images {Img0,Img1,...,Imgn} from the video;

[0010] Step S2: Preprocess the acquired image to obtain the preprocessed image;

[0011] Step S3: Draw a velocity measurement line, with the direction of the velocity measurement line consistent with the direction of water flow;

[0012] Step S4: Calculate the motion vector optical flow field of the image based on the preprocessed image, and filter the motion vectors according to the direction of the velocity line to obtain the effective motion vectors;

[0013] Step S5: Calibrate the camera to obtain the camera focal length, and keep all camera parameters unchanged after calibration;

[0014] Step S6: Calculate the scale of any point on the image based on the camera calibration results;

[0015] Step S7: Estimate the actual distance of the motion based on the motion vector coordinates and scale of the optical flow tracing;

[0016] Step S8: Calculate the actual distance of the water flow based on the actual distance, and calculate the final water flow velocity based on the actual distance of the water flow and the movement time.

[0017] Preferably, step S2 involves performing noise reduction and enhancement processing on the image, including image grayscale conversion, median filtering, and histogram equalization.

[0018] Preferably, step S3 employs the following methods:

[0019] A velocity measurement line L:(P0,P1) is drawn along the direction of water flow, and the direction of the optical flow field vector is calibrated using the velocity measurement line; where P0 represents the coordinates of the starting point of the velocity measurement line, and P1 represents the coordinates of the ending point; the rotation angle θ of the velocity measurement line is:

[0020]

[0021] Preferably, step S4 employs the following methods:

[0022] Step S4.1: Perform corner detection on the previous frame image Img0 to obtain the corner set FP0{p00,p01,...,p0n};

[0023] Step S4.2: Track the corner point set FP0 detected in image Img0 one by one on the second frame image Img1 to obtain the tracking corner point set FP1{p10,p11,...,p1n};

[0024] Step S4.3: Perform sparse optical flow tracing on the corner set FP1 tracked in image Img1 on image Img0 in reverse order to obtain the verification corner set PF0r{pr0,pr1,...,prn} on image Img0;

[0025] Step S4.4: Calculate whether the Euclidean distance D{d0,d1,...,dn} between the corresponding corner points of the detection corner point set FP0 and the verification corner point set FP0r on image Img0 is greater than the preset threshold T. If it is, the corner point is determined to be a poor tracking point, and the corresponding corner points in FP0 and FP1 are deleted to obtain the filtered (FP0',FP1') point pairs.

[0026] Step S4.5: Based on the filtered (FP0',FP1') point pairs, construct the motion vector set {(p00',p10'),(p01',p11'),...,(p0n',p1n')} for the two frames of images; the Euclidean distance of each point pair is the pixel distance of the point's motion;

[0027] Step S4.6: Calculate the rotation angle p_θ of each group of motion vectors (p0n', p1n'). If the difference between p_θ and the rotation angle θ of the velocity measuring line is greater than the preset threshold, then the group of motion vectors is determined to be an interference vector, and the current group of motion vectors is deleted.

[0028] Step S4.7: The filtered motion vectors are valid motion vectors, and the Euclidean distance of each group of motion vectors is estimated as the pixel distance of the point's movement.

[0029] Preferably, step S5 employs the following methods:

[0030] Step S5.1: Draw an equal four-square grid on a flat white paper and record the actual length and width (Wr, Hr) of a single-square grid;

[0031] Step S5.2: Lay the paper flat on the table, take a vertical picture of the paper with the camera to obtain a calibration image, and record the vertical distance d between the camera and the paper;

[0032] Step S5.3: Perform contour detection on the calibration image to obtain the pixel length and width of each cell {(w0,h0),(w1,h1),(w2,h2),(w3,h3)}; calculate the average length and width (w,h) of the next cell in the pixel coordinate system by calculating the average value of the pixel length and width of each cell.

[0033] Step S5.4: Calculate the camera focal length F based on the principle of similar triangles and the focal length calculation formula;

[0034] or

[0035] Preferably, step S6 employs the following methods:

[0036] Step S6.1: Calculate the offset angle angle_y of any point P on the video relative to the center of the field of view in the y-direction;

[0037]

[0038] Where F represents the camera's calibrated focal length, and y represents the y-coordinate of point P;

[0039] Step S6.2: Calculate the offset angle angle_x of point P relative to the center of the field of view in the x-direction; the offset angle has positive and negative values. In the camera coordinate system, if the camera is offset in the positive x-direction, then the positive x-direction is positive, and the negative x-direction is negative.

[0040]

[0041] Where θ_x represents the horizontal offset angle of the camera;

[0042] Step S6.3: Calculate the focal length_y of point P in the y-direction;

[0043]

[0044] Step S6.4: Calculate the focal length of point P;

[0045]

[0046] Step S6.5: Calculate the offset angles angle_x_real and angle_y_real of point P relative to the camera in the x and y directions, respectively;

[0047] angle_x_real=θ_x+angle_x

[0048] angle_y_real=θ_y+angle_y

[0049] Where θ_y represents the vertical offset angle of the camera;

[0050] Step S6.6: The actual depth of point P in the y-direction, real_distance_y;

[0051]

[0052] Step S6.7: Calculate the actual depth real_distance of point P;

[0053]

[0054] Step S6.8: The final scale of point P is focal_length:real_distance.

[0055] Preferably, step S7 involves estimating the actual distance of the motion vector by treating the scale of the center point of the motion vector as the entire vector scale.

[0056] Preferably, step S8 employs the following methods:

[0057] Step S8.1: Estimate the actual distance for each valid motion vector to obtain the actual motion distance D{d0,d1,...,dn} of the feature point. Take the average of all actual motion distances as the actual distance D of the water flow during this period.

[0058] Step S8.2: Calculate the actual motion time of the two frames;

[0059]

[0060] A water flow velocity estimation system based on traditional optical flow calculation provided by the present invention includes:

[0061] Module M1: Acquires continuous video images of water flow {Img0,Img1,...,Imgn};

[0062] Module M2: Preprocesses the acquired image to obtain a preprocessed image;

[0063] Module M3: Draw the velocity measurement line, with the direction of the velocity measurement line consistent with the direction of water flow;

[0064] Module M4: Calculates the motion vector optical flow field of the image based on the preprocessed image, and filters the motion vectors according to the direction of the velocity line to obtain the effective motion vectors;

[0065] Module M5: calibrates the camera to obtain the camera focal length and keeps all camera parameters unchanged after calibration;

[0066] Module M6: Calculates the scale of any point on the image based on the camera calibration results;

[0067] Module M7: Estimates the actual distance of motion based on the motion vector coordinates and scale of optical flow tracing;

[0068] Module M8: Calculates the actual distance of the water flow based on the actual distance measured, and calculates the final water flow velocity based on the actual distance of the water flow and the movement time.

[0069] Preferably, module M2 employs image denoising and enhancement processing including image grayscale conversion, median filtering, and histogram equalization;

[0070] The module M3 adopts:

[0071] A velocity measurement line L:(P0,P1) is drawn along the direction of water flow, and the direction of the optical flow field vector is calibrated using the velocity measurement line; where P0 represents the coordinates of the starting point of the velocity measurement line, and P1 represents the coordinates of the ending point; the rotation angle θ of the velocity measurement line is:

[0072]

[0073] The module M4 adopts:

[0074] Module M4.1: Performs corner detection on the previous frame image Img0 to obtain the corner set FP0{p00,p01,...,p0n};

[0075] Module M4.2: On the second frame image Img1, the corner point set FP0 detected in image Img0 is tracked one by one to obtain the tracked corner point set FP1{p10,p11,...,p1n};

[0076] Module M4.3: Performs sparse optical flow tracing on the corner set FP1 tracked in image Img1 on image Img0 in reverse order to obtain the verification corner set PF0r{pr0,pr1,...,prn} on image Img0;

[0077] Module M4.4: Calculate whether the Euclidean distance D{d0,d1,...,dn} between the corresponding corner points of the detection corner point set FP0 and the verification corner point set FP0r on image Img0 is greater than a preset threshold T. If so, the corner point is determined to be a poor tracking point, and the corresponding corner point in FP0 and FP1 is deleted to obtain the filtered (FP0',FP1') point pair.

[0078] Module M4.5: Based on the filtered (FP0',FP1') point pairs, a motion vector set {(p00',p10'),(p01',p11'),...,(p0n',p1n')} is constructed for two frames of images; the Euclidean distance of each point pair is the pixel distance of the point's motion;

[0079] Module M4.6: Calculate the rotation angle p_θ of each group of motion vectors (p0n', p1n'). If the difference between p_θ and the rotation angle θ of the velocity measuring line is greater than the preset threshold, the group of motion vectors is determined to be an interference vector and the current group of motion vectors is deleted.

[0080] Module M4.7: The filtered motion vectors are valid motion vectors, and the Euclidean distance of each group of motion vectors is estimated as the pixel distance of the point's movement;

[0081] The module M5 adopts:

[0082] Module M5.1: Draw an equal four-square grid on a flat white paper and record the actual length and width (Wr, Hr) of a single-square grid;

[0083] Module M5.2: Lay the paper flat on the table, and the camera takes a vertical picture of the paper to obtain a calibration image, and records the vertical distance d between the camera and the paper;

[0084] Module M5.3: Perform contour detection on the calibration image to obtain the pixel length and width of each cell {(w0,h0),(w1,h1),(w2,h2),(w3,h3)}; calculate the average length and width (w,h) of the next cell in the pixel coordinate system by averaging the pixel length and width of each cell.

[0085] Module M5.4: Determines the camera focal length F based on the principle of similar triangles and the focal length calculation formula;

[0086] or

[0087] The module M6 adopts:

[0088] Module M6.1: Calculates the y-axis offset angle_y of any point P on the video relative to the center of the field of view;

[0089]

[0090] Where F represents the camera's calibrated focal length, and y represents the y-coordinate of point P;

[0091] Module M6.2: Calculates the offset angle angle_x of point P relative to the center of the field of view in the x-direction; the offset angle is positive and negative. In the camera coordinate system, if the camera is offset in the positive x-direction, then the positive x-direction is positive, and the negative x-direction is negative.

[0092]

[0093] Where θ_x represents the horizontal offset angle of the camera;

[0094] Module M6.3: Calculates the focal length_y of point P in the y-direction;

[0095]

[0096] Module M6.4: Calculates the focal length of point P;

[0097]

[0098] Module M6.5: Calculate the offset angles angle_x_real and angle_y_real of point P relative to the camera in the x and y directions, respectively;

[0099] angle_x_real=θ_x+angle_x

[0100] angle_y_real=θ_y+angle_y

[0101] Where θ_y represents the vertical offset angle of the camera;

[0102] Module M6.6: The actual depth of point P in the y-direction, real_distance_y;

[0103]

[0104] Module M6.7: Calculates the actual depth of point P, real_distance;

[0105]

[0106] Module M6.8: The final scale for the location of point P is focal_length:real_distance;

[0107] The module M7 uses the following method: it treats the scale of the center point of the motion vector as the entire vector scale to estimate the actual distance of the motion vector;

[0108] The module M8 adopts:

[0109] Module M8.1: Estimate the actual distance for each valid motion vector to obtain the actual motion distance D{d0,d1,...,dn} of the feature point, and take the average of all actual motion distances as the actual distance D of the water flow during that time period;

[0110] Module M8.2: Calculates the actual motion time of two frames of images;

[0111]

[0112] Where fps represents the video frame rate; F n F0 represents the frame number of the nth frame, and F0 represents the frame number of the 0th frame.

[0113] Compared with the prior art, the present invention has the following beneficial effects:

[0114] 1. This invention provides a complete implementation process for a water flow velocity estimation algorithm, which achieves efficient tracking of water flow feature points and removal of inferior feature points in standard mode through an improved LK optical flow tracing algorithm;

[0115] 2. In response to abnormal weather conditions such as heavy rain and strong winds, this invention constructively sets up manually drawn speed measurement lines to accurately eliminate motion vectors in abnormal directions, and specifically solves the impact of external factors such as water surface ripples, waves, and rapid currents on water flow estimation.

[0116] 3. At the application level, in order to reduce calibration costs, this invention improves the camera calibration process based on the axiom of similar triangles and the camera focal length calculation formula. The improved process has higher requirements for the accuracy of input parameters, but lower calibration costs. Attached Figure Description

[0117] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:

[0118] Figure 1 This is a flowchart of a water flow velocity estimation method based on traditional optical flow calculation.

[0119] Figure 2 This is a schematic diagram for calculating the scale. Detailed Implementation

[0120] The present invention will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present invention, but do not limit the invention in any way. It should be noted that those skilled in the art can make several changes and improvements without departing from the concept of the present invention. These all fall within the protection scope of the present invention.

[0121] Example 1

[0122] To reduce the impact of external factors on water flow velocity measurement technology based on video analysis and improve the accuracy of water flow velocity estimation and detection methods, a water flow velocity estimation method and system based on traditional optical flow calculation is proposed.

[0123] This invention estimates water flow velocity based on sparse optical flow tracing algorithms, camera calibration algorithms, and actual distance measurement algorithms. The water flow velocity estimation method based on traditional optical flow calculation, such as... Figure 1 As shown, it includes:

[0124] Image input steps: Take two adjacent consecutive water flow images Img0 and Img1 from the video, record the corresponding frame numbers F0 and F1, and the video frame rate fps;

[0125] Image preprocessing steps: Image denoising and enhancement are performed using image grayscale conversion, median filtering, and histogram equalization;

[0126] Steps for drawing speed measurement lines: Draw the speed measurement lines manually, ensuring that the direction of the speed measurement lines is consistent with the direction of water flow.

[0127] Lk sparse optical flow tracing steps: Use the sparse optical flow tracing algorithm to calculate the motion vector optical flow field of two frames of images, and filter the motion vectors according to the direction of the velocity line to obtain the effective motion vectors.

[0128] Camera calibration steps: Calibrate the camera to obtain the camera focal length, and keep all camera parameters unchanged after calibration.

[0129] Steps for calculating the scale: Calculate the scale (pixel distance: actual distance) of any point on the image based on the camera calibration results.

[0130] Actual distance calculation steps: Estimate the actual distance of motion based on the motion vector coordinates of optical flow tracing and the scale calculation method.

[0131] Water flow velocity estimation steps: Calculate the actual distance of the water flow based on the actual distance, and then divide it by the flow time to obtain the final water flow velocity within that time period.

[0132] The image input step includes:

[0133] The optical flow tracing algorithm calculates the velocity and direction of motion of each target in an image between consecutive frames. Therefore, it is necessary to prepare at least two consecutive or adjacent water flow images as input {Img0,Img1,...,Imgn}, and record the frame number {F0,F1,...,Fn} of each input image, as well as the video frame rate fps. Then, the actual motion time of the two frames is T(0,n):

[0134]

[0135] The step of delineating the velocity measurement line includes: delineating the velocity measurement line L: (P0, P1) along the water flow direction to calibrate the direction of the optical flow field vector, thereby reducing the influence of external information such as wind, ripples, and waves on the velocity measurement. Here, P0 represents the coordinates of the starting point of the velocity measurement line, and P1 represents the coordinates of the ending point. The rotation angle θ of the velocity measurement line is then:

[0136]

[0137] The Lk sparse optical flow tracing steps include:

[0138] In video moving object tracking, sparse optical flow tracking is a classic algorithm that can plot the tracking trajectory and direction of motion of moving objects. This invention uses an improved sparse optical flow tracking algorithm to track water flow features. The specific implementation steps are as follows:

[0139] Step 4.1: Take the two consecutive frames of water flow images associated with each other in the input image, and denote them as Img0 and Img1;

[0140] Step 4.2: Perform grayscale conversion and necessary image denoising and enhancement preprocessing on the image; specifically, use median filtering for image denoising and histogram equalization for image enhancement.

[0141] Step 4.3: Use the Shi-Tomasi corner detection algorithm to detect corners in the previous frame image Img0 to obtain the corner set FP0{p00,p01,...,p0n};

[0142] Step 4.4: Use the sparse optical flow tracing algorithm to trace the corner point set FP0 detected by Img0 one by one on the second frame image Img1 to obtain the tracing corner point set FP1{p10,p11,...,p1n};

[0143] Step 4.5: To verify the accuracy of corner tracking, sparse optical flow tracking is performed on the corner set FP1 tracked by Img1 on Img0 in reverse to obtain the verification corner set PF0r{pr0,pr1,...,prn} on Img0;

[0144] Step 4.6: Calculate whether the Euclidean distance D{d0,d1,...,dn} between the corresponding corner points in the detection corner point set FP0 and the verification corner point set FP0r on Img0 is greater than the specified threshold T, where T can be set by the user; if so, the corner point is determined to be a poor tracking point, and the corresponding corner point in FP0 and FP1 is deleted.

[0145] Step 4.7: The (FP0',FP1') point pairs filtered in Step 4.6 constitute the motion vector set {(p00',p10'),(p01',p11'),...,(p0n',p1n')} of the two frames. The Euclidean distance of each point pair is the pixel distance of the point's motion.

[0146] Step 4.8: Calculate the rotation angle p_θ of each group of motion vectors (p0n', p1n'). If the difference between p_θ and the rotation angle θ of the velocity measuring line is greater than the specified threshold, that is, there is a huge difference between the direction of the motion vector and the direction of the velocity measuring line. The threshold can be specified by yourself. Then the group of motion vectors is determined to be interference vectors and is removed.

[0147] Step 4.9: The motion vectors filtered in Step 4.8 are valid motion vectors. The Euclidean distance of each set of motion vectors can be estimated as the pixel distance of the point's movement.

[0148] The camera calibration steps include:

[0149] Motion tracked by lk sparse optical flow is pixel-level motion. The optical flow vector length only represents the pixel distance of the motion, not the actual motion distance. Therefore, it is necessary to map pixel coordinates to real-world coordinates to obtain the actual motion distance. This invention proposes an improved camera calibration algorithm based on the well-known principle of similar triangles and the camera's focal length calculation formula to achieve the mapping from pixel coordinates to real-world coordinates. The specific implementation steps are as follows:

[0150] Step 5.1: Draw an equal four-square grid on a flat white paper. Alternatively, you can use a calibration board directly and record the actual length and width (Wr, Hr) of a single square.

[0151] Step 5.2: Lay the paper flat on the table, take a vertical picture of the paper with the camera to obtain a calibration image, and record the vertical distance d between the camera and the paper.

[0152] Step 5.3: Perform contour detection on the calibration image to obtain the pixel dimensions {(w0,h0),(w1,h1),(w2,h2),(w3,h3)} of each cell. Calculate the average dimensions (w,h) of the next cell in the pixel coordinate system by averaging the pixel dimensions of each cell.

[0153] Step 5.4: Determine the camera focal length F based on the principle of similar triangles and the focal length calculation formula;

[0154] or

[0155] The scale calculation steps include:

[0156] like Figure 2 As shown, the camera coordinate system is defined with the center point of the camera perpendicular to the ground, and the pixel coordinate system is defined with the top left corner of the image as the center. Wherein:

[0157] d: Vertical distance of the camera from the ground

[0158] θ_x: Horizontal offset angle of the camera

[0159] θ_y: Vertical offset angle of the camera

[0160] O: Center of the camera's field of view

[0161] Ox: The horizontal component at point O

[0162] Oy: The vertical component of point O

[0163] P: Any point on the video

[0164] The steps for calculating the scale (pixel distance: actual distance) of any point P(x,y) on the image are as follows: where, it is assumed that the image size is uniformly 1920*1080;

[0165] Step 6.1: Calculate the offset angle angle_y of point P relative to the center of the field of view in the y direction. The offset angle has positive and negative values. In the camera coordinate system, the positive y direction is positive and the negative y direction is negative.

[0166] F represents the camera's rated focal length.

[0167] Step 6.2: Calculate the offset angle angle_x of point P relative to the center of the field of view in the x-direction. The offset angle has positive and negative values. In the camera coordinate system, if the camera is offset in the positive x-direction, then the positive x-direction is positive, and the negative x-direction is negative. The opposite is true if the camera is offset in the negative x-direction.

[0168]

[0169] Step 6.3: Calculate the focal length_y of point P in the y-direction:

[0170]

[0171] Step 6.4: Calculate the focal length of point P:

[0172]

[0173] Step 6.5: Calculate the offset angles angle_x_real and angle_y_real of point P relative to the camera in the x and y directions, respectively:

[0174] angle_x_real=θ_x+angle_x

[0175] angle_y_real=θ_y+angle_y

[0176] Step 6.6: The actual depth of point P in the y-direction is real_distance_y:

[0177]

[0178] Step 6.7: Further calculate the actual depth of point P, real_distance:

[0179]

[0180] Step 6.8: The final scale of point P is focal_length: real_distance.

[0181] The actual distance estimation step includes:

[0182] Given that the scale (pixel distance: actual distance) of each point in the image is different, we now calculate the actual distance the corner point moves from P1(x1,y1) to P2(x2,y2). Since the pixel distance the corner point moves between two frames is very short, we reasonably assume that the movement of point P1->P2 is linear. Therefore, the linear formula for L(P1-P2) is:

[0183]

[0184] The integral formula for calculating the actual displacement distance between P1 and P2 is as follows:

[0185]

[0186] The water flow velocity estimation step includes:

[0187] The actual motion vector is estimated for each valid motion vector using the actual distance estimation method, resulting in the actual motion distance D{d0,d1,...,dn} of the feature point. The average of all actual motion distances is taken as the actual distance D of the water flow during that time period. Given that the actual motion time of the two frames is T(0,n), the final estimated water flow velocity during that time period is SPEED=D / T(0,n).

[0188] The present invention also provides a water flow velocity estimation system based on traditional optical flow calculation. The water flow velocity estimation system based on traditional optical flow calculation can be implemented by executing the process steps of the water flow velocity estimation method based on traditional optical flow calculation. That is, those skilled in the art can understand the water flow velocity estimation method based on traditional optical flow calculation as a preferred embodiment of the water flow velocity estimation system based on traditional optical flow calculation.

[0189] Those skilled in the art will understand that, besides implementing the system and its various devices, modules, and units provided by this invention in the form of purely computer-readable program code, the same functions can be achieved entirely through logical programming of the method steps, making the system and its various devices, modules, and units of this invention function in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, the system and its various devices, modules, and units provided by this invention can be considered as a hardware component, and the devices, modules, and units included therein for implementing various functions can also be considered as structures within the hardware component; alternatively, the devices, modules, and units for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.

[0190] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.

Claims

1. A method for estimating water flow velocity based on traditional optical flow calculation, characterized in that, include: Step S1: Acquire continuous water flow images {Img0,Img1,...,Imgn} from the video; Step S2: Preprocess the acquired image to obtain the preprocessed image; Step S3: Draw a velocity measurement line, with the direction of the velocity measurement line consistent with the direction of water flow; Step S4: Calculate the motion vector optical flow field of the image based on the preprocessed image, and filter the motion vectors according to the direction of the velocity line to obtain the effective motion vectors; Step S5: Calibrate the camera to obtain the camera focal length, and keep all camera parameters unchanged after calibration; Step S6: Calculate the scale of any point on the image based on the camera calibration results; Step S7: Estimate the actual distance of the motion based on the motion vector coordinates and scale of the optical flow tracing; Step S8: Calculate the actual distance of the water flow based on the actual distance, and calculate the final water flow velocity based on the actual distance of the water flow and the movement time; Step S3 employs the following: A velocity measurement line L:(P0,P1) is drawn along the direction of water flow, and the direction of the optical flow field vector is calibrated using the velocity measurement line; where P0 represents the coordinates of the starting point of the velocity measurement line, P1 represents the coordinates of the ending point, and the rotation angle of the velocity measurement line is... for: ; Step S4 employs the following: Step S4.1: Perform corner detection on the previous frame image Img0 to obtain the corner set FP0{p00,p01,...,p0n}; Step S4.2: Track the corner point set FP0 detected in image Img0 one by one on the second frame image Img1 to obtain the tracking corner point set FP1{p10,p11,...,p1n}; Step S4.3: Perform sparse optical flow tracing on the corner set FP1 tracked in image Img1 on image Img0 in reverse order to obtain the verification corner set PF0r{pr0,pr1,...,prn} on image Img0; Step S4.4: Calculate whether the Euclidean distance D{d0,d1,...,dn} between the corresponding corner points of the detection corner point set FP0 and the verification corner point set FP0r on image Img0 is greater than the preset threshold T. If it is, the corner point is determined to be a poor tracking point, and the corresponding corner points in FP0 and FP1 are deleted to obtain the filtered (FP0',FP1') point pairs. Step S4.5: Based on the filtered (FP0',FP1') point pairs, construct the motion vector set {(p00',p10'),(p01',p11'),...,(p0n',p1n')} for the two frames of images; the Euclidean distance of each point pair is the pixel distance of the point's motion; Step S4.6: Calculate the rotation angle of each set of motion vectors (p0n', p1n'). ,like Rotation angle with speed measuring line If the difference is greater than a preset threshold, the motion vector group is determined to be an interference vector and the current motion vector group is deleted. Step S4.7: The filtered motion vectors are valid motion vectors, and the Euclidean distance of each group of motion vectors is estimated as the pixel distance of the point's movement.

2. The method for estimating water flow velocity based on traditional optical flow calculation according to claim 1, characterized in that, Step S2 involves performing noise reduction and enhancement processing on the image, including image grayscale conversion, median filtering, and histogram equalization.

3. The method for estimating water flow velocity based on traditional optical flow calculation according to claim 1, characterized in that, Step S5 employs the following: Step S5.1: Draw an equal four-square grid on a flat piece of white paper, and record the actual length and width of one square. ; Step S5.2: Lay the paper flat on the table, take a vertical picture of the paper with the camera to obtain a calibration image, and record the vertical distance between the camera and the paper. ; Step S5.3: Perform contour detection on the calibration image to obtain the pixel dimensions of each cell. The average length and width of a cell in the pixel coordinate system are obtained by calculating the average length and width of each cell. ; Step S5.4: Determine the camera focal length based on the principle of similar triangles and the focal length calculation formula. ; 。 4. The method for estimating water flow velocity based on traditional optical flow calculation according to claim 1, characterized in that, Step S6 employs the following: Step S6.1: Calculate the position of any point P in the video relative to the center of the field of view. offset angle ; in, This indicates the camera's calibrated focal length. Point P coordinate; Step S6.2: Calculate the position of point P relative to the center of the field of view. offset angle The offset angle has positive and negative values. In the camera coordinate system, if the camera is offset in the positive x direction, then the positive x direction is positive, and the negative x direction is negative. in, Indicates the horizontal offset angle of the camera; Step S6.3: Calculate the position of point P. Focal depth ; Step S6.4: Calculate the focal depth of point P ; Step S6.5: Calculate the position of point P relative to the camera. , directional offset angle and ; in, Indicates the vertical offset angle of the camera; Step S6.6: Point P is at actual depth ; Step S6.7: Calculate the actual depth of point P. ; Step S6.8: The final scale of point P is obtained as follows. .

5. The method for estimating water flow velocity based on traditional optical flow calculation according to claim 1, characterized in that, Step S7 involves estimating the actual distance of the motion vector by treating the scale of the center point of the motion vector as the entire vector scale.

6. The method for estimating water flow velocity based on traditional optical flow calculation according to claim 1, characterized in that, Step S8 employs the following: Step S8.1: Estimate the actual distance for each valid motion vector to obtain the actual motion distance D{d0,d1,...,dn} of the feature point. Take the average of all actual motion distances as the actual distance D of the water flow during this period. Step S8.2: Calculate the actual motion time of the two frames; in, Indicates the video frame rate; This indicates the frame number of the nth frame. This indicates the frame number of frame 0.

7. A water flow velocity estimation system based on traditional optical flow calculation, characterized in that, include: Module M1: Acquires continuous video images of water flow {Img0,Img1,...,Imgn}; Module M2: Preprocesses the acquired image to obtain a preprocessed image; Module M3: Draw the velocity measurement line, with the direction of the velocity measurement line consistent with the direction of water flow; Module M4: Calculates the motion vector optical flow field of the image based on the preprocessed image, and filters the motion vectors according to the direction of the velocity line to obtain the effective motion vectors; Module M5: calibrates the camera to obtain the camera focal length and keeps all camera parameters unchanged after calibration; Module M6: Calculates the scale of any point on the image based on the camera calibration results; Module M7: Estimates the actual distance of motion based on the motion vector coordinates and scale of optical flow tracing; Module M8: Calculates the actual distance of the water flow based on the actual distance measured, and calculates the final water flow velocity based on the actual distance of the water flow and the movement time; The module M3 adopts: A velocity measurement line L:(P0,P1) is drawn along the direction of water flow, and the direction of the optical flow field vector is calibrated using the velocity measurement line; where P0 represents the coordinates of the starting point of the velocity measurement line, P1 represents the coordinates of the ending point, and the rotation angle of the velocity measurement line is... for: ; The module M4 adopts: Module M4.1: Performs corner detection on the previous frame image Img0 to obtain the corner set FP0{p00,p01,...,p0n}; Module M4.2: Track the corner point set FP0 detected in image Img0 one by one on the second frame image Img1 to obtain the tracked corner point set FP1{p10,p11,...,p1n}; Module M4.3: Performs sparse optical flow tracing on the corner set FP1 tracked in image Img1 on image Img0 in reverse order to obtain the verification corner set PF0r{pr0,pr1,...,prn} on image Img0; Module M4.4: Calculate whether the Euclidean distance D{d0,d1,...,dn} between the corresponding corner points of the detection corner point set FP0 and the verification corner point set FP0r on image Img0 is greater than a preset threshold T. If so, the corner point is determined to be a poor tracking point, and the corresponding corner point in FP0 and FP1 is deleted to obtain the filtered (FP0',FP1') point pair. Module M4.5: Based on the filtered (FP0',FP1') point pairs, construct the motion vector set {(p00',p10'),(p01',p11'),...,(p0n',p1n')} of two frames of images; the Euclidean distance of each point pair is the pixel distance of the point's motion; Module M4.6: Calculates the rotation angle of each set of motion vectors (p0n', p1n'). ,like Rotation angle with speed measuring line If the difference is greater than a preset threshold, the motion vector group is determined to be an interference vector and the current motion vector group is deleted. Module M4.7: The filtered motion vectors are valid motion vectors, and the Euclidean distance of each group of motion vectors is estimated as the pixel distance of the point's movement.

8. The water flow velocity estimation system based on traditional optical flow calculation according to claim 7, characterized in that, The module M2 employs image denoising and enhancement processes including image grayscale conversion, median filtering, and histogram equalization. The module M5 adopts: Module M5.1: Draw equal four-square grids on a flat white sheet of paper, and record the actual length and width of one square. ; Module M5.2: Lay the paper flat on the table, and the camera takes a vertical picture of the paper to obtain a calibration image, recording the vertical distance between the camera and the paper. ; Module M5.3: Performs contour detection on the calibration image to obtain the pixel dimensions of each cell. The average length and width of a cell in the pixel coordinate system are obtained by calculating the average length and width of each cell. ; Module M5.4: Determines the camera's focal length based on the principle of similar triangles and the focal length calculation formula. ; ; The module M6 adopts: Module M6.1: Calculates the position of any point P on the video relative to the center of the field of view. offset angle ; in, This indicates the camera's calibrated focal length. Point P coordinate; Module M6.2: Calculates the position of point P relative to the center of the field of view. offset angle The offset angle has positive and negative values. In the camera coordinate system, if the camera is offset in the positive x direction, then the positive x direction is positive, and the negative x direction is negative. in, Indicates the horizontal offset angle of the camera; Module M6.3: Calculate point P in Focal depth ; Module M6.4: Calculate the focal depth of point P ; Module M6.5: Calculate the position of point P relative to the camera. , directional offset angle and ; in, Indicates the vertical offset angle of the camera; Module M6.6: Point P is at actual depth ; Module M6.7: Calculates the actual depth of point P. ; Module M6.8: The final scale for the location of point P is... ; The module M7 uses the following method: it treats the scale of the center point of the motion vector as the entire vector scale to estimate the actual distance of the motion vector; The module M8 adopts: Module M8.1: Estimate the actual distance for each valid motion vector to obtain the actual motion distance D{d0,d1,...,dn} of the feature point, and take the average of all actual motion distances as the actual distance D of the water flow during that time period; Module M8.2: Calculates the actual motion time of two frames of images; in, Indicates the video frame rate; This indicates the frame number of the nth frame. This indicates the frame number of frame 0.

Citation Information

Patent Citations

  • Low water flow velocity detection method and electronic equipment

    CN115690154A

  • Fluid motion vector estimation method based on feature optical flow

    CN106683114A

  • River surface flow velocity estimation method based on optical flow calculation and readable storage medium

    CN113012195A