Flow rate distribution prediction method and device, storage medium and computer device

By randomly rotating and differentially masking river video data, the problem of inaccurate flow velocity prediction in existing technologies is solved, achieving more accurate flow velocity distribution prediction, which is applicable to river-related research and applications.

CN121353993BActive Publication Date: 2026-03-17CHINA INST OF WATER RESOURCES & HYDROPOWER RES +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-17
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing video-based flow velocity prediction methods lack effective preprocessing of river video data, resulting in inaccurate flow velocity distribution predictions, especially in river regions with different morphologies where flow velocity features are not effectively extracted.

Method used

By randomly rotating and grouping the river video data, and setting mask blocks and mask bars for different groups, data augmentation and model optimization are performed. This includes feature extraction using methods such as making the mask blocks square, setting the mask bar length to be equal to the river length, and setting the mask bar width to be related to the river width.

Benefits of technology

This improves the model's adaptability to videos shot from different angles, reduces the risk of overfitting, enhances the model's generalization performance, and enables it to extract local and overall flow velocity features of the river more accurately, thereby improving the accuracy of flow velocity distribution prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121353993B_ABST
    Figure CN121353993B_ABST
Patent Text Reader

Abstract

The embodiment of the application discloses a kind of prediction method, device, storage medium and computer equipment of flow rate distribution, it is related to computer vision field.The first model is obtained by training first sample set in the present application.Then sample set video frame is randomly rotated, and then divided into two groups.For the first group of video frames, determine the river area, and then set square mask block according to mask block parameters;For the second group, also determine the river area, and set mask strip according to mask strip parameters, the number is 1, the length matches the length of river area, and the width is related to the width of river area.Two groups after mask processing are combined into second sample set, and the second model is obtained by adjusting the parameters of the first model.Finally, the trained second model is used to process the input river monitoring video, and the flow rate distribution graph is output, which can improve the accuracy of the prediction result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer vision, and more particularly to a method, apparatus, storage medium, and computer device for predicting flow velocity distribution. Background Technology

[0002] With the development of computer vision and deep learning technologies, using video analytics to predict river flow velocity distribution has become an emerging and promising method. However, existing video-based flow velocity prediction methods often lack effective preprocessing of river video data. River channels in videos exhibit diverse morphologies, and videos may suffer from issues such as viewpoint changes and noise interference, which can affect the training effect and prediction accuracy of the model. Furthermore, existing methods fail to extract effective flow velocity features specifically for river channels with different morphologies, such as meandering channels or channels with significant width variations.

[0003] Therefore, an improved flow velocity distribution prediction method is needed, which can perform reasonable preprocessing and enhancement of river video data, and set appropriate mask structures according to the characteristics of the river channel area, thereby improving the accuracy and reliability of flow velocity distribution prediction. Summary of the Invention

[0004] This application provides a method, apparatus, storage medium, and computer device for predicting flow velocity distribution, which can solve the problem of low accuracy in flow velocity distribution prediction results in the prior art. The technical solution is as follows:

[0005] In a first aspect, embodiments of this application provide a method for predicting flow velocity distribution, the method comprising:

[0006] The first model is obtained by training using the first sample set; the first sample set includes multiple river videos.

[0007] For each river video in the first sample set, the video frames are randomly rotated based on a preset angle range;

[0008] The first sample set after rotation is divided into a first group and a second group;

[0009] For each river video in the first group, a river channel region is determined in the video frame of the river video, and a mask block is set in the river channel region according to the mask block parameters; the shape of the mask block is square.

[0010] For each river video in the second group, the river channel region is determined in the video frame of the river video, and a mask bar is set in the river channel region according to the mask bar parameters; wherein, the number of mask bars set is equal to 1, the length of the mask bar is equal to the length of the river channel region in the river video, and the width of the mask bar is related to the width of the river channel in the river video;

[0011] The first and second groups after masking are merged to obtain the second sample set;

[0012] The network parameters of the first model are adjusted using the second sample set to obtain the second model;

[0013] The trained second model is used to process the input river monitoring video to obtain a flow velocity distribution map.

[0014] Secondly, embodiments of this application provide a flow velocity distribution prediction device, the device comprising:

[0015] A preliminary training unit is used to train a first model using a first sample set; the first sample set includes multiple river videos.

[0016] The rotation unit is used to randomly rotate the video frames of each river video in the first sample set based on a preset angle range.

[0017] A grouping unit is used to divide the rotated first sample set into a first group and a second group.

[0018] The first masking unit is used to determine the river channel region in the video frame of each river video in the first group, and to set a mask block in the river channel region according to the mask block parameters; the shape of the mask block is square.

[0019] The second masking unit is used to determine the river channel region in the video frame of each river video in the second group, and to set a mask bar in the river channel region according to the mask bar parameters; wherein, the number of mask bars set is equal to 1, the length of the mask bar is equal to the length of the river channel region in the river video, and the width of the mask bar is related to the width of the river channel in the river video.

[0020] The merging unit is used to merge the first and second groups after masking to obtain the second sample set;

[0021] The secondary training unit is used to adjust the network parameters of the first model using the second sample set to obtain the second model;

[0022] The prediction unit is used to process the input river monitoring video using a trained second model to obtain a flow velocity distribution map.

[0023] Thirdly, embodiments of this application provide a computer storage medium storing a plurality of instructions adapted for loading by a processor and executing the above-described method steps.

[0024] Fourthly, embodiments of this application provide a computer device, which may include: a processor and a memory; wherein the memory stores a computer program, the computer program being adapted to be loaded by the processor and to execute the above-described method steps.

[0025] The beneficial effects of the technical solutions provided in some embodiments of this application include at least the following:

[0026] Random rotation of river video frames in the first sample set increases the diversity of the training data. This data augmentation method enables the model to learn river features from different perspectives, improves the model's adaptability to videos shot from different angles, reduces the risk of overfitting, and enhances the model's generalization performance.

[0027] The first model was adjusted using the processed sample set to obtain the second model, which enables the model to extract features more accurately when faced with complex and variable river video data, laying the foundation for subsequent accurate prediction of flow velocity distribution.

[0028] For different groups of river videos, mask blocks and mask bars are set separately. Square mask blocks are used for the first group, allowing for flexible layout based on the river channel conditions and effectively capturing local flow velocity characteristics. Mask bars are used for the second group, with the length of the mask bars equal to the length of the river channel and the width related to the river channel width, better conforming to the river channel shape and comprehensively capturing overall flow velocity information. This differentiated masking method fully considers the different characteristics of river channel areas, improving the targeting of feature extraction.

[0029] Through the above series of operations, including data preprocessing, model optimization, and targeted masking, the trained second model can process the input river monitoring video more accurately, thereby obtaining a more accurate flow velocity distribution map and providing reliable data support for river-related research and applications. Attached Figure Description

[0030] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0031] Figure 1 This is a flowchart illustrating the velocity distribution prediction method provided in the embodiments of this application;

[0032] Figure 2 This is a schematic diagram of the mask block setting provided in an embodiment of this application;

[0033] Figure 3 This is a schematic diagram of the mask bar setting provided in an embodiment of this application;

[0034] Figure 4 This is a schematic diagram of the flow velocity distribution diagram according to an embodiment of this application;

[0035] Figure 5 This is a schematic diagram of the structure of a flow velocity distribution prediction device provided in this application;

[0036] Figure 6 This is a schematic diagram of the structure of a computer device provided in this application. Detailed Implementation

[0037] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0038] Please see Figure 1 The diagram below illustrates a flow velocity distribution prediction method provided in this application. Figure 2 As shown, the method described in this application embodiment may include the following steps:

[0039] S101. The first model is obtained by training using the first sample set; the first sample set includes multiple river videos.

[0040] The computer equipment first loads all river video data from the first sample set. These videos must include scenes with different lighting, water flow conditions, and riverbed morphology. Velocity labels are acquired using a non-invasive optical measurement technique called Particle Image Velometry (PIV): in a real river scene, highly homing tracer particles (such as hollow glass microspheres or fluorescent particles) are seeded into the water flow, and two synchronous high-speed cameras capture the particle trajectories from different angles. The displacement of particles between consecutive frames is analyzed using a cross-correlation algorithm. Combined with camera calibration parameters (such as focal length and viewing angle) and known time intervals, two-dimensional or three-dimensional velocity vectors at various locations within the riverbed are calculated. The measurement results are post-processed (such as noise filtering and data interpolation) to generate a high-precision velocity distribution map, which serves as the ground truth label for the video frames. During training, the equipment uses a deep learning framework (such as PyTorch or TensorFlow) to construct an initial model structure (such as a Convolutional Neural Network (CNN) or a temporal model 3D-CNN). Forward propagation is used to calculate the prediction results, and a loss function (such as mean squared error, MSE) is used to quantify the difference between the predicted values ​​and the ground truth PIV measurements. During the backpropagation phase, the device iteratively updates the model weights based on gradient descent algorithms (such as the Adam optimizer) until the loss function converges or the preset number of training rounds is reached, and finally outputs the first model.

[0041] For example, suppose the first sample set contains 100 river videos, each 10 seconds long and at 30fps. In a real river channel, researchers deployed tracer particles every meter and used two 500fps high-speed cameras to film obliquely from the bank, covering a 50-meter stretch of the river. Through PIV analysis, the average flow velocity value (accuracy ±0.02 m / s) of each 10×10 pixel region in each frame was obtained and labeled as the flow velocity tag for the video frame. The computer used ResNet-50 as the base model, taking a sequence of video frames (256×256 pixels) as input and outputting a flow velocity distribution map of the same size. After 50 rounds of training, the model's average error on the validation set decreased to 0.15 m / s (compared to the PIV ground truth), at which point the model parameters were saved as the first model.

[0042] S102. Randomly rotate the video frames of each river video in the first sample set based on a preset angle range.

[0043] The computer equipment processes each video segment in the first sample set frame by frame. First, it parses the pixel matrix of the video frame, then generates a random rotation angle based on a preset angle range (e.g., [-5°, 5°]). The rotation operation is implemented through an affine transformation, ensuring the center point of the frame remains unchanged, and filling the blank areas after rotation with pixels (e.g., black filling or edge duplication). The rotated frames are then saved as temporary video files or memory arrays to ensure consistency in subsequent processing.

[0044] S103. Divide the first sample set after rotation into a first group and a second group.

[0045] The computer equipment employs stratified sampling or random partitioning strategies to divide the rotated sample set into a first group and a second group proportionally (e.g., 7:3). During partitioning, it is crucial to ensure a balanced distribution of data between the two groups across dimensions such as river channel type (e.g., straight or curved) and flow velocity range (e.g., low or high speed) to avoid overfitting or underfitting the model due to data bias. The partitioning results are stored as a list of files or a database index for easy independent processing later.

[0046] S104. For each river video in the first group, determine the river channel region in the video frame of the river video, and set a mask block in the river channel region according to the mask block parameters; the shape of the mask block is square.

[0047] The computer equipment first locates the river region in the video frame using a semantic segmentation model (such as U-Net) or a threshold segmentation algorithm, generating a binary mask image (river pixel is 1, background is 0). Then, based on mask block parameters (such as a square with sides of 50 pixels), mask block coordinates are randomly generated within the river region, ensuring that the mask blocks are completely within the river and do not overlap. During mask processing, pixel values ​​within the mask block region are set to zero or replaced with noise to simulate a data loss scenario.

[0048] For example: See Figure 2 The diagram shows the mask block setup. For a certain video frame in the first group, the computer device detects that the river area is a rectangle with a length of 300 pixels and a width of 100 pixels. Based on the parameters, a square mask block with a side length of 50 pixels is randomly generated within the river area, covering the coordinate position (200, 50) of the frame. The pixel value within the mask block is set to 255.

[0049] In one possible approach, the number of mask blocks is related to the complexity of the river video and the rate of change of the flow velocity.

[0050] The number of mask blocks N is determined based on the complexity of the river video and the rate of change of flow velocity:

[0051] λ represents the scaling factor, λ∈[0.5,2], C represents the complexity of the river video, and V represents the maximum value of the rate of change of the river velocity in the river video;

[0052] T represents the total number of video frames, I t Let I represent the pixel matrix of the t-th frame image. t+1 Let ||*||2 represent the pixel matrix of the (t+1)th frame of the image, where ||*||2 represents the Euclidean distance.

[0053] v(t) represents the global flow rate value of the image in frame t, and v(t+1) represents the global flow rate value of the image in frame t+1.

[0054] This embodiment combines the complexity C of the river video with the maximum value V of the rate of change of flow velocity. This method dynamically adjusts the number of mask blocks based on the video content. This allows the number of mask blocks to adapt to river videos with varying complexity and flow velocity, making it more flexible and effective in handling diverse river scenes.

[0055] Video complexity is measured by calculating the sum of the Euclidean distances between the pixel matrices of adjacent frames, which accurately reflects the degree of dynamic change in video content. The maximum rate of change of flow velocity is determined by calculating the maximum difference in global flow velocity values ​​between adjacent frames, effectively capturing rapid changes in river flow velocity.

[0056] The introduction of the scaling factor λ allows for adjustment of the sensitivity of the number of mask blocks to complexity and rate of change of flow within the range of [0.5, 2]. This enables a flexible balance between the impact of complexity and rate of change of flow of flow on the number of mask blocks, depending on specific application requirements and video characteristics.

[0057] Ensuring the number of mask blocks N is between 1 and 3 guarantees a reasonable number of mask blocks, avoiding the adverse effects of too many or too few mask blocks on subsequent processing. Overall, this embodiment, by comprehensively considering the complexity and flow rate change rate of the river video and introducing a scaling factor for adjustment, can adaptively determine a suitable number of mask blocks, thereby improving the accuracy and adaptability of river video processing.

[0058] In one or more possible embodiments, the size S of the mask block is calculated based on the size of the river region:

[0059] S = max(α*W+β,β), where S represents the size of the mask block, α represents the width scaling factor, β represents the latest size offset, W represents the average width of the river region, α∈[0.1,0.3], and β≥16 pixels.

[0060] This embodiment allows for flexible control of the ratio between the mask block size and the river channel width by adjusting the value of α. For example, when more detailed analysis of local river channel features is required, a smaller α value can be selected to make the mask block size relatively small; when focusing on the overall features of the river channel, a larger α value can be selected to increase the mask block size.

[0061] β ensures that the minimum size of the mask block is not less than a certain value (β≥16 pixels). This setting avoids generating mask blocks that are too small when the channel is narrow, ensuring that the mask blocks have a sufficient size for effective analysis and processing. For example, in tasks such as optical flow calculation, mask blocks that are too small may lead to inaccurate or unstable calculation results.

[0062] The formula S=max(α×W+β,β) ensures that the mask block size S is always greater than or equal to β. This constraint guarantees the reasonableness of the mask block size and prevents situations where the calculated size is too small, thus affecting the subsequent processing results.

[0063] The calculation method in this embodiment has a simple formula, and the operations involved are mainly multiplication, addition and maximum value operation. It has low computational complexity, is easy to implement and integrate into various river video analysis systems, and can quickly obtain the mask block size to meet real-time or near real-time processing requirements.

[0064] Overall, this embodiment ensures that the mask block size is reasonable and adaptable to changes in river channel size, while having advantages such as simple calculation and adjustable parameters, which can effectively improve the accuracy and applicability of mask block generation in river video analysis.

[0065] In some possible embodiments of this application, the position of the mask block is determined according to the following method.

[0066] The size of the mask block is S*S, and the coordinates of the top-left corner of the mask block are (x, y).

[0067] ;

[0068] r x and r y It is a random number uniformly distributed in [0,1), (x min ,y min (x) represents the coordinates of the top-left corner of the smallest enclosing rectangle of the river channel area. max ,y max ) represents the coordinates of the lower right corner of the smallest enclosing rectangle of the river channel area.

[0069] This embodiment introduces random numbers uniformly distributed within [0,1), making the top-left corner coordinates (x,y) of the mask block random. This randomness helps to more comprehensively and evenly cover different locations within the river channel area, avoiding overly concentrated or regular mask block positions. This allows for the acquisition of information such as flow velocity at different parts of the river channel, improving the comprehensiveness and accuracy of the overall river channel analysis.

[0070] By utilizing the coordinates of the minimum bounding rectangle of the river channel region and combining it with the mask block size S, the position of the mask block is effectively constrained. This ensures that the generated mask block always remains within the river channel region and does not exceed the river channel boundary. This guarantees that the information contained in the mask block is only valid information about the river and avoids the introduction of irrelevant background information that could interfere with the analysis results due to the mask block exceeding the river channel region.

[0071] This embodiment considers the mask block size S and the size of the river channel region (represented by the minimum enclosing rectangle). Regardless of changes in the mask block size or the shape and size of the river channel region, a reasonable mask block position can be calculated according to the formula. This makes the method highly versatile and applicable to mask blocks of various sizes and river channel regions of different shapes.

[0072] The calculation formula in this embodiment mainly consists of basic arithmetic operations and rounding operations. The calculation process is simple, easy to implement, and fast. In scenarios requiring real-time or rapid analysis, such as processing river videos, it can efficiently determine the location of mask blocks, meeting the computational efficiency requirements of practical applications.

[0073] S105. For each river video in the second group, determine the river channel region in the video frame of the river video, and set a mask bar in the river channel region according to the mask bar parameters; wherein, the number of mask bars set is equal to 1, the length of the mask bar is equal to the length of the river channel region in the river video, and the width of the mask bar is related to the width of the river channel in the river video.

[0074] The computer equipment first locates the river channel area, then generates mask bars based on mask bar parameters (e.g., width of 10 pixels, length related to the river channel width). The mask bar length is typically set to 90%-100% of the river channel length, and the width is dynamically adjusted according to the average river flow velocity (e.g., the higher the flow velocity, the narrower the width). The mask bars are placed along the river centerline or in a random direction to ensure coverage of the water flow characteristic area. The mask processing method is the same as for mask blocks, achieving data occlusion through pixel replacement.

[0075] For example, see Figure 3 The diagram shows the setup of the mask bar. For a certain video frame in the second group, the river region is 400 pixels long and 80 pixels wide. The computer generates a mask bar with a width of 10 pixels and a length of 400 pixels, which is placed along the horizontal center line of the river, covering the region from (200, 40) to (200, 420) of the frame. The pixel values ​​within the mask bar are replaced with random noise.

[0076] In one possible embodiment of this application, the method for determining a river region in a river video includes:

[0077] The computer inputs preprocessed video frames into the loaded semantic segmentation model, initiating the model's inference process. During inference, the encoder first performs a series of convolution and pooling operations on the input image, progressively extracting low-level to high-level features. These features include information such as image texture, edges, and color. Next, the decoder uses these features to perform upsampling and other operations, restoring the feature map to a size similar to the input image and assigning a category label to each pixel in the image. For the river region recognition task, the model assigns specific labels to pixels belonging to the river.

[0078] The model outputs a segmentation map of the same size as the input image, where each pixel has a category label. The computer then performs post-processing on this segmentation map. First, it filters the map to remove isolated or potentially noisy pixels, resulting in a smoother and more accurate segmentation. Next, based on the pixel category labels, it connects pixels belonging to river channels to form continuous river regions. Morphological operations, such as dilation and erosion, further optimize the shape and boundaries of these river regions to better reflect actual river morphology. Finally, the computer identifies the river regions within the video frame and represents and stores them in an appropriate format (e.g., bounding boxes, polygons) for subsequent analysis and processing, such as flow velocity calculation and mask block generation.

[0079] S106. The first and second groups after masking are merged to obtain the second sample set.

[0080] The computer device merges the metadata (such as file paths and annotation information) of the first group (containing video with masked blocks) and the second group (containing video with masked bars) into a unified dataset list. During the merging process, data integrity is checked, invalid frames resulting from masking (such as completely black frames) are removed, and the index file is regenerated for subsequent loading. The second sample set is the same size as the rotated first sample set, but its data distribution is more diverse due to the different mask types.

[0081] For example: The first group, after processing with mask blocks, contains 140 video segments, and the second group, after processing with mask bars, contains 60 video segments. The computer merges the two into a second sample set, totaling 200 video segments, of which 70% contain mask blocks and 30% contain mask bars. The merged dataset is stored as a CSV file, recording the mask type and parameters for each video segment.

[0082] S107. The network parameters of the first model are adjusted using the second sample set to obtain the second model.

[0083] In this process, the computer equipment uses a second sample set as input and employs a transfer learning strategy to fine-tune the first model. Specifically, some low-level network parameters of the first model (such as convolutional layers) are fixed, and only high-level networks (such as fully connected layers) or newly added mask recovery modules are trained. During training, the loss function must simultaneously consider flow velocity prediction errors and mask region reconstruction errors (such as L1 loss) to enhance the model's robustness to occluded data. The number of fine-tuning epochs is usually less than the initial training epochs to avoid overfitting.

[0084] S108. Using the trained second model, process the input river monitoring video to obtain a flow velocity distribution map.

[0085] The computer equipment first preprocesses the input river monitoring video (e.g., uniform frame rate, size scaling), then inputs it frame by frame into a second model. The model generates a flow velocity prediction map for each frame through forward propagation, where each pixel value corresponds to the flow velocity at that location in the river channel. Finally, the equipment merges the prediction maps of all frames in chronological order into a flow velocity distribution map in video format, or extracts keyframes to generate a static distribution map. The output can be overlaid on the original video for visualization and analysis.

[0086] For example: See Figure 4 The diagram shown illustrates the flow velocity distribution. Inputting a 30-second river monitoring video (10fps), the computer generates 300 predicted flow velocity maps, each with a resolution of 512×512 pixels and a pixel value range of 0-5 m / s (gradient from blue to red). The final output is a flow velocity distribution video, clearly showing phenomena such as accelerated flow velocity at river bends and decreased flow velocity at shallow areas.

[0087] In some possible embodiments of this application, it also includes:

[0088] Adjust the flow velocity values ​​in the aforementioned flow velocity distribution map:

[0089] , This represents the adjusted flow velocity value at the target point (x, y).

[0090] The velocity distribution map is a two-dimensional matrix V(x, y), where (x, y) are pixel coordinates and V(x, y) represents the velocity value at that point;

[0091] Ω represents a local window centered at (x, y), with a window size of 3*3 or 5*5, and N represents the number of valid points within the window.

[0092] In this embodiment, the flow velocity value of the target point is adjusted by selecting a local window Ω centered on the target point (x,y) and averaging the flow velocity values ​​of all points within the window. This method can smooth the flow velocity of the target point using the flow velocity information of surrounding points, reducing random errors or noise interference in the flow velocity value of a single point, and making the flow velocity distribution more stable and reliable.

[0093] Because the averaging operation is performed within a local window, rather than a global average across the entire map, it can smooth the velocity values ​​while better preserving the overall characteristics and local trends of the velocity distribution map. For example, important information such as the velocity differences between different areas of the river channel will not be excessively smoothed out.

[0094] The window size can be set to different sizes, such as 3*3 or 5*5, and the appropriate window size should be selected according to actual needs. Smaller window sizes (such as 3*3) can handle local velocity changes more finely and retain more details; larger window sizes (such as 5*5) can perform smoothing over a larger range and are suitable for macroscopic analysis of velocity distribution, improving the flexibility and applicability of the method.

[0095] The calculation process in this embodiment is relatively simple and easy to implement. When processing large-scale flow velocity distribution data, it can complete the calculation within a reasonable time, meeting the computational efficiency requirements of practical applications.

[0096] This application has the following beneficial effects:

[0097] Random rotation of river video frames in the first sample set increases the diversity of the training data. This data augmentation method enables the model to learn river features from different perspectives, improves the model's adaptability to videos shot from different angles, reduces the risk of overfitting, and enhances the model's generalization performance.

[0098] The first model was adjusted using the processed sample set to obtain the second model, which enables the model to extract features more accurately when faced with complex and variable river video data, laying the foundation for subsequent accurate prediction of flow velocity distribution.

[0099] For different groups of river videos, mask blocks and mask bars are set separately. Square mask blocks are used for the first group, allowing for flexible layout based on the river channel conditions and effectively capturing local flow velocity characteristics. Mask bars are used for the second group, with the length of the mask bars equal to the length of the river channel and the width related to the river channel width, better conforming to the river channel shape and comprehensively capturing overall flow velocity information. This differentiated masking method fully considers the different characteristics of river channel areas, improving the targeting of feature extraction.

[0100] Through the above series of operations, including data preprocessing, model optimization, and targeted masking, the trained second model can process the input river monitoring video more accurately, thereby obtaining a more accurate flow velocity distribution map and providing reliable data support for river-related research and applications.

[0101] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.

[0102] Please see Figure 5This illustration shows a schematic diagram of a flow velocity distribution prediction device provided in an exemplary embodiment of this application, hereinafter referred to as device 5. Device 5 can be implemented as all or part of a computer device through software, hardware, or a combination of both. Device 5 includes: a preliminary training unit 501, a rotation unit 502, a grouping unit 503, a first masking unit 504, a second masking unit 505, a merging unit 506, a secondary training unit 507, and a prediction unit 508.

[0103] The initial training unit 501 is used to train a first model using a first sample set; the first sample set includes multiple river videos.

[0104] The rotation unit 502 is used to randomly rotate the video frames of each river video in the first sample set based on a preset angle range.

[0105] Grouping unit 503 is used to divide the rotated first sample set into a first group and a second group;

[0106] The first masking unit 504 is used to determine a river channel region in the video frame of each river video in the first group, and to set a mask block in the river channel region according to the mask block parameters; the shape of the mask block is square.

[0107] The second masking unit 505 is used to determine the river channel region in the video frame of each river video in the second group, and to set a mask bar in the river channel region according to the mask bar parameters; wherein, the number of mask bars set is equal to 1, the length of the mask bar is equal to the length of the river channel region in the river video, and the width of the mask bar is related to the width of the river channel in the river video.

[0108] The merging unit 506 is used to merge the first group and the second group after masking to obtain the second sample set;

[0109] The secondary training unit 507 is used to adjust the network parameters of the first model using the second sample set to obtain the second model;

[0110] Prediction unit 508 is used to process the input river monitoring video using the trained second model to obtain a flow velocity distribution map.

[0111] In one or more possible embodiments, the number of mask blocks N is determined based on the complexity of the river video and the rate of change of flow velocity:

[0112] λ represents the scaling factor, λ∈[0.5,2], C represents the complexity of the river video, and V represents the maximum value of the rate of change of the river velocity in the river video;

[0113] T represents the total number of video frames, I t Let I represent the pixel matrix of the t-th frame image. t+1 Let ||*||2 represent the pixel matrix of the (t+1)th frame of the image, where ||*||2 represents the Euclidean distance.

[0114] v(t) represents the global flow rate value of the image in frame t, and v(t+1) represents the global flow rate value of the image in frame t+1.

[0115] In one or more possible embodiments, the size S of the mask block is calculated based on the size of the river region:

[0116] S = max(α*W+β,β), where S represents the size of the mask block, α represents the width scaling factor, β represents the latest size offset, W represents the average width of the river region, α∈[0.1,0.3], and β≥16 pixels.

[0117] In one or more possible embodiments, the size of the mask block is S*S, and the coordinates of the top-left corner of the mask block are (x, y).

[0118] ;

[0119] r x and r y It is a random number uniformly distributed in [0,1), (x min ,y min (x) represents the coordinates of the top-left corner of the smallest enclosing rectangle of the river channel area. max ,y max ) represents the coordinates of the lower right corner of the smallest enclosing rectangle of the river channel area.

[0120] In one or more possible embodiments, the preset angle range is ±5 degrees.

[0121] In one or more possible embodiments, river regions are determined in video frames based on a semantic segmentation model.

[0122] In one or more possible embodiments, it also includes:

[0123] An adjustment unit is used to adjust the flow velocity values ​​in the flow velocity distribution map.

[0124] , This represents the adjusted flow velocity value at the target point (x, y).

[0125] The velocity distribution map is a two-dimensional matrix V(x, y), where (x, y) are pixel coordinates and V(x, y) represents the velocity value at that point;

[0126] Ω represents a local window centered at (x, y), with a window size of 3*3 or 5*5, and N represents the number of valid points within the window.

[0127] It should be noted that the device 5 provided in the above embodiments, when performing the flow velocity distribution prediction method, is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the above functions. In addition, the flow velocity distribution prediction device and the flow velocity distribution prediction method embodiments provided in the above embodiments belong to the same concept, and the implementation process is detailed in the method embodiments, which will not be repeated here.

[0128] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0129] This application also provides a computer storage medium that can store multiple instructions, which are adapted to be loaded and executed by a processor as described above. Figure 1 The method steps of the illustrated embodiment can be found in the following documentation for detailed execution. Figure 2 The specific details of the illustrated embodiments will not be elaborated here.

[0130] This application also provides a computer program product that stores at least one instruction, which is loaded and executed by the processor to implement the flow velocity distribution prediction method as described in the above embodiments.

[0131] Please see Figure 6 This document provides a schematic diagram of the structure of a computer device according to an embodiment of this application. Figure 6 As shown, the computer device 600 may include: at least one processor 601, at least one network interface 604, user interface 603, memory 605, and at least one communication bus 602.

[0132] The communication bus 602 is used to enable communication between these components.

[0133] The user interface 603 may include a display screen and a camera. Optionally, the user interface 603 may also include a standard wired interface and a wireless interface.

[0134] The network interface 604 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).

[0135] The processor 601 may include one or more processing cores. The processor 601 connects to various parts of the computer device 600 using various interfaces and lines, and performs various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 605, and by calling data stored in the memory 605. Optionally, the processor 601 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 601 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 601 and may be implemented as a separate chip.

[0136] The memory 605 may include random access memory (RAM) or read-only memory. Optionally, the memory 605 may include a non-transitory computer-readable storage medium. The memory 605 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 605 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 605 may also be at least one storage device located remotely from the aforementioned processor 601. Figure 6 As shown, the memory 605, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and application programs.

[0137] exist Figure 6In the computer device 600 shown, the user interface 603 is mainly used to provide an input interface for the user and to obtain user input data; while the processor 601 can be used to call the application program stored in the memory 605 and specifically execute, such as Figure 2 The method shown can be referred to for details. Figure 2 As shown, it will not be elaborated further here.

[0138] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory, or random access memory, etc.

[0139] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.

Claims

1. A method of predicting a flow rate distribution, characterized by, The method comprises the following steps: training a first model by using a first sample set, wherein the first sample set comprises a plurality of river videos; randomly rotating video frames of each river video in the first sample set based on a preset angle range; dividing the first sample set after the rotation processing into a first group and a second group; for each river video in the first group, determining a river channel region in the video frames of the river video, and setting a mask block in the river channel region according to mask block parameters; the shape of the mask block is a square; for each river video in the second group, determining a river channel region in the video frames of the river video, and setting a mask strip in the river channel region according to mask strip parameters; wherein the number of the mask strips set is equal to 1, the length of the mask strip is equal to the length of the river channel region in the river video, and the width of the mask strip is related to the width of the river channel in the river video; combining the first group and the second group after the mask processing to obtain a second sample set; adjusting network parameters of the first model by using the second sample set to obtain a second model; processing an input river monitoring video by using the trained second model to obtain a flow velocity distribution diagram.

2. The method of claim 1, wherein, determining the number N of mask blocks according to the complexity of the river video and the flow velocity change rate: , λ represents a scaling coefficient, λ ∈ [0.5, 2], C represents the complexity of the river video, and V represents the maximum value of the flow rate change rate of the river video. , T denotes the total number of frames of the video, I t denotes the pixel matrix of the t-th frame of the image, I t+1 denotes the pixel matrix of the t+1-th frame of the image, ||*||2denotes the Euclidean distance; v(t) represents the global flow value of the t-th frame image, and v(t+1) represents the global flow value of the t+1-th frame image.

3. The method according to claim 1 or 2, characterized in that, calculating the size S of the mask block according to the size of the river channel region: S = max (α * W + β, β), S represents the size of the mask block, α represents a width scaling coefficient, β represents a latest size offset, W represents the average width of the river channel region, α ∈ [0.1, 0.3], and β ≥ 16 pixels.

4. The method of claim 3, wherein, The size of the mask block is S*S, the top-left corner coordinates (x, y) of the mask block are (x, y), and then ; , r x and r y are random numbers uniformly distributed in [0, 1), (x min , y min ) represents the left upper corner coordinate of the minimum enclosing rectangle of the river region, (x max , y max ) represents the right lower corner coordinate of the minimum enclosing rectangle of the river region.

5. The method according to claim 1 or 2 or 4, characterized in that, the preset angle range is plus or minus 5 degrees.

6. The method of claim 5, wherein, determining the river channel region in the video frames according to the semantic segmentation model.

7. The method of claim 6, wherein, The method further comprises the following steps: adjusting the flow velocity value of the flow velocity distribution diagram: , adjusted flow rate value of the target point (x, y) the flow velocity distribution diagram is a two-dimensional matrix V(x, y), (x, y) is a pixel coordinate, and V(x, y) represents the flow velocity value of the point; Ω represents a local window with (x, y) as the center, the size of the window is 3*3 or 5*5, and N represents the number of effective points in the window.

8. A flow rate distribution prediction device characterized by comprising: The method comprises the following steps: a preliminary training unit is configured to train a first model by using a first sample set; the first sample set comprises a plurality of river videos; a rotation unit is configured to randomly rotate video frames of each river video in the first sample set based on a preset angle range; a grouping unit is configured to divide the first sample set after the rotation processing into a first group and a second group; a first mask unit is configured to, for each river video in the first group, determine a river channel region in the video frames of the river video, and set a mask block in the river channel region according to mask block parameters; the shape of the mask block is a square; a second mask unit is configured to, for each river video in the second group, determine a river channel region in the video frames of the river video, and set a mask strip in the river channel region according to mask strip parameters; wherein the number of the mask strips set is equal to 1, the length of the mask strip is equal to the length of the river channel region in the river video, and the width of the mask strip is related to the width of the river channel in the river video; The merging unit is configured to merge the first group and the second group after the mask processing to obtain a second sample set. The secondary training unit is configured to adjust network parameters of the first model by using the second sample set to obtain a second model. The prediction unit is configured to process the input river monitoring video by using the trained second model to obtain a flow velocity distribution map.

9. A computer storage medium, characterized in that The computer storage medium stores a plurality of instructions, which are suitable for being loaded and executed by a processor to perform the method steps of any one of claims 1-7.

10. A computer device, comprising: Comprise: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded and executed by the processor to perform the method steps of any one of claims 1-7.

Citation Information

Patent Citations

  • Flow rate monitoring method and system

    CN110187142A

  • Video-based river flow rate and flow velocity monitoring method and system

    CN117288283A