Water level identification method and device

By detecting the image area to be measured of the water ruler and calculating the actual length of the water ruler exposed to the water surface, the problem of difficult identification caused by stain adhesion on the water ruler is solved, and a higher precision water level recognition is achieved.

CN119810813APending Publication Date: 2025-04-11POWERCHINA ZHONGNAN ENG
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411788001.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The existing water level recognition method based on water ruler image is difficult to identify because water grass, mud, and other stains are often attached to the water ruler.

Method used

By detecting the image area to be tested of the water ruler, the target detection frame of the water ruler is obtained using the object detection model, and the relationship between the pixel length and actual length of the exposed water surface of the water ruler in the image is calculated, and the water level value is then calculated.

Benefits of technology

Improve the accuracy and reliability of water level recognition, and reduce the difficulty of identification due to stain adhesion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119810813A_ABST
    Figure CN119810813A_ABST
Patent Text Reader

Abstract

The invention provides a water level identification method and device. The method for detecting the ith water gauge of the target detection water area comprises the following steps: (A) collecting a to-be-detected water gauge image, and determining a to-be-detected image area; (B) inputting the to-be-detected image area into the water gauge detection model to obtain a target detection frame, and judging whether the to-be-detected water gauge image can be used for identifying the current water level according to the first judgment result and the second judgment result; (C) calculating the pixel length of the water gauge exposed out of the water surface by using the positions of the top edge and the bottom edge of the target detection frame in the to-be-detected water gauge image and the error value when the water gauge detection model detects the vertex of the water gauge; (D) calculating the actual length of the water gauge exposed out of the water surface by using a relational expression between the pixel length of the water gauge in the to-be-measured water gauge image and the actual length and the pixel length of the water gauge exposed out of the water surface; and (E) calculating to obtain a water level value by using the total length of the scale part of the water gauge, the actual length of the water gauge exposed out of the water surface and the underwater position elevation value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer vision and water level monitoring, and in particular to a water level recognition method and device. Background Art

[0002] In the field of water resources management and flood prevention and disaster reduction, water level information, as the core element of the hydrological monitoring system, has immeasurable value. With the intensification of global climate change and the frequent occurrence of extreme weather events, flood disasters have become a major challenge threatening the safety of human life and property.

[0003] Traditional water level monitoring methods, such as manually reading water level gauges, are not only inefficient but also easily affected by human factors, resulting in inaccurate data or delays. With the rapid development of technologies such as the Internet of Things, artificial intelligence, and image processing, the field of water level monitoring has ushered in a new revolutionary change. Existing automatic water level gauges mainly include pressure water level gauges, float water level gauges, ultrasonic water level gauges, radar water level gauges, etc., but these methods have problems such as high equipment cost and difficulty in installation. In contrast, the image-based water level recognition method is not only low-cost, but also easy to maintain.

[0004] At present, the main image-based water level recognition methods are:

[0005] 1. Use traditional image processing methods such as binarization and directional gradient histogram to extract and identify the water gauge scale, such as the document "Design and Research of Water Level Detection System in Sanmenxia Reservoir Area of ​​the Yellow River Based on Image Recognition Technology" (Author: Liu Xiaoqiang et al.; Journal Name: Journal of Sanmenxia Vocational and Technical College; Issue 2, 2022);

[0006] 2. First locate the location of the water gauge through the target detection network, and then detect and identify the water gauge characters, such as the patent application with the patent publication number CN114067095A and the name "Water level recognition method based on water gauge character detection and recognition";

[0007] 3. The water area and the background area are segmented through an image segmentation network to determine the water level of the water gauge, and based on the water level of the water gauge, characters of the water gauge located on the water level are detected, such as the patent application with patent publication number CN115049684A and name “A water gauge recognition method and system based on water area segmentation”.

[0008] The above water level recognition method based on water gauge image requires the recognition of water gauge scale / water gauge characters. However, there are often stains such as aquatic plants and mud attached to the water gauge, which greatly increases the difficulty of recognizing water gauge scale and character images, making it difficult to recognize water level using water gauge images. Summary of the invention

[0009] The present invention provides a water level recognition method to solve the problem that stains such as waterweed and mud attached to a water gauge make the recognition of the existing water level recognition method based on a water gauge image difficult.

[0010] In order to solve the above technical problems, the technical solution adopted by the present invention is: a water level recognition method, which detects the water gauge to identify the current water level, characterized in that the water level recognition method comprises the following steps:

[0011] (A) determining an image region to be detected corresponding to the i-th water gauge in the water gauge image to be detected of the i-th water gauge, so that the image region to be detected contains at most only the i-th water gauge and at least a complete image of the i-th water gauge in the water gauge image to be detected; wherein the water gauge image to be detected of the i-th water gauge is acquired by an image acquisition device at an i-th preset point, i∈[1,N], N is the number of water gauges in the target detection water area;

[0012] (B) inputting the image area to be detected into a water gauge detection model to obtain a target detection frame corresponding to the water gauge, and obtaining a result of the first judgment and a result of the second judgment;

[0013] If any one of the first judgment result and the second judgment result is yes, it is determined that the current water level cannot be identified using the water gauge image to be measured of the i-th water gauge, and the current detection of the i-th water gauge is terminated;

[0014] If both the first judgment result and the second judgment result are negative, executing step (C);

[0015] Wherein, the first judgment is whether the i-th water ruler is not detected in the image area to be detected, and the second judgment is whether the bottom end of the water ruler scale part in the image area to be detected is higher than the current water surface of the target detection water area; wherein, for the image area to be detected where both the first judgment result and the second judgment result are negative, the top edge of the target detection frame is the position of the water ruler vertex detected by the water ruler detection model, and the bottom edge of the target detection frame is the position of the water surface detected by the water ruler detection model;

[0016] (C) Using the position of the top and bottom edges of the target detection frame in the water gauge image to be measured, the error value d when the water gauge detection model detects the vertex of the i-th water gauge i , calculate the pixel length XL(i) of the i-th water gauge exposed above the water surface in the water gauge image to be measured;

[0017] (D) using the relationship between the pixel length of the i-th water gauge in the water gauge image to be measured and the actual length and the pixel length XL(i) of the i-th water gauge protruding from the water surface in the water gauge image to be measured, calculate the actual length YL(i) of the i-th water gauge protruding from the water surface;

[0018] (E) Using the total length L(i) of the scale part of the i-th water gauge, the actual length YL(i) of the i-th water gauge above the water surface, and the elevation value G(i) of the bottom of the water corresponding to the i-th water gauge, the water level value W(i) obtained when the i-th water gauge is tested is calculated.

[0019] According to the above technical solution of the present invention, in step (B), if the bottom of the scale part is higher than the water surface, it means that the scale part of the water ruler is not located in the water, and the water level value cannot be obtained using the water ruler image to be tested of the water ruler. If the first judgment result and the second judgment result are both negative, it means that the i-th water ruler is detected in the image area to be detected, and the scale part of the water ruler is located in the water. In step (C), the error of the water ruler detection model is taken into account, so that the detection accuracy is better. In step (D), the relationship between the pixel length and the actual length of each water ruler is considered, so that the actual length of the i-th water ruler exposed to the water surface in the water ruler image to be tested can be obtained. In step (E), the total length of the scale part of the i-th water ruler, the actual length of the water ruler exposed to the water surface, and the elevation value of the bottom position corresponding to the water ruler can be used to calculate the water level value W(i) obtained when the i-th water ruler is detected.

[0020] In the above technical solution, a pixel coordinate system oxy is established in the water gauge image to be measured of the i-th water gauge;

[0021] In the pixel coordinate system oxy, o is the coordinate origin, the x-axis and the y-axis are respectively the horizontal axis and the vertical axis of the pixel coordinate system oxy; the x-axis is parallel to the width direction of the water gauge image to be measured, and the y-axis is parallel to the height direction of the water gauge image to be measured;

[0022] The top and bottom edges of the target detection frame and the top and bottom edges of the image area to be detected are parallel to the x-axis;

[0023] The two sides of the target detection frame and the two sides of the image area to be detected are parallel to the y-axis.

[0024] The position of the image area to be detected corresponding to the i-th water gauge in the water gauge image to be detected of the i-th water gauge is a fixed position, and the image area to be detected corresponding to the i-th water gauge can at least accommodate the complete image of the i-th water gauge when the i-th water gauge is completely exposed above the water surface.

[0025] Preferably, the width direction of the water gauge image to be measured from left to right is the direction of the x-axis, the height direction of the water gauge image to be measured from top to bottom is the direction of the y-axis, and the upper left corner of the water gauge image to be measured is the coordinate origin o.

[0026] In the above technical solution, the step (C) is specifically: using the following formula to calculate the pixel length XL(i) of the i-th water gauge exposed above the water surface in the water gauge image to be measured:

[0027]

[0028] in, is the y-axis coordinate of the top edge of the target detection box in the pixel coordinate system, is the y-axis coordinate of the bottom edge of the target detection box in the pixel coordinate system;

[0029] in, is the y-axis coordinate of the top edge of the target detection box predicted and outputted according to the corresponding water gauge image to be tested when the water gauge detection model is used to perform the first detection on the i-th water gauge, in the pixel coordinate system of the water gauge image to be tested, y top (i,0) is the coordinate of the actual vertex of the i-th water gauge on the y-axis in the pixel coordinate system of the water gauge image to be measured.

[0030] According to the above technical solution of the present invention, the error between the top edge of the target detection frame and the actual water gauge vertex in the ordinate is taken into account, thereby reducing the error in measurement and improving the measurement accuracy. Since the vertex detection error value d corresponding to the i-th water gauge can be determined when the i-th water gauge is first detected using the water gauge detection model, i Therefore, when the water gauge is subsequently tested to identify the water level, if XL(i) needs to be calculated, d i Substitute this into the calculation formula of XL(i).

[0031] In the above technical solution, the step (D) is specifically: using the following formula to calculate the actual length YL(i) of the i-th water gauge exposed above the water surface:

[0032] YL(i)=a i,1 ×[XL(i)] K +a i,2 ×[XL(i)] K-1 +...+a i,K+1 ;

[0033] Among them, a i,1 、a i,2 , …, a i,K+1 is the K+1 coefficient corresponding to the i-th water gauge, a i,1 、a i,2 , …, a i,K+1 It is obtained by fitting the actual lengths of K+1 different length segments along the length direction of the water gauge in the part of the i-th water gauge exposed above the water surface and the projection lengths of the above K+1 different length segments in the y-axis direction of the pixel coordinate system in the corresponding water gauge image to be measured, K≥2.

[0034] Compared with directly representing the relationship between the pixel length and the actual length by a linear relationship, the above technical solution of the present invention adopts a second-order or higher-order equation, so that the fitting accuracy is higher. In the present invention, when the water gauge detection model is used to perform the first detection on the i-th water gauge, the above K + 1 coefficients can be obtained by fitting. When the water gauge is subsequently detected to identify the water level, if it is necessary to calculate YL(i), the above K + 1 coefficients obtained by fitting can be directly substituted into the calculation formula of YL(i).

[0035] In the preferred technical solution, the specific method for obtaining the K + 1 coefficients a i,1 、a i,2 、…、a i,K+1 is as follows:

[0036] In the part of the i-th water gauge exposed above the water surface, K + 2 points are determined along the length direction of the water gauge, so that the actual distance between adjacent two points is ΔL;

[0037] The actual lengths corresponding to the K + 1 different length segments determined by the above K + 2 points and the projection lengths of the above K + 1 different length segments in the y-axis direction of the pixel coordinate system are used for fitting to obtain the K + 1 coefficients a i,1 、a i,2 、…、a i,K+1 ;

[0038] According to the above technical solution of the present invention, K + 2 points and K + 1 different length segments can be determined in the part of the i-th water gauge exposed above the water surface, and the actual lengths of the above K + 1 different length segments are corresponded to their pixel lengths in the y-axis direction, so as to obtain the K + 1 coefficients by fitting.

[0039] In a more preferred technical solution, the above K + 1 different length segments are respectively a length segment with an actual length of ΔL, a length segment with an actual length of 2×ΔL, ……, a length segment with an actual length of (K + 1)×ΔL.

[0040] In the above technical solution, W(i) = L(i) - YL(i) + G(i).

[0041] In the above technical solution, in step (B), if it is determined that the current water level cannot be recognized by using the image of the water gauge to be measured of the i-th water gauge, and i < N, then the (i + 1)-th water gauge in the target detection water area is detected; when i = N, then the detection starts again from the first water gauge in the target detection water area. Wherein, N is the number of water gauges in the target detection water area.

[0042] In the above technical solution, the method for obtaining the i-th preset point is: adjust the position of the image acquisition device and the parameter settings of the image acquisition device so that the area occupied by the entire i-th water gauge is located in the picture, and use the current position of the image acquisition device and the current parameter settings of the image acquisition device as the i-th preset point of the image acquisition device.

[0043] During the research, the applicant found that since there are multiple water gauges in a water area, and multiple water gauges need to be repeatedly monitored using the same image acquisition device, that is, when different water gauges need to be monitored, the camera's direction, focal length, magnification and other parameters all need to be readjusted, making the monitoring process more complicated. According to the above technical solution of the present invention, for a water gauge, when the image of the water gauge is captured, the area occupied by the entire water gauge is located in the picture, and the parameters and position of the image acquisition device (such as direction, focal length, magnification, etc.) are recorded as the preset point corresponding to the water gauge. When the water gauge is monitored again next time, the image acquisition device can be set to the preset point, thereby simplifying the monitoring method of multiple water gauges in a water area. Among them, the area occupied by the i-th water gauge as a whole includes not only the part of the water gauge exposed above the water surface, but also the part of the water gauge located under the water. That is, when the i-th water gauge is exposed above the water surface as a whole, the image of the water gauge to be measured captured at the i-th preset point can include the overall image of the i-th water gauge in the image.

[0044] In the preferred technical solution, the parameter settings of the image acquisition device include focal length and magnification.

[0045] In the above technical solution, the method for obtaining the water gauge detection model includes:

[0046] Collecting water gauge images, the collected water gauge images at least include a water gauge whose bottom end of the scale portion is higher than the water surface and a water gauge whose bottom end of the scale portion is not higher than the water surface;

[0047] A water ruler mark truth value frame as the true value is marked on each collected water ruler image; wherein: for a water ruler whose bottom end of the scale part is higher than the water surface, the top edge of the water ruler mark truth value frame passes through the top of the water ruler, and the bottom edge of the water ruler mark truth value frame passes through the bottom end of the scale part of the water ruler; for a water ruler whose bottom end of the scale part is not higher than the water surface, the top edge of the water ruler mark truth value frame passes through the top of the water ruler, and the bottom edge of the water ruler mark truth value frame is the position of the water surface;

[0048] The water gauge image used for training in the collected water gauge images is used as the input of the target detection network to obtain the water gauge mark prediction frame as the prediction value, and the error between the water gauge mark prediction frame and the water gauge mark true value frame is calculated according to the target loss function;

[0049] Updating parameters of the target detection network according to the error;

[0050] Repeat the above steps until the training goal is met;

[0051] The target detection network obtained after training is used as the water gauge detection model;

[0052] According to the above technical solution of the present invention, images of a water ruler above the water surface (the bottom of the scale part is above the water surface), a water ruler in contact with the water surface or in the water (the bottom of the scale part is not above the water surface) are input into the target detection network for training, so that when images corresponding to a water ruler above the water surface, a water ruler in contact with the water surface or in the water are collected, they can be identified. For a water ruler above the water surface, the bottom edge position of the target detection frame output by the water ruler detection model is the position of the bottom of the scale part. For a water ruler in contact with the water surface or in the water (the bottom of the scale part is not above the water surface), the bottom edge position of the target detection frame output by the water ruler detection model is the position of the water surface.

[0053] In a preferred technical solution, the training goal is that the number of iterations reaches a preset number of iterations, or that the target loss function is not greater than a preset threshold.

[0054] In the preferred technical solution, the collected water level images include water level images of different water areas, water level images of different lighting conditions, and water level images of different weather conditions; the different water areas include rivers, lakes, and reservoirs; the different lighting conditions include day and night; the different weather conditions include sunny days, cloudy days, and rainy days.

[0055] According to the above technical solution of the present invention, water gauge images under different lighting and weather conditions can be collected, so that the trained target detection network is suitable for water gauge detection in different environments.

[0056] In the above technical solution, the target loss function L improved for:

[0057] L improved =L original +L y ;

[0058] Among them, L original is the original loss function of the target detection network; the new term L y The expression is:

[0059]

[0060] Among them, λ y is the vertical axis loss weight; The vertical coordinate of the top edge of the water gauge prediction box, The vertical coordinate of the bottom edge of the water ruler prediction box, The bottom ordinate of the water gauge mark truth box, is the vertical coordinate of the top edge of the watermark truth box; m is the batch size, which refers to the number of samples used by the target detection network to update the parameters of the target detection network in each iteration during the training process; λ ymax is the weight of the bottom ordinate. When the bottom of the scale of the water gauge is higher than the water surface, λ ymax The value range is [0, 0.03]; when the bottom of the scale part of the water gauge is not higher than the water surface, λ ymax The value is 1; y The value range is [0.0005, 0.005].

[0061] The target detection network is any one of the YOLO series target detection network, the RCNN series target detection network, and the SSD target detection network.

[0062] According to the above technical solution of the present invention, when training the target detection network, a new item L is added to the original loss function of the target detection network. y For a water gauge whose bottom end of the scale is not higher than the water surface, λ ymax =1, that is, the top edge deviation of the water gauge mark prediction box and the top edge deviation of the water gauge mark true value box And the bottom edge deviation of the water gauge mark prediction box and the bottom edge deviation of the water gauge mark true value box As the training target, the top and bottom edges of the target detection frame obtained by the trained target detection network have a small deviation from the actual water gauge vertex position and the actual water surface position respectively. For the water gauge where the bottom of the scale is higher than the water surface, λ ymax The value range is [0, 0.03], preferably when λ ymax = 0, that is, at this time, only the top edge deviation of the water ruler mark prediction box and the top edge deviation of the water ruler mark true value box is used as the training target. For a water ruler whose bottom end of the scale part is higher than the water surface, the environment where the bottom end of the scale part of the water ruler is located is relatively complex. There may be plants near the bottom end of the scale part of the water ruler in the image, which makes it difficult to identify the bottom end of the scale part of the water ruler for a water ruler whose bottom end of the scale part is higher than the water surface. If the trained model is expected to accurately identify the bottom end of the scale part of a water ruler whose bottom end of the scale part is higher than the water surface, a lot of training time is required. Moreover, the recognition of the bottom end of the scale part of a water ruler whose bottom end of the scale part is higher than the water surface is not the focus of this application. Through the above technical solution of the present invention, when the bottom end of the scale part of the water ruler is higher than the water surface, let λ ymax =0, that is, only focusing on the deviation between the top edge of the water gauge mark prediction box and the top edge of the water gauge mark true value box, thereby achieving the effect of simplifying model training.

[0063] According to the same inventive concept, the present invention also provides a water level identification device, including a computer device; the computer device is configured or programmed to execute the steps of the above-mentioned water level identification method. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0065] Figure 1 A schematic flow chart of a water level identification method according to an embodiment of the present invention;

[0066] Figure 2 Schematic diagram of the process of step S2 in the water level identification method according to an embodiment of the present invention;

[0067] Figure 3 It is a schematic diagram of the detection accuracy of the model in the test set in the water level recognition method according to an embodiment of the present invention;

[0068] Figure 4 It is a schematic diagram of the detection results of the model on some sample images in the water level recognition method according to an embodiment of the present invention;

[0069] Figure 5 Schematic diagram of the process of step S4 in the water level identification method according to an embodiment of the present invention;

[0070] Figure 6 Schematic diagram of the flow of step S42 in the water level identification method according to an embodiment of the present invention;

[0071] Fig. 6A A schematic diagram of the position of an image area to be detected in a water gauge image to be detected according to an embodiment of the present invention;

[0072] Figure 7 Schematic diagram of the flow of step S43 in the water level identification method according to an embodiment of the present invention;

[0073] Figure 8 Schematic diagram of the flow of step S44 in the water level identification method according to an embodiment of the present invention;

[0074] Fig. 9 A schematic diagram of water level segment marking in a water level identification method according to an embodiment of the present invention;

[0075] Fig.10 Schematic diagram of the process of step S5 in the water level identification method according to an embodiment of the present invention;

[0076] Fig.11 This is a schematic diagram of the water level recognition result at night using the water level recognition method according to an embodiment of the present invention;

[0077] Fig.12It is a schematic diagram of the water level recognition result during the day using the water level recognition method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0078] In order to make the purpose, technical solutions and advantages of the present invention clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and implementation examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0079] This embodiment provides a water level recognition method, which involves target detection and water gauge calibration. The method is used to detect the water gauge to identify the current water level. The water level recognition method includes the following steps:

[0080] (A) determining an image region to be detected (also referred to as ROI, i.e., a region of interest in the image to be detected) corresponding to the i-th water gauge in the water gauge image to be detected of the i-th water gauge, so that the image region to be detected contains at most only the i-th water gauge and at least a complete image of the i-th water gauge in the water gauge image to be detected; wherein the water gauge image to be detected of the i-th water gauge is acquired by an image acquisition device at an i-th preset point, i∈[1,N], and N is the number of water gauges in the target detection water area;

[0081] (B) inputting the image area to be detected into a water gauge detection model to obtain a target detection frame corresponding to the water gauge, and obtaining a result of the first judgment and a result of the second judgment;

[0082] If any one of the first judgment result and the second judgment result is yes, it is determined that the current water level cannot be identified using the water gauge image to be measured of the i-th water gauge, and the current detection of the i-th water gauge is terminated;

[0083] If both the first judgment result and the second judgment result are negative, executing step (C);

[0084] Wherein, the first judgment is whether the i-th water ruler is not detected in the image area to be detected, and the second judgment is whether the bottom end of the water ruler scale part in the image area to be detected is higher than the current water surface of the target detection water area; wherein, for the image area to be detected where both the first judgment result and the second judgment result are negative, the top edge of the target detection frame is the position of the water ruler vertex detected by the water ruler detection model, and the bottom edge of the target detection frame is the position of the water surface detected by the water ruler detection model;

[0085] (C) Using the position of the top and bottom edges of the target detection frame in the water gauge image to be measured, the error value d when the water gauge detection model detects the vertex of the i-th water gauge i, calculate the pixel length XL(i) of the i-th water gauge exposed above the water surface in the water gauge image to be measured;

[0086] (D) using the relationship between the pixel length of the i-th water gauge in the water gauge image to be measured and the actual length and the pixel length XL(i) of the i-th water gauge protruding from the water surface in the water gauge image to be measured, calculate the actual length YL(i) of the i-th water gauge protruding from the water surface;

[0087] (E) Using the total length L(i) of the scale part of the i-th water gauge, the actual length YL(i) of the i-th water gauge above the water surface, and the elevation value G(i) of the bottom of the water corresponding to the i-th water gauge, the water level value W(i) obtained when the i-th water gauge is tested is calculated.

[0088] A pixel coordinate system oxy is established in the water gauge image to be measured of the i-th water gauge.

[0089] In the pixel coordinate system oxy, o is the coordinate origin (i.e., the coordinate origin is located at the end point of the upper left corner of the water gauge image to be measured), the x-axis and the y-axis are respectively the horizontal axis and the vertical axis of the pixel coordinate system oxy, the x-axis is parallel to the width direction of the water gauge image to be measured, and extends from the coordinate origin to the right side of the water gauge image to be measured, and the y-axis is parallel to the height direction of the water gauge image to be measured, and extends from the coordinate origin to the bottom of the water gauge image to be measured; the lower limit value and the upper limit value of the coordinate on the x-axis of the image area to be detected corresponding to the i-th water gauge are respectively The lower limit and upper limit of the coordinates of the image area to be detected corresponding to the i-th water ruler on the y-axis are The position of the image area to be detected corresponding to the i-th water gauge in the water gauge image to be detected of the i-th water gauge is a fixed position, and the image area to be detected corresponding to the i-th water gauge can contain the complete image of the i-th water gauge at least when the i-th water gauge is exposed to the water surface as a whole. Among them, for the same water gauge, the position of the image area to be detected in the water gauge image to be detected is fixed, that is, for the same water gauge, are all constant values. For the same water ruler, after determining the coordinates of the image area to be detected corresponding to the water ruler image to be tested of the water ruler, the same coordinates of the image area to be detected can be used for subsequent detection of the water ruler. When determining the image area to be detected, the water ruler in the water ruler image to be tested may only be partially exposed above the water surface. In practice, the approximate position of the entire water ruler can be determined based on the part and position of the water ruler exposed above the water surface, and then the position of the image area to be detected can be determined. In this embodiment, the width direction of the water ruler image to be tested is from left to right as the direction of the x-axis, and the height direction of the water ruler image to be tested is from top to bottom as the direction of the y-axis, and the upper left corner of the water ruler image to be tested is the coordinate origin o. The applicant's research found that since the features of the bottom edge of the water ruler (i.e., the water surface position) are relatively obvious, while the features at the vertex position are not so obvious in comparison, there is a certain error in the water ruler detection model detecting the vertex of the water ruler. If the error is compensated by pre-calibrating the vertical coordinates of the water ruler vertices, that is, each time detection is performed, the error value of the water ruler detection model when detecting the water ruler vertices is obtained by subtracting the vertical coordinates of the top edge of the target detection frame from the vertical coordinates of the pre-calibrated water ruler vertices. Then, if there is an error in the movement of the camera, that is, when the camera is pre-calibrated and located at the i-th preset point during subsequent detection, the positions of the water rulers in the two collected images are not completely consistent, and there is a deviation, resulting in a deviation in the coordinates of the water ruler vertices in the image. Then, the water ruler vertices in the image during pre-calibration and the water ruler vertices in the image during subsequent formal detection are not the same pixel point. If the above method is used to compensate for the error of the model detecting the water ruler vertices, the error compensation effect will be poor.

[0090] In this application, d i is the difference between the actual vertical coordinate of the vertex of the i-th water gauge in the image and the vertical coordinate of the vertex of the i-th water gauge detected by the water gauge detection model based on the image. Therefore, the error value of the model detecting the water gauge vertex in the current scene is obtained through preliminary detection, and then the error of the water gauge vertex detection can be compensated during the formal detection. Even if there is a deviation when the camera moves, the error change of the water gauge vertex detection by the water gauge detection model in the scene corresponding to the i-th water gauge is small. Even if there is a deviation between the two images collected by the camera during preliminary detection and subsequent detection, the water gauge vertex detected by the water gauge detection model is based on the position of the water gauge vertex in the image during the actual detection, and thus the error is compensated by d i As a vertex detection error compensation value, it can still achieve a good compensation effect, making the method more robust.

[0091] The step (C) is specifically as follows: using the following formula to calculate the pixel length XL(i) of the i-th water gauge exposed above the water surface in the water gauge image to be measured:

[0092]

[0093] in, is the y-axis coordinate of the top edge of the target detection box in the pixel coordinate system, is the y-axis coordinate of the bottom edge of the target detection box in the pixel coordinate system;

[0094] in, is the y-axis coordinate of the top edge of the target detection box predicted and outputted according to the corresponding water gauge image to be tested when the water gauge detection model is used to perform the first detection on the i-th water gauge, in the pixel coordinate system of the water gauge image to be tested, y top (i,0) is the coordinate of the actual vertex of the i-th water gauge on the y-axis in the pixel coordinate system of the water gauge image to be measured.

[0095] The step (D) is specifically as follows: using the following formula to calculate the actual length YL(i) of the i-th water gauge exposed above the water surface:

[0096] YL(i)=a i,1 ×[XL(i)] K +a i,2 ×[XL(i)] K-1 +...+a i,K+1 ;

[0097] Among them, a i,1 、a i,2 , …, a i,K+1 is the K+1 coefficient corresponding to the i-th water gauge, a i,1 、a i,2 , …, a i,K+1 It is obtained by fitting the actual lengths of K+1 different length segments along the length direction of the water gauge in the part of the i-th water gauge exposed above the water surface and the projection lengths of the above K+1 different length segments in the y-axis direction of the pixel coordinate system in the corresponding water gauge image to be measured, K≥2.

[0098] In the image to be detected, the length direction of the water ruler is not necessarily parallel to the y-axis direction. Fig. 9 As shown in the figure, K = 2, three segments are selected from the part of the water gauge exposed to the water surface, namely, the three segments are: the part from point P1 to point P2, the part from point P1 to point P3, and the part from point P1 to point P4. When fitting, the actual lengths of the above three segments (which can be obtained through actual measurement) and the projection lengths of the above three segments on the y-axis of the pixel coordinate system (corresponding to H 12 , H 13 , H 14 ), the coefficient a can be obtained by fitting i,1 、a i,2 、a i,3 .

[0099] Preferably, the fitting obtains K+1 coefficients a i,1 、a i,2 , …, a i,K+1The specific method is as follows:

[0100] Determine K + 2 points along the length direction of the exposed part of the i-th water gauge above the water surface, such that the actual distance between adjacent two points is ΔL;

[0101] Use the actual lengths corresponding to the K + 1 different length segments determined by the above K + 2 points and the projected lengths of the above K + 1 different length segments in the y-axis direction of the pixel coordinate system to fit and obtain K + 1 coefficients a i,1 、a i,2 、…、a i,K+1 ;

[0102] More preferably, the K + 1 different length segments are respectively a length segment with an actual length of ΔL, a length segment with an actual length of 2×ΔL, ……, a length segment with an actual length of (K + 1)×ΔL.

[0103] W(i) = L(i) - YL(i) + G(i).

[0104] In the step (B), if it is determined that the current water level cannot be recognized using the image of the i-th water gauge to be measured, and i < N, then the (i + 1)-th water gauge in the target detection water area is detected; when i = N, then the detection starts again from the 1st water gauge in the target detection water area. Wherein, N is the number of water gauges in the target detection water area.

[0105] The method for obtaining the i-th preset point is: adjust the position of the image acquisition device and the parameter settings of the image acquisition device, such that the area occupied by the whole of the i-th water gauge is located in the picture, and take the current position of the image acquisition device and the current parameter settings of the image acquisition device as the i-th preset point of the image acquisition device. The parameter settings of the image acquisition device may include focal length, magnification. When the whole of the i-th water gauge is exposed above the water surface, the proportion of the image of the whole of the i-th water gauge in the height direction in the corresponding image of the water gauge to be measured may be not less than 1 / 2, and the specific proportion may be set according to actual needs.

[0106] The method for obtaining the water gauge detection model includes:

[0107] Collect water gauge images, and the collected water gauge images at least include water gauges with the bottom end of the scale part above the water surface and water gauges with the bottom end of the scale part not above the water surface;

[0108] Mark the true value frame of the water gauge identification as the true value on each collected water gauge image; wherein: for the water gauge with the bottom end of the scale part above the water surface, the top edge of the true value frame of the water gauge identification passes through the top end of the water gauge, and the bottom edge of the true value frame of the water gauge identification passes through the bottom end of the scale part of the water gauge; for the water gauge with the bottom end of the scale part not above the water surface, the top edge of the true value frame of the water gauge identification passes through the top end of the water gauge, and the bottom edge of the true value frame of the water gauge identification is the position of the water surface;

[0109] The water gauge image used for training in the collected water gauge images is used as the input of the target detection network to obtain the water gauge mark prediction frame as the prediction value, and the error between the water gauge mark prediction frame and the water gauge mark true value frame is calculated according to the target loss function;

[0110] Updating parameters of the target detection network according to the error;

[0111] Repeat the above steps until the training goal is met;

[0112] The target detection network obtained after training is used as the water gauge detection model;

[0113] Preferably, the training goal is that the number of iterations reaches a preset number of iterations, or that the target loss function is not greater than a preset threshold;

[0114] Preferably, the collected water gauge images include water gauge images of different water areas, water gauge images of different lighting conditions, and water gauge images of different weather conditions; the different water areas include rivers, lakes, and reservoirs; the different lighting conditions include daytime and nighttime; the different weather conditions include sunny days, cloudy days, and rainy days. Through the above settings, the method of the present invention has better robustness and can cope with the detection of water gauges in different environments.

[0115] The target loss function includes the target loss function of the existing target detection network and also includes an additional L y ; That is, the objective loss function L improved for:

[0116] L improved =L original +L y ;

[0117] L original is the original loss function of the target detection network; L y The expression is:

[0118]

[0119] Among them, λ y is the vertical axis loss weight; The vertical coordinate of the top edge of the water gauge prediction box, The vertical coordinate of the bottom edge of the water ruler prediction box, The bottom ordinate of the water gauge mark truth box, is the vertical coordinate of the top edge of the water ruler mark truth box; m is the number of samples used by the target detection network to update the network parameters in each iteration during the training process; λ ymax is the weight of the bottom ordinate. When the bottom of the scale of the water gauge is higher than the water surface, λ ymaxThe value range is [0, 0.03]; when the bottom of the scale part of the water gauge is not higher than the water surface, λ ymax The value is 1; y The value range of is [0.0005, 0.005];

[0120] The target detection network is any one of the YOLO series target detection network, the RCNN series target detection network, and the SSD target detection network.

[0121] In the present application, the loss function of the water gauge detection model is improved to strengthen the constraints on the bottom edge (ie, water surface position) coordinate prediction.

[0122] According to the same inventive concept, the present invention also provides a water level identification device, including a computer device; the computer device is configured or programmed to execute the steps of the above-mentioned water level identification method.

[0123] The embodiments of the present invention are described in further detail below.

[0124] The present invention calculates the pixel length of the water gauge protruding from the water surface through the detection frame predicted by the target detection network, and then calculates the actual length of the water gauge protruding from the water surface based on the mapping relationship between the water gauge pixel length determined by the water gauge calibration and the actual length, and subtracts the actual length of the water gauge protruding from the water surface from the total length of the water gauge to obtain the water gauge reading, and then calculates the water level value.

[0125] The present invention provides a water level recognition method, comprising the following steps: S1, water gauge image acquisition; S2, model construction and deployment; S3, preset point setting and detection area framing; S4, water gauge calibration; S5, water level value calculation. Specifically:

[0126] S1. Acquisition of water gauge images: Collect water gauge images in various scenarios, covering a wide range of environmental conditions including rivers, lakes, reservoirs, etc., and consider the impact of day and night differences and weather changes on image quality, and try to include multiple styles of water gauges; then perform data processing (such as data cleaning and data enhancement) on the collected images.

[0127] S2. Model construction and deployment: The processed and annotated water gauge image dataset is used for target detection network training to obtain a water gauge detection model, and then deployed to the edge device. The target detection network refers to the YOLOv7 target detection network. The edge device refers to Rockchip RK3588.

[0128] S3, preset point setting and detection area framing: for each water gauge in the task scene, camera preset points are set and the target detection area (i.e., the image area to be detected) is manually framed.

[0129] S4. Water gauge calibration: calibrate each water gauge in the task scenario.

[0130] S5. Calculation of water level value: Calculate the water level value using the network model obtained in steps S1 to S4, relevant calibration parameters of the water gauge and the fitting function.

[0131] For further information, see Figure 2 , step S2 comprises:

[0132] S21: Water gauge image dataset production, annotate the collected water gauge images with target truth frames and add category labels (i.e., water gauge identification truth frames), and export the annotated images as the basic dataset B0. Then, the original image in the basic dataset B0 is regionally captured according to the saved target truth frame coordinates to obtain separate captured images of each water gauge. At the same time, the target truth frame coordinates corresponding to the original image of the basic dataset are converted into the corresponding coordinates in the captured image. After batch processing, the cropped image dataset B1 is obtained, and the dataset B1 is randomly divided into training set D1, validation set V1, and test set T1.

[0133] For a water ruler whose bottom end of the scale part is higher than the water surface, the top edge of the target truth value frame passes through the top of the water ruler, and the bottom edge of the target truth value frame passes through the bottom end of the scale part of the water ruler; for a water ruler whose bottom end of the scale part is not higher than the water surface, the top edge of the target truth value frame passes through the top of the water ruler, and the bottom edge of the target truth value frame is the water surface.

[0134] S22: Target detection network model training.

[0135] When training the object detection network, the input of the model is an image containing only a water gauge, and the output of the model is the predicted water gauge object detection box.

[0136] By improving the objective loss function of the original neural network YOLOv7, a specific term is added to it, called L y , which is used to represent the mean absolute error MAE between the vertical coordinates of the water ruler detection frame output by the model and the vertical coordinates of the target true value frame, including the vertical coordinates of the bottom edge of the water ruler detection frame The vertical coordinate of the bottom edge of the target truth box The mean absolute error MAE between the top and bottom vertical coordinates of the water gauge detection frame The vertical coordinate of the top edge of the target truth box The mean absolute error MAE between them. Then the training data set D1 is used for neural network YOLOv7 training to obtain the water gauge detection model MA. y The calculation formula is:

[0137]

[0138] Among them, λ y is the vertical axis loss weight, in this embodiment, yThe value is 0.0005. m is the batch size, which refers to the number of samples used by the target detection network to update the network parameters in each iteration during the training process. ymax is the weight of the bottom ordinate. For the water level on land (class label is on_ground), λ ymax The value is 0; for the water gauge in water (class label is in_water), λ ymax The value is 1.

[0139] The original loss function of the YOLOv7 target detection network is expressed as:

[0140] L original =λ box ·L box +λ obj ·L obj +λ cls ·L cls ;

[0141] Among them, λ box is the positioning loss weight, L box is the positioning loss; obj is the confidence loss weight, L obj is the confidence loss; cls is the classification loss weight, L cls is the classification loss.

[0142] In addition to the YOLOv7 target detection network, any one of the other YOLO series target detection networks (such as yolov5, yolov8), RCNN series target detection networks, and SSD target detection networks can also be used instead. When any of the above target detection networks is used, the original loss function is set to the existing technical content.

[0143] The detection accuracy of the trained water gauge detection model MA in the test set T1 is as follows: Figure 3 shown. Figure 3 In , when the confidence is 0.916, the accuracy of all categories (i.e., category on_ground, category in_water) is 1. The detection results of some sample images are as follows Figure 4 shown.

[0144] S23: Model deployment, deploy the trained water gauge detection model MA to the edge device. In this embodiment, Rockchip RK3588 is used as the edge device. First, the water gauge detection model MA needs to be converted from a PyTorch (.pt) deep learning model to an RKNN (.rknn) model through the RKNN-Toolkit2 tool provided by Rockchip; then the exported RKNN model is deployed to the RK3588 board, and the board RKNPU driver, RKNN Server and Runtime library are configured; finally, the board NPU resources can be used to infer the input data through the RKNN Toolkit Lite tool provided by Rockchip.

[0145] Furthermore, in step S3, it is necessary to set preset points and frame the detection area for each water gauge. First, control the camera to move to the position of the first water gauge (for example, through the existing onvif protocol), adjust the focal length and magnification so that the target water gauge appears clearly in the center of the picture, set the first preset point corresponding to the first water gauge, and set preset points for all remaining water gauges in turn; then, manually frame the target detection area (i.e., the image area to be detected) at each preset point. Save the coordinates of the image area to be detected after confirmation i=1,2,....,N, where N represents the number of preset points.

[0146] For further information, see Figure 5 In step S4, each water gauge needs to be calibrated, and the water gauge calibration includes:

[0147] S41: Determine the actual total length L(i) of the i-th water gauge and the water level reference elevation value G(i). The actual total length of the water gauge is a known quantity, which can be obtained, for example, by pre-measurement or by the scale of the water gauge.

[0148] S42: Water gauge pre-detection.

[0149] S43: Pre-solve the difference between the top edge of the target detection frame and the vertical coordinate of the water ruler vertex.

[0150] S44: A quadratic function is used to fit the mapping relationship between the pixel length and the actual length.

[0151] For further information, see Figure 6 In step S42, the water gauge pre-detection specifically includes the following steps:

[0152] S421: Image cropping, using the coordinates of the image area to be detected The water gauge image to be measured obtained at the i-th preset point is cropped.

[0153] S422: Target detection: input the water gauge image after region cropping into the water gauge detection model MA to obtain the coordinates of the target detection frame in the cropped image. and the category of the target (on_ground, in_water).

[0154] S423: Coordinate conversion, target detection frame coordinates Convert to the original coordinates of the water gauge image to be measured The conversion formula is as follows:

[0155]

[0156] like Fig. 6A As shown in the figure, oN1N2N3 is the water gauge image to be measured, and the oxy coordinate system is established in the water gauge image to be measured as shown in the figure, where o is the coordinate origin of the water gauge image to be measured. M1M2M3M4 is the framed detection area, that is, the water gauge detection model is input as the cropped image, where M1 is the origin of the coordinate system established in the cropped image, xa and ya are the two coordinate axes of the coordinate system of the cropped image, and the lower limit and upper limit of the target detection frame obtained by the model in the xa axis of the coordinate system of the cropped image are respectively The lower and upper limits of the ya axis are The coordinates of the target detection box in the oxy coordinate system can be obtained through coordinate transformation.

[0157] For further information, see Figure 7 In step S43, pre-solving the difference between the top edge of the target detection frame and the ordinate of the water ruler vertex specifically includes the following steps:

[0158] S431: calibrate the water gauge vertex in the water gauge image to be measured obtained at the i-th preset point, and obtain the vertical coordinate y of the water gauge vertex in the pixel coordinate system of the water gauge image to be measured top (i,0).

[0159] S432: Calculate the vertical coordinate y of the water gauge vertex top (i,0) and the vertical coordinate of the top edge of the target detection frame in the water gauge image to be measured The difference between i , and save. That is, when the water gauge detection model is used to detect the i-th water gauge for the first time, determine d i The value of d is used each time the water level is detected using the i-th water gauge, without recalculating the vertex error value. i The value of .

[0160] For further information, see Figure 8 In step S44, the mapping relationship between the quadratic function fitting pixel length and the actual length specifically includes the following steps:

[0161] S441: calibrate four points on the water gauge image to be measured obtained at the i-th preset point, so that the three water gauge segments determined by the four points increase equidistantly in actual length, such as Fig. 9 As shown, the corresponding pixel length (H) of each water gauge segment in the y-axis direction can also be calculated from the calibration coordinates of these four points. 12 ,H 13 ,H 14 ), thus obtaining three sets of corresponding relationships of “pixel length-actual length”.

[0162] S442: Substitute the three sets of correspondences of “pixel length-actual length” obtained in the previous step into the quadratic function YL(i)=a i,1 ×[XL(i)] 2 +a i,2 ×[XL(i)] 1 +a i,3 The three coefficients of the polynomial can be solved, namely a i,1 、a i,2 、a i,3 .

[0163] S443: Use the solved quadratic function to represent the mapping relationship between the pixel length corresponding to the i-th water ruler and the actual length, where XL(i) represents the pixel length and YL(i) represents the actual length.

[0164] For further information, see Fig.10 , step S5 comprises:

[0165] S51: The camera moves to the i-th preset point to obtain the water gauge image to be measured.

[0166] S52: Run the water gauge detection model MA to perform target detection on the water gauge image to be detected obtained at the i-th preset point to obtain the classification result and the detection frame coordinates.

[0167] Determine whether the classification result is in_water (i.e. "in the water"). If no water gauge is detected or the target category is on_ground (i.e. "on the ground"), the camera is controlled to jump to the next preset point through the onvif protocol until a water gauge with the category in_water is detected.

[0168] S53: When the water gauge category is in_water, the vertical coordinate of the bottom edge of the detection frame is The vertical coordinate of the top edge Make a difference and subtract the pre-solved vertical coordinate y of the water gauge vertex top (i,0) and the vertical coordinate of the top edge of the target detection box The difference between i, calculate the pixel length XL(i) of the water ruler exposed above the water surface.

[0169] S54: Determine whether the obtained pixel length XL(i) is greater than 0. If XL(i) is less than 0, the camera is controlled to jump to the next preset point through the onvif protocol; if XL(i) is greater than 0, substitute it into the quadratic function YL(i)=a i,1 ×[XL(i)] 2 +a i,2 ×[XL(i)] 1 +a i,3 , calculate the actual length YL(i) of the water ruler above the water surface.

[0170] S55: Subtract the actual total length L(i) of the water gauge from the actual length YL(i) of the water gauge above the water surface to obtain the water gauge reading R(i). The water level value can be calculated by adding the water gauge reading R(i) to the water level reference elevation value G(i).

[0171] Among them, step S51, step S52, step S53, step S54, and step S55 correspond to step (A), step (B), step (C), step (D), and step (E), respectively.

[0172] The method of using water gauge images to train the target detection network, using the trained water gauge detection model to detect the water gauge and then calculate the water level value can adapt to complex and changing scenes by using the powerful representation ability of deep neural networks, and has strong robustness. However, there are the following difficulties and problems in the specific implementation:

[0173] (1) The object detection box predicted by the object detection network usually cannot fit the real edge of the water gauge well, so it is difficult to calculate the pixel length of the water gauge above the water surface using the coordinates of the object detection box.

[0174] (2) After the preset points of the image acquisition device (such as a camera) are set, slight deviations may occur when the image acquisition device is moved. Therefore, the water level value cannot be directly calculated by calibrating the vertex coordinates of the water gauge.

[0175] (3) In perspective projection, there are optical phenomena such as objects that are larger near and smaller far away, and objects that are wider near and narrower far away. Directly using a linear relationship to represent the mapping between the pixel length of the water ruler and the actual length often results in a large error.

[0176] The present invention provides a clear optimization direction for the model by improving the loss function of the target detection network, so that the detection frame predicted by the model can fit the real edge of the water gauge more closely, reducing the detection error of the target frame; framing the detection area effectively improves the anti-interference ability of the model; by pre-solving the difference between the top edge of the detection frame and the vertical coordinate of the water gauge vertex, the movement deviation of the camera preset point and the error of the vertical coordinate of the water gauge vertex predicted by the model can be dealt with; using a polynomial to fit the mapping relationship between the pixel length of the water gauge and the actual length can alleviate the near-big-far-small effect to a certain extent; combining the water gauge detection result with the water gauge calibration result to calculate the water level value improves the accuracy of water level recognition.

[0177] This method was deployed and verified at a hydrological station. The water level recognition results at night are shown in the following example. Fig.11 As shown in the figure, an example of the water level recognition result during the day is as follows Fig.12 The white box in the figure represents the detection area manually framed by the method, the green box in the figure represents the detection result output by the water gauge detection model in the method, and the upper left corner of the figure shows the water gauge reading and water level value calculated by the method, and the error is within 1 cm, which verifies the effectiveness of the method of the present invention.

[0178] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0179] The embodiments of the present invention are described in detail above, but the contents are only preferred embodiments of the present invention and cannot be considered to limit the scope of implementation of the present invention. All equivalent changes and improvements made according to the scope of the present invention should still be included in the scope of the present invention. After reading the present invention, the modifications of various equivalent forms of the present invention by those skilled in the art all fall within the scope defined by the claims attached to this application. In the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other.

Claims

1. A water level recognition method, which detects a water gauge to identify the current water level, characterized in that: The water level identification method comprises the following steps: (A) determining an image region to be detected corresponding to the i-th water gauge in the water gauge image to be detected of the i-th water gauge, so that the image region to be detected contains at most only the i-th water gauge and at least a complete image of the i-th water gauge in the water gauge image to be detected; wherein the water gauge image to be detected of the i-th water gauge is acquired by an image acquisition device at an i-th preset point, i∈[1,N], N is the number of water gauges in the target detection water area; (B) inputting the image area to be detected into a water gauge detection model to obtain a target detection frame corresponding to the water gauge, and obtaining a result of the first judgment and a result of the second judgment; If any one of the first judgment result and the second judgment result is yes, it is determined that the current water level cannot be identified using the water gauge image to be measured of the i-th water gauge, and the current detection of the i-th water gauge is terminated; If both the first judgment result and the second judgment result are negative, executing step (C); Wherein, the first judgment is whether the i-th water ruler is not detected in the image area to be detected, and the second judgment is whether the bottom end of the water ruler scale part in the image area to be detected is higher than the current water surface of the target detection water area; wherein, for the image area to be detected where both the first judgment result and the second judgment result are negative, the top edge of the target detection frame is the position of the water ruler vertex detected by the water ruler detection model, and the bottom edge of the target detection frame is the position of the water surface detected by the water ruler detection model; (C) Using the position of the top and bottom edges of the target detection frame in the water gauge image to be measured, the error value d when the water gauge detection model detects the vertex of the i-th water gauge i , calculate the pixel length XL(i) of the i-th water gauge exposed above the water surface in the water gauge image to be measured; (D) using the relationship between the pixel length of the i-th water gauge in the water gauge image to be measured and the actual length and the pixel length XL(i) of the i-th water gauge protruding from the water surface in the water gauge image to be measured, calculate the actual length YL(i) of the i-th water gauge protruding from the water surface; (E) Using the total length L(i) of the scale part of the i-th water gauge, the actual length YL(i) of the i-th water gauge above the water surface, and the elevation value G(i) of the bottom of the water corresponding to the i-th water gauge, the water level value W(i) obtained when the i-th water gauge is tested is calculated.

2. The water level identification method according to claim 1, characterized in that: A pixel coordinate system oxy is established in the water gauge image to be measured of the i-th water gauge, wherein o is the coordinate origin, and the x-axis and y-axis are respectively the horizontal axis and the vertical axis of the pixel coordinate system oxy; the position of the image area to be detected corresponding to the i-th water gauge in the water gauge image to be measured of the i-th water gauge is a fixed position, and the image area to be detected corresponding to the i-th water gauge can at least accommodate the complete image of the i-th water gauge when the i-th water gauge is exposed as a whole above the water surface.

3. The water level identification method according to claim 2, characterized in that: The step (C) is specifically as follows: using the following formula to calculate the pixel length XL(i) of the i-th water gauge exposed above the water surface in the water gauge image to be measured: in, is the y-axis coordinate of the top edge of the target detection box in the pixel coordinate system, is the y-axis coordinate of the bottom edge of the target detection box in the pixel coordinate system; in, is the y-axis coordinate of the top edge of the target detection box predicted and outputted according to the corresponding water gauge image to be tested when the water gauge detection model is used to perform the first detection on the i-th water gauge, in the pixel coordinate system of the water gauge image to be tested, y top (i,0) is the coordinate of the actual vertex of the i-th water gauge on the y-axis in the pixel coordinate system of the water gauge image to be measured.

4. The water level identification method according to claim 2, characterized in that: The step (D) is specifically as follows: using the following formula to calculate the actual length YL(i) of the i-th water gauge exposed above the water surface: YL(i)=a i,1 ×[XL(i)] K +a i,2 ×[XL(i)] K-1 +...+a i,K+1 ; Among them, a i,1 、a i,2 , …, a i,K+1 is the K+1 coefficient corresponding to the i-th water gauge, a i,1 、a i,2 , …, a i,K+1 It is obtained by fitting the actual lengths of K+1 different length segments along the length direction of the water gauge in the part of the i-th water gauge exposed above the water surface and the projection lengths of the above K+1 different length segments in the y-axis direction of the pixel coordinate system in the corresponding water gauge image to be measured, K≥2; preferably, K+1 coefficients a are obtained by fitting i,1 、a i,2 , …, a i,K+1 The specific method is: Determine K+2 points along the length of the water gauge in the part of the i-th water gauge that is exposed above the water surface, so that the actual distance between two adjacent points is △L; The K+1 coefficients a are obtained by fitting the actual lengths of the K+1 segments of different lengths determined by the K+2 points and the projection lengths of the K+1 segments of different lengths in the y-axis direction of the pixel coordinate system. i,1 、a i,2 , …, a i,K+1 ; More preferably, the K+1 different length segments are respectively a length segment with an actual length of ΔL, a length segment with an actual length of 2×ΔL, ..., a length segment with an actual length of (K+1)×ΔL.

5. The water level identification method according to any one of claims 1 to 4, characterized in that: W(i) = L(i) - YL(i) + G(i).

6. The water level identification method according to any one of claims 1 to 4, characterized in that: In the step (B), if it is determined that the water gauge image of the i-th water gauge cannot be used to recognize the current water level and i < N, then the (i + 1)-th water gauge in the target detection water area is detected; when i = N, the detection starts again from the 1st water gauge in the target detection water area; where N is the number of water gauges in the target detection water area.

7. The water level identification method according to any one of claims 1 to 4, characterized in that: The method for obtaining the i-th preset point is as follows: Adjust the position of the image acquisition device and the parameter settings of the image acquisition device so that the area occupied by the whole of the i-th water gauge is located in the picture, and take the current position of the image acquisition device and the current parameter settings of the image acquisition device as the i-th preset point of the image acquisition device; Preferably, the parameter settings of the image acquisition device include focal length and magnification.

8. The water level identification method according to any one of claims 1 to 4, characterized in that: The method for obtaining the water gauge detection model includes: Collect water gauge images, and the collected water gauge images at least include water gauges with the bottom end of the scale part above the water surface and water gauges with the bottom end of the scale part not higher than the water surface; Mark the true value frame of the water gauge identification as the ground truth on each collected water gauge image; where: for the water gauge with the bottom end of the scale part above the water surface, the top edge of the true value frame of the water gauge identification passes through the top of the water gauge, and the bottom edge of the true value frame of the water gauge identification passes through the bottom end of the scale part of the water gauge; for the water gauge with the bottom end of the scale part not higher than the water surface, the top edge of the true value frame of the water gauge identification passes through the top of the water gauge, and the bottom edge of the true value frame of the water gauge identification is the position of the water surface; Take the water gauge images for training in the collected water gauge images as the input of the target detection network to obtain the predicted frame of the water gauge identification as the prediction value, and calculate the error between the predicted frame of the water gauge identification and the true value frame of the water gauge identification according to the target loss function; Update the parameters of the target detection network according to the error; Repeat the above steps until the training objective is met; Take the trained target detection network as the water gauge detection model; Preferably, the training objective is that the number of iterations reaches a preset number of iterations, or the target loss function is not greater than a preset threshold; Preferably, the collected water gauge images include water gauge images in different water areas, water gauge images under different lighting conditions, and water gauge images under different weather conditions; the different water areas include rivers, lakes, and reservoirs; the different lighting conditions include day and night; the different weather conditions include sunny, cloudy, and rainy.

9. The water level identification method according to claim 8, characterized in that: The objective loss function L improved for: L improved =L original +L y ; Among them, L original is the original loss function of the target detection network; the new term L y The expression is: Among them, λ y is the vertical axis loss weight; The vertical coordinate of the top edge of the water gauge prediction box, The vertical coordinate of the bottom edge of the water ruler prediction box, The bottom ordinate of the water gauge mark truth box, is the vertical coordinate of the top edge of the water ruler mark truth box; m is the number of samples used by the target detection network to update the parameters of the target detection network in each iteration during the training process; λ ymax is the weight of the bottom ordinate. When the bottom of the scale of the water gauge is higher than the water surface, λ ymax The value range is [0, 0.03]; when the bottom of the scale part of the water gauge is not higher than the water surface, λ ymax The value is 1; y The value range of is [0.0005, 0.005]; the target detection network is any one of the YOLO series target detection network, the RCNN series target detection network, and the SSD target detection network.

10. A water level identification device, characterized in that: Including a computer device; The computer device is configured or programmed to execute the steps of the water level recognition method according to any one of claims 1-9.

Citation Information

Patent Citations

  • Water level identification method based on water gauge character detection and identification

    CN114067095A

  • Water gauge identification method and system based on water area segmentation

    CN115049684A