A water level measurement method, product, device and storage medium
By inputting the image in the water ruler video stream to the water ruler recognition model after training, detecting the water surface and water rule values, the existing water level measurement methods are solved, and efficient and accurate water level detection and real-time alarm are achieved.
Patent Information
- Application Number
- CN202411825700.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2044-12-12
AI Technical Summary
The existing water level measurement methods are inefficient, the data is not updated in time, and are susceptible to human factors. The vision-based deep learning water ruler detection method is low in accuracy and is greatly affected by environmental factors, resulting in detection errors and alarm delays.
By inputting the current water ruler image in the received water ruler video stream in real time into the training water ruler recognition model, the water surface, preset icons and water ruler values are detected, and the targets are screened based on confidence, the water level height is calculated, the water ruler recognition process is simplified, and the efficiency and accuracy are improved.
It improves the efficiency and accuracy of water level detection, reduces detection errors, avoids errors affected by environmental factors, realizes real-time alarms, and reduces the risk of flood prevention delays.
Smart Images

Figure CN119274183B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of water level monitoring, and in particular to a water level measurement method, product, device and storage medium. Background Art
[0002] Water level, as a key element of hydrological measurement, is the basic supporting data for water resource allocation and flood and drought prevention. Water resources and water security issues seriously affect the development of the national economy. The efficient allocation of water resources and the effective prevention of flood disasters depend on the real-time and accurate monitoring of water level data. Therefore, it is of great significance to carry out research on water level measurement methods.
[0003] Traditional water level measurement methods are mainly divided into two categories: manual water gauge reading method and automatic data collection method using sensors (such as pressure, ultrasonic, radar and other sensors). They have been widely used in water level measurement practice. However, the manual water gauge reading method requires manual on-site reading, which is inefficient, and the data is not updated in a timely manner and is subject to greater interference from human factors. Readings using equipment such as sensor floats are not only expensive but also easy to damage.
[0004] With the development of smart water conservancy construction and information technology, surveillance cameras are installed all over rivers and reservoirs, and image-based water level measurement methods are gradually applied to water level monitoring. This method uses cameras to identify the water gauge and provides real-time visual water level data at monitoring points. The construction and maintenance costs are low, so it has broad application prospects. However, the current vision-based deep learning water gauge detection method usually combines the target segmentation network and the target detection network to identify the water gauge scale. This method is limited by the number of pictures, small data samples, low precision, and in the case of clear water, reflection, turbulence (i.e., rapid water flow), waves, dirt at the bottom of the water gauge, water surface reflection, and visible scales below the water surface, it will seriously affect the detection accuracy, and the detection value fluctuates greatly. In addition, the model parameters are large, and it is difficult to achieve real-time alarms, which leads to alarm delays and delays in flood control. Summary of the invention
[0005] In view of this, the purpose of this application is to provide a water level measurement method, product, device and storage medium, which can simplify the water gauge recognition process, improve the efficiency of water gauge recognition, and avoid detection errors, thereby improving the efficiency and accuracy of water level detection. The specific scheme is as follows:
[0006] In a first aspect, the present application discloses a water level measurement method, comprising:
[0007] The current water gauge image in the real-time received water gauge video stream is input into the trained water gauge recognition model to detect the current water gauge image and obtain a corresponding water gauge detection result; the water gauge detection result includes the recognized water surface, the preset icon on the water gauge, the water gauge value marked on the water gauge and the confidence level corresponding to each of the water gauge values; a plurality of preset icons are distributed on the water gauge to divide the water level scale by each of the preset icons;
[0008] Filtering a preset number of target confidences and corresponding target preset icons and target water gauge values from the water gauge detection results in descending order of confidence;
[0009] Based on the distance between the icon position of the target preset icon on the water ruler and the target intersection point, and combined with the numerical position of the target water ruler value on the water ruler, the actual water level height corresponding to the target intersection point is calculated; the target intersection point is the intersection point of the water ruler and the water surface in the current water ruler image.
[0010] Optionally, the step of inputting the current water gauge image in the real-time received water gauge video stream into the trained water gauge recognition model to detect the current water gauge image and obtain a corresponding water gauge detection result includes:
[0011] Acquire a water gauge image in a water gauge video stream received in real time to obtain a current water gauge image; the water gauge video stream is a video stream collected after alternately irradiating the water surface in the area where the target water gauge is located with natural light and white light whose illumination intensity meets a preset high-intensity condition;
[0012] The current water gauge image is input into the trained water gauge recognition model to detect the current water gauge image and obtain a corresponding water gauge detection result.
[0013] Optionally, the step of selecting a preset number of target confidences and corresponding target preset icons and target water gauge values from the water gauge detection results in descending order of confidences includes:
[0014] Correcting the water gauge in the current water gauge image according to the length and direction of the preset icon in the water gauge detection result to obtain a corrected water gauge image;
[0015] Determining whether there is a water gauge element under the water surface in the corrected water gauge image;
[0016] If there is no water gauge element under the water surface in the corrected water gauge image, sorting the multiple confidences in the water gauge detection result in descending order of confidence;
[0017] A preset number of target confidences are screened from the sorted confidences, and a target preset icon and a target water gauge value corresponding to each of the target confidences are obtained from the water gauge detection result.
[0018] Optionally, the water level measurement method further includes:
[0019] If there are water gauge elements under the water surface in the corrected water gauge image, the step of inputting the current water gauge image in the real-time received water gauge video stream into the trained water gauge recognition model is re-executed to detect the current water gauge image and obtain the corresponding water gauge detection result.
[0020] Optionally, the actual water level height corresponding to the target intersection point is calculated based on the distance between the icon position of the target preset icon on the water gauge and the target intersection point, and in combination with the numerical position of the target water gauge value on the water gauge, including:
[0021] Obtaining the number of pixels occupied by each of the target preset icons and the icon size, and judging whether each of the target water gauge values is correct based on the numerical position of the target water gauge value on the water gauge, the size of the target water gauge value and the icon size;
[0022] If all the target water gauge values are correct, then determining the maximum confidence level among the multiple target confidence levels, and obtaining the vertical coordinate value of the target water gauge value corresponding to the maximum confidence level;
[0023] Based on the distance between the target intersection point and the target preset icon corresponding to the maximum confidence, the vertical coordinate value and the corresponding number of pixel points, the actual water level height corresponding to the target intersection point is calculated.
[0024] Optionally, the water level measurement method further includes:
[0025] Labeling each collected historical water gauge image to obtain a first water gauge image set;
[0026] Performing image enhancement on each water gauge image in the first water gauge image set to obtain an enhanced image set;
[0027] The enhanced image set is input into the initial image enhancement network to sequentially perform model training on the image generation network and the image discrimination network in the initial image enhancement network to obtain a trained image enhancement network; the image generation network includes a feature fusion network constructed based on the first convolutional network and the activation function layer, and a context feature enhancement network constructed based on the second convolutional network and the upsampling layer;
[0028] Generate new water gauge images through the image generation network in the trained image enhancement network, and label the new water gauge images to obtain a second water gauge image set;
[0029] The first water gauge image set and the second water gauge image set are input into an initial water gauge recognition model for training to obtain the trained water gauge recognition model.
[0030] Optionally, performing image enhancement on each water gauge image in the first water gauge image set to obtain an enhanced image set includes:
[0031] Performing brightness change on each water gauge image in the first water gauge image set to obtain a first changed water gauge image;
[0032] Performing a color change on the first changed water-rule image based on a target color selected from a preset color set, so as to change the color of the water-rule in the first changed water-rule image to the target color, thereby obtaining a second changed water-rule image;
[0033] A noise element having any color in the preset color set is randomly added to each of the second changed water gauge images to obtain an enhanced image set including a plurality of noise enhanced images.
[0034] Optionally, before changing the color of the first changed water gauge image based on a target color selected from a preset color set, the method further includes:
[0035] The preset color set is constructed based on the color of the water gauge value marked on the water gauge and the color of the preset icon.
[0036] Optionally, the step of inputting the enhanced image set into an initial image enhancement network to sequentially perform model training on an image generation network and an image recognition network in the initial image enhancement network to obtain a trained image enhancement network comprises:
[0037] Extracting a first number of water gauge images from the enhanced image set to obtain a first type of image;
[0038] Randomly extract a second number of water gauge images from the enhanced image set and remove the area where the water gauge is located from the randomly extracted water gauge images to obtain a second type of image;
[0039] Inputting the first category of images and the second category of images into the image generation network in the initial image enhancement network for model training, and outputting the generated images;
[0040] The generated image and the first type of image are input into the image recognition network in the initial image enhancement network for model training to obtain a trained image enhancement network.
[0041] Optionally, inputting the first category of images and the second category of images into an image generation network in an initial image enhancement network for model training, and outputting a generated image, comprises:
[0042] Converting the first type of image into a binary image to obtain a converted image, and resizing the converted image to obtain a first resized image;
[0043] resizing the second type of image to obtain a second adjusted image, and normalizing the second adjusted image to obtain a first normalized image;
[0044] The first adjusted image and the first normalized image are input into an image generation network in an initial image enhancement network for model training, and a generated image is output.
[0045] Optionally, the step of inputting the generated image and the first type of image into an image discrimination network in an initial image enhancement network for model training to obtain a trained image enhancement network includes:
[0046] resizing the generated image to obtain a third adjusted image, and normalizing the third adjusted image to obtain a second normalized image;
[0047] resizing the first type of image to obtain a fourth adjusted image, and normalizing the fourth adjusted image to obtain a third normalized image;
[0048] The second normalized image and the third normalized image are input into the image recognition network in the initial image enhancement network for model training to obtain a trained image enhancement network.
[0049] Optionally, the trained water gauge recognition model is a model obtained by training an initial water gauge recognition model based on a fast spatial pyramid pooling network, a target feature extraction network and a feature fusion network using a historical water gauge image set; the target feature extraction network is a network constructed based on a third number of convolutional networks and a fourth number of C3 networks.
[0050] In a second aspect, the present application discloses a computer program product, including a computer program / instructions, which implement the aforementioned water level measurement method when executed by a processor.
[0051] In a third aspect, the present application discloses an electronic device, comprising a processor and a memory; wherein the processor implements the aforementioned water level measurement method when executing a computer program stored in the memory.
[0052] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned water level measurement method is implemented.
[0053] It can be seen that the present application first inputs the current water gauge image in the real-time received water gauge video stream into the trained water gauge recognition model to detect the current water gauge image and obtain the corresponding water gauge detection result; the water gauge detection result includes the identified water surface, the preset icon on the water gauge, the water gauge value marked on the water gauge and the confidence corresponding to each of the water gauge values; a number of preset icons are distributed on the water gauge to divide the water level scale by each of the preset icons; in order of confidence from large to small, a preset number of target confidences and the corresponding target preset icons and target water gauge values are screened from the water gauge detection results; based on the distance between the icon position of the target preset icon on the water gauge and the target junction point, and combined with the numerical position of the target water gauge value on the water gauge, the actual water level height corresponding to the target junction point is calculated; the target junction point is the junction point of the water gauge and the water surface in the current water gauge image. The present application first detects the current water gauge image to be measured through the trained water gauge recognition model, so as to obtain a water gauge detection result including the water surface, the preset icon on the water gauge, the water gauge value marked on the water gauge, and the confidence corresponding to each water gauge value. Then, a preset number of target confidences and the corresponding target preset icons and target water gauge values are screened out from the water gauge detection result. Finally, based on the distance between the icon position of the target preset icon on the water gauge and the intersection point, and combined with the numerical position of the target water gauge value on the water gauge, the intersection point of the water gauge and the water surface is calculated. In accordance with the actual water level height, the present application adopts a water gauge recognition model, takes into account the water gauge value and the preset icon at the same time, abandons the traditional character recognition method, simplifies the water gauge recognition process, improves the efficiency of water gauge recognition, and avoids detection errors by detecting the water gauge value and the preset icon with high confidence for water level measurement. In addition, the present application adopts the method of the intersection of the water gauge and the water surface, and calculates the actual water level by the distance between the icon position and the intersection point, which can effectively avoid the influence of the intersection point position due to factors such as turbulent water flow or waves, thereby improving the accuracy of water level detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0055] Figure 1A flow chart of a water level measurement method disclosed in this application;
[0056] Figure 2 A schematic diagram of a specific water gauge image disclosed in this application;
[0057] Figure 3 A specific structural diagram of letter E disclosed in this application;
[0058] Figure 4 A schematic diagram of a specific water gauge recognition model structure disclosed in this application;
[0059] Figure 5 A schematic diagram of a specific water level gauge detection result output content disclosed in this application;
[0060] Figure 6 A schematic diagram of a specific optimized SPPF network structure disclosed in this application;
[0061] Figure 7 A schematic diagram of a specific C3 network structure disclosed in this application;
[0062] Figure 8 A schematic diagram of a specific B1 network structure disclosed in this application;
[0063] Fig. 9 A schematic diagram of a specific B2 network structure disclosed in this application;
[0064] Fig.10 A schematic diagram of a specific convolutional network structure disclosed in this application;
[0065] Fig.11 A schematic diagram of a specific image generation network structure disclosed in this application;
[0066] Fig.12 A schematic diagram of a specific image recognition network structure disclosed in this application;
[0067] Fig.13 A schematic diagram of a specific image enhancement network structure disclosed in this application;
[0068] Fig.14 A flow chart of a specific water level measurement method disclosed in this application;
[0069] Fig.15 A schematic diagram of a specific water gauge detection result disclosed in this application;
[0070] Fig.16 A schematic diagram of a specific water gauge detection result disclosed in this application;
[0071] Fig.17A schematic diagram of a specific water gauge detection result disclosed in this application;
[0072] Fig.18 A schematic diagram of a specific water gauge detection result disclosed in this application;
[0073] Fig.19 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0074] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0075] The present application discloses a water level measurement method. Figure 1 As shown, the method includes:
[0076] Step S11: input the current water gauge image in the real-time received water gauge video stream into the trained water gauge recognition model to detect the current water gauge image and obtain a corresponding water gauge detection result; the water gauge detection result includes the identified water surface, the preset icon on the water gauge, the water gauge value marked on the water gauge and the confidence level corresponding to each of the water gauge values; a number of preset icons are distributed on the water gauge, and the water level scale is divided by each of the preset icons.
[0077] It should be pointed out that the water level measurement solution proposed in this application can be applied to edge computing devices, such as edge servers, edge boxes and other devices.
[0078] In this embodiment, when performing water level measurement, the water gauge image in the water gauge video stream collected by the camera and other devices can be received in real time by the edge computing device to obtain the current water gauge image, and then the current water gauge image is input into the trained water gauge recognition model, so that the current water gauge image can be detected by the model to obtain the corresponding water gauge detection result; wherein, the water gauge detection result includes the identified water surface, the preset icon on the water gauge, the water gauge value marked on the water gauge, and the confidence level corresponding to each of the water gauge values. In addition, a number of preset icons are distributed on the water gauge, so that the water level scale is divided by each of the preset icons.
[0079] For details, see Figure 2 As shown, Figure 2A specific water gauge image is shown, which includes information such as water surface and water gauge, where the water gauge is composed of the letter E and water gauge values (including 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, etc.). Figure 3 As shown, each letter E in the water gauge consists of 5 intervals of unit length.
[0080] In a specific implementation, the current water gauge image in the real-time received water gauge video stream is input into the trained water gauge recognition model to detect the current water gauge image and obtain a corresponding water gauge detection result, including: obtaining the water gauge image in the real-time received water gauge video stream to obtain the current water gauge image; the water gauge video stream is a video stream collected after the water surface in the area where the target water gauge is located is alternately illuminated by natural light and white light whose illumination intensity meets the preset high intensity condition; the current water gauge image is input into the trained water gauge recognition model to detect the current water gauge image and obtain a corresponding water gauge detection result. In this embodiment, in order to improve the detection accuracy of the horizontal plane, prevent the error of the numerical detection of the water gauge in the water, and improve the detection accuracy, the water surface in the area where the target water gauge is located can be illuminated by alternating natural light and white light whose illumination intensity meets the preset high intensity condition, so as to collect a video stream near the target water gauge. When the edge computing device receives the water gauge image in the water gauge video stream, it is input into the trained water gauge recognition model for detection, so as to obtain a corresponding water gauge detection result. By irradiating the horizontal surface near the water gauge with high-intensity white light, the influence of the water gauge being visible underwater due to the water being too clear or the water gauge having a reflection in the water is avoided, thereby effectively improving the detection accuracy.
[0081] The trained water gauge recognition model is a model obtained by training the initial water gauge recognition model based on the fast spatial pyramid pooling network, the target feature extraction network and the feature fusion network using the historical water gauge image set; the target feature extraction network is a network constructed based on the third number of convolutional networks and the fourth number of C3 networks. Figure 4 As shown, Figure 4 A specific water gauge recognition model is shown, which includes a fast spatial pyramid pooling (SPPF, Spatial Pyramid Pooling Fast) network, a feature extraction network based on multiple convolutional networks and multiple C3 networks, and a feature fusion network based on multiple convolutional networks. By fusing multiple networks into the water gauge recognition network, the number of model parameters can be reduced, which is more conducive to deployment on edge computing devices, not only reducing the size of the model's video memory, but also improving the model's detection efficiency.
[0082] Specifically, when Figure 4 When the water gauge recognition model in the detection of the water gauge image, the following steps can be included:
[0083] Step 1: Access the water gauge video stream and extract the water gauge image from the water gauge video stream;
[0084] Step 2: preprocess the water gauge image to obtain a preprocessed image; for example, scale the water gauge image to a specific size. Preferably, the specific size is set to 640*640. It should be noted that in the process of scaling, the aspect ratio of the image is not changed. The largest side can be scaled to 640, and the smaller side can be filled with grayscale.
[0085] Step 3: Obtain the preprocessed image and obtain the eigenvalue of [1,3,640,640], where the four elements in [1,3,640,640] represent the number of images, the number of channels, and the length and width of pixel values, respectively;
[0086] Step 4: Input the above eigenvalues of [1, 3, 640, 640] into the Conv network to obtain the eigenvalues of [1, 64, 320, 320];
[0087] Step 5: Input the above feature value of [1,64,320,320] into the Conv network to obtain the feature value of [1,128,160,160];
[0088] Step 6: Input the above eigenvalues of [1,128,160,160] into the C3 network to obtain the eigenvalues of [1,128,160,160];
[0089] Step 7: Input the above eigenvalues of [1,128,160,160] into the Conv network to obtain the eigenvalue g1 of [1,256,80,80];
[0090] Step 8: Input the above eigenvalue g1 into the C3 network to obtain the eigenvalue of [1,256,80,80];
[0091] Step 9: Input the above eigenvalues of [1,256,80,80] into the Conv network to obtain the eigenvalue g2 of [1,512,40,40];
[0092] Step 10: Input the above eigenvalue g2 into the C3 network to obtain the eigenvalue g3 of [1,512,40,40];
[0093] Step 11: Input the above eigenvalue g3 into the Conv network to obtain the eigenvalue g4 of [1,1024,20,20];
[0094] Step 12: Input the above eigenvalue g4 into the C3 network to obtain the eigenvalue g5 of [1,1024,20,20];
[0095] Step 13: Input the above eigenvalue g5 into the fast spatial pyramid pooling network (i.e., SPPF network) for feature fusion to obtain the eigenvalue g6 of [1, 1024, 20, 20];
[0096] Step 13.1: The input feature value is processed by the Conv network, and the result is copied into two parts, one of which is processed by Maxpool2d and merged with the other part;
[0097] Step 13.2: Pass the combined result through the Conv network to obtain the output feature value of the SPPF network;
[0098] Step 14: Input the eigenvalue g5 and the eigenvalue g6 into the feature fusion network 1;
[0099] STEP14.1: The eigenvalue g6 passes through the Conv network to obtain the new eigenvalue G1_1, and the eigenvalue g5 passes through two Conv networks to obtain the new eigenvalues G1_2 and G1_3;
[0100] STEP14.2: Multiply the corresponding elements of eigenvalue G1_1 and eigenvalue G1_2 to obtain eigenvalue G1_4;
[0101] STEP14.3: Add the corresponding position elements of eigenvalue G1_4 and eigenvalue G1_3 to obtain the fused eigenvalue Gc1_1;
[0102] Step 15: Merge the fused eigenvalue Gc1_1 and the eigenvalue G1_1 to obtain the eigenvalue g7;
[0103] Step 16: Input the eigenvalue g7 to the Conv network, eigenvalue g8;
[0104] Step 17: Input the eigenvalue g8 and the eigenvalue g3 into the feature fusion network 2 to obtain the fused eigenvalue Gc2_1; the process is the same as step 14;
[0105] Step 18: Input the fused eigenvalue Gc2_1 into the Conv network, eigenvalue g9;
[0106] Step 19: Merge the eigenvalue g7 and the eigenvalue g9 to obtain the eigenvalue g10;
[0107] Step 20: Input the eigenvalue g10 into the Conv network to obtain the eigenvalue g11;
[0108] Step 21: Input the eigenvalue g11 into the Conv network to obtain the eigenvalue g12;
[0109] Step 22: Input the eigenvalue g11 and the eigenvalue g12 into the feature fusion network 3 to obtain the fused eigenvalue Gc3_1; the process is the same as step 14;
[0110] Step 23: Input the fused eigenvalue Gc3_1 into the Conv network to obtain a new eigenvalue g13;
[0111] Step 24: Input the new eigenvalue g13 into the Conv network to obtain the water gauge detection result Detect1;
[0112] Step 25: Combine the eigenvalue g13 and the eigenvalue g8 to obtain the eigenvalue g14;
[0113] Step 26: Input the eigenvalue g14 into the Conv network to obtain the water gauge detection result Detect2;
[0114] Step 27: Input the eigenvalue g14 and the eigenvalue G1_1 into the feature fusion network 4 to obtain the fused eigenvalue Gc4_1; the process is the same as step 14;
[0115] Step 28: Input the fused feature value Gc4_1 into the Conv network to obtain the water gauge detection result Detect3.
[0116] For details, see Figure 5 As shown, Figure 5 The figure shows the specific contents of each water level detection result Detect, which includes four parts: bbox (bounding box), seg (segmentation mask), class (category) and score (category score).
[0117] It should be noted that this application optimizes the model structure of the traditional SPPF network, further simplifies the model structure of the SPPF network, reduces the number of original maximum pooling layers, and thus improves the overall processing efficiency of the model. Figure 6 As shown, Figure 6A specific optimized SPPF network is shown. When the water level is measured through the network, the input eigenvalue can be first convolved through a convolution layer (i.e., a Conv layer with network parameters of k=1, s=1, p=0, and c=512). Then, the convolution result is copied into two copies, one of which is input into a feature fusion node, and the other is input into a Maxpool2d layer (i.e., a two-dimensional maximum pooling layer with network parameters of k=3, s=1, and p=2) for processing. Then, the two processing results are subjected to multi-scale feature fusion through the feature fusion node, and then the combined result is convolved through a Conv layer (with network parameters of k=1, s=1, p=0, and c=1024) to obtain the output eigenvalue. In the convolution network, k represents kernel (the size of the convolution kernel), c represents column (the number of layers), s represents stride (the step length), and p represents padding (the number of padding).
[0118] For details, see Figure 7 As shown, Figure 7 A specific C3 network is shown, which includes 3 convolutional layers (with parameters k=1, s=1), 1 B1 network or B2 network and 1 eigenvalue merging node. The network structures of the B1 network and the B2 network are shown in Figure 8 and Fig. 9 As shown, Figure 8 The B1 network in includes 2 convolutional layers and a feature value merging node. Fig. 9 The B2 network in includes 2 convolutional layers. In addition, see Fig.10 As shown, Fig.10 The network structure of the convolutional network in the target feature extraction network in the water gauge recognition model after training is shown, which specifically includes 1 Conv2d layer (2D convolutional layer), 1 BN (Batch Normalization) layer and 1 SiLU (Sigmoid Linear Unit, an improved activation function) layer. The accuracy of feature extraction can be improved by combining multiple C3 networks and convolutional networks.
[0119] In this embodiment, the specific acquisition process of the trained water gauge recognition model may include: labeling each collected historical water gauge image to obtain a first water gauge image set; performing image enhancement on each water gauge image in the first water gauge image set to obtain an enhanced image set; inputting the enhanced image set into the initial image enhancement network to perform model training on the image generation network and the image discrimination network in the initial image enhancement network in turn to obtain a trained image enhancement network; the image generation network includes a feature fusion network constructed based on the first convolutional network and the activation function layer, and a context feature enhancement network constructed based on the second convolutional network and the upsampling layer; generating a new water gauge image through the image generation network in the trained image enhancement network, and labeling the new water gauge image to obtain a second water gauge image set; inputting the first water gauge image set and the second water gauge image set into the initial water gauge recognition model for training to obtain the trained water gauge recognition model. For example, historical water gauge images are collected, and then the water gauge and water surface in each historical water gauge image are pixel-marked to distinguish the water gauge and water surface area, and then the letter E on the water gauge and the water gauge value are marked (i.e., labeled) to obtain the corresponding first water gauge image set, wherein the category label corresponding to the water gauge value can be set to 0 / 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 / 9, and if the water gauge value is greater than 9, it can be read by a combination of values; then, each water gauge image in the first water gauge image set is enhanced, such as brightness, color change, noise, scaling, mixup (referring to randomly extracting two categories in the training set and mixing them together using a linear interpolation method) and Mosaic (referring to randomly cropping four pictures and then splicing them into one picture as training data) and other image enhancement processing is performed on the water gauge image to obtain the corresponding enhanced image set; further, the enhanced image set is sequentially input into the image generation network and the image discrimination network in the initial image enhancement network for model training, thereby obtaining a trained image enhancement network.
[0120] It should be noted that see Fig.11 As shown in , the image generation network contains multiple feature fusion networks based on the first convolutional network (Conv) and activation function (SiLU) layer, and a context feature enhancement network based on the second convolutional network (Conv) and upsampling (upsample) layer. In addition, see Fig.12 As shown in the figure, the image recognition network contains multiple feature fusion networks based on the third convolutional network (Conv) and activation function (SiLU) layer. After image recognition, the similarity value between the real image and the generated image will be given, where 1 represents the same and 0 represents different. By combining the context feature enhancement network and the feature fusion network, the model can effectively improve the effect of water gauge detection.
[0121] Specifically, the image enhancement of each water-rule image in the first water-rule image set to obtain an enhanced image set may include: changing the brightness of each water-rule image in the first water-rule image set to obtain a first changed water-rule image; changing the color of the first changed water-rule image based on a target color selected from a preset color set to change the color of the water-rule in the first changed water-rule image to the target color to obtain a second changed water-rule image; and randomly adding noise elements of any color in the preset color set to each of the second changed water-rule images to obtain an enhanced image set including multiple noise-enhanced images. In this embodiment, considering that the colors of the water-rule value and the letter E are mainly red, black, and blue, when performing color changes, the water-rule color can be transformed into these three colors, thereby increasing the diversity of the sample, and when performing noise enhancement, red, black, and blue can also be randomly added to the noise, thereby increasing the interference of the background color on the foreground, thereby increasing the difficulty of recognizing the sample. Specifically, the brightness of each water-scale image in the first water-scale image set can be changed to obtain a first changed water-scale image, and then the color of the first changed water-scale image can be changed based on a target color selected from a preset color set, such as red, black, and blue, so that the color of the water scale in the first changed water-scale image is changed to red, black, and blue to obtain a second changed water-scale image; then, noise elements in red, black, and blue are randomly added to each of the second changed water-scale images to obtain an enhanced image set including multiple noise-enhanced images.
[0122] It should be noted that, before the color of the first changed water gauge image is changed based on the target color selected from the preset color set, it specifically further includes: constructing the preset color set based on the color of the water gauge value marked on the water gauge and the color of the preset icon. In this embodiment, before the color of the water gauge image is changed, it is necessary to construct a preset color set based on the color of the water gauge value marked on the water gauge and the color of the preset icon (such as the letter E), such as a set containing three colors: red, black, and blue.
[0123] Specifically, the step of inputting the enhanced image set into the initial image enhancement network to perform model training on the image generation network and the image recognition network in the initial image enhancement network in turn to obtain a trained image enhancement network may include: extracting a first number of water-rule images from the enhanced image set to obtain a first type of image; randomly extracting a second number of water-rule images from the enhanced image set and removing the area where the water-rule is located from the randomly extracted water-rule images to obtain a second type of image; inputting the first type of image and the second type of image into the image generation network in the initial image enhancement network to perform model training and output the generated image; inputting the generated image and the first type of image into the image recognition network in the initial image enhancement network to perform model training to obtain a trained image enhancement network. In this embodiment, refer to Fig.13 As shown, in order to further increase the diversity of samples, m water-rule images can be extracted from the enhanced image set to obtain the first type of images, and then p water-rule images can be randomly extracted from the enhanced image set, and the area where the water-rule is located is removed from the randomly extracted water-rule images, and the image without the water-rule is used as a noise image to obtain the second type of images; then, the above two types of images (i.e., the first type of images and the second type of images) are input into the image generation network in the initial image enhancement network for model training, and the generated image is output, and the generated image and the first type of image are simultaneously input into the image discrimination network in the initial image enhancement network for model training, thereby obtaining the trained image enhancement network. It should be pointed out that after passing through the image recognition network, a numerical probability pro between 0 and 1 can be obtained. Further, the Loss function (loss function) is adjusted and controlled to increase the probability of 1, which is used to train the image generation network for i times. At the same time, the Loss function (loss function) is adjusted and controlled to increase the probability of 0, which is used to train the image recognition network for j times. Preferably, the Loss function can use the same function, and the above two steps can be controlled by taking the opposite of Loss. Preferably, the relationship between the ratio of i and j and the numerical probability pro can be expressed as follows:
[0124] ;
[0125] in, .
[0126] Repeat the above Loss function adjustment and control steps until the probabilities of the two labels of the image recognition network are both around 0.5 and the model training is terminated.
[0127] It should be pointed out that by training the image generation network first and then the image recognition network, model oscillation can be prevented.
[0128] In a specific implementation, the inputting of the first type of image and the second type of image into the image generation network in the initial image enhancement network for model training and outputting the generated image may specifically include: converting the first type of image into a binary image to obtain a converted image, and resizing the converted image to obtain a first adjusted image; resizing the second type of image to obtain a second adjusted image, and normalizing the second adjusted image to obtain a first normalized image; inputting the first adjusted image and the first normalized image into the image generation network in the initial image enhancement network for model training and outputting the generated image. In this embodiment, the first type of image may be converted into a binary image (i.e., a Mask image) to obtain a converted image, and then the converted image may be resized to obtain a first adjusted image. At the same time, the second type of image may be resized to obtain a second adjusted image, and then the second adjusted image may be normalized to obtain a first normalized image. The first adjusted image and the first normalized image may be input into the image generation network for model training and outputting the generated image. For details, see Fig.11 As shown, the generated image can be obtained by following the steps below:
[0129] Step 1: Convert the first type of image and the corresponding label into a Mask image, and then adjust the size of the Mask image to obtain a first adjusted image, such as adjusting the size of the Mask image to 640*640 (in pixels);
[0130] Step 2: resizing the second type of image, such as resizing the second type of image to 640*640;
[0131] Step 3: normalizing the second adjusted image in step 2 to obtain a first normalized image;
[0132] Step 4: Input the first normalized image in step 3 and the first adjusted image in step 1 into the feature fusion network 1 for feature fusion, specifically including the following steps:
[0133] Step 4.1: Pass the first normalized image in step 3 through a Conv network to obtain feature F1, and pass the first adjusted image in step 1 through two Conv networks to obtain features F2 and F3;
[0134] Step 4.2: Multiply the corresponding position elements of feature F1 and feature F2 to obtain feature F4;
[0135] Step 4.3: Add the corresponding position elements of feature F4 and feature F3 to obtain feature F5;
[0136] Step 4.4: Input feature F5 into the Conv network to obtain new features;
[0137] Step 4.5: Pass the new features in step 4.4 through the Silu layer to obtain feature F6;
[0138] Step 4.6: Merge feature F6 and feature F1 to obtain the feature value Fco1 after the first feature fusion processing;
[0139] Step 5: Input the first adjusted image and eigenvalue Fco1 in step 1 into the feature fusion network 2. The network process is the same as step 4 to obtain the eigenvalue Fco2 after the second feature fusion processing.
[0140] Step 6: Input the first adjusted image and eigenvalue Fco2 in step 1 into the feature fusion network 3. The network process is the same as step 4, and the eigenvalue Fco3 after the third feature fusion processing is obtained;
[0141] Step 7: Input the eigenvalues Fco3 and Fco2 into the context feature enhancement network 1 constructed based on the convolutional network and the upsampling layer for feature enhancement, which specifically includes the following steps:
[0142] Step 7.1: Pass the eigenvalue Fco3 through the Conv network to obtain the feature Fc1;
[0143] Step 7.2: Pass feature Fc1 through the Conv network to obtain feature Fc2, and pass feature Fc1 through the Conv network to obtain feature Fc3;
[0144] Step 7.3: Upsample feature Fc2 and feature Fc3 respectively to obtain feature Fc4 and feature Fc5;
[0145] Step 7.4: Multiply the corresponding position elements of feature Fc2 and feature Fc4 to obtain feature Fc6;
[0146] Step 7.5: Add the corresponding position elements of feature Fc6 and feature Fc5 to obtain the feature value Fud1 of context feature enhancement network 1;
[0147] Step 8: Input the eigenvalue Fco2 and the feature Fco1 into the context feature enhancement network 2. The network process is the same as step 7 to obtain the eigenvalue Fud2 of the context feature enhancement network 2.
[0148] Step 9: Input the feature value Fud1 and feature Fud2 into the context feature enhancement network 3. The network process is the same as step 7 to obtain the feature value Fud3 of the context feature enhancement network 3.
[0149] Step 10: Pass the eigenvalue Fud3 through the Conv network to obtain the eigenvalue Fud4;
[0150] Step 11: Pass the eigenvalue Fud4 through the Conv network to obtain the generated image.
[0151] In a specific embodiment, the step of inputting the generated image and the first type of image into the image recognition network in the initial image enhancement network for model training to obtain a trained image enhancement network may specifically include: resizing the generated image to obtain a third adjusted image, and normalizing the third adjusted image to obtain a second normalized image; resizing the first type of image to obtain a fourth adjusted image, and normalizing the fourth adjusted image to obtain a third normalized image; and inputting the second normalized image and the third normalized image into the image recognition network in the initial image enhancement network for model training to obtain a trained image enhancement network. In this embodiment, the generated image can be resized to obtain a third adjusted image, and the third adjusted image can be normalized to obtain a second normalized image. At the same time, the first type of image can be resized to obtain a fourth adjusted image, and the fourth adjusted image can be normalized to obtain a third normalized image. The second normalized image and the third normalized image are then simultaneously input into the image recognition network in the initial image enhancement network for model training, thereby obtaining a trained image enhancement network. For details, see Fig.12 As shown, the trained image enhancement network can be obtained by following the steps below:
[0152] Step 1: resize the generated image to obtain a third adjusted image, such as resizing the generated image to 640*640;
[0153] Step 2: resizing the first type of image to obtain a fourth resized image, such as resizing the first type of image to 640*640;
[0154] Step 3: normalize the fourth adjusted image in step 2 to obtain feature f1, and normalize the third adjusted image in step 1 to obtain feature f2;
[0155] Step 4: Add information features of the image, merge features f1 and f2 to obtain feature f1+f2;
[0156] Step 5: Pass the combined features f1+f2 through the Conv network to obtain feature f3;
[0157] Step 6: Pass feature f3 through the Silu layer to obtain a new feature f4;
[0158] Step 7: Pass the new feature f4 through the Conv network to obtain the new feature f5;
[0159] Step 8: Pass the new feature f5 through the Silu layer to obtain the new feature f6;
[0160] Step 9: Pass feature f1 through the Conv network to obtain new feature f7;
[0161] Step 10: Pass the new feature f7 through Silu to obtain the new feature f8;
[0162] Step 11: Add the original image features, add the new features f6 and f8 at corresponding positions to obtain the new feature f9;
[0163] Step 12: Pass the new feature f9 through the Conv network to obtain a new feature f10;
[0164] Step 13: Pass the new feature f10 through Silu to obtain the new feature f11;
[0165] Step 14: Pass the above feature f2 through the Conv network to obtain a new feature f12;
[0166] Step 15: Pass the new feature f12 through Silu to obtain the new feature f13;
[0167] Step 16: Add the original image features, add the corresponding position elements of features f11 and f13, and obtain the new feature f14;
[0168] Step 17: Pass the new feature f14 through the Conv network to obtain a new feature f15;
[0169] Step 18: Pass the new feature f15 through the Conv network to obtain the similarity value.
[0170] Step S12: Filtering a preset number of target confidences and corresponding target preset icons and target water gauge values from the water gauge detection results in order of confidence from large to small.
[0171] In this embodiment, after detecting the current water level image to obtain the corresponding water level detection result, further, a preset number of target confidences, as well as the target preset icons and target water level values corresponding to each target confidence, can be screened out from the above water level detection results in order of confidence from large to small.
[0172] Step S13: Based on the distance between the icon position of the target preset icon on the water ruler and the target intersection point, and combined with the numerical position of the target water ruler value on the water ruler, calculate the actual water level height corresponding to the target intersection point; the target intersection point is the intersection point between the water ruler and the water surface in the current water ruler image.
[0173] In this embodiment, after screening out a preset number of target confidences and the corresponding target preset icons and target water gauge values, the intersection point between the water gauge and the water surface in the current water gauge image is calculated to obtain the target intersection point, and then based on the distance between the icon position of the above-mentioned target preset icon on the water gauge and the target intersection point, and combined with the numerical position of the above-mentioned target water gauge value on the water gauge, the actual water level height corresponding to the above-mentioned target intersection point is calculated.
[0174] Specifically, the method of calculating the actual water level height corresponding to the target junction point based on the distance between the icon position of the target preset icon on the water ruler and the target junction point, and in combination with the numerical position of the target water ruler value on the water ruler, may include: obtaining the number of pixels and the icon size occupied by each of the target preset icons, and judging whether each of the target water ruler values is correct based on the numerical position of the target water ruler value on the water ruler, the size of the target water ruler value and the icon size; if each of the target water ruler values is correct, determining the maximum confidence level among multiple target confidence levels, and obtaining the vertical coordinate value of the target water ruler value corresponding to the maximum confidence level; calculating the actual water level height corresponding to the target junction point based on the distance between the target junction point and the target preset icon corresponding to the maximum confidence level, the vertical coordinate value and the corresponding number of pixels. For example, according to the position of the top three letters E in confidence, the number of pixels n (i.e., the number of pixels occupied by the letter E) in each unit length direction in the current water gauge image and the length L of the letter E are obtained, and then based on the numerical position of the top three target water gauge values on the water gauge, the size of the target water gauge value and the length L of the letter E, it is detected whether each target water gauge value is correct, for example, whether it complies with the preset calculation rules. If they all comply, the detection is correct. At this time, the water gauge value corresponding to the maximum confidence and the letter E can be used as the detection reference. Specifically, the maximum value among multiple target confidences can be determined first to obtain the maximum confidence, and then the vertical coordinate value of the target water gauge value corresponding to the maximum confidence can be obtained, and then the distance between the position of the target junction point and the position of the target preset icon corresponding to the maximum confidence is calculated, and finally the actual water level height h corresponding to the target junction point is calculated based on the distance, the above-mentioned vertical coordinate value and the number of pixels occupied by the corresponding letter E. The specific process includes:
[0175] ;
[0176] Where Val is the difference between any two water gauge values. and They represent the vertical coordinate values at the corresponding positions of the two water gauge values, and n is the number of pixels occupied by each letter E;
[0177] Next, the intersection point of the water surface and the water gauge is calculated. There are two specific cases: when the water surface is a plane, the intersection point of the water surface and the water gauge is selected as the intersection point; when the water surface is affected by environmental factors such as turbulence, wind and waves, the average of the highest point and the lowest point of the intersection point of the water surface and the water gauge is selected as the intersection point;
[0178] Furthermore, the distance between the position of the junction point and the position of the letter E, that is, the distance between the two, is calculated, and based on the distance, the number of pixels n and the difference Val, the actual water level h corresponding to the junction point is calculated. The specific calculation formula is:
[0179] ;
[0180] in, Indicates the value of the water level at the highest point. Indicates the position of the highest point, represents the position of the junction point, n is the number of pixels occupied by each letter E, and h is the actual water level height corresponding to the junction point. It should be pointed out that this scheme can be used as a self-check for model detection by detecting whether the water gauge values ranked in the top three confidence levels are correct, thereby reducing detection errors. In addition, by detecting the position and direction of the letter E and comparing the data in the vertical direction, the computational complexity can be reduced.
[0181] Furthermore, after calculating the actual water level height corresponding to the target intersection point based on the distance between the icon position of the target preset icon on the water gauge and the target intersection point, and combining the numerical position of the target water gauge value on the water gauge, it can also include: judging whether the actual water level height exceeds the preset water level height; if the actual water level height exceeds the preset water level height, generating water level alarm information. In this embodiment, after measuring the water level of the current water gauge image, it can be further judged whether the actual water level height corresponding to the water surface and the intersection point of the water gauge exceeds the preset water level height. If it exceeds, it indicates that the current water level is too high. At this time, the corresponding water level alarm information can be generated and the alarm can be triggered so that the relevant staff can take corresponding measures in time after receiving the water level alarm information to avoid personal safety and property losses caused by excessively high water levels.
[0182] It can be seen that the embodiment of the present application first inputs the current water gauge image in the real-time received water gauge video stream into the trained water gauge recognition model to detect the current water gauge image and obtain the corresponding water gauge detection result; the water gauge detection result includes the identified water surface, the preset icon on the water gauge, the water gauge value marked on the water gauge and the confidence corresponding to each of the water gauge values; a number of preset icons are distributed on the water gauge to divide the water level scale by each of the preset icons; in order of confidence from large to small, a preset number of target confidences and the corresponding target preset icons and target water gauge values are screened from the water gauge detection results; based on the distance between the icon position of the target preset icon on the water gauge and the target junction point, and combined with the numerical position of the target water gauge value on the water gauge, the actual water level height corresponding to the target junction point is calculated; the target junction point is the junction point of the water gauge and the water surface in the current water gauge image. The embodiment of the present application first detects the current water gauge image to be measured through the trained water gauge recognition model, so as to obtain a water gauge detection result including the recognized water surface, the preset icon on the water gauge, the water gauge value marked on the water gauge, and the confidence corresponding to each water gauge value, and then selects the target confidences and the corresponding target preset icons and target water gauge values of the top preset number of confidence rankings from the water gauge detection result, and finally calculates the intersection point of the water gauge and the water surface based on the distance between the icon position of the target preset icon on the water gauge and the intersection point, and in combination with the numerical position of the target water gauge value on the water gauge. The actual water level height should be calculated by the embodiment of the present application. The water gauge recognition model is used, and the water gauge value and the preset icon are taken into consideration at the same time, and the traditional character recognition method is abandoned. The process of water gauge recognition can be simplified, and the efficiency of water gauge recognition can be improved. Moreover, by detecting the water gauge value and the preset icon with high confidence for water level measurement, detection errors can be avoided. In addition, the embodiment of the present application adopts the method of the intersection of the water gauge and the water surface, and calculates the actual water level through the distance between the icon position and the intersection point, which can effectively avoid the influence of the intersection point position due to factors such as turbulent water flow or waves, thereby improving the accuracy of water level detection.
[0183] The present application discloses a specific water level measurement method. Fig.14 As shown, the method includes:
[0184] Step S21: input the current water gauge image in the real-time received water gauge video stream into the trained water gauge recognition model to detect the current water gauge image and obtain a corresponding water gauge detection result; the water gauge detection result includes the identified water surface, the preset icon on the water gauge, the water gauge value marked on the water gauge and the confidence level corresponding to each of the water gauge values; a number of preset icons are distributed on the water gauge, and the water level scale is divided by each of the preset icons.
[0185] For details, see Fig.15 , Fig.16 , Fig.17 , Fig.18 As shown, actual water gauge detection results are shown in the scene where there is a reflection on the water surface, a clear water surface, a scene where the water surface is affected by turbulence or wind and waves, and a scene where the lower end of the water gauge is corroded by the water surface.
[0186] Step S22: Correcting the water gauge in the current water gauge image according to the length and direction of the preset icon in the water gauge detection result to obtain a corrected water gauge image.
[0187] For example, the water gauge in the current water gauge image is corrected according to the length and direction of the letter E in the above water gauge detection result to obtain a corrected water gauge image.
[0188] Step S23: Determine whether there is a water gauge element under the water surface in the corrected water gauge image.
[0189] Furthermore, it is determined whether there is a water gauge element under the water surface in the corrected water gauge image, that is, whether water gauge information is displayed.
[0190] Step S24: If there is no water gauge element under the water surface in the corrected water gauge image, multiple confidences in the water gauge detection result are sorted in descending order of confidence to obtain sorted confidences.
[0191] In this embodiment, if there is no water gauge element under the water surface in the corrected water gauge image, the multiple confidence levels in the water gauge detection result are sorted in descending order of confidence level.
[0192] Step S25: Filter a preset number of target confidences from the sorted confidences, and obtain a target preset icon and a target water gauge value corresponding to each of the target confidences from the water gauge detection result.
[0193] In this embodiment, a preset number of target confidences can be screened from the above-mentioned sorted confidences, and then the target preset icons and target water gauge values corresponding to each target confidence can be obtained from the above-mentioned water gauge detection results.
[0194] In this embodiment, if there are water gauge elements under the water surface in the corrected water gauge image, the step of inputting the current water gauge image in the real-time received water gauge video stream into the trained water gauge recognition model is re-executed to detect the current water gauge image and obtain the corresponding water gauge detection result. In this embodiment, if there are water gauge elements under the water surface in the corrected water gauge image, it indicates that the currently collected water gauge image is unqualified. At this time, the water gauge image can be acquired again and the new water gauge image can be recognized. By using a water gauge value with high confidence and a preset icon for judgment, detection errors can be avoided. If it does not meet the calculation rules, the water gauge recognition is performed again, thereby effectively avoiding the occurrence of false alarms and the like.
[0195] Step S26: Based on the distance between the icon position of the target preset icon on the water ruler and the target intersection point, and combined with the numerical position of the target water ruler value on the water ruler, calculate the actual water level height corresponding to the target intersection point; the target intersection point is the intersection point between the water ruler and the water surface in the current water ruler image.
[0196] For more specific processing procedures of the above S26, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be elaborated here.
[0197] It can be seen that after the embodiment of the present application detects the current water gauge image to obtain the corresponding water gauge detection result, the water gauge in the current water gauge image is corrected according to the length and direction of the preset icon in the water gauge detection result to obtain the corrected water gauge image, and it is determined whether there is a water gauge element under the water surface in the corrected water gauge image. If there is no water gauge element under the water surface in the corrected water gauge image, multiple confidences in the water gauge detection result are sorted in order from large to small to obtain the sorted confidences, and then a preset number of target confidences are filtered from the sorted confidences, and the target preset icons and target water gauge values corresponding to each target confidence are obtained from the water gauge detection result. Finally, based on the distance between the icon position of the target preset icon on the water gauge and the target junction point, and combined with the numerical position of the target water gauge value on the water gauge, the actual water level height corresponding to the target junction point is calculated. The embodiment of the present application compares the position of the water gauge value with the distance between the water gauge and the water surface, thereby avoiding recognition errors caused by corrosion or obstruction at the bottom of the water gauge. In addition, by correcting the water gauge image and performing water gauge recognition based on the corrected water gauge image, the detection accuracy can be effectively improved, thereby improving the accuracy of water level measurement.
[0198] Furthermore, the present application also discloses an electronic device. Fig.19 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0199] Fig.19 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the water level measurement method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0200] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0201] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0202] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, and can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the water level measurement method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0203] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the water level measurement method disclosed above. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the above embodiments, and no further description will be given here.
[0204] Furthermore, an embodiment of the present application also discloses a computer program product, including a computer program / instruction, which implements the steps of the water level measurement method disclosed above when executed by a processor.
[0205] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0206] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0207] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0208] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0209] The above is a detailed introduction to a water level measurement method, product, equipment and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A water level measurement method, characterized in that: include: The current water gauge image in the real-time received water gauge video stream is input into the trained water gauge recognition model to detect the current water gauge image and obtain a corresponding water gauge detection result; the water gauge detection result includes the recognized water surface, the preset icon on the water gauge, the water gauge value marked on the water gauge and the confidence level corresponding to each of the water gauge values; a plurality of preset icons are distributed on the water gauge to divide the water level scale by each of the preset icons; Filtering a preset number of target confidences and corresponding target preset icons and target water gauge values from the water gauge detection results in order of confidence from large to small; The number of pixels occupied by each of the target preset icons and the icon size are obtained, and based on the numerical position of the target water level value on the water level, the size of the target water level value and the icon size, it is determined whether each of the target water level values is correct; if each of the target water level values is correct, the maximum confidence level among the multiple target confidence levels is determined, and the vertical coordinate value of the target water level value corresponding to the maximum confidence level is obtained; Based on the distance between the target junction point and the target preset icon corresponding to the maximum confidence, the vertical coordinate value and the corresponding number of pixel points, the actual water level height corresponding to the target junction point is calculated; the target junction point is the junction point between the water gauge and the water surface in the current water gauge image.
2. The water level measurement method according to claim 1, characterized in that: The current water gauge image in the real-time received water gauge video stream is input into the trained water gauge recognition model to detect the current water gauge image and obtain a corresponding water gauge detection result, including: Acquire a water gauge image in a water gauge video stream received in real time to obtain a current water gauge image; the water gauge video stream is a video stream collected after alternately irradiating the water surface in the area where the target water gauge is located with natural light and white light whose illumination intensity meets a preset high-intensity condition; The current water gauge image is input into the trained water gauge recognition model to detect the current water gauge image and obtain a corresponding water gauge detection result.
3. The water level measurement method according to claim 1, characterized in that: The method of selecting a preset number of target confidences and corresponding target preset icons and target water gauge values from the water gauge detection results in the order of confidence from large to small includes: Correcting the water gauge in the current water gauge image according to the length and direction of the preset icon in the water gauge detection result to obtain a corrected water gauge image; Determining whether there is a water gauge element under the water surface in the corrected water gauge image; If there is no water gauge element under the water surface in the corrected water gauge image, sorting the multiple confidences in the water gauge detection result in descending order of confidence; A preset number of target confidences are screened from the sorted confidences, and a target preset icon and a target water gauge value corresponding to each of the target confidences are obtained from the water gauge detection result.
4. The water level measurement method according to claim 3, characterized in that: Also includes: If there are water gauge elements under the water surface in the corrected water gauge image, the step of inputting the current water gauge image in the real-time received water gauge video stream into the trained water gauge recognition model is re-executed to detect the current water gauge image and obtain the corresponding water gauge detection result.
5. The water level measurement method according to claim 1, characterized in that: Also includes: Labeling each collected historical water gauge image to obtain a first water gauge image set; Performing image enhancement on each water gauge image in the first water gauge image set to obtain an enhanced image set; Inputting the enhanced image set into the initial image enhancement network to sequentially perform model training on the image generation network and the image recognition network in the initial image enhancement network to obtain a trained image enhancement network; The image generation network includes a feature fusion network constructed based on the first convolutional network and the activation function layer, and a context feature enhancement network constructed based on the second convolutional network and the upsampling layer; Generate new water gauge images through the image generation network in the trained image enhancement network, and label the new water gauge images to obtain a second water gauge image set; The first water gauge image set and the second water gauge image set are input into an initial water gauge recognition model for training to obtain the trained water gauge recognition model.
6. The water level measurement method according to claim 5, characterized in that: The step of performing image enhancement on each water gauge image in the first water gauge image set to obtain an enhanced image set includes: Performing brightness change on each water gauge image in the first water gauge image set to obtain a first changed water gauge image; Performing a color change on the first changed water-rule image based on a target color selected from a preset color set, so as to change the color of the water-rule in the first changed water-rule image to the target color, thereby obtaining a second changed water-rule image; A noise element having any color in the preset color set is randomly added to each of the second changed water gauge images to obtain an enhanced image set including a plurality of noise enhanced images.
7. The water level measurement method according to claim 6, characterized in that: Before changing the color of the first changed water gauge image based on the target color selected from the preset color set, the method further includes: The preset color set is constructed based on the color of the water gauge value marked on the water gauge and the color of the preset icon.
8. The water level measurement method according to claim 5, characterized in that: The step of inputting the enhanced image set into the initial image enhancement network to sequentially perform model training on the image generation network and the image recognition network in the initial image enhancement network to obtain a trained image enhancement network comprises: Extracting a first number of water gauge images from the enhanced image set to obtain a first type of image; Randomly extract a second number of water gauge images from the enhanced image set and remove the area where the water gauge is located from the randomly extracted water gauge images to obtain a second type of image; Inputting the first category of images and the second category of images into the image generation network in the initial image enhancement network for model training, and outputting the generated images; The generated image and the first type of image are input into the image recognition network in the initial image enhancement network for model training to obtain a trained image enhancement network.
9. The water level measurement method according to claim 8, characterized in that: The step of inputting the first type of image and the second type of image into an image generation network in an initial image enhancement network for model training, and outputting a generated image, comprises: Converting the first type of image into a binary image to obtain a converted image, and resizing the converted image to obtain a first resized image; resizing the second type of image to obtain a second adjusted image, and normalizing the second adjusted image to obtain a first normalized image; The first adjusted image and the first normalized image are input into an image generation network in an initial image enhancement network for model training, and a generated image is output.
10. The water level measurement method according to claim 9, characterized in that: The step of inputting the generated image and the first type of image into an image recognition network in an initial image enhancement network for model training to obtain a trained image enhancement network comprises: resizing the generated image to obtain a third adjusted image, and normalizing the third adjusted image to obtain a second normalized image; resizing the first type of image to obtain a fourth adjusted image, and normalizing the fourth adjusted image to obtain a third normalized image; The second normalized image and the third normalized image are input into the image recognition network in the initial image enhancement network for model training to obtain a trained image enhancement network.
11. The water level measurement method according to any one of claims 1 to 10, characterized in that: The trained water gauge recognition model is a model obtained by training an initial water gauge recognition model based on a fast spatial pyramid pooling network, a target feature extraction network and a feature fusion network using a historical water gauge image set; the target feature extraction network is a network constructed based on a third number of convolutional networks and a fourth number of C3 networks.
12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the water level measurement method according to any one of claims 1 to 11 is implemented.
13. An electronic device, characterized in that: It comprises a processor and a memory; wherein, when the processor executes the computer program stored in the memory, the water level measurement method according to any one of claims 1 to 11 is implemented.
14. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein, when the computer program is executed by a processor, the water level measurement method according to any one of claims 1 to 11 is implemented.
Citation Information
Patent Citations
Water gauge water level machine vision detection method and device with free shooting visual angle
CN115578695A