Virtual water gauge water level identification method based on Unet network
Through technologies such as Unet network and Canny edge detection, water level line features are extracted, which solves the problem of low recognition accuracy of traditional water level identification methods under pollution and occlusion, achieves efficient and stable water level monitoring, and improves the real-time and real-time performance of the water conservancy industry. accuracy.
Patent Information
- Application Number
- CN202410782104.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-09-17
AI Technical Summary
Traditional water level identification methods are easily contaminated and blocked under the influence of water quality, resulting in low identification accuracy and difficulty in achieving high-precision water level monitoring.
The virtual water gauge water level identification method based on the Unet network is used to calculate the average ordinate pixel value of the water level line and the image coordinates through image acquisition, enhanced preprocessing, Unet network feature extraction, Canny edge detection and spatial transformation network adaptive correction. corresponding relationship to achieve accurate calculation of water level values.
It improves the real-time and accuracy of water level identification, reduces the impact of environmental factors on monitoring, enhances the automation level and accuracy, overcomes the identification errors in traditional methods, and is suitable for water level monitoring in complex scenarios.
Smart Images

Figure CN118658053A
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of water level monitoring, and in particular to a virtual water gauge water level recognition method based on a Unet network. Background Art
[0002] Electronic water gauge is an advanced instrument used to measure liquid level. Compared with traditional mechanical water gauge, electronic water gauge has the advantages of high precision, convenient operation and real-time reading, and is widely used in industry, construction, environmental protection and other fields.
[0003] Water gauge water level recognition stems from the demand for water resource management and flood risk prevention. Water level is a key indicator for evaluating changes in water volume in water bodies. Timely understanding of water level changes is crucial for the management and dispatch of reservoirs, rivers, lakes and other water bodies. Traditional water level recognition usually uses sensor water level gauges, radar water level gauges, ultrasonic water level gauges and other methods. At present, the method for water gauge water level value recognition is the physical water gauge method. The physical water gauge method uses character recognition technology. The "E" character and digital characters on the water gauge represent fixed water level scales. The water gauge water level value represented by the number of characters is calculated by training the network, and the recognition network has a fast calculation speed.
[0004] However, when identifying the symbols and numeric characters corresponding to the water level value of the water gauge, the water gauge characters must be clear and unobstructed. Since water quality affects the traditional water level recognition method, the water gauge is polluted or obstructed, making it difficult to recognize or the recognition accuracy is low, which affects the accuracy of water level recognition. Based on this, a virtual water gauge water level recognition method based on the Unet network is proposed. Summary of the invention
[0005] The purpose of the present invention is to provide a virtual water gauge water level recognition method based on Unet network, which solves the technical problem that the water gauge in the traditional water level recognition method is polluted or blocked due to water quality, which is difficult to recognize or has low recognition accuracy, thus affecting the accuracy of water level recognition.
[0006] The purpose of the present invention can be achieved through the following technical solutions:
[0007] A virtual water gauge water level recognition method based on Unet network includes the following steps:
[0008] Step 1: Use an image acquisition device to collect the original image of the water gauge;
[0009] Step 2: Perform enhancement preprocessing on the original water gauge image to obtain the processed image;
[0010] Step 3: Input the processed image into the Unet network to separate the water area from the image;
[0011] Step 4: Detect the water area extracted by the Canny edge detection operator, project the pixel coordinates of the edge points into a straight line, extract the water edge line, and obtain the average ordinate pixel value of the water level line according to the water edge line;
[0012] Step 5: Adaptively correct the water level edge line through the spatial transformation network STN to correct the water level edge line to the horizontal direction;
[0013] Step 6: Obtain the corresponding relationship between the water level height value and the image coordinate pixel value, and calculate the water level value based on the corresponding relationship.
[0014] As a further solution of the present invention: the specific method of separating the water area from the image by using the Unet network is:
[0015] The image features are gradually extracted and restored through the Unet network, and finally a feature map of the same size as the original input is obtained, and the water area is separated from the image.
[0016] As a further solution of the present invention: the feature extraction part in the Unet network is a depth-wise separable convolution, which includes channel-wise convolution and point-wise convolution. The channel-wise convolution uses a convolution kernel for each channel, and the number of channels in the output feature layer is the same as the input; the point-by-point convolution performs weighted combination in the depth direction, and the number of output feature layers is equal to the number of previous feature layers.
[0017] As a further solution of the present invention: the specific method of extracting the edge line of the water body is:
[0018] The Canny operator is used to detect and extract the water level line at the edge of the extracted water area, and then the pixel coordinates of the edge line of the detection image are counted, the average coordinates of all edge points are calculated and projected into a straight line, and then the edge line of the water body is obtained.
[0019] As a further solution of the present invention: the specific method of obtaining the average vertical coordinate pixel value of the water level line is:
[0020] When the pixel coordinates of the edge points are projected into a straight line, the x coordinates of all edge points are averaged to obtain an average horizontal coordinate, and the y coordinates of all edge points are averaged to obtain an average vertical coordinate. Since the water level is usually parallel to the horizon, that is, the water level is horizontal, then the vertical coordinates of all points on this line are the same, that is, the y value is the same. Therefore, this line can be represented by a simple linear equation y=y0, where y0 is the average vertical coordinate of all edge points, that is, the average vertical coordinate pixel value of the water level.
[0021] As a further solution of the present invention: the specific method of obtaining the corresponding relationship between the water level value and the image coordinate pixel value is:
[0022] First, obtain the actual water level values corresponding to the two known scale values and their corresponding vertical coordinate pixel values, and use the formula |d1-d2| / |y1-y2|=CX to obtain the relationship between the actual water level value and the pixel value, that is, the proportional coefficient CX between the actual water level difference and the pixel coordinate difference, where d1 and d2 are the actual water level values corresponding to the two known scale values, and y1 and y2 are the vertical coordinate pixel values corresponding to the two actual water level values.
[0023] As a further solution of the present invention: the specific method of calculating the water level value according to the corresponding relationship between the water level height value and the image coordinate pixel value is:
[0024] The water level calculation formula is: It can be deduced that |d0-d1| / |y0-y1|=|d1-d2| / |y1-y2|;
[0025] By solving this equation, we can get the water level calculation formula: |d0|=(|d1-d2| / |y1-y2|)*|y0-y1|+|d1|, and then we can calculate the water level value |d0| corresponding to the water level line;
[0026] Among them, d1 represents the actual water level value corresponding to a certain scale in the image, and d2 represents the actual water level value corresponding to another scale; y1 represents the ordinate pixel value corresponding to a certain scale of the image, y2 represents the ordinate pixel value corresponding to another scale, and y0 is the ordinate pixel value corresponding to the calculated water level value, that is, the average ordinate pixel value of the water level line.
[0027] As a further solution of the present invention: the specific operation of the enhancement preprocessing is to use the color restoration multi-scale MSRCR technology to enhance the input original image to improve the image quality and reduce the influence of environmental factors such as lighting.
[0028] Beneficial effects of the present invention:
[0029] The present invention solves the problem that the water gauge is difficult to identify or has low identification accuracy after being polluted or blocked in the traditional water level identification method. By introducing a virtual water gauge water level identification method based on the Unet network, it does not rely on the physical ruler, but uses computer vision and deep learning technology to extract water level line features from the image, thereby realizing water level identification in complex scenes. This method improves the real-time and accuracy of water level monitoring in the water conservancy industry, makes water level monitoring more efficient and stable, and reduces monitoring errors caused by environmental factors, effectively overcomes the interference of environmental factors on water level monitoring, and improves the automation level and accuracy of water level identification, which is of great significance to the fields of water resources management and flood prevention. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The present invention will be further described below in conjunction with the accompanying drawings.
[0031] Figure 1 It is a schematic diagram of the framework structure of the method of the present invention. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0033] Embodiment 1
[0034] See also Figure 1 As shown, the present invention is a virtual water gauge water level identification method based on Unet network, comprising the following steps:
[0035] Step 1: Use an image acquisition device to acquire the original image of the water gauge. The image acquisition device can be a camera, a still camera, a video camera, or other device that can acquire the water gauge image;
[0036] Step 2: Perform enhancement preprocessing on the original water gauge image collected by the image acquisition device to obtain a processed image;
[0037] The specific operation of the enhancement preprocessing is to use the multi-scale color restoration (MSRCR) technology to enhance the input original image to improve the image quality and reduce the influence of environmental factors such as lighting. This preprocessing step helps to improve the effect of subsequent processing because it makes the color of the image closer to the real color of the object, which helps to improve the accuracy and robustness of subsequent processing steps, thereby creating better conditions for accurate detection of the water level line;
[0038] The color of an object itself is constant. Due to the influence of the scene light source, the color of the recorded image will change to varying degrees. However, the human neurophysiological function is constant in perceiving the color of an object. Multi-scale image enhancement with color restoration (MSRCR) is based on the human visual perception mechanism. It reduces the influence of environmental factors such as light on the image and enhances the image adaptively. It is an existing and mature technology, so it will not be elaborated here.
[0039] Step 3: Input the processed image into the improved Unet network for automatic recognition of the water part of the image. The Unet network gradually extracts image features and restores its size through the encoder-decoder structure, and finally obtains a feature map of the same size as the original input, and separates the water area from the image;
[0040] Unet is an encoder-decoder structure. The left half is the feature extraction part, and the right half is the upsampling part. The feature extraction part is responsible for gradually reducing the size and number of channels of the input image while extracting high-level features of the image. The upsampling part gradually restores the encoder features to the size and number of channels of the original input image through upsampling and skip connections.
[0041] Unet network is a deep learning model commonly used in image segmentation tasks. The improved Unet network is to change the traditional convolution block of the feature extraction part into a depthwise separable convolution. The depthwise separable convolution includes channel-wise convolution and pointwise convolution. Channel-wise convolution uses a convolution kernel for each channel, and the number of channels in the output feature layer is the same as that in the input; point-wise convolution performs weighted combination in the depth direction, and the number of output feature layers is equal to the number of previous feature layers. This improvement improves the efficiency and accuracy of feature extraction.
[0042] The improvement is that the traditional convolution block is replaced by a depth-separable convolution. Each channel is processed using a separate convolution kernel through channel-by-channel convolution, while the point-by-point convolution performs weighted combination in the depth direction, which improves the efficiency and accuracy of feature extraction.
[0043] Step 4: For the water area extracted by the improved Unet network, the Canny edge detection operator is used to detect the water area part, the pixel coordinates of the edge points are projected into a straight line, the water edge line is extracted, and the average ordinate pixel value of the water level line is obtained according to the water edge line;
[0044] The Canny operator is used to detect and extract the water level line at the edge of the extracted water area, and then the pixel coordinates of the edge line of the detection image are counted, the average coordinates of all edge points are calculated and projected into a straight line, and then the edge line of the water body is obtained, which helps to determine the precise position of the water level line. The specific method is:
[0045] In image processing, when the pixel coordinates of edge points are projected into a straight line, it usually refers to determining the equation of a straight line, not just a single point. Even if the x-coordinates of all edge points are averaged to obtain an average horizontal coordinate, and the y-coordinates of all edge points are averaged to obtain an average vertical coordinate, this average coordinate point itself is located on the straight line of the water level we want to determine;
[0046] Since the water level is usually parallel to the horizon, that is, the water level is horizontal, then the ordinates of all points on this line are the same, that is, the y value is the same. Therefore, this line can be represented by a simple linear equation y=y0, where y0 is the average ordinate of all edge points, that is, the average ordinate pixel value of the water level:
[0047] The straight line y=y0 extends horizontally in the image from the leftmost to the rightmost of the x-axis. Since all edge points are gathered near the same straight line y=y0, it is reasonable to assume that they represent points on the same horizontal line. Therefore, by taking the average of the ordinates of these points, a representative ordinate value is obtained to determine the position of the entire water level line.
[0048] So, while from a mathematical point of view we do get just one point, in the context of image processing and computer vision, this point represents a line whose equation is and this line spans the entire field of view in the image, representing the water level;
[0049] It should be noted that when using the Canny operator for edge detection, it is necessary to appropriately select the threshold parameter to ensure that the edge of the water level line can be effectively detected. When calculating the average coordinates of the edge points, a weighted average method can be used, where the weight can be determined based on the intensity or other characteristics of the edge points to improve the accuracy of the water level line positioning. Since the water body area may contain fluctuations or other interference, the water body area is smoothed before extracting the edge line, such as using a Gaussian filter, to reduce the impact of noise;
[0050] Step 5: Adaptively correct the water level edge line through the spatial transformation network STN to correct the water level edge line to the horizontal direction;
[0051] The spatial transformer network STN has the functions of forward propagation, backward propagation and gradient parameter update, and both the input and output can be images or feature maps, which can be inserted in any part of the convolutional neural network. It can maintain spatial invariance after image correction. The extracted water level edge is adaptively corrected to the horizontal direction through the spatial transformer network STN, ensuring the accuracy of the water level and maintaining spatial invariance in complex scenes.
[0052] Step 6: Obtain the corresponding relationship between the water level value and the image coordinate pixel value, and calculate the water level value based on the corresponding relationship. The specific method is as follows:
[0053] First, the actual water level values corresponding to the two known scale values and their corresponding ordinate pixel values are obtained, and the relationship between the actual water level value and the pixel value, that is, the proportional coefficient CX between the actual water level difference and the pixel coordinate difference, is obtained through the formula |d1-d2| / |y1-y2|=CX, where d1 and d2 are the actual water level values corresponding to the two known scale values, and y1 and y2 are the ordinate pixel values corresponding to the two actual water level values;
[0054] For example, in a water gauge image, suppose there are two known scales, meter and meter, corresponding to the actual water level values, and their corresponding vertical coordinate pixel values in the image.
[0055] Design a water level calculation formula, and obtain the water level value corresponding to the water level line through the water level calculation formula;
[0056] The specific water level calculation formula is:
[0057] This formula takes into account the relationship between the actual water level value and the ordinate pixel value corresponding to different scales, so that the water level value corresponding to the water level line can be calculated, where d1 represents the actual water level value corresponding to a certain scale in the image, and d2 represents the actual water level value corresponding to another scale; y1 represents the ordinate pixel value corresponding to a certain scale of the image, y2 represents the ordinate pixel value corresponding to another scale, y0 is the ordinate pixel value corresponding to the calculated water level value, that is, the average ordinate pixel value of the water level line, and |d0| is the water level value corresponding to the water level line;
[0058] The water level calculation formula is: It can be deduced that |d0-d1| / |y0-y1|=|d1-d2| / |y1-y2|;
[0059] By solving this equation, the water level value can be calculated as: |d0|=(|d1-d2| / |y1-y2|)*|y0-y1|+|d1|;
[0060] For example: suppose there is a water level image, where d1 = 10 meters, d2 = 20 meters are the actual water level values corresponding to the two known scales, y1 = 100 pixels, y2 = 200 pixels are the ordinate pixel values corresponding to the two scales in the image, and the average ordinate pixel value of the water level line y0 = 150. The specific way to calculate the water level value of the water level line in the image is:
[0061] Substitute it into the above formula |d0|=(|d1-d2| / |y1-y2|)*|y0-y1|+|d1| to calculate the water level value |d0|;
[0062] |d0|=(|10-20| / |100-200|)*|150-100|+|10|=5+10=15;
[0063] Therefore, based on the average ordinate pixel value of the water level line in the image, the corresponding water level value can be calculated to be 15 meters;
[0064] The whole solution solves the problem that the water gauge is difficult to identify or has low recognition accuracy due to pollution or occlusion in traditional water level identification methods. By introducing a virtual water gauge water level identification method based on the Unet network, it does not rely on the physical scale, but uses computer vision and deep learning technology to extract water level line features from the image, thereby realizing water level identification in complex scenes. This method improves the real-time and accuracy of water level monitoring in the water conservancy industry, makes water level monitoring more efficient and stable, and reduces monitoring errors caused by environmental factors, effectively overcomes the interference of environmental factors on water level monitoring, and improves the automation level and accuracy of water level identification, which is of great significance to fields such as water resources management and flood prevention.
[0065] The above formulas are all dimensionless and numerical calculations. The formula is a formula for the most recent real situation obtained by collecting a large amount of data and performing software simulation. The preset parameters and thresholds in the formula are set by technicians in this field according to actual conditions.
[0066] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A virtual water gauge water level recognition method based on Unet network, characterized in that: The following steps are involved: Step 1: Use an image acquisition device to collect the original image of the water gauge; Step 2: Perform enhancement preprocessing on the original water gauge image to obtain the processed image; Step 3: Input the processed image into the Unet network to separate the water area from the image; Step 4: Detect the water area extracted by the Canny edge detection operator, project the pixel coordinates of the edge points into a straight line, extract the water edge line, and obtain the average ordinate pixel value of the water level line according to the water edge line; Step 5: Adaptively correct the water level edge line through the spatial transformation network STN to correct the water level edge line to the horizontal direction; Step 6: Obtain the corresponding relationship between the water level height value and the image coordinate pixel value, and calculate the water level value based on the corresponding relationship.
2. According to the Unet network-based virtual water gauge water level identification method of claim 1, it is characterized in that: The specific method of separating the water area from the image through the Unet network is: The image features are gradually extracted and restored through the Unet network, and finally a feature map of the same size as the original input is obtained, and the water area is separated from the image.
3. According to the Unet network-based virtual water gauge water level identification method of claim 2, it is characterized in that: The feature extraction part in the Unet network is depth-wise separable convolution, which includes channel-wise convolution and point-wise convolution. Channel-wise convolution uses a convolution kernel for each channel, and the number of channels in the output feature layer is the same as the input; point-wise convolution performs weighted combination in the depth direction, and the number of output feature layers is equal to the number of previous feature layers.
4. According to the Unet network-based virtual water gauge water level identification method of claim 3, it is characterized in that: The specific method of extracting the edge line of the water body is: The Canny operator is used to detect and extract the water level line at the edge of the extracted water area, and then the pixel coordinates of the edge line of the detection image are counted, the average coordinates of all edge points are calculated and projected into a straight line, and then the edge line of the water body is obtained.
5. The virtual water gauge water level identification method based on Unet network according to claim 4 is characterized in that: The specific method for obtaining the average vertical coordinate pixel value of the water level line is: When the pixel coordinates of the edge points are projected into a straight line, the x coordinates of all edge points are averaged to obtain an average horizontal coordinate, and the y coordinates of all edge points are averaged to obtain an average vertical coordinate. Since the water level is usually parallel to the horizon, that is, the water level is horizontal, then the vertical coordinates of all points on this line are the same, that is, the y value is the same. Therefore, this line can be represented by a simple linear equation y=y0, where y0 is the average vertical coordinate of all edge points, that is, the average vertical coordinate pixel value of the water level.
6. The virtual water gauge water level identification method based on Unet network according to claim 1 is characterized in that: The specific method of obtaining the corresponding relationship between the water level value and the image coordinate pixel value is: First, obtain the actual water level values corresponding to the two known scale values and their corresponding vertical coordinate pixel values, and use the formula |d1-d2| / |y1-y2|=CX to obtain the relationship between the actual water level value and the pixel value, that is, the proportional coefficient CX between the actual water level difference and the pixel coordinate difference, where d1 and d2 are the actual water level values corresponding to the two known scale values, and y1 and y2 are the vertical coordinate pixel values corresponding to the two actual water level values.
7. The virtual water gauge water level identification method based on Unet network according to claim 6 is characterized in that: The specific method of calculating the water level value according to the corresponding relationship between the water level height value and the image coordinate pixel value is: The water level calculation formula is: It can be deduced that |d0-d1| / |y0-y1|=|d1-d2| / |y1-y2|. By solving this equation, the water level calculation formula can be obtained as follows: |d0|=(|d1-d2| / |y1-y2|)*|y0-y1|+|d1|. Then, the water level value |d0| corresponding to the water level line can be calculated. Among them, d1 represents the actual water level value corresponding to a certain scale in the image, and d2 represents the actual water level value corresponding to another scale; y1 represents the ordinate pixel value corresponding to a certain scale of the image, y2 represents the ordinate pixel value corresponding to another scale, and y0 is the ordinate pixel value corresponding to the calculated water level value, that is, the average ordinate pixel value of the water level line.
8. The virtual water gauge water level identification method based on Unet network according to claim 1 is characterized in that: The specific operation of enhancement preprocessing is to enhance the input original image using color restoration multi-scale technology.
9. The virtual water gauge water level identification method based on Unet network according to claim 2 is characterized in that: Unet is an encoder-decoder structure. The left half is the feature extraction part, and the right half is the upsampling part. The feature extraction part is responsible for gradually reducing the size and number of channels of the input image while extracting high-level features of the image. The upsampling part gradually restores the features of the encoder to the size and number of channels of the original input image through upsampling and jump connections.
Citation Information
Cited By
High-precision ruler scale identification method and system based on machine vision
CN119049030A
Yangtze river water level prediction method of hybrid model
CN119990411A
