Improved flow monitoring method of time difference measuring instrument based on path optimization algorithm
By using an improved transit time measuring instrument based on a path optimization algorithm in hydrological data monitoring, combined with a variety of sensors and image processing technology, the flow measurement path is dynamically optimized, which solves the problem of interference from air bubbles and suspended matter in the water and improves measurement accuracy. and efficiency, reducing equipment dependence.
Patent Information
- Application Number
- CN202410527320.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-28
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2044-04-28
AI Technical Summary
It is difficult to effectively identify and avoid the interference of air bubbles and suspended solids in water with existing technology during hydrological data monitoring, resulting in inaccurate measurement results, complex and expensive equipment, and inability to flexibly respond to changing environmental conditions.
The improved transit time meter flow monitoring method based on path optimization algorithm is used to collect and identify air bubbles and suspended solids information in real time through camera devices, infrared sensors and laser measuring instruments. It is combined with the Canny edge detection algorithm and learner network to construct the optimal flow rate. Measurement path, dynamic optimization of measurement strategy.
Significantly improves the accuracy and efficiency of flow measurement, reduces dependence on high-end equipment, achieves a balance between cost-effectiveness and operational flexibility, and enables accurate flow monitoring in complex river basins.
Smart Images

Figure CN118470054B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to an improved time difference measuring instrument flow monitoring method based on a path optimization algorithm, and belongs to the technical field of fluid measurement. Background Art
[0002] Hydrological data monitoring is an important basis for environmental, resource utilization and protection. Although existing technologies have taken a variety of measures to reduce this impact, such as adjusting the ultrasonic frequency or using complex signal processing algorithms to improve the signal's anti-interference ability, these methods often cannot fundamentally solve the problem. On the one hand, these methods may require expensive equipment support or increase the complexity of the system; on the other hand, they usually cannot provide sufficient flexibility to cope with changing environmental conditions and fluid properties.
[0003] Therefore, it is particularly important to develop a flow measurement method that can identify and avoid interference from air bubbles and suspended matter in water in real time. Such a method can not only improve the accuracy and reliability of measurement, but also reduce the dependence on high-end equipment, thus achieving a better balance between cost-effectiveness and operational flexibility. Summary of the invention
[0004] In order to solve the above technical problems, the present invention proposes an improved time-difference flow measuring instrument flow monitoring method based on a path optimization algorithm, aiming to solve the technical problem in the prior art that the natural river flow measurement device is affected by the change of river water level and the change of sensor installation position, and at the same time improve the flow monitoring in complex river basins.
[0005] To achieve the above object, the technical solution adopted by the present invention is:
[0006] The present invention provides an improved time difference method flow rate monitoring method based on a path optimization algorithm, and the specific steps are as follows:
[0007] S1. Collecting air bubble and suspended matter information data in the flow area to be measured;
[0008] S2, obtaining the size and volume of air bubbles and suspended objects, and making corresponding processing for targets with smaller volumes;
[0009] S3, constructing an optimal path algorithm for flow measurement based on the volume of air bubbles and suspended objects obtained by the edge detection algorithm and the distance measured by the laser measuring instrument;
[0010] S4. Train the optimal path algorithm.
[0011] Further, the step S1 is specifically as follows:
[0012] S11, using a camera device to collect current watershed image information in real time;
[0013] The camera device is installed on the steering seat of the time-of-day measuring instrument. As the steering seat rotates, the camera device will also take real-time photos. When air bubbles and suspended objects are detected on the river surface, the camera device will take photos and process them. The images will be used for classification and path planning in the later stage.
[0014] S12, using infrared sensor to assist in identification;
[0015] Use infrared sensors for auxiliary identification. By receiving infrared radiation signals emitted by objects, infrared sensors work without visible light and can identify objects at night or in low-light environments.
[0016] S13, using a laser measuring instrument to measure the distances of the air bubbles and the suspended objects from the measuring instrument;
[0017] The laser measuring instrument is installed on the steering seat. When the steering seat rotates, the laser measuring instrument emits a laser beam and receives the light reflected by the laser beam from the air bubble and the surface of the suspended object, thereby measuring the distance between the target object and the equipment;
[0018] S14. When the camera device detects air bubbles and suspended objects on the river surface, it takes images in a timely manner and issues ultrasonic instructions, using a spectrum analyzer to receive the spectrum signal transmitted and returned by the transducer.
[0019] Further, the step S2 is specifically as follows:
[0020] S21, use Canny edge detection algorithm to detect the size and volume of air bubbles and suspended objects;
[0021] The Canny edge detection algorithm works as follows:
[0022] The target object obtained by the camera device is first pre-processed by a Gaussian filter, and the following formula is used for Gaussian smoothing:
[0023]
[0024] Among them, G(x,y) represents the image result after filtering, x, y represent the position of the pixel in the image, and σ is the standard deviation, which is used to control the smoothness of the filter;
[0025] Use a multi-channel fusion mechanism, that is, by adjusting the different angles of the time difference flow measurement device, take original images in different directions, construct N groups of input data, filter these N groups of data, and use channel fusion technology for weighted fusion. The implementation method is as follows:
[0026]
[0027] Among them A1 , A 2 , A 3 …, A N Represents different channels, that is, image information taken at different angles. “*” represents matrix multiplication, which is used to calculate the similarity between two channels. 1 , α 2 …α N , which indicates the similarity between the paths. The similarity of images at different angles is inconsistent;
[0028] Based on the similarity, re-weight each channel:
[0029] A=(α 1 , α 2 , α 3 …α N )*(A 1 , A 2 , A 3 …, A N )
[0030] A represents the weighted image features of each channel;
[0031] Then, the gradient strength and direction of each channel image information after processing are calculated to determine the position and direction of the potential edge in the image. The Sobel operator is used to calculate the gradient in the horizontal and vertical directions respectively. The calculation formula is:
[0032]
[0033]
[0034] Among them, G x and G y are the gradients of the image in the horizontal and vertical directions, G and θ represent the gradient strength and direction, respectively, and arctan() represents the inverse trigonometric function;
[0035] Then, the non-maximum suppression technique is used to refine the edges in the image to ensure that the edges are presented in the form of thin lines. Finally, by setting a high threshold (T h igh ) and the low threshold (T low ) to mark strong and weak edges;
[0036] By quantifying the closed contours formed by these edges, the volumes of air bubbles and suspended objects are estimated:
[0037] V=max(W i *H i *L i )
[0038] Among them, W i, H i , L i Represents the length, width and height of each bubble or suspended object. Max represents the maximum value function. In order to measure accurately, the volume of each object is measured multiple times and the maximum value is taken as the final volume.
[0039] S22, treat small air bubbles and suspended matter;
[0040] Set volume threshold V M , when V <V M That is, when the volume of detected air bubbles and suspended objects is smaller than a preset threshold, ultrasonic waves are used to perform a clearing operation.
[0041] Further, the step S3 is specifically as follows:
[0042] S31, calculating the distance from the bubble or suspended matter to the path;
[0043] D is the distance from the bubble to the time difference measuring instrument, which is calculated as:
[0044]
[0045] Where v is the speed of sound, t i It represents the round trip time of the i-th path, N represents the number of effective echo paths, and the distance is optimized by compensating for this multipath effect through distance calculation. α represents the tilt angle of the measuring instrument, and d represents the distance from the bubble or suspended object to the optimal path. The calculation formula is:
[0046] d=D*sin(α)
[0047] S32, constructing an optimal path algorithm;
[0048] According to the volume V of the air bubbles and suspended objects and the distance D obtained in the previous step, the optimal path algorithm is constructed. The origin represents the air bubbles and suspended objects in the river, y represents the optimal path formula, y1 and y2 represent the two paths closest to y for the air bubbles or suspended objects on both sides of the path, and d1 and d2 represent the distances from y1 and y2 to the optimal path y.
[0049] The calculation formula of y1 is:
[0050] W11X1+W12X2+W13X3....W1nXn=d1
[0051] The y2 calculation formula is:
[0052] W21X1+W22X2+W23X3....W2nXn=d2
[0053] X1, X2, X3…Xn represent each bubble and suspended object, W11, W12, W13…W1n represent the weight of each bubble and suspended object, and the calculation formula is:
[0054]
[0055] Where η represents a hyperparameter to prevent division by zero errors, and i represents the number of target objects;
[0056] In order to obtain the optimal calculation path y, two conditions need to be met;
[0057] On the one hand, d1 and d2 are required to be large, that is, far away from the center line y, so as to reduce the interference of bubbles and suspended objects on both sides of the center line on the ultrasonic signal on the path;
[0058] On the other hand, it is required that as many bubbles and suspended objects as possible are located on the paths y1 and y2, so that most of the bubbles and suspended objects are far away from the path through which the ultrasonic signal passes;
[0059] When the above conditions are met, we iteratively search for a set of parameters {W1, W2, W3, …Wn} to construct the optimal path algorithm formula:
[0060] y=W1X1+W2X2+W3X3....WnXn
[0061] The above formula represents the optimal measurement path prediction algorithm. After training, the specific values of {W1, W2, W3, …Wn} can be obtained, and then the distances d1 and d2 can be obtained in reverse.
[0062] Further, the step S4 is specifically as follows:
[0063] S41, build a learner network;
[0064] Specifically, the input x represents each bubble and suspended object feature, and first passes through a linear layer, which has a weight matrix and a bias vector. The dimension of the weight matrix is 256x6, which means that the input feature size is 6 and the output feature size is 256;
[0065] Next is a batch normalization layer, which normalizes the output of the previous layer so that the output maintains a distribution with a mean close to 0 and a standard deviation close to 1 during training;
[0066] Then there is a nonlinear activation function that allows small gradients when the input value is less than zero to avoid the output of the activation function being completely zero and prevent the "dead neuron" phenomenon;
[0067] The weight matrix dimension of the second linear layer is 256x256, which means that this layer accepts 256 features of the previous layer as input and outputs 256 features, followed by a batch normalization layer and a nonlinear activation function;
[0068] This is followed by an add operator, which adds the output of the LeakyReLU after the first linear layer to the output of the second nonlinear activation function element-wise, which is a residual connection;
[0069] This is followed by a dimensionality reduction linear layer with a weight matrix size of 128x256, which indicates that the network is reducing the 256-dimensional feature space to 128 dimensions. This is followed by another batch normalization and non-linear activation function;
[0070] The network then passes through a linear layer that further reduces the dimension to 64, with a corresponding weight matrix of 64x128, followed by batch normalization and LeakyReLU;
[0071] Finally, the network has an output layer, which is a linear layer with a corresponding weight matrix of 1x64, which maps the 64-dimensional features to a single output. This network represents the mapping relationship from input x to y.
[0072] S42, start iterative training for the above network, input the pre-collected sample data into the model, set the training batch to 1000 times, use Adam as the learner, set the learning rate to 0.01, and use the following loss formula:
[0073]
[0074] Among them, α represents weight information, h s (x (i) ) represents the predicted value, y (i) Represents the true value, and Loss represents the loss value between the two.
[0075] Compared with the prior art, the flow monitoring method of the present invention has the following beneficial effects:
[0076] This application uses high-precision sensors and image processing technology to collect and accurately identify information about air bubbles and suspended matter in water in real time, providing an unprecedented method for visualizing interference factors. It uses edge detection algorithm optimization, uses advanced image processing algorithms for edge detection, accurately locates air bubbles and suspended matter, optimizes the identification process, reduces errors, and uses dynamic optimization of flow measurement paths: By building a fluid dynamics model and applying a path planning algorithm, dynamic optimization of the flow measurement path is achieved. This is a new solution that can adjust the measurement strategy based on real-time data and significantly improve the accuracy and efficiency of measurements. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] Figure 1 A flow chart of the flow monitoring method of the improved time difference method measuring instrument based on the path optimization algorithm provided by the present invention;
[0078] Figure 2 The spectrum difference diagram of air bubbles and suspended objects in the improved time difference method flow monitoring method of the measuring instrument based on the path optimization algorithm provided by the present invention;
[0079] Figure 3 Comparison of original image and filtered image of the improved time difference method flow monitoring method based on path optimization algorithm provided by the present invention;
[0080] Figure 4 The figure shows the final output diagram of edge detection of the flow monitoring method of the improved time difference measuring instrument based on the path optimization algorithm;
[0081] Figure 5 A distance measurement diagram of a flow monitoring method of an improved time difference measuring instrument based on a path optimization algorithm provided by the present invention;
[0082] Figure 6 The optimal path calculation diagram of the improved time difference method flow monitoring method based on the path optimization algorithm provided by the present invention;
[0083] Figure 7 This is the river spectrum diagram of Example 1;
[0084] Figure 8 This is the river monitoring map of Example 2;
[0085] Fig. 9 This is the river spectrum diagram of Example 2. DETAILED DESCRIPTION
[0086] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments:
[0087] refer to Figure 1 , the improved time difference method flow monitoring method based on path optimization algorithm includes the following steps:
[0088] Step S1: Collect information data of air bubbles and suspended matter in the flow area to be measured. The principle of the time difference measuring instrument is to measure the river flow by emitting ultrasonic waves through a transducer. The average velocity of the fluid can be calculated by using the time difference between the propagation of ultrasonic signals downstream and upstream, thereby obtaining the flow. However, when using a transducer to collect the river flow in the current area, it is affected by air bubbles and suspended matter in the water. Air bubbles and suspended matter can scatter or absorb the ultrasonic waves released by the transducer, thereby affecting the accuracy of the measurement results. Therefore, it is necessary to monitor and collect information on air bubbles and suspended matter in the river area in real time.
[0089] In this implementation, S1 specifically includes:
[0090] S11. Use a high-definition camera to collect the current watershed image information in real time. The high-definition camera is installed on the steering seat 4 of the time-difference measuring instrument. As the steering seat rotates, the high-definition camera will also take pictures in real time. When air bubbles and suspended objects are detected on the surface of the river, the images are photographed and processed. The images are used for classification and path planning in the later stage.
[0091] S12. Use infrared sensors to assist in identification. Affected by weather and environmental factors, when it is cloudy or at night, the camera device will be disturbed. In order to prevent the inability to accurately obtain image information with only a high-definition camera device, an infrared sensor is used for auxiliary identification. An infrared sensor is a device that can detect and measure infrared radiation emitted by an object. By receiving infrared radiation signals emitted by an object, the infrared sensor can work in the absence of visible light, thereby realizing the identification of objects at night or in low-light environments.
[0092] S13, using a laser measuring instrument to measure the distance from the air bubble and the suspended object to the measuring instrument. The laser measuring instrument is installed on the steering seat 4. When the steering seat rotates, the measuring instrument emits a laser beam and receives the light reflected by the laser beam on the surface of the air bubble and the suspended object to measure the distance between the target object and the device.
[0093] S14. When the camera device detects air bubbles and suspended objects on the river surface, it will take pictures in time and issue ultrasonic instructions, using the spectrum analyzer to receive the spectrum signal transmitted and returned by the transducer. When ultrasonic waves penetrate the medium containing bubbles or suspended matter, the bubbles and suspended matter have different scattering and absorption abilities for ultrasonic waves, which makes the reflected ultrasonic signal present distinguishable characteristics in the spectrum. By comparing and analyzing the differences in these spectra, it is possible to effectively distinguish between bubbles and suspended matter in the fluid. Figure 2 The following figure shows the difference in the spectra of air bubbles and suspended objects.
[0094] As can be seen from the figure, air bubbles have specific resonant frequencies due to the compressible nature of the gas inside them. Near these resonant frequencies, the scattering and absorption of ultrasound by air bubbles are greatly enhanced, resulting in obvious peaks in the spectrum. In contrast, solid suspensions usually have a wider frequency response range and no obvious resonant peaks, because their physical properties are relatively uniform and are not easy to resonate at specific frequencies. At the same time, the scattering characteristics of air bubbles strongly depend on the ratio of their size to the wavelength of ultrasound. When the size of the bubble is close to or larger than the wavelength of ultrasound, the scattering effect becomes significant, while the scattering of solid suspensions is more uniform and usually does not change extremely with size.
[0095] Step S2: Obtain the size and volume of air bubbles and suspended objects, and process the smaller objects accordingly.
[0096] In this implementation, S2 specifically includes:
[0097] S21, use Canny edge detection algorithm to detect the size and volume of air bubbles and suspended objects;
[0098] The Canny edge detection algorithm extracts useful structural information from different visual objects and is a very widely used edge extraction algorithm in traditional computer vision. It aims to accurately identify edges from images and is particularly suitable for accurate size and volume detection.
[0099] The target object obtained by high-definition video is first pre-processed by Gaussian filter to reduce the impact of image noise. The principle is to perform weighted averaging on the entire image. The value of each pixel is obtained by weighted averaging itself and other pixel values in the neighborhood. The following formula is used for Gaussian smoothing:
[0100]
[0101] Among them, G(x,y) represents the image result after filtering, x, y represent the position of the pixel in the image, and σ is the standard deviation, which is used to control the smoothness of the filter.
[0102] Figure 3 (a)(c) show the original images. Figure 3 (b) and (d) show images processed by Gaussian filtering. It can be seen from the images that compared with the original images, the images processed by filtering retain the main structures of air bubbles and suspended objects while significantly suppressing the noise in the images. The Gaussian filtering process effectively smoothes the image and reduces the impact of environmental noise on the performance of subsequent edge detection algorithms.
[0103] In order to better restore the true appearance of air bubbles and suspended objects, this patent innovatively uses a multi-channel fusion mechanism, that is, by adjusting the different angles of the time difference flow measurement device, taking original images in different directions, and constructing N sets of input data. After filtering these N sets of data, the channel fusion technology is used for weighted fusion. The implementation method is as follows:
[0104]
[0105] Among them A 1 , A 2 , A 3 …, A NRepresents different channels, that is, image information taken at different angles. “*” represents matrix multiplication, which is used to calculate the similarity between two channels. 1 , α 2 …α N , which indicates the similarity between directions. The similarity of images at different angles is inconsistent. For example, the similarity between the front shot and the shot tilted by 20° is higher than that of the shot tilted by 60°.
[0106] Based on the similarity, re-weight each channel:
[0107] A=(α 1 , α 2 , α 3 …α N )*(A 1 , A 2 , A 3 …, A N )⑶
[0108] A represents the weighted image feature of each channel. After this processing, the edge parts with higher similarity can be strengthened, while the edge information with lower similarity can be suppressed.
[0109] Then, the gradient strength and direction of each channel image information after processing are calculated to determine the position and direction of the potential edge in the image. The Sobel operator is used to calculate the gradient in the horizontal and vertical directions respectively. The calculation formula is:
[0110]
[0111]
[0112] Among them, G x and G y are the gradients of the image in the horizontal and vertical directions, respectively, G and θ represent the gradient strength and direction, respectively. arctan() represents the inverse trigonometric function.
[0113] Then, the non-maximum suppression technique is used to refine the edges in the image to ensure that the edges are presented in the form of thin lines. Finally, by setting a high threshold (T h igh ) and the low threshold (T low ) to mark strong edges and weak edges. A strong edge is directly considered as a true edge, and a weak edge is also considered as a true edge if it is connected to a strong edge. Figure 4 The figure shows the result after being processed by the Canny edge detection algorithm.
[0114] in Figure 4 (a) is the air bubble edge detection result. Figure 4(b) is the result of suspended object edge detection. In the figure, it can be clearly seen that the edges of air bubbles and suspended objects are accurately identified. After channel fusion processing, these edges are further refined, weak edges connected to strong edges are strengthened, and isolated weak edges are suppressed, which are considered to be caused by noise or non-critical features. Not only does it enhance the visibility of the edges of air bubbles and suspended objects, but it also provides accurate edge information for subsequent volume calculations. By quantifying the closed contours formed by these edges, the volume of air bubbles and suspended objects can be estimated:
[0115] V=max(W i *H i *L i ⑹
[0116] Among them, W i , H i , L i Represents the length, width and height of each bubble or suspended object. Max represents the maximum value function. In order to measure accurately, the volume of each object is measured multiple times and the maximum value is taken as the final volume.
[0117] S22, treat small air bubbles and suspended matter;
[0118] Set volume threshold V M , when V <V M That is, when the volume of detected air bubbles and suspended objects is smaller than the preset threshold, ultrasonic waves are used for removal. The pressure waves generated by ultrasonic waves in the liquid will induce cavitation and form tiny bubbles. These bubbles will undergo rapid expansion and contraction, generating tiny jets and acoustic streams, which will act on the air bubbles, causing them to float to the surface and release, and on the suspended objects, causing them to aggregate into larger particles or push them to move around the water.
[0119] Step S3: constructing an optimal path algorithm for flow measurement based on the volumes of air bubbles and suspended objects obtained by the edge detection algorithm and the distance measured by the laser measuring instrument;
[0120] In this implementation, S3 specifically includes:
[0121] S31, calculating the distance from the bubble or suspended matter to the path;
[0122] like Figure 5 The distance measurement diagram shown in the figure shows that D represents the distance from the bubble to the time difference measuring instrument, which is calculated as follows:
[0123]
[0124] Where v is the speed of sound, t irepresents the round trip time of the ith path. N represents the number of valid echo paths.
[0125] Different from the traditional echo measurement method, the measurement method proposed in this patent can be applied in complex environments. Since the sound waves may experience multiple reflections before reaching the receiver, especially in an environment with many obstacles, the distance calculation proposed in this patent can compensate for this multipath effect to optimize the distance.
[0126] The α shown in the figure represents the inclination angle of the measuring instrument, and d represents the distance from the bubble or suspended object to the optimal path. The calculation formula is:
[0127] d=D*sin(α)⑻
[0128] S32, constructing an optimal path algorithm;
[0129] According to the volume V of the bubble and the suspended object and the distance D obtained in the previous step, construct Figure 6 The optimal path algorithm shown in the figure. The blue origin represents the air bubbles and suspended objects in the river, y represents the optimal path formula, y1 and y2 represent the two paths of the air bubbles or suspended objects on both sides of the path closest to y, and d1 and d2 represent the distances from y1 and y2 to the optimal path y.
[0130] The calculation formula of y1 is:
[0131] W11X1+W12X2+W13X3…W1nXn=d1⑼
[0132] The y2 calculation formula is:
[0133] W21X1+W22X2+W23X3…W2nXn=d2⑽
[0134] X1, X2, X3…Xn represent each bubble and suspended object, W11, W12, W13…W1n represent the weight of each bubble and suspended object, and the calculation formula is:
[0135]
[0136] Among them, η represents a hyperparameter to prevent zero division errors, and i represents the number of target objects. Generally speaking, the larger the volume and the closer the distance, the greater the impact on the ultrasonic wave, so the greater its proportion.
[0137] In order to obtain the optimal calculation path y, two conditions need to be met. On the one hand, d1 and d2 are required to be as large as possible, that is, as far away from the center line y as possible, so as to reduce the interference of bubbles and suspended objects on both sides of the center line on the ultrasonic signal on the path; on the other hand, as many bubbles and suspended objects as possible are required to be located on the paths y1 and y2, so that most of the bubbles and suspended objects are far away from the path passed by the ultrasonic signal. When the above conditions are met, iteratively search for such a set of parameters {W1, W2, W3, ... Wn} to construct the optimal path algorithm formula:
[0138] y=W1X1+W2X2+W3X3…WnXn⑿
[0139] The above formula represents the optimal measurement path prediction algorithm. After training, the specific values of {W1, W2, W3, …Wn} can be obtained, and then the distances d1 and d2 can be obtained in reverse.
[0140] Step S4: training the optimal path algorithm;
[0141] In this implementation, S4 specifically includes:
[0142] S41, build a learner network;
[0143] The patented training path algorithm neural network, whose input x represents the feature of each bubble and suspended object, first passes through a linear layer, which has a weight matrix and a bias vector. The dimension of the weight matrix is 256x6, indicating that the input feature size is 6 and the output feature is 256.
[0144] Next is a batch normalization (BatchNorm) layer, which normalizes the output of the previous layer so that the output maintains a distribution with a mean close to 0 and a standard deviation close to 1 during training, in order to speed up the convergence of the training process and prevent the gradient from disappearing or exploding.
[0145] This is followed by a nonlinear activation function, which is a nonlinear function that allows small gradients when the input value is less than zero to avoid the output of the activation function being completely zero. This helps keep the gradients flowing in the neural network and prevent the "dead neuron" phenomenon.
[0146] The weight matrix dimension of the second linear layer is 256x256, which means that this layer accepts 256 features of the previous layer as input and outputs 256 features. This is followed by a batch normalization layer and a non-linear activation function.
[0147] This is followed by an add operator that adds the output of the LeakyReLU after the first linear layer to the output of the second nonlinear activation function element-wise, which is a residual connection. Residual connections help solve the gradient vanishing problem in deep networks and allow for the training of deeper network structures.
[0148] This is followed by a dimensionality reduction linear layer with a weight matrix size of 128x256, which indicates that the network is reducing the 256-dimensional feature space to 128 dimensions. This is followed by another batch normalization and non-linear activation function.
[0149] The network then passes through a linear layer that further reduces the dimension to 64 (weight matrix is 64x128), followed by batch normalization and LeakyReLU.
[0150] Finally, the network has an output layer, which is a linear layer (weight matrix is 1x64), which maps the 64-dimensional features to a single output. This network represents the mapping relationship from input x to y.
[0151] S42, start iterative training for the above network, input the pre-collected sample data into the model, set the training batch to 1000 times, use Adam as the learner, set the learning rate to 0.01, and use the following loss formula:
[0152]
[0153] Among them, α represents weight information, h s (x (i) ) represents the predicted value, y (i) Represents the true value, and Loss represents the loss value between the two.
[0154] Different from the past, this application applies weighted processing to the sample loss value. Specifically, when the loss is large, the corresponding weight is reduced; and when the loss is small, the weight is increased. This processing method aims to make the model pay more attention to the model with prediction errors.
[0155] The loss iteration is as follows:
[0156] Number of training sessions Loss 1 87 2 85 3 76 4 55 … … 998 0.15 999 0.15 1000 0.14
[0157] Finally, the model loss dropped to 0.14, and the model training met the standard. The model will be used to predict the flow path in the basin.
[0158] Embodiment 1:
[0159] When measuring flow in a river basin, the camera device detected an unknown object in the water area and used sound waves for spectrum detection. The spectrum diagram is as follows Figure 7 :
[0160] As can be seen from the figure, the amplitude jitter is too large, so it is identified as an air bubble. The Canny edge detection algorithm is used to identify and calculate the volume V of the air bubble, whose sizes are V = {6e-5m3, 7e-5m3, 5e-6m3}. Given the initial distance d = {2e-2m, 3e-2m, 1.5e-2m}, the initial W is obtained according to formula 11, and the initial path is constructed:
[0161] y=W*X
[0162] Using the learner network, the training batch is set to 1000 times, the learner is Adam, the learning rate is set to 0.01, and the loss is based on the formula provided by this patent. The optimal measurement path is finally calculated as follows:
[0163] y=0.0015*X1+0.002*X2+0.0001*X3
[0164] Embodiment 2:
[0165] At night, due to the dim light, in order to accurately monitor objects in the river basin, the infrared sensor is activated to monitor Figure 8 Image shown:
[0166] Use sound waves to perform spectrum detection, and the spectrum diagram is as follows Fig. 9 As shown:
[0167] It is observed that the peak is relatively gentle, and the target object is determined to be a suspended object. At the same time, the edge detection algorithm is used to calculate the volume of the target object, and its size is V = {6e-7m3, 7e-7m3, 5e-7m3, 5e-6m3, 3.5e-7m3, 2.55e-7m3, 5.11e-7m3, 6e-6m3, 8e-8m3, 6.5e-7m3, 7e-7m3, 5e-7m3, 3.5e-6m3, 7e-7m3, 6.6e-7m3}. Initial distance d = {3.2e-2m, 4.23e-2m, 1.42e-2m, 2.55e-2m, 3.15e-3m, 1.56e-2m, 4.25e-2m, 3.25e-2m, 1.5e-3m, 2e-2m, 3.44e-2m, 1.85e-3m, 2.1e-2m, 7.1e-2m, 1.5e-2m}, get the initial W according to formula 11, and construct the initial path:
[0168] y=W*X
[0169] Using the learner network, the training batch is set to 1000 times, the learner is Adam, the learning rate is set to 0.01, and the loss is based on the formula provided by this patent. The optimal measurement path is finally calculated as follows:
[0170] y=0.0025*X1+0.012*X2+0.0001*X3+0.0045*X4+0.0023*X5+0.00011*X6+0.0075*X7+0.0024 *X8+0.00051*X9+0.0015*X10+0.0022*X11+0.00001*X12+0.005*X13+0.002*X14+0.0001*X15
[0171] The above description is only a preferred embodiment of the present invention and does not constitute any other form of limitation to the present invention. Any modification or equivalent change made based on the technical essence of the present invention still falls within the scope of protection required by the present invention.
Claims
1. The improved time difference method flow monitoring method based on the path optimization algorithm, the specific steps are as follows: S1. Collecting air bubble and suspended matter information data in the flow area to be measured; S2, obtaining the size and volume of air bubbles and suspended objects, and making corresponding processing for targets with smaller volumes; The step S2 is specifically as follows: S21, use Canny edge detection algorithm to detect the size and volume of air bubbles and suspended objects; The Canny edge detection algorithm works as follows: The target object obtained by the camera device is first pre-processed by a Gaussian filter, and the following formula is used for Gaussian smoothing: in, G(x,y) represents the image result after filtering, x, y represent the position of the pixel in the image, and σ is the standard deviation, which is used to control the smoothness of the filter; Use a multi-channel fusion mechanism, that is, by adjusting the different angles of the time difference flow measurement device, take original images in different directions, construct N groups of input data, filter these N groups of data, and use channel fusion technology for weighted fusion. The implementation method is as follows: Among them, A1, A2, A3…, A N Indicates different channels, that is, image information taken at different angles. "*" represents matrix multiplication, which is used to calculate the similarity between two channels, α1, α2…α N , which indicates the similarity between the paths. The similarity of images at different angles is inconsistent; Based on the similarity, re-weight each channel: A=(α1,α2,α3…α N )*(A1, A2, A3…, A N ) A represents the weighted image features of each channel; Then, the gradient strength and direction of each channel image information after processing are calculated to determine the position and direction of the potential edge in the image. The Sobel operator is used to calculate the gradient in the horizontal and vertical directions respectively. The calculation formula is: Among them, G x and G y are the gradients of the image in the horizontal and vertical directions, G and θ represent the gradient strength and direction, respectively, and arctan() represents the inverse trigonometric function; Then, the non-maximum suppression technique is used to refine the edges in the image to ensure that the edges are presented in the form of thin lines. Finally, by setting a high threshold (T high ) and the low threshold (T low ) to mark strong and weak edges; By quantifying the closed contours formed by these edges, the volumes of air bubbles and suspended objects are estimated: V=max(W i *H i *L i ) Among them, W i , H i , L i Represents the length, width and height of each bubble or suspended object. Max represents the maximum value function. In order to measure accurately, the volume of each object is measured multiple times and the maximum value is taken as the final volume. S22, treat small air bubbles and suspended matter; Set volume threshold V M , when V <V M , that is, when the volume of detected air bubbles and suspended objects is smaller than a preset threshold, ultrasonic waves are used to perform a clearing operation; S3, based on the volume of air bubbles and suspended objects obtained by the edge detection algorithm and the distance measured by the laser measuring instrument, the distance is the distance from the measured air bubbles and suspended objects to the measuring instrument, constructing an optimal path algorithm for flow measurement; The step S3 is specifically as follows: S31, calculating the distance from the bubble or suspended matter to the path; D is the distance from the bubble to the time difference measuring instrument, which is calculated as: Where v is the speed of sound, t i It represents the round trip time of the i-th path, N represents the number of effective echo paths, and the distance is optimized by compensating for this multipath effect through distance calculation. α represents the tilt angle of the measuring instrument, and d represents the distance from the bubble or suspended object to the optimal path. The calculation formula is: d=D*sin(α) S32, constructing an optimal path algorithm; According to the volume V of the air bubbles and suspended objects and the distance D obtained in the previous step, the optimal path algorithm is constructed. The origin represents the air bubbles and suspended objects in the river, y represents the optimal path formula, y1 and y2 represent the two paths closest to y for the air bubbles or suspended objects on both sides of the path, and d1 and d2 represent the distances from y1 and y2 to the optimal path y. The calculation formula of y1 is: W11X1+W12X2+W13X3....W1nXn=d1 The y2 calculation formula is: W21X1+W22X2+W23X3....W2nXn=d2 X1, X2, X3…Xn represent each bubble and suspended object, W11, W12, W13…W1n represent the weight of each bubble and suspended object, and the calculation formula is: Where η represents a hyperparameter to prevent division by zero errors, and i represents the number of target objects; In order to obtain the optimal calculation path y, two conditions need to be met; On the one hand, d1 and d2 are required to be large, that is, far away from the center line y, so as to reduce the interference of bubbles and suspended objects on both sides of the center line on the ultrasonic signal on the path; On the other hand, it is required that as many bubbles and suspended objects as possible are located on the paths y1 and y2, so that most of the bubbles and suspended objects are far away from the path through which the ultrasonic signal passes; When the above conditions are met, we iteratively search for a set of parameters {W1, W2, W3, …Wn} to construct the optimal path algorithm formula: y=W1X1+W2X2+W3X3....WnXn The above formula represents the optimal measurement path prediction algorithm. After training, the specific values of {W1, W2, W3, …Wn} can be obtained, and then the distances d1 and d2 can be obtained in reverse. S4, training optimal path algorithm; The step S4 is specifically as follows: S41, build a learner network; Specifically, the input x represents the feature of each bubble and suspended object. It first passes through a linear layer, which has a weight matrix and a bias vector. The dimension of the weight matrix is 256x6, which means that the input feature size is 6 and the output feature size is 256. Next is a batch normalization layer, which normalizes the output of the previous layer so that the output maintains a distribution with a mean close to 0 and a standard deviation close to 1 during training. Then there is a nonlinear activation function that allows small gradients when the input value is less than zero to avoid the output of the activation function being completely zero and prevent the "dead neuron" phenomenon; The weight matrix dimension of the second linear layer is 256x256, which means that this layer accepts 256 features of the previous layer as input and outputs 256 features, followed by a batch normalization layer and a nonlinear activation function; This is followed by an add operator, which adds the output of the LeakyReLU after the first linear layer to the output of the second nonlinear activation function element-wise, which is a residual connection; Next is a dimensionality reduction linear layer with a weight matrix size of 128x256, which indicates that the network is reducing the 256-dimensional feature space to 128 dimensions, followed by another batch normalization and non-linear activation function; The network then passes through a linear layer that further reduces the dimension to 64, with a corresponding weight matrix of 64x128, followed by batch normalization and LeakyReLU; Finally, the network has an output layer, which is a linear layer with a corresponding weight matrix of 1x64, which maps the 64-dimensional features to a single output. This network represents the mapping relationship from input x to y. S42, start iterative training for the above network, input the pre-collected sample data into the model, set the training batch to 1000 times, use Adam as the learner, set the learning rate to 0.01, and use the following loss formula: Among them, α represents weight information, h s (x (i) ) represents the predicted value, y (i) Represents the true value, and Loss represents the loss value between the two.
2. The improved time difference method flow rate monitoring method based on path optimization algorithm according to claim 1 is characterized in that: The step S1 is specifically as follows: S11, using a camera to collect current watershed image information in real time; The camera device is installed on the steering seat of the time-of-day measuring instrument. As the steering seat rotates, the camera device will also take real-time photos. When air bubbles and suspended objects are detected on the river surface, the camera device will take photos and process them. The images will be used for classification and path planning in the later stage. S12, using infrared sensor to assist in identification; Use infrared sensors for auxiliary identification. By receiving infrared radiation signals emitted by objects, infrared sensors work without visible light and can identify objects at night or in low-light environments. S13, using a laser measuring instrument to measure the distances of the air bubbles and the suspended objects from the measuring instrument; The laser measuring instrument is installed on the steering seat. When the steering seat rotates, the laser measuring instrument emits a laser beam and receives the light reflected by the laser beam on the air bubble and the surface of the suspended object to measure the distance between the target object and the equipment. S14. When the camera device detects air bubbles and suspended objects on the river surface, it takes images in a timely manner and issues ultrasonic instructions, using a spectrum analyzer to receive the spectrum signal transmitted and returned by the transducer.
